From 08c8e78a40646d0d0dc5905597b689974598aa80 Mon Sep 17 00:00:00 2001 From: ivan-angjelkoski Date: Tue, 12 Nov 2024 11:26:16 +0100 Subject: [PATCH] refactor: sgt trailing modes lp --- .../ExecArgCreateSpotGridStrategy.ts | 25 ++++++++++++++++--- .../sdk-ts/src/core/modules/wasm/types.ts | 8 ++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/wasm/exec-args/ExecArgCreateSpotGridStrategy.ts b/packages/sdk-ts/src/core/modules/wasm/exec-args/ExecArgCreateSpotGridStrategy.ts index 8f3002278..a62649bc5 100644 --- a/packages/sdk-ts/src/core/modules/wasm/exec-args/ExecArgCreateSpotGridStrategy.ts +++ b/packages/sdk-ts/src/core/modules/wasm/exec-args/ExecArgCreateSpotGridStrategy.ts @@ -9,6 +9,7 @@ import { ExitConfig, StrategyType, TrailingArithmetic, + TrailingArithmeticLP, } from '../types.js' export declare namespace ExecArgCreateSpotGridStrategy { export interface Params { @@ -21,7 +22,11 @@ export declare namespace ExecArgCreateSpotGridStrategy { takeProfit?: ExitConfig exitType?: ExitType strategyType?: StrategyType - trailingArithmetic?: TrailingArithmetic + trailingArithmetic?: { + upperTrailing: string + lowerTrailing: string + lpMode?: boolean + } } export interface Data { @@ -38,7 +43,7 @@ export declare namespace ExecArgCreateSpotGridStrategy { exit_price: string } exit_type?: ExitType - strategy_type?: StrategyType | TrailingArithmetic + strategy_type?: StrategyType | TrailingArithmetic | TrailingArithmeticLP } } @@ -58,6 +63,20 @@ export default class ExecArgCreateSpotGridStrategy extends ExecArgBase< toData(): ExecArgCreateSpotGridStrategy.Data { const { params } = this + const trailingBounds = params.trailingArithmetic + ? { + upper_trailing_bound: params.trailingArithmetic.upperTrailing, + lower_trailing_bound: params.trailingArithmetic.lowerTrailing, + } + : undefined + + const strategyType = + params.trailingArithmetic && trailingBounds + ? params.trailingArithmetic.lpMode + ? { trailing_arithmetic_lp: trailingBounds } + : { trailing_arithmetic: trailingBounds } + : params.strategyType ?? StrategyType.Arithmetic + return { subaccount_id: params.subaccountId, levels: params.levels, @@ -76,7 +95,7 @@ export default class ExecArgCreateSpotGridStrategy extends ExecArgBase< exit_price: params.takeProfit.exitPrice, } : undefined, - strategy_type: params.trailingArithmetic ?? params.strategyType, + strategy_type: strategyType, } } diff --git a/packages/sdk-ts/src/core/modules/wasm/types.ts b/packages/sdk-ts/src/core/modules/wasm/types.ts index fa2940cda..d414bbc8f 100644 --- a/packages/sdk-ts/src/core/modules/wasm/types.ts +++ b/packages/sdk-ts/src/core/modules/wasm/types.ts @@ -6,6 +6,7 @@ export enum ExitType { export enum StrategyType { Arithmetic = 'arithmetic', + ArithmeticLP = 'arithmetic_lp', Geometric = 'geometric', } @@ -16,6 +17,13 @@ export type TrailingArithmetic = { } } +export type TrailingArithmeticLP = { + trailing_arithmetic_lp: { + lower_trailing_bound: string + upper_trailing_bound: string + } +} + export type ExitConfig = { exitType: ExitType exitPrice: string