@gmx-io/sdk 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/build/cjs/src/abis/ClaimHandler.json +439 -0
  2. package/build/cjs/src/abis/StBTC.json +1225 -0
  3. package/build/cjs/src/abis/SyntheticsReader.json +480 -19
  4. package/build/cjs/src/abis/index.js +4 -0
  5. package/build/cjs/src/configs/__tests__/markets.spec.js +1 -1
  6. package/build/cjs/src/configs/__tests__/tokens.spec.js +2 -1
  7. package/build/cjs/src/configs/batch.js +12 -0
  8. package/build/cjs/src/configs/chains.js +57 -6
  9. package/build/cjs/src/configs/contracts.js +66 -68
  10. package/build/cjs/src/configs/dataStore.js +14 -3
  11. package/build/cjs/src/configs/express.js +4 -2
  12. package/build/cjs/src/configs/markets.js +72 -0
  13. package/build/cjs/src/configs/oracleKeeper.js +19 -34
  14. package/build/cjs/src/configs/tokens.js +185 -1
  15. package/build/cjs/src/index.js +3 -3
  16. package/build/cjs/src/modules/orders/helpers.js +21 -13
  17. package/build/cjs/src/modules/orders/helpers.spec.js +1 -1
  18. package/build/cjs/src/modules/orders/orders.js +3 -3
  19. package/build/cjs/src/modules/positions/positions.js +9 -0
  20. package/build/cjs/src/modules/utils/utils.js +3 -3
  21. package/build/cjs/src/prebuilt/hashedKinkModelMarketRatesKeys.json +82 -0
  22. package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +512 -0
  23. package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +152 -0
  24. package/build/cjs/src/types/subsquid.js +193 -1
  25. package/build/cjs/src/types/swapStrategy.js +2 -0
  26. package/build/cjs/src/types/trade.js +1 -0
  27. package/build/cjs/src/utils/__tests__/numbers.spec.js +17 -9
  28. package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
  29. package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +2 -0
  30. package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +4 -0
  31. package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
  32. package/build/cjs/src/utils/__tests__/prices.spec.js +3 -2
  33. package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +19 -0
  34. package/build/cjs/src/utils/errors/transactionsErrors.js +9 -2
  35. package/build/cjs/src/utils/fees/executionFee.js +9 -1
  36. package/build/cjs/src/utils/numbers.js +52 -34
  37. package/build/cjs/src/utils/orderTransactions.js +3 -1
  38. package/build/cjs/src/utils/orders.js +8 -2
  39. package/build/cjs/src/utils/prices.js +1 -1
  40. package/build/cjs/src/utils/swap/botanixStaking.js +90 -0
  41. package/build/cjs/src/utils/swap/buildSwapStrategy.js +224 -0
  42. package/build/cjs/src/utils/swap/externalSwapPath.js +41 -0
  43. package/build/cjs/src/utils/swap/externalSwapQuoteByPath.js +27 -0
  44. package/build/cjs/src/utils/swap/swapValues.js +288 -9
  45. package/build/cjs/src/utils/tokens.js +10 -1
  46. package/build/cjs/src/utils/trade/amounts.js +89 -41
  47. package/build/cjs/src/utils/trade/trade.js +2 -2
  48. package/build/cjs/src/utils/twap/uiFeeReceiver.js +26 -6
  49. package/build/esm/src/abis/ClaimHandler.json +439 -0
  50. package/build/esm/src/abis/StBTC.json +1225 -0
  51. package/build/esm/src/abis/SyntheticsReader.json +480 -19
  52. package/build/esm/src/abis/index.js +4 -0
  53. package/build/esm/src/configs/__tests__/markets.spec.js +1 -1
  54. package/build/esm/src/configs/__tests__/tokens.spec.js +3 -2
  55. package/build/esm/src/configs/batch.js +13 -1
  56. package/build/esm/src/configs/chains.js +56 -5
  57. package/build/esm/src/configs/contracts.js +67 -69
  58. package/build/esm/src/configs/dataStore.js +9 -0
  59. package/build/esm/src/configs/express.js +5 -3
  60. package/build/esm/src/configs/markets.js +73 -1
  61. package/build/esm/src/configs/oracleKeeper.js +18 -29
  62. package/build/esm/src/configs/tokens.js +186 -2
  63. package/build/esm/src/index.js +3 -3
  64. package/build/esm/src/modules/orders/helpers.js +21 -13
  65. package/build/esm/src/modules/orders/helpers.spec.js +1 -1
  66. package/build/esm/src/modules/orders/orders.js +3 -3
  67. package/build/esm/src/modules/positions/positions.js +9 -0
  68. package/build/esm/src/modules/utils/utils.js +3 -3
  69. package/build/esm/src/prebuilt/hashedKinkModelMarketRatesKeys.json +82 -0
  70. package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +512 -0
  71. package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +152 -0
  72. package/build/esm/src/types/subsquid.js +192 -0
  73. package/build/esm/src/types/swapStrategy.js +1 -0
  74. package/build/esm/src/types/trade.js +1 -0
  75. package/build/esm/src/utils/__tests__/numbers.spec.js +18 -10
  76. package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
  77. package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +2 -0
  78. package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +4 -0
  79. package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
  80. package/build/esm/src/utils/__tests__/prices.spec.js +3 -2
  81. package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +20 -1
  82. package/build/esm/src/utils/errors/transactionsErrors.js +9 -2
  83. package/build/esm/src/utils/fees/executionFee.js +11 -3
  84. package/build/esm/src/utils/numbers.js +50 -31
  85. package/build/esm/src/utils/orderTransactions.js +3 -1
  86. package/build/esm/src/utils/orders.js +8 -2
  87. package/build/esm/src/utils/prices.js +1 -1
  88. package/build/esm/src/utils/swap/botanixStaking.js +83 -0
  89. package/build/esm/src/utils/swap/buildSwapStrategy.js +219 -0
  90. package/build/esm/src/utils/swap/externalSwapPath.js +37 -0
  91. package/build/esm/src/utils/swap/externalSwapQuoteByPath.js +23 -0
  92. package/build/esm/src/utils/swap/swapValues.js +287 -8
  93. package/build/esm/src/utils/tokens.js +7 -0
  94. package/build/esm/src/utils/trade/amounts.js +89 -41
  95. package/build/esm/src/utils/trade/trade.js +2 -2
  96. package/build/esm/src/utils/twap/uiFeeReceiver.js +24 -5
  97. package/build/types/src/abis/index.d.ts +1 -1
  98. package/build/types/src/configs/batch.d.ts +2 -1
  99. package/build/types/src/configs/chains.d.ts +20 -37
  100. package/build/types/src/configs/contracts.d.ts +62 -63
  101. package/build/types/src/configs/dataStore.d.ts +5 -0
  102. package/build/types/src/configs/express.d.ts +1 -0
  103. package/build/types/src/configs/markets.d.ts +2 -1
  104. package/build/types/src/configs/oracleKeeper.d.ts +2 -3
  105. package/build/types/src/configs/tokens.d.ts +1 -0
  106. package/build/types/src/index.d.ts +1 -1
  107. package/build/types/src/modules/base.d.ts +1 -1
  108. package/build/types/src/modules/orders/helpers.d.ts +10 -2
  109. package/build/types/src/modules/orders/orders.d.ts +10 -1
  110. package/build/types/src/types/orders.d.ts +1 -1
  111. package/build/types/src/types/sdk.d.ts +2 -1
  112. package/build/types/src/types/subsquid.d.ts +691 -0
  113. package/build/types/src/types/swapStrategy.d.ts +33 -0
  114. package/build/types/src/types/tokens.d.ts +6 -0
  115. package/build/types/src/types/trade.d.ts +19 -4
  116. package/build/types/src/utils/multicall.d.ts +1 -1
  117. package/build/types/src/utils/numbers.d.ts +8 -3
  118. package/build/types/src/utils/orderTransactions.d.ts +2 -3
  119. package/build/types/src/utils/prices.d.ts +1 -1
  120. package/build/types/src/utils/swap/botanixStaking.d.ts +11 -0
  121. package/build/types/src/utils/swap/buildSwapStrategy.d.ts +22 -0
  122. package/build/types/src/utils/swap/externalSwapPath.d.ts +13 -0
  123. package/build/types/src/utils/swap/externalSwapQuoteByPath.d.ts +6 -0
  124. package/build/types/src/utils/swap/swapValues.d.ts +10 -3
  125. package/build/types/src/utils/tokens.d.ts +2 -0
  126. package/build/types/src/utils/trade/amounts.d.ts +5 -2
  127. package/build/types/src/utils/twap/uiFeeReceiver.d.ts +13 -0
  128. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ import { ExternalSwapQuote, SwapPathStats } from "./trade";
2
+ type BaseSwapStrategy = {
3
+ amountIn: bigint;
4
+ amountOut: bigint;
5
+ usdIn: bigint;
6
+ usdOut: bigint;
7
+ priceIn: bigint;
8
+ priceOut: bigint;
9
+ feesUsd: bigint;
10
+ };
11
+ export type NoSwapStrategy = BaseSwapStrategy & {
12
+ type: "noSwap";
13
+ externalSwapQuote: undefined;
14
+ swapPathStats: undefined;
15
+ };
16
+ export type ExternalSwapStrategy = BaseSwapStrategy & {
17
+ type: "externalSwap";
18
+ externalSwapQuote: ExternalSwapQuote;
19
+ swapPathStats: undefined;
20
+ };
21
+ export type InternalSwapStrategy = BaseSwapStrategy & {
22
+ type: "internalSwap";
23
+ swapPathStats: SwapPathStats;
24
+ externalSwapQuote: undefined;
25
+ };
26
+ export type CombinedSwapStrategy = BaseSwapStrategy & {
27
+ type: "combinedSwap";
28
+ externalSwapQuote: ExternalSwapQuote;
29
+ swapPathStats: SwapPathStats;
30
+ };
31
+ export type SwapStrategyForIncreaseOrders = NoSwapStrategy | ExternalSwapStrategy | InternalSwapStrategy | CombinedSwapStrategy;
32
+ export type SwapStrategyForSwapOrders = NoSwapStrategy | InternalSwapStrategy | CombinedSwapStrategy;
33
+ export {};
@@ -45,6 +45,7 @@ export type Token = {
45
45
  isV1Available?: boolean;
46
46
  isPlatformToken?: boolean;
47
47
  isPlatformTradingToken?: boolean;
48
+ isStaking?: boolean;
48
49
  shouldResetAllowance?: boolean;
49
50
  };
50
51
  export type TokenInfo = Token & {
@@ -88,6 +89,11 @@ export type SignedTokenPermit = {
88
89
  r: string;
89
90
  s: string;
90
91
  token: string;
92
+ onchainParams: {
93
+ name: string;
94
+ version: string;
95
+ nonce: bigint;
96
+ };
91
97
  };
92
98
  export type InfoTokens = {
93
99
  [key: string]: TokenInfo;
@@ -1,5 +1,7 @@
1
1
  import { ExternalSwapFeeItem, FeeItem, SwapFeeItem } from "./fees";
2
2
  import { DecreasePositionSwapType, OrderType } from "./orders";
3
+ import { SwapStrategyForIncreaseOrders } from "./swapStrategy";
4
+ import { TokensData } from "./tokens";
3
5
  export declare enum TradeType {
4
6
  Long = "Long",
5
7
  Short = "Short",
@@ -39,7 +41,7 @@ export type SwapAmounts = {
39
41
  usdOut: bigint;
40
42
  priceIn: bigint;
41
43
  priceOut: bigint;
42
- swapPathStats: SwapPathStats | undefined;
44
+ swapStrategy: SwapStrategyForIncreaseOrders;
43
45
  minOutputAmount: bigint;
44
46
  uiFeeUsd?: bigint;
45
47
  };
@@ -48,8 +50,7 @@ export type IncreasePositionAmounts = {
48
50
  initialCollateralUsd: bigint;
49
51
  collateralDeltaAmount: bigint;
50
52
  collateralDeltaUsd: bigint;
51
- swapPathStats: SwapPathStats | undefined;
52
- externalSwapQuote: ExternalSwapQuote | undefined;
53
+ swapStrategy: SwapStrategyForIncreaseOrders;
53
54
  indexTokenAmount: bigint;
54
55
  sizeDeltaUsd: bigint;
55
56
  sizeDeltaInTokens: bigint;
@@ -212,7 +213,8 @@ export type FindSwapPath = (usdIn: bigint, opts?: {
212
213
  }) => SwapPathStats | undefined;
213
214
  export type TradeFeesType = "swap" | "increase" | "decrease" | "edit";
214
215
  export declare enum ExternalSwapAggregator {
215
- OpenOcean = "openOcean"
216
+ OpenOcean = "openOcean",
217
+ BotanixStaking = "botanixStaking"
216
218
  }
217
219
  export type ExternalSwapQuote = {
218
220
  aggregator: ExternalSwapAggregator;
@@ -235,6 +237,18 @@ export type ExternalSwapQuote = {
235
237
  estimatedExecutionFee: bigint;
236
238
  };
237
239
  };
240
+ export type ExternalSwapPath = {
241
+ aggregator: ExternalSwapAggregator;
242
+ inTokenAddress: string;
243
+ outTokenAddress: string;
244
+ };
245
+ export type ExternalSwapQuoteParams = {
246
+ chainId: number;
247
+ receiverAddress: string;
248
+ gasPrice: bigint | undefined;
249
+ tokensData: TokensData | undefined;
250
+ botanixStakingAssetsPerShare: bigint | undefined;
251
+ };
238
252
  export type ExternalSwapCalculationStrategy = "byFromValue" | "leverageBySize";
239
253
  export type ExternalSwapInputs = {
240
254
  amountIn: bigint;
@@ -280,5 +294,6 @@ export type TradeSearchParams = {
280
294
  pool?: string;
281
295
  collateral?: string;
282
296
  market?: string;
297
+ chainId?: string;
283
298
  };
284
299
  export {};
@@ -12,7 +12,7 @@ export declare class Multicall {
12
12
  };
13
13
  static getInstance(sdk: GmxSdk): Promise<Multicall>;
14
14
  constructor(sdk: GmxSdk);
15
- get chainId(): number;
15
+ get chainId(): import("../configs/chains").UiContractsChain;
16
16
  call(request: MulticallRequestConfig<any>, maxTimeout: number): Promise<MulticallResult<any>>;
17
17
  }
18
18
  export type SkipKey = null | undefined | false;
@@ -48,11 +48,13 @@ export declare function formatTokenAmount(amount?: bigint, tokenDecimals?: numbe
48
48
  minThreshold?: string;
49
49
  maxThreshold?: string;
50
50
  displayPlus?: boolean;
51
+ isStable?: boolean;
51
52
  }): string | undefined;
52
53
  export declare function formatTokenAmountWithUsd(tokenAmount?: bigint, usdAmount?: bigint, tokenSymbol?: string, tokenDecimals?: number, opts?: {
53
54
  fallbackToZero?: boolean;
54
55
  displayDecimals?: number;
55
56
  displayPlus?: boolean;
57
+ isStable?: boolean;
56
58
  }): string | undefined;
57
59
  /**
58
60
  *
@@ -65,8 +67,11 @@ export declare function formatRatePercentage(rate?: bigint, opts?: {
65
67
  export declare function formatUsdPrice(price?: bigint, opts?: Parameters<typeof formatUsd>[1]): string | undefined;
66
68
  export declare function formatPercentageDisplay(percentage: number, hideThreshold?: number): string;
67
69
  export declare function formatAmountHuman(amount: BigNumberish | undefined, tokenDecimals: number, showDollar?: boolean, displayDecimals?: number): string;
68
- export declare function formatBalanceAmount(amount: bigint, tokenDecimals: number, tokenSymbol?: string, showZero?: boolean, toExponential?: boolean): string;
69
- export declare function formatBalanceAmountWithUsd(amount: bigint, amountUsd: bigint, tokenDecimals: number, tokenSymbol?: string, showZero?: boolean): string;
70
+ export declare function formatBalanceAmount(amount: bigint, tokenDecimals: number, tokenSymbol?: string, { showZero, toExponential, isStable, }?: {
71
+ showZero?: boolean;
72
+ toExponential?: boolean;
73
+ isStable?: boolean;
74
+ }): string;
70
75
  export declare function formatFactor(factor: bigint): string;
71
76
  export declare function numberWithCommas(x: BigNumberish): string;
72
77
  export declare const formatAmount: (amount: BigNumberish | undefined, tokenDecimals: number, displayDecimals?: number, useCommas?: boolean, defaultValue?: string, visualMultiplier?: number) => string;
@@ -117,7 +122,7 @@ type DeserializeBigIntInObject<T> = {
117
122
  };
118
123
  export declare function serializeBigIntsInObject<T extends object>(obj: T): SerializedBigIntsInObject<T>;
119
124
  export declare function deserializeBigIntsInObject<T extends object>(obj: T): DeserializeBigIntInObject<T>;
120
- export declare function calculateDisplayDecimals(price?: bigint, decimals?: number, visualMultiplier?: number): 5 | 2 | 3 | 4 | 6 | 7 | 8 | 9;
125
+ export declare function calculateDisplayDecimals(price?: bigint, decimals?: number, visualMultiplier?: number, isStable?: boolean): 5 | 2 | 3 | 4 | 6 | 7 | 8 | 9;
121
126
  export declare function clamp(value: number, min: number, max: number): number;
122
127
  export declare function absDiffBps(value: bigint, base: bigint): bigint;
123
128
  export {};
@@ -3,7 +3,7 @@ import { DecreasePositionSwapType, OrderType } from "../types/orders";
3
3
  import { ContractPrice, ERC20Address, TokensData } from "../types/tokens";
4
4
  import { ExternalSwapQuote } from "../types/trade";
5
5
  import { TwapOrderParams } from "../types/twap";
6
- type ExchangeRouterCall = {
6
+ export type ExchangeRouterCall = {
7
7
  method: string;
8
8
  params: any[];
9
9
  };
@@ -131,6 +131,7 @@ export type SwapOrderParams = CommonOrderParams & {
131
131
  swapPath: string[];
132
132
  externalSwapQuote: ExternalSwapQuote | undefined;
133
133
  minOutputAmount: bigint;
134
+ expectedOutputAmount?: bigint;
134
135
  orderType: OrderType.MarketSwap | OrderType.LimitSwap;
135
136
  triggerRatio: bigint | undefined;
136
137
  };
@@ -187,7 +188,6 @@ export declare function buildTokenTransfersParamsForIncreaseOrSwap({ chainId, re
187
188
  externalSwapQuote: ExternalSwapQuote | undefined;
188
189
  minOutputAmount: bigint;
189
190
  swapPath: string[];
190
- orderType: OrderType;
191
191
  }): TokenTransfersParams;
192
192
  export declare function getBatchExternalCalls(batchParams: BatchOrderTxnParams): ExternalCallsPayload;
193
193
  export declare function combineExternalCalls(externalCalls: ExternalCallsPayload[]): ExternalCallsPayload;
@@ -228,4 +228,3 @@ export declare function getBatchSwapsCount(orderParams: BatchOrderTxnParams | un
228
228
  export declare function getIsEmptyBatch(orderParams: BatchOrderTxnParams | undefined): boolean;
229
229
  export declare function getBatchIsNativePayment(orderParams: BatchOrderTxnParams): boolean;
230
230
  export declare function getIsInvalidBatchReceiver(batchParams: BatchOrderTxnParams, signerAddress: string): boolean;
231
- export {};
@@ -8,7 +8,7 @@ export declare function getMarkPrice(p: {
8
8
  isLong: boolean;
9
9
  }): bigint;
10
10
  export declare function getShouldUseMaxPrice(isIncrease: boolean, isLong: boolean): boolean;
11
- export declare function getOrderThresholdType(orderType: OrderType, isLong: boolean): TriggerThresholdType;
11
+ export declare function getOrderThresholdType(orderType: OrderType, isLong: boolean): TriggerThresholdType | undefined;
12
12
  export declare function getAcceptablePriceInfo(p: {
13
13
  marketInfo: MarketInfo;
14
14
  isIncrease: boolean;
@@ -0,0 +1,11 @@
1
+ import { TokensData } from "../../types/tokens";
2
+ import { ExternalSwapQuote } from "../../types/trade";
3
+ export declare const getBotanixStakingExternalSwapQuote: ({ tokenInAddress, tokenOutAddress, amountIn, gasPrice, receiverAddress, tokensData, assetsPerShare, }: {
4
+ tokenInAddress: string;
5
+ tokenOutAddress: string;
6
+ amountIn: bigint;
7
+ gasPrice: bigint;
8
+ receiverAddress: string;
9
+ tokensData: TokensData;
10
+ assetsPerShare: bigint;
11
+ }) => ExternalSwapQuote | undefined;
@@ -0,0 +1,22 @@
1
+ import { MarketsInfoData } from "../../types/markets";
2
+ import { SwapStrategyForSwapOrders } from "../../types/swapStrategy";
3
+ import { TokenData } from "../../types/tokens";
4
+ import { ExternalSwapQuoteParams, SwapOptimizationOrderArray } from "../../types/trade";
5
+ export declare function buildSwapStrategy({ amountIn, tokenIn, tokenOut, marketsInfoData, chainId, swapOptimizationOrder, externalSwapQuoteParams, }: {
6
+ chainId: number;
7
+ amountIn: bigint;
8
+ tokenIn: TokenData;
9
+ tokenOut: TokenData;
10
+ marketsInfoData: MarketsInfoData | undefined;
11
+ swapOptimizationOrder: SwapOptimizationOrderArray | undefined;
12
+ externalSwapQuoteParams: ExternalSwapQuoteParams;
13
+ }): SwapStrategyForSwapOrders;
14
+ export declare function buildReverseSwapStrategy({ amountOut, tokenIn, tokenOut, marketsInfoData, chainId, externalSwapQuoteParams, swapOptimizationOrder, }: {
15
+ chainId: number;
16
+ amountOut: bigint;
17
+ tokenIn: TokenData;
18
+ tokenOut: TokenData;
19
+ marketsInfoData: MarketsInfoData | undefined;
20
+ externalSwapQuoteParams: ExternalSwapQuoteParams;
21
+ swapOptimizationOrder: SwapOptimizationOrderArray | undefined;
22
+ }): SwapStrategyForSwapOrders;
@@ -0,0 +1,13 @@
1
+ import { ExternalSwapPath } from "../../types/trade";
2
+ export declare const AVAILABLE_BOTANIX_DEPOSIT_PAIRS: {
3
+ from: string;
4
+ to: string;
5
+ }[];
6
+ export declare const AVAILABLE_BOTANIX_WITHDRAW_PAIRS: {
7
+ from: string;
8
+ to: string;
9
+ }[];
10
+ export declare const getAvailableExternalSwapPaths: ({ chainId, fromTokenAddress, }: {
11
+ chainId: number;
12
+ fromTokenAddress: string;
13
+ }) => ExternalSwapPath[];
@@ -0,0 +1,6 @@
1
+ import { ExternalSwapPath, ExternalSwapQuote, ExternalSwapQuoteParams } from "../../types/trade";
2
+ export declare const getExternalSwapQuoteByPath: ({ amountIn, externalSwapPath, externalSwapQuoteParams, }: {
3
+ amountIn: bigint;
4
+ externalSwapPath: ExternalSwapPath;
5
+ externalSwapQuoteParams: ExternalSwapQuoteParams;
6
+ }) => ExternalSwapQuote | undefined;
@@ -1,6 +1,7 @@
1
+ import { MarketsInfoData } from "../../types/markets";
1
2
  import type { TokenData, TokensRatio } from "../../types/tokens";
2
- import { SwapRoute } from "../../types/trade";
3
3
  import type { FindSwapPath, SwapAmounts, SwapOptimizationOrderArray } from "../../types/trade";
4
+ import { ExternalSwapQuoteParams, SwapRoute } from "../../types/trade";
4
5
  export declare function getSwapAmountsByFromValue(p: {
5
6
  tokenIn: TokenData;
6
7
  tokenOut: TokenData;
@@ -9,8 +10,11 @@ export declare function getSwapAmountsByFromValue(p: {
9
10
  isLimit: boolean;
10
11
  swapOptimizationOrder?: SwapOptimizationOrderArray;
11
12
  allowedSwapSlippageBps?: bigint;
12
- findSwapPath: FindSwapPath;
13
13
  uiFeeFactor: bigint;
14
+ marketsInfoData: MarketsInfoData | undefined;
15
+ chainId: number;
16
+ externalSwapQuoteParams: ExternalSwapQuoteParams | undefined;
17
+ findSwapPath: FindSwapPath;
14
18
  }): SwapAmounts;
15
19
  export declare function getSwapAmountsByToValue(p: {
16
20
  tokenIn: TokenData;
@@ -18,9 +22,12 @@ export declare function getSwapAmountsByToValue(p: {
18
22
  amountOut: bigint;
19
23
  triggerRatio?: TokensRatio;
20
24
  isLimit: boolean;
21
- findSwapPath: FindSwapPath;
22
25
  swapOptimizationOrder?: SwapOptimizationOrderArray;
23
26
  allowedSwapSlippageBps?: bigint;
24
27
  uiFeeFactor: bigint;
28
+ marketsInfoData: MarketsInfoData | undefined;
29
+ chainId: number;
30
+ externalSwapQuoteParams: ExternalSwapQuoteParams | undefined;
31
+ findSwapPath: FindSwapPath;
25
32
  }): SwapAmounts;
26
33
  export declare function getSwapPathComparator(order?: SwapOptimizationOrderArray | undefined): (a: SwapRoute, b: SwapRoute) => 1 | 0 | -1;
@@ -39,6 +39,8 @@ export declare function getAmountByRatio(p: {
39
39
  }): bigint;
40
40
  export declare function getIsWrap(token1: Token, token2: Token): boolean | undefined;
41
41
  export declare function getIsUnwrap(token1: Token, token2: Token): boolean | undefined;
42
+ export declare function getIsStake(token1: Token, token2: Token): boolean | undefined;
43
+ export declare function getIsUnstake(token1: Token, token2: Token): boolean | undefined;
42
44
  export declare function getTokensRatioByPrice(p: {
43
45
  fromToken: Token;
44
46
  toToken: Token;
@@ -1,8 +1,8 @@
1
- import { MarketInfo } from "../../types/markets";
1
+ import { MarketInfo, MarketsInfoData } from "../../types/markets";
2
2
  import { PositionInfo } from "../../types/positions";
3
3
  import { UserReferralInfo } from "../../types/referrals";
4
4
  import { TokenData, TokensRatio } from "../../types/tokens";
5
- import { ExternalSwapQuote, FindSwapPath, IncreasePositionAmounts, TriggerThresholdType } from "../../types/trade";
5
+ import { ExternalSwapQuote, ExternalSwapQuoteParams, FindSwapPath, IncreasePositionAmounts, TriggerThresholdType } from "../../types/trade";
6
6
  type IncreasePositionParams = {
7
7
  marketInfo: MarketInfo;
8
8
  indexToken: TokenData;
@@ -22,6 +22,9 @@ type IncreasePositionParams = {
22
22
  strategy: "leverageBySize" | "leverageByCollateral" | "independent";
23
23
  findSwapPath: FindSwapPath;
24
24
  uiFeeFactor: bigint;
25
+ marketsInfoData: MarketsInfoData | undefined;
26
+ chainId: number;
27
+ externalSwapQuoteParams: ExternalSwapQuoteParams | undefined;
25
28
  };
26
29
  export declare function getIncreasePositionAmounts(p: IncreasePositionParams): IncreasePositionAmounts;
27
30
  export declare function getTokensRatio({ fromToken, toToken, triggerRatioValue, markPrice, }: {
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Ui fee receiver structure:
3
+ * 0-3 (4) bytes (0-7 chars) - PREFIX
4
+ * 4-15 (12) bytes (8-32 chars) - 12 bytes buffer
5
+ * 16 (1) byte (33-34 chars) - isExpress flag
6
+ * 17 (1) byte (35-36 chars) - numberOfParts (hex encoded)
7
+ * 18-19 (2) bytes (37-40 chars) - twapId
8
+ * 20 (1) byte (41-42 chars) - VERSION
9
+ *
10
+ * Total: 0x + 20 bytes (41 hex characters)
11
+ */
1
12
  export declare function generateTwapId(): string;
2
13
  export declare function createTwapUiFeeReceiver({ numberOfParts }: {
3
14
  numberOfParts: number;
@@ -5,5 +16,7 @@ export declare function createTwapUiFeeReceiver({ numberOfParts }: {
5
16
  export declare function decodeTwapUiFeeReceiver(address: string): {
6
17
  twapId: string;
7
18
  numberOfParts: number;
19
+ isExpress: boolean;
8
20
  } | void;
9
21
  export declare function isValidTwapUiFeeReceiver(address: string): boolean;
22
+ export declare function setUiFeeReceiverIsExpress(uiFeeReceiver: string, isExpress: boolean): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "main": "./build/cjs/src/index.js",
6
6
  "module": "./build/esm/src/index.js",