@gmx-io/sdk 1.5.0-alpha-9 → 1.5.0-alpha-10

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 (201) hide show
  1. package/build/cjs/scripts/subsquid-codegen.js +1 -1
  2. package/build/cjs/src/clients/v2/__tests__/data.spec.js +85 -0
  3. package/build/cjs/src/clients/v2/__tests__/decrease.spec.js +471 -0
  4. package/build/cjs/src/clients/v2/__tests__/editCancel.spec.js +259 -0
  5. package/build/cjs/src/clients/v2/__tests__/errors.spec.js +261 -0
  6. package/build/cjs/src/clients/v2/__tests__/increase.spec.js +764 -0
  7. package/build/cjs/src/clients/v2/__tests__/subaccount.spec.js +74 -0
  8. package/build/cjs/src/clients/v2/__tests__/swap.spec.js +192 -0
  9. package/build/cjs/src/clients/v2/__tests__/testUtil.js +136 -0
  10. package/build/cjs/src/clients/v2/index.js +162 -27
  11. package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +48 -0
  12. package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +342 -0
  13. package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +90 -0
  14. package/build/cjs/src/codegen/subsquid.js +323 -1
  15. package/build/cjs/src/configs/chains.js +11 -1
  16. package/build/cjs/src/configs/contracts.js +7 -7
  17. package/build/cjs/src/configs/markets.js +56 -2
  18. package/build/cjs/src/configs/tokens.js +63 -132
  19. package/build/cjs/src/test/mock.js +1 -1
  20. package/build/cjs/src/utils/__tests__/markets.spec.js +10 -0
  21. package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
  22. package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +2 -0
  23. package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
  24. package/build/cjs/src/utils/__tests__/positions.spec.js +59 -7
  25. package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +34 -0
  26. package/build/cjs/src/utils/balances/api.js +65 -0
  27. package/build/cjs/src/utils/buyback/api.js +7 -0
  28. package/build/cjs/src/utils/buyback/types.js +2 -0
  29. package/build/cjs/src/utils/errors/index.js +1 -0
  30. package/build/cjs/src/utils/errors/isIgnoredEstimateGasError.js +23 -0
  31. package/build/cjs/src/utils/express/index.js +18 -0
  32. package/build/cjs/src/utils/express/types.js +2 -0
  33. package/build/cjs/src/utils/express/utils/batchOrderUtils.js +218 -0
  34. package/build/cjs/src/utils/express/utils/bridgeOutUtils.js +73 -0
  35. package/build/cjs/src/utils/express/utils/estimateExpressParams.js +244 -0
  36. package/build/cjs/src/utils/express/utils/expressParamsUtils.js +22 -0
  37. package/build/cjs/src/utils/express/utils/fetchGelatoGasTankBalance.js +13 -0
  38. package/build/cjs/src/utils/express/utils/gelatoRelayUtils.js +77 -0
  39. package/build/cjs/src/utils/express/utils/globalExpressParams.js +40 -0
  40. package/build/cjs/src/utils/express/utils/index.js +27 -0
  41. package/build/cjs/src/utils/express/utils/oracleParamsUtils.js +49 -0
  42. package/build/cjs/src/utils/express/utils/referralUtils.js +35 -0
  43. package/build/cjs/src/utils/express/utils/relayParamsUtils.js +208 -0
  44. package/build/cjs/src/utils/fees/priceImpact.js +1 -2
  45. package/build/cjs/src/utils/http/http.js +86 -13
  46. package/build/cjs/src/utils/markets/utils.js +8 -0
  47. package/build/cjs/src/utils/metrics/index.js +7 -0
  48. package/build/cjs/src/utils/numbers/utils.js +29 -27
  49. package/build/cjs/src/utils/orderTransactions/api.js +88 -0
  50. package/build/cjs/src/utils/orderTransactions/index.js +2 -0
  51. package/build/cjs/src/utils/orderTransactions/simulation.js +141 -0
  52. package/build/cjs/src/utils/orderTransactions/utils.js +4 -1
  53. package/build/cjs/src/utils/orderTransactions/validateTypedData.js +100 -0
  54. package/build/cjs/src/utils/positions/utils.js +5 -19
  55. package/build/cjs/src/utils/rpc/createViemRpc.js +39 -0
  56. package/build/cjs/src/utils/rpc/index.js +5 -0
  57. package/build/cjs/src/utils/signer/index.js +5 -0
  58. package/build/cjs/src/utils/signer/privateKeySigner.js +42 -0
  59. package/build/cjs/src/utils/subaccount/api.js +22 -0
  60. package/build/cjs/src/utils/subaccount/generateSubaccount.js +19 -0
  61. package/build/cjs/src/utils/subaccount/getEmptySubaccountApproval.js +24 -0
  62. package/build/cjs/src/utils/subaccount/getSubaccountApprovalTypedData.js +51 -0
  63. package/build/cjs/src/utils/subaccount/hashSubaccountApproval.js +28 -0
  64. package/build/cjs/src/utils/subaccount/index.js +30 -0
  65. package/build/cjs/src/utils/subaccount/types.js +2 -0
  66. package/build/cjs/src/utils/swap/swapPath.js +4 -1
  67. package/build/cjs/src/utils/trade/types.js +1 -1
  68. package/build/cjs/src/utils/tradeHistory/utils.js +14 -28
  69. package/build/cjs/src/utils/twap/index.js +4 -1
  70. package/build/cjs/src/utils/twap/uiFeeReceiver.js +23 -7
  71. package/build/esm/scripts/subsquid-codegen.js +1 -1
  72. package/build/esm/src/clients/v2/__tests__/data.spec.js +83 -0
  73. package/build/esm/src/clients/v2/__tests__/decrease.spec.js +469 -0
  74. package/build/esm/src/clients/v2/__tests__/editCancel.spec.js +257 -0
  75. package/build/esm/src/clients/v2/__tests__/errors.spec.js +259 -0
  76. package/build/esm/src/clients/v2/__tests__/increase.spec.js +762 -0
  77. package/build/esm/src/clients/v2/__tests__/subaccount.spec.js +72 -0
  78. package/build/esm/src/clients/v2/__tests__/swap.spec.js +190 -0
  79. package/build/esm/src/clients/v2/__tests__/testUtil.js +124 -0
  80. package/build/esm/src/clients/v2/index.js +136 -4
  81. package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +48 -0
  82. package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +342 -0
  83. package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +90 -0
  84. package/build/esm/src/codegen/subsquid.js +321 -0
  85. package/build/esm/src/configs/chains.js +11 -1
  86. package/build/esm/src/configs/contracts.js +7 -7
  87. package/build/esm/src/configs/markets.js +55 -1
  88. package/build/esm/src/configs/tokens.js +62 -130
  89. package/build/esm/src/test/mock.js +1 -1
  90. package/build/esm/src/utils/__tests__/markets.spec.js +10 -0
  91. package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
  92. package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +2 -0
  93. package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
  94. package/build/esm/src/utils/__tests__/positions.spec.js +60 -8
  95. package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +35 -1
  96. package/build/esm/src/utils/balances/api.js +56 -0
  97. package/build/esm/src/utils/buyback/api.js +3 -0
  98. package/build/esm/src/utils/buyback/types.js +1 -0
  99. package/build/esm/src/utils/errors/index.js +1 -0
  100. package/build/esm/src/utils/errors/isIgnoredEstimateGasError.js +19 -0
  101. package/build/esm/src/utils/express/index.js +2 -0
  102. package/build/esm/src/utils/express/types.js +1 -0
  103. package/build/esm/src/utils/express/utils/batchOrderUtils.js +210 -0
  104. package/build/esm/src/utils/express/utils/bridgeOutUtils.js +69 -0
  105. package/build/esm/src/utils/express/utils/estimateExpressParams.js +238 -0
  106. package/build/esm/src/utils/express/utils/expressParamsUtils.js +16 -0
  107. package/build/esm/src/utils/express/utils/fetchGelatoGasTankBalance.js +9 -0
  108. package/build/esm/src/utils/express/utils/gelatoRelayUtils.js +71 -0
  109. package/build/esm/src/utils/express/utils/globalExpressParams.js +36 -0
  110. package/build/esm/src/utils/express/utils/index.js +11 -0
  111. package/build/esm/src/utils/express/utils/oracleParamsUtils.js +42 -0
  112. package/build/esm/src/utils/express/utils/referralUtils.js +30 -0
  113. package/build/esm/src/utils/express/utils/relayParamsUtils.js +198 -0
  114. package/build/esm/src/utils/fees/priceImpact.js +1 -2
  115. package/build/esm/src/utils/http/http.js +84 -12
  116. package/build/esm/src/utils/markets/utils.js +8 -0
  117. package/build/esm/src/utils/metrics/index.js +4 -0
  118. package/build/esm/src/utils/numbers/utils.js +25 -24
  119. package/build/esm/src/utils/orderTransactions/api.js +77 -0
  120. package/build/esm/src/utils/orderTransactions/index.js +2 -0
  121. package/build/esm/src/utils/orderTransactions/simulation.js +136 -0
  122. package/build/esm/src/utils/orderTransactions/utils.js +4 -1
  123. package/build/esm/src/utils/orderTransactions/validateTypedData.js +95 -0
  124. package/build/esm/src/utils/positions/utils.js +5 -19
  125. package/build/esm/src/utils/rpc/createViemRpc.js +35 -0
  126. package/build/esm/src/utils/rpc/index.js +1 -0
  127. package/build/esm/src/utils/signer/index.js +1 -0
  128. package/build/esm/src/utils/signer/privateKeySigner.js +38 -0
  129. package/build/esm/src/utils/subaccount/api.js +16 -0
  130. package/build/esm/src/utils/subaccount/generateSubaccount.js +15 -0
  131. package/build/esm/src/utils/subaccount/getEmptySubaccountApproval.js +20 -0
  132. package/build/esm/src/utils/subaccount/getSubaccountApprovalTypedData.js +47 -0
  133. package/build/esm/src/utils/subaccount/hashSubaccountApproval.js +24 -0
  134. package/build/esm/src/utils/subaccount/index.js +6 -0
  135. package/build/esm/src/utils/subaccount/types.js +1 -0
  136. package/build/esm/src/utils/swap/swapPath.js +5 -2
  137. package/build/esm/src/utils/trade/types.js +1 -1
  138. package/build/esm/src/utils/tradeHistory/utils.js +13 -26
  139. package/build/esm/src/utils/twap/index.js +1 -0
  140. package/build/esm/src/utils/twap/uiFeeReceiver.js +20 -6
  141. package/build/types/src/clients/v2/__tests__/data.spec.d.ts +1 -0
  142. package/build/types/src/clients/v2/__tests__/decrease.spec.d.ts +1 -0
  143. package/build/types/src/clients/v2/__tests__/editCancel.spec.d.ts +1 -0
  144. package/build/types/src/clients/v2/__tests__/errors.spec.d.ts +1 -0
  145. package/build/types/src/clients/v2/__tests__/increase.spec.d.ts +1 -0
  146. package/build/types/src/clients/v2/__tests__/subaccount.spec.d.ts +1 -0
  147. package/build/types/src/clients/v2/__tests__/swap.spec.d.ts +1 -0
  148. package/build/types/src/clients/v2/__tests__/testUtil.d.ts +25 -0
  149. package/build/types/src/clients/v2/index.d.ts +59 -1
  150. package/build/types/src/codegen/prebuilt/index.d.ts +480 -0
  151. package/build/types/src/codegen/subsquid.d.ts +1276 -44
  152. package/build/types/src/configs/chains.d.ts +10 -1
  153. package/build/types/src/configs/contracts.d.ts +6 -6
  154. package/build/types/src/configs/markets.d.ts +5 -0
  155. package/build/types/src/configs/tokens.d.ts +6 -1
  156. package/build/types/src/utils/balances/api.d.ts +39 -0
  157. package/build/types/src/utils/buyback/api.d.ts +5 -0
  158. package/build/types/src/utils/buyback/types.d.ts +15 -0
  159. package/build/types/src/utils/chains/types.d.ts +1 -0
  160. package/build/types/src/utils/errors/index.d.ts +1 -0
  161. package/build/types/src/utils/errors/isIgnoredEstimateGasError.d.ts +2 -0
  162. package/build/types/src/utils/express/index.d.ts +2 -0
  163. package/build/types/src/utils/express/types.d.ts +95 -0
  164. package/build/types/src/utils/express/utils/batchOrderUtils.d.ts +98 -0
  165. package/build/types/src/utils/express/utils/bridgeOutUtils.d.ts +21 -0
  166. package/build/types/src/utils/express/utils/estimateExpressParams.d.ts +37 -0
  167. package/build/types/src/utils/express/utils/expressParamsUtils.d.ts +19 -0
  168. package/build/types/src/utils/express/utils/fetchGelatoGasTankBalance.d.ts +5 -0
  169. package/build/types/src/utils/express/utils/gelatoRelayUtils.d.ts +25 -0
  170. package/build/types/src/utils/express/utils/globalExpressParams.d.ts +31 -0
  171. package/build/types/src/utils/express/utils/index.d.ts +11 -0
  172. package/build/types/src/utils/express/utils/oracleParamsUtils.d.ts +10 -0
  173. package/build/types/src/utils/express/utils/referralUtils.d.ts +17 -0
  174. package/build/types/src/utils/express/utils/relayParamsUtils.d.ts +63 -0
  175. package/build/types/src/utils/http/http.d.ts +16 -1
  176. package/build/types/src/utils/http/types.d.ts +3 -0
  177. package/build/types/src/utils/metrics/index.d.ts +4 -0
  178. package/build/types/src/utils/numbers/utils.d.ts +2 -5
  179. package/build/types/src/utils/orderTransactions/api.d.ts +158 -0
  180. package/build/types/src/utils/orderTransactions/index.d.ts +2 -0
  181. package/build/types/src/utils/orderTransactions/simulation.d.ts +26 -0
  182. package/build/types/src/utils/orderTransactions/validateTypedData.d.ts +6 -0
  183. package/build/types/src/utils/positions/utils.d.ts +1 -9
  184. package/build/types/src/utils/rpc/createViemRpc.d.ts +3 -0
  185. package/build/types/src/utils/rpc/index.d.ts +26 -0
  186. package/build/types/src/utils/signer/index.d.ts +23 -0
  187. package/build/types/src/utils/signer/privateKeySigner.d.ts +19 -0
  188. package/build/types/src/utils/subaccount/api.d.ts +50 -0
  189. package/build/types/src/utils/subaccount/generateSubaccount.d.ts +8 -0
  190. package/build/types/src/utils/subaccount/getEmptySubaccountApproval.d.ts +9 -0
  191. package/build/types/src/utils/subaccount/getSubaccountApprovalTypedData.d.ts +24 -0
  192. package/build/types/src/utils/subaccount/hashSubaccountApproval.d.ts +1 -0
  193. package/build/types/src/utils/subaccount/index.d.ts +7 -0
  194. package/build/types/src/utils/subaccount/types.d.ts +55 -0
  195. package/build/types/src/utils/tokens/types.d.ts +0 -1
  196. package/build/types/src/utils/trade/types.d.ts +1 -1
  197. package/build/types/src/utils/tradeHistory/utils.d.ts +0 -1
  198. package/build/types/src/utils/twap/index.d.ts +1 -0
  199. package/build/types/src/utils/twap/types.d.ts +2 -0
  200. package/build/types/src/utils/twap/uiFeeReceiver.d.ts +10 -2
  201. package/package.json +40 -3
@@ -139,54 +139,63 @@ declare const SOURCE_CHAIN_CONFIGS: {
139
139
  readonly name: "Optimism Sepolia";
140
140
  readonly slug: "optimism-sepolia";
141
141
  readonly explorerUrl: "https://sepolia-optimism.etherscan.io/";
142
+ readonly gasPriceBuffer: undefined;
142
143
  };
143
144
  readonly 11155111: {
144
145
  readonly chainId: 11155111;
145
146
  readonly name: "Sepolia";
146
147
  readonly slug: "sepolia";
147
148
  readonly explorerUrl: "https://sepolia.etherscan.io/";
149
+ readonly gasPriceBuffer: undefined;
148
150
  };
149
151
  readonly 8453: {
150
152
  readonly chainId: 8453;
151
153
  readonly name: "Base";
152
154
  readonly slug: "base-mainnet";
153
155
  readonly explorerUrl: "https://basescan.org/";
156
+ readonly gasPriceBuffer: 3000n;
154
157
  };
155
158
  readonly 56: {
156
159
  readonly chainId: 56;
157
160
  readonly name: "BNB";
158
161
  readonly slug: "bnb-mainnet";
159
162
  readonly explorerUrl: "https://bscscan.com/";
163
+ readonly gasPriceBuffer: 3000n;
160
164
  };
161
165
  readonly 1: {
162
166
  readonly chainId: 1;
163
167
  readonly name: "Ethereum";
164
168
  readonly slug: "ethereum-mainnet";
165
169
  readonly explorerUrl: "https://etherscan.io/";
170
+ readonly gasPriceBuffer: 3000n;
166
171
  };
167
172
  readonly 42161: {
168
173
  readonly chainId: 42161;
169
174
  readonly name: "Arbitrum";
170
175
  readonly slug: "arbitrum";
171
176
  readonly explorerUrl: "https://arbiscan.io/";
177
+ readonly gasPriceBuffer: undefined;
172
178
  };
173
179
  readonly 43114: {
174
180
  readonly chainId: 43114;
175
181
  readonly name: "Avalanche";
176
182
  readonly slug: "avalanche";
177
183
  readonly explorerUrl: "https://snowtrace.io/";
184
+ readonly gasPriceBuffer: undefined;
178
185
  };
179
186
  readonly 421614: {
180
187
  readonly chainId: 421614;
181
188
  readonly name: "Arbitrum Sepolia";
182
189
  readonly slug: "arbitrum-sepolia";
183
190
  readonly explorerUrl: "https://sepolia.arbiscan.io/";
191
+ readonly gasPriceBuffer: undefined;
184
192
  };
185
193
  readonly 43113: {
186
194
  readonly chainId: 43113;
187
195
  readonly name: "Avalanche Fuji";
188
196
  readonly slug: "avalanche-fuji";
189
197
  readonly explorerUrl: "https://testnet.snowtrace.io/";
198
+ readonly gasPriceBuffer: undefined;
190
199
  };
191
200
  };
192
201
  export type ContractsChainName = (typeof CONTRACTS_CHAIN_CONFIGS)[keyof typeof CONTRACTS_CHAIN_CONFIGS]["name"];
@@ -210,7 +219,7 @@ export declare function getMaxFeePerGas(chainId: ContractsChainId): bigint | und
210
219
  export declare function getGasPricePremium(chainId: ContractsChainId): bigint | undefined;
211
220
  export declare function getMaxPriorityFeePerGas(chainId: ContractsChainId): 1500000000n | 7n | 500000n;
212
221
  export declare function getMinExecutionFeeUsd(chainId: ContractsChainId): 1000000000000000000000000000n | undefined;
213
- export declare function getGasPriceBuffer(chainId: ContractsChainId): 2000n | undefined;
222
+ export declare function getGasPriceBuffer(chainId: ContractsChainId | SourceChainId): 2000n | 3000n | undefined;
214
223
  export declare function isChainDisabled(chainId: ContractsChainId): false;
215
224
  export declare function getChainNativeTokenSymbol(chainId: ContractsChainId): "ETH" | "AVAX" | "BTC";
216
225
  export declare function getChainWrappedTokenSymbol(chainId: ContractsChainId): "WETH" | "WAVAX" | "PBTC";
@@ -57,7 +57,7 @@ export declare const CONTRACTS: {
57
57
  ChainlinkPriceFeedProvider: string;
58
58
  ClaimHandler: string;
59
59
  ExternalHandler: string;
60
- OpenOceanRouter: string;
60
+ KyberSwapRouter: string;
61
61
  Multicall: string;
62
62
  ArbitrumNodeInterface: string;
63
63
  LayerZeroEndpoint: string;
@@ -119,7 +119,7 @@ export declare const CONTRACTS: {
119
119
  ChainlinkPriceFeedProvider: string;
120
120
  ClaimHandler: string;
121
121
  ExternalHandler: string;
122
- OpenOceanRouter: string;
122
+ KyberSwapRouter: string;
123
123
  Multicall: string;
124
124
  ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
125
125
  LayerZeroEndpoint: string;
@@ -152,7 +152,7 @@ export declare const CONTRACTS: {
152
152
  ChainlinkPriceFeedProvider: string;
153
153
  ClaimHandler: string;
154
154
  ExternalHandler: string;
155
- OpenOceanRouter: "0x0000000000000000000000000000000000000000";
155
+ KyberSwapRouter: "0x0000000000000000000000000000000000000000";
156
156
  Multicall: string;
157
157
  LayerZeroEndpoint: string;
158
158
  ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
@@ -218,7 +218,7 @@ export declare const CONTRACTS: {
218
218
  ChainlinkPriceFeedProvider: string;
219
219
  ClaimHandler: string;
220
220
  ExternalHandler: string;
221
- OpenOceanRouter: "0x0000000000000000000000000000000000000000";
221
+ KyberSwapRouter: string;
222
222
  Multicall: string;
223
223
  LayerZeroEndpoint: string;
224
224
  ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
@@ -310,7 +310,7 @@ export declare const CONTRACTS: {
310
310
  LayerZeroProvider: string;
311
311
  ChainlinkPriceFeedProvider: string;
312
312
  ClaimHandler: string;
313
- OpenOceanRouter: "0x0000000000000000000000000000000000000000";
313
+ KyberSwapRouter: "0x0000000000000000000000000000000000000000";
314
314
  ExternalHandler: string;
315
315
  Multicall: string;
316
316
  ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
@@ -355,7 +355,7 @@ export declare const CONTRACTS: {
355
355
  BN_GMX: "0x0000000000000000000000000000000000000000";
356
356
  USDG: "0x0000000000000000000000000000000000000000";
357
357
  ES_GMX_IOU: "0x0000000000000000000000000000000000000000";
358
- OpenOceanRouter: "0x0000000000000000000000000000000000000000";
358
+ KyberSwapRouter: "0x0000000000000000000000000000000000000000";
359
359
  Vault: "0x0000000000000000000000000000000000000000";
360
360
  PositionRouter: "0x0000000000000000000000000000000000000000";
361
361
  RewardRouter: "0x0000000000000000000000000000000000000000";
@@ -9,6 +9,11 @@ export type MarketConfig = {
9
9
  };
10
10
  export type MarketsConfigMap = Record<string, MarketConfig>;
11
11
  export declare const MARKETS: Record<ContractsChainId, MarketsConfigMap>;
12
+ /**
13
+ * Markets excluded from swap path routing (collateral swaps and express fee swaps).
14
+ * GM token buying/selling of these markets is unaffected — only routing through them is blocked.
15
+ */
16
+ export declare const DISABLED_SWAP_ROUTE_MARKETS: Partial<Record<ContractsChainId, string[]>>;
12
17
  export type MarketLabel = `${string}/USD [${string}-${string}]`;
13
18
  export declare function getMarketsByChainId(chainId: ContractsChainId): Record<string, MarketConfig>;
14
19
  export declare function getMarketByLabel(chainId: ContractsChainId, label: MarketLabel): MarketConfig;
@@ -38,6 +38,12 @@ export declare const TOKEN_COLOR_MAP: {
38
38
  MATIC: string;
39
39
  EIGEN: string;
40
40
  SATS: string;
41
+ XAU: string;
42
+ XAG: string;
43
+ GOLD: string;
44
+ SILVER: string;
45
+ XPT: string;
46
+ XPD: string;
41
47
  default: string;
42
48
  };
43
49
  export declare const TOKENS_MAP: {
@@ -87,7 +93,6 @@ export declare function getTokenBySymbol(chainId: number, symbol: string, { isSy
87
93
  export declare function convertTokenAddress<T extends keyof TokenAddressTypesMap, R extends TokenAddressTypesMap[T]>(chainId: number, address: string, convertTo?: T): R;
88
94
  export declare function getNormalizedTokenSymbol(tokenSymbol: string): string;
89
95
  export declare function isChartAvailableForToken(chainId: number, tokenSymbol: string): boolean;
90
- export declare function getPriceDecimals(chainId: number, tokenSymbol?: string): number;
91
96
  export declare function getTokenBySymbolSafe(chainId: number, symbol: string, params?: Parameters<typeof getTokenBySymbol>[2]): Token | undefined;
92
97
  export declare function isTokenInList(token: Token, tokenList: Token[]): boolean;
93
98
  export declare function isSimilarToken(tokenA: Token, tokenB: Token): boolean;
@@ -0,0 +1,39 @@
1
+ import { ContractsChainId } from "../../configs/chains";
2
+ import { IHttp } from "../http/types";
3
+ export type ApproveTokenParams = {
4
+ tokenAddress: string;
5
+ spender: SpenderType;
6
+ amount?: bigint;
7
+ };
8
+ export type ApproveTokenResult = {
9
+ to: string;
10
+ data: string;
11
+ value: bigint;
12
+ };
13
+ export type WalletBalance = {
14
+ symbol: string;
15
+ address: string;
16
+ decimals: number;
17
+ balance: bigint;
18
+ };
19
+ export type TokenAllowance = {
20
+ symbol: string;
21
+ address: string;
22
+ decimals: number;
23
+ allowance: bigint;
24
+ };
25
+ export type SpenderType = "router" | "glv";
26
+ export declare function fetchWalletBalances(ctx: {
27
+ api: IHttp;
28
+ }, params: {
29
+ address: string;
30
+ }): Promise<WalletBalance[]>;
31
+ export declare function fetchAllowances(ctx: {
32
+ api: IHttp;
33
+ }, params: {
34
+ address: string;
35
+ spender: SpenderType;
36
+ }): Promise<TokenAllowance[]>;
37
+ export declare function buildApproveTransaction(ctx: {
38
+ chainId: ContractsChainId;
39
+ }, params: ApproveTokenParams): ApproveTokenResult;
@@ -0,0 +1,5 @@
1
+ import { IHttp } from "../http/types";
2
+ import { BuybackWeeklyStatsResponse } from "./types";
3
+ export declare function fetchApiBuybackWeeklyStats(ctx: {
4
+ api: IHttp;
5
+ }): Promise<BuybackWeeklyStatsResponse>;
@@ -0,0 +1,15 @@
1
+ export type BuybackWeekData = {
2
+ weekStart: number;
3
+ weekEnd: number;
4
+ weeklyAccrued: string;
5
+ cumulativeAccrued: string;
6
+ };
7
+ export type BuybackSummary = {
8
+ totalAccrued: string;
9
+ latestWeekAccrued: string;
10
+ weeksTracked: number;
11
+ };
12
+ export type BuybackWeeklyStatsResponse = {
13
+ summary: BuybackSummary;
14
+ weeks: BuybackWeekData[];
15
+ };
@@ -54,4 +54,5 @@ export type SourceChainConfig = {
54
54
  name: string;
55
55
  slug: string;
56
56
  explorerUrl: string;
57
+ gasPriceBuffer?: bigint;
57
58
  };
@@ -1,2 +1,3 @@
1
+ export * from "./isIgnoredEstimateGasError";
1
2
  export * from "./parseError";
2
3
  export * from "./transactionsErrors";
@@ -0,0 +1,2 @@
1
+ import type { ErrorLike } from "./parseError";
2
+ export declare function isIgnoredEstimateGasError(error: ErrorLike): boolean;
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./utils";
@@ -0,0 +1,95 @@
1
+ import type { ExternalCallsPayload } from "../orderTransactions";
2
+ import type { Subaccount, SubaccountValidations } from "../subaccount";
3
+ import type { SignedTokenPermit, TokenData } from "../tokens/types";
4
+ export type { Subaccount, SubaccountOnchainData, SubaccountSerializedConfig, SignedSubaccountApproval, SubaccountValidations } from "../subaccount";
5
+ export type OracleParamsPayload = {
6
+ tokens: string[];
7
+ providers: string[];
8
+ data: string[];
9
+ };
10
+ export type RelayFeePayload = {
11
+ feeToken: string;
12
+ feeAmount: bigint;
13
+ feeSwapPath: string[];
14
+ };
15
+ export type RelayParamsPayload = {
16
+ oracleParams: OracleParamsPayload;
17
+ tokenPermits: SignedTokenPermit[];
18
+ externalCalls: ExternalCallsPayload;
19
+ fee: RelayFeePayload;
20
+ deadline: bigint;
21
+ desChainId: bigint;
22
+ userNonce: bigint;
23
+ };
24
+ export type RelayParamsPayloadWithSignature = RelayParamsPayload & {
25
+ signature: string;
26
+ };
27
+ export type RawRelayParamsPayload = Omit<RelayParamsPayload, "deadline">;
28
+ export type GasPaymentParams = {
29
+ gasPaymentToken: TokenData;
30
+ relayFeeToken: TokenData;
31
+ gasPaymentTokenAddress: string;
32
+ relayerFeeTokenAddress: string;
33
+ relayerFeeAmount: bigint;
34
+ gasPaymentTokenAmount: bigint;
35
+ totalRelayerFeeTokenAmount: bigint;
36
+ gasPaymentTokenAsCollateralAmount: bigint;
37
+ };
38
+ export type GasPaymentValidations = {
39
+ isOutGasTokenBalance: boolean;
40
+ needGasPaymentTokenApproval: boolean;
41
+ isValid: boolean;
42
+ };
43
+ export type BatchTypedData = {
44
+ domain: {
45
+ name: string;
46
+ version: string;
47
+ chainId: number;
48
+ verifyingContract: string;
49
+ };
50
+ types: Record<string, {
51
+ name: string;
52
+ type: string;
53
+ }[]>;
54
+ message: Record<string, any>;
55
+ };
56
+ export type ExpressTxnData = {
57
+ callData: string;
58
+ to: string;
59
+ feeToken: string;
60
+ feeAmount: bigint;
61
+ };
62
+ export type ExpressParamsEstimationMethod = "approximate" | "estimateGas";
63
+ export type ExpressTxnParams = {
64
+ chainId: number;
65
+ subaccount: Subaccount | undefined;
66
+ relayParamsPayload: RawRelayParamsPayload;
67
+ gasPaymentParams: GasPaymentParams;
68
+ gasLimit: bigint;
69
+ l1GasLimit: bigint;
70
+ gasPrice: bigint;
71
+ executionFeeAmount: bigint;
72
+ executionGasLimit: bigint;
73
+ estimationMethod: ExpressParamsEstimationMethod;
74
+ gasPaymentValidations: GasPaymentValidations;
75
+ subaccountValidations: SubaccountValidations | undefined;
76
+ isGmxAccount: boolean;
77
+ };
78
+ export type ExpressTransactionBuilder = (params: {
79
+ relayParams: RawRelayParamsPayload;
80
+ gasPaymentParams: GasPaymentParams;
81
+ subaccount: Subaccount | undefined;
82
+ }) => Promise<{
83
+ txnData: ExpressTxnData;
84
+ }>;
85
+ export type ExpressTransactionEstimatorParams = {
86
+ account: string;
87
+ gasPaymentTokenAsCollateralAmount: bigint;
88
+ executionFeeAmount: bigint;
89
+ executionGasLimit: bigint;
90
+ transactionPayloadGasLimit: bigint;
91
+ transactionExternalCalls: ExternalCallsPayload | undefined;
92
+ subaccountActions: number;
93
+ isValid: boolean;
94
+ expressTransactionBuilder: ExpressTransactionBuilder;
95
+ };
@@ -0,0 +1,98 @@
1
+ import type { ContractsChainId, SourceChainId } from "../../../configs/chains";
2
+ import type { IMetrics } from "../../metrics";
3
+ import type { BatchOrderTxnParams } from "../../orderTransactions";
4
+ import type { IRpc } from "../../rpc";
5
+ import type { BuiltGlobalExpressParams } from "./globalExpressParams";
6
+ import type { BatchTypedData, ExpressTxnData, RawRelayParamsPayload, RelayParamsPayload } from "../types";
7
+ export declare function getBatchTypedData({ chainId, signingChainId, batchParams, relayParams, account, subaccountApprovalHash, relayRouterAddress, }: {
8
+ chainId: ContractsChainId;
9
+ signingChainId?: SourceChainId | ContractsChainId;
10
+ batchParams: BatchOrderTxnParams;
11
+ relayParams: RelayParamsPayload;
12
+ account: string;
13
+ subaccountApprovalHash?: string;
14
+ relayRouterAddress: string;
15
+ }): BatchTypedData;
16
+ export declare function buildBatchOrderCalldata({ chainId, batchParams, relayParamsPayload, signature, account, srcChainId, subaccountApproval, isGmxAccount, deadline: overrideDeadline, }: {
17
+ chainId: ContractsChainId;
18
+ batchParams: BatchOrderTxnParams;
19
+ relayParamsPayload: RawRelayParamsPayload;
20
+ signature: string;
21
+ account: string;
22
+ srcChainId?: SourceChainId;
23
+ subaccountApproval?: {
24
+ subaccount: string;
25
+ [key: string]: any;
26
+ };
27
+ isGmxAccount: boolean;
28
+ deadline?: bigint;
29
+ }): ExpressTxnData & {
30
+ relayRouterAddress: string;
31
+ };
32
+ export declare function getBatchParamsLists(batchParams: BatchOrderTxnParams): {
33
+ createOrderParamsList: {
34
+ addresses: {
35
+ receiver: string;
36
+ uiFeeReceiver: string;
37
+ cancellationReceiver: string;
38
+ callbackContract: string;
39
+ market: string;
40
+ initialCollateralToken: import("../../tokens").ERC20Address;
41
+ swapPath: string[];
42
+ };
43
+ numbers: {
44
+ sizeDeltaUsd: bigint;
45
+ initialCollateralDeltaAmount: bigint;
46
+ triggerPrice: 0n | import("../../tokens").ContractPrice;
47
+ acceptablePrice: 0n | import("../../tokens").ContractPrice;
48
+ executionFee: bigint;
49
+ callbackGasLimit: bigint;
50
+ minOutputAmount: bigint;
51
+ validFromTime: bigint;
52
+ };
53
+ orderType: import("../../orders").OrderType;
54
+ decreasePositionSwapType: import("../../orders").DecreasePositionSwapType;
55
+ isLong: boolean;
56
+ shouldUnwrapNativeToken: boolean;
57
+ autoCancel: boolean;
58
+ referralCode: string;
59
+ dataList: string[];
60
+ }[];
61
+ updateOrderParamsList: {
62
+ key: string;
63
+ sizeDeltaUsd: bigint;
64
+ acceptablePrice: import("../../tokens").ContractPrice;
65
+ triggerPrice: import("../../tokens").ContractPrice;
66
+ minOutputAmount: bigint;
67
+ validFromTime: bigint;
68
+ autoCancel: boolean;
69
+ executionFeeIncrease: bigint;
70
+ }[];
71
+ cancelOrderKeys: string[];
72
+ };
73
+ export declare function buildSignedBatchOrderCalldata({ config, account, batchParams, relayParamsPayload, signature, isGmxAccount, signingChainId, subaccountApproval, deadline, }: {
74
+ config: BuiltGlobalExpressParams;
75
+ account: string;
76
+ batchParams: BatchOrderTxnParams;
77
+ relayParamsPayload: RawRelayParamsPayload;
78
+ signature: string;
79
+ isGmxAccount: boolean;
80
+ signingChainId?: number;
81
+ subaccountApproval?: {
82
+ subaccount: string;
83
+ [key: string]: any;
84
+ };
85
+ deadline?: bigint;
86
+ }): ExpressTxnData & {
87
+ relayRouterAddress: string;
88
+ };
89
+ export declare function simulateExpressOrder({ rpc, simulationOrigin, callData, to, stateOverride, metrics, }: {
90
+ rpc: IRpc;
91
+ simulationOrigin: string;
92
+ callData: string;
93
+ to: string;
94
+ stateOverride?: Parameters<IRpc["estimateGas"]>[0]["stateOverride"];
95
+ metrics?: IMetrics;
96
+ }): Promise<{
97
+ gasLimit: bigint;
98
+ }>;
@@ -0,0 +1,21 @@
1
+ import type { ContractsChainId, SourceChainId } from "../../../configs/chains";
2
+ import type { IAbstractSigner } from "../../signer";
3
+ import type { ExpressTxnData, RawRelayParamsPayload } from "../types";
4
+ export type BridgeOutParams = {
5
+ token: string;
6
+ amount: bigint;
7
+ minAmountOut: bigint;
8
+ provider: string;
9
+ data: string;
10
+ };
11
+ export declare function buildAndSignBridgeOutTxn({ chainId, srcChainId, relayParamsPayload, params, signer, account, emptySignature, relayerFeeTokenAddress, relayerFeeAmount, }: {
12
+ chainId: ContractsChainId;
13
+ srcChainId: SourceChainId;
14
+ relayParamsPayload: RawRelayParamsPayload;
15
+ params: BridgeOutParams;
16
+ signer: IAbstractSigner | undefined;
17
+ account: string;
18
+ emptySignature?: boolean;
19
+ relayerFeeTokenAddress: string;
20
+ relayerFeeAmount: bigint;
21
+ }): Promise<ExpressTxnData>;
@@ -0,0 +1,37 @@
1
+ import type { ContractsChainId } from "../../../configs/chains";
2
+ import type { IMetrics } from "../../metrics";
3
+ import type { IRpc, StateOverrideEntry } from "../../rpc";
4
+ import type { SignedTokenPermit, TokenData, TokensAllowanceData } from "../../tokens/types";
5
+ import type { BuiltGlobalExpressParams } from "./globalExpressParams";
6
+ import type { ExpressParamsEstimationMethod, ExpressTransactionEstimatorParams, ExpressTxnParams, GasPaymentValidations, Subaccount, SubaccountValidations } from "../types";
7
+ export declare function getNeedTokenApprove(tokenAllowanceData: TokensAllowanceData | undefined, tokenAddress: string | undefined, amountToSpend: bigint | undefined, permits: SignedTokenPermit[]): boolean;
8
+ export declare function getGasPaymentValidations({ gasPaymentToken, gasPaymentTokenAmount, gasPaymentTokenAsCollateralAmount, gasPaymentAllowanceData, tokenPermits, isGmxAccount, }: {
9
+ gasPaymentToken: TokenData;
10
+ gasPaymentTokenAmount: bigint;
11
+ gasPaymentTokenAsCollateralAmount: bigint;
12
+ gasPaymentAllowanceData: TokensAllowanceData | undefined;
13
+ tokenPermits: SignedTokenPermit[];
14
+ isGmxAccount: boolean;
15
+ }): GasPaymentValidations;
16
+ export type EstimateExpressParamsInput = {
17
+ chainId: ContractsChainId;
18
+ isGmxAccount: boolean;
19
+ globalExpressParams: BuiltGlobalExpressParams;
20
+ transactionParams: ExpressTransactionEstimatorParams;
21
+ estimationMethod?: ExpressParamsEstimationMethod;
22
+ requireValidations?: boolean;
23
+ subaccount?: Subaccount;
24
+ throwOnInvalid?: boolean;
25
+ overrideGasLimit?: bigint;
26
+ rpc?: IRpc;
27
+ simulationOrigin?: string;
28
+ stateOverride?: StateOverrideEntry[];
29
+ metrics?: IMetrics;
30
+ gasPaymentAllowanceData?: TokensAllowanceData;
31
+ getSubaccountValidations?: (params: {
32
+ requiredActions: number;
33
+ subaccount: Subaccount;
34
+ subaccountRouterAddress: string;
35
+ }) => SubaccountValidations;
36
+ };
37
+ export declare function estimateExpressParams({ chainId, isGmxAccount, transactionParams, globalExpressParams, estimationMethod, requireValidations, subaccount: rawSubaccount, throwOnInvalid, overrideGasLimit, rpc, simulationOrigin, stateOverride, metrics, gasPaymentAllowanceData, getSubaccountValidations, }: EstimateExpressParamsInput): Promise<ExpressTxnParams | undefined>;
@@ -0,0 +1,19 @@
1
+ import type { GasPaymentValidations } from "../types";
2
+ export declare class ExpressEstimationError extends Error {
3
+ name: string;
4
+ }
5
+ export declare class ExpressEstimationInsufficientGasPaymentTokenBalanceError extends ExpressEstimationError {
6
+ readonly params?: {
7
+ balance?: bigint | undefined;
8
+ requiredAmount?: bigint | undefined;
9
+ } | undefined;
10
+ name: string;
11
+ constructor(params?: {
12
+ balance?: bigint | undefined;
13
+ requiredAmount?: bigint | undefined;
14
+ } | undefined);
15
+ }
16
+ export declare function getIsValidExpressParams({ gasPaymentValidations, }: {
17
+ gasPaymentValidations: GasPaymentValidations;
18
+ [key: string]: unknown;
19
+ }): boolean;
@@ -0,0 +1,5 @@
1
+ export declare function fetchGelatoGasTankBalance(chainId: number): Promise<{
2
+ balance: bigint;
3
+ decimals: number;
4
+ unit: string;
5
+ } | undefined>;
@@ -0,0 +1,25 @@
1
+ import type { ContractsChainId } from "../../../configs/chains";
2
+ import { type GelatoEvmRelayerClient } from "../../gelatoRelay/utils";
3
+ import type { ExpressTxnData } from "../types";
4
+ export declare class GelatoRelayError extends Error {
5
+ readonly cause?: unknown;
6
+ constructor(message: string, cause?: unknown);
7
+ }
8
+ export type GelatoRelayResult = {
9
+ taskId: string;
10
+ relayerClient: GelatoEvmRelayerClient;
11
+ };
12
+ export declare function sendToGelatoRelay({ chainId, txnData, }: {
13
+ chainId: ContractsChainId;
14
+ txnData: ExpressTxnData;
15
+ }): Promise<GelatoRelayResult>;
16
+ export declare function waitForGelatoTask(relayerClient: GelatoEvmRelayerClient, taskId: string, options?: {
17
+ timeout?: number;
18
+ pollingInterval?: number;
19
+ }): Promise<{
20
+ transactionHash?: string;
21
+ blockNumber?: number;
22
+ status: "success" | "failed";
23
+ statusCode: number;
24
+ message?: string;
25
+ }>;
@@ -0,0 +1,31 @@
1
+ import type { ContractsChainId } from "../../../configs/chains";
2
+ import type { GasLimitsConfig, L1ExpressOrderGasReference } from "../../fees/types";
3
+ import type { MarketsInfoData } from "../../markets/types";
4
+ import type { SignedTokenPermit, TokensData } from "../../tokens/types";
5
+ export type GlobalExpressParams = {
6
+ chainId: ContractsChainId;
7
+ gasLimits: GasLimitsConfig;
8
+ gasPrice: bigint;
9
+ tokensData: TokensData;
10
+ marketsInfoData: MarketsInfoData;
11
+ gasPaymentTokenAddress?: string;
12
+ tokenPermits?: SignedTokenPermit[];
13
+ l1Reference?: L1ExpressOrderGasReference;
14
+ bufferBps?: number;
15
+ };
16
+ export declare function buildGlobalExpressParams({ chainId, gasLimits, gasPrice, tokensData, marketsInfoData, gasPaymentTokenAddress, tokenPermits, l1Reference, bufferBps, }: GlobalExpressParams): {
17
+ chainId: 43114 | 42161 | 3637 | 4326 | 43113 | 421614;
18
+ gasLimits: GasLimitsConfig;
19
+ gasPrice: bigint;
20
+ tokensData: TokensData;
21
+ marketsInfoData: MarketsInfoData;
22
+ gasPaymentTokenAddress: string;
23
+ relayerFeeTokenAddress: string;
24
+ gasPaymentToken: import("../../tokens/types").TokenData;
25
+ relayerFeeToken: import("../../tokens/types").TokenData;
26
+ tokenPermits: SignedTokenPermit[];
27
+ l1Reference: L1ExpressOrderGasReference | undefined;
28
+ bufferBps: number;
29
+ findFeeSwapPath: import("../../trade").FindSwapPath;
30
+ };
31
+ export type BuiltGlobalExpressParams = ReturnType<typeof buildGlobalExpressParams>;
@@ -0,0 +1,11 @@
1
+ export * from "../types";
2
+ export * from "./oracleParamsUtils";
3
+ export * from "./relayParamsUtils";
4
+ export * from "./batchOrderUtils";
5
+ export * from "./gelatoRelayUtils";
6
+ export * from "./globalExpressParams";
7
+ export * from "./expressParamsUtils";
8
+ export * from "./estimateExpressParams";
9
+ export * from "./fetchGelatoGasTankBalance";
10
+ export * from "./bridgeOutUtils";
11
+ export * from "./referralUtils";
@@ -0,0 +1,10 @@
1
+ import { ContractsChainId } from "../../../configs/chains";
2
+ import type { ExternalCallsPayload } from "../../orderTransactions";
3
+ import type { OracleParamsPayload } from "../types";
4
+ export declare function getOracleParamsForRelayParams({ chainId, gasPaymentTokenAddress, relayerFeeTokenAddress, feeSwapPath, externalCalls, }: {
5
+ chainId: ContractsChainId;
6
+ gasPaymentTokenAddress: string;
7
+ relayerFeeTokenAddress: string;
8
+ feeSwapPath: string[];
9
+ externalCalls: ExternalCallsPayload | undefined;
10
+ }): OracleParamsPayload;
@@ -0,0 +1,17 @@
1
+ import type { ContractsChainId, SourceChainId } from "../../../configs/chains";
2
+ import type { IAbstractSigner } from "../../signer";
3
+ import type { RelayParamsPayload } from "../types";
4
+ export declare function signSetTraderReferralCode({ signer, relayParams, referralCode, chainId, srcChainId, }: {
5
+ signer: IAbstractSigner;
6
+ relayParams: RelayParamsPayload;
7
+ referralCode: string;
8
+ chainId: ContractsChainId;
9
+ srcChainId: SourceChainId;
10
+ }): Promise<string>;
11
+ export declare function signRegisterCode({ signer, relayParams, referralCode, chainId, srcChainId, }: {
12
+ signer: IAbstractSigner;
13
+ relayParams: RelayParamsPayload;
14
+ referralCode: string;
15
+ chainId: ContractsChainId;
16
+ srcChainId: SourceChainId;
17
+ }): Promise<string>;