@gmx-io/sdk 1.0.5 → 1.0.7

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 (194) hide show
  1. package/build/cjs/src/abis/ArbitrumNodeInterface.json +105 -0
  2. package/build/cjs/src/abis/CustomErrors.json +613 -16
  3. package/build/cjs/src/abis/ERC20PermitInterface.json +118 -0
  4. package/build/cjs/src/abis/GelatoRelayRouter.json +1426 -0
  5. package/build/cjs/src/abis/RelayParams.json +110 -0
  6. package/build/cjs/src/abis/SubaccountApproval.json +17 -0
  7. package/build/cjs/src/abis/SubaccountGelatoRelayRouter.json +1885 -0
  8. package/build/cjs/src/abis/SyntheticsReader.json +1 -131
  9. package/build/cjs/src/abis/__tests__/abis.spec.js +40 -0
  10. package/build/cjs/src/abis/index.js +8 -0
  11. package/build/cjs/src/configs/__tests__/permits.spec.js +109 -0
  12. package/build/cjs/src/configs/__tests__/tokens.spec.js +1 -1
  13. package/build/cjs/src/configs/chains.js +36 -5
  14. package/build/cjs/src/configs/contracts.js +15 -3
  15. package/build/cjs/src/configs/dataStore.js +26 -4
  16. package/build/cjs/src/configs/express.js +35 -0
  17. package/build/cjs/src/configs/factors.js +6 -4
  18. package/build/cjs/src/configs/tokens.js +50 -0
  19. package/build/cjs/src/configs/twap.js +10 -0
  20. package/build/cjs/src/index.js +3 -3
  21. package/build/cjs/src/modules/markets/index.js +1 -0
  22. package/build/cjs/src/modules/markets/query-builders.js +4 -0
  23. package/build/cjs/src/modules/orders/helpers.js +3 -1
  24. package/build/cjs/src/modules/orders/transactions/createDecreaseOrderTxn.js +1 -1
  25. package/build/cjs/src/modules/orders/transactions/createIncreaseOrderTxn.js +6 -3
  26. package/build/cjs/src/modules/orders/transactions/createSwapOrderTxn.js +1 -1
  27. package/build/cjs/src/modules/utils/utils.js +11 -1
  28. package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +119 -0
  29. package/build/cjs/src/test/mock.js +30 -1
  30. package/build/cjs/src/types/subsquid.js +2303 -0
  31. package/build/cjs/src/types/twap.js +2 -0
  32. package/build/cjs/src/utils/__tests__/numbers.spec.js +217 -0
  33. package/build/cjs/src/utils/__tests__/orderTransactions/batchUtils.spec.js +241 -0
  34. package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +595 -0
  35. package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +296 -0
  36. package/build/cjs/src/utils/__tests__/orderTransactions/externalCalls.spec.js +118 -0
  37. package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +762 -0
  38. package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +469 -0
  39. package/build/cjs/src/utils/__tests__/orderTransactions/updateOrder.spec.js +80 -0
  40. package/build/cjs/src/utils/__tests__/parseError.spec.js +263 -0
  41. package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +45 -0
  42. package/build/cjs/src/utils/bigmath.js +3 -0
  43. package/build/cjs/src/utils/callContract.js +2 -2
  44. package/build/cjs/src/utils/errors/index.js +18 -0
  45. package/build/cjs/src/utils/errors/parseError.js +150 -0
  46. package/build/cjs/src/utils/{contracts.js → errors/transactionsErrors.js} +35 -3
  47. package/build/cjs/src/utils/fees/executionFee.js +52 -1
  48. package/build/cjs/src/utils/fees/index.js +8 -4
  49. package/build/cjs/src/utils/gelatoRelay.js +5 -0
  50. package/build/cjs/src/utils/hash.js +6 -1
  51. package/build/cjs/src/utils/marketKeysAndConfigs.js +4 -0
  52. package/build/cjs/src/utils/markets.js +7 -3
  53. package/build/cjs/src/utils/numbers.js +560 -5
  54. package/build/cjs/src/utils/orderTransactions.js +638 -0
  55. package/build/cjs/src/utils/orders.js +7 -1
  56. package/build/cjs/src/utils/simulateExecuteOrder.js +6 -2
  57. package/build/cjs/src/utils/swap/__tests__/mockRouting.spec.js +11 -6
  58. package/build/cjs/src/utils/swap/__tests__/swapRouting.spec.js +4 -4
  59. package/build/cjs/src/utils/swap/__tests__/swapStats.spec.js +9 -0
  60. package/build/cjs/src/utils/swap/swapPath.js +30 -13
  61. package/build/cjs/src/utils/swap/swapRouting.js +4 -2
  62. package/build/cjs/src/utils/swap/swapStats.js +6 -5
  63. package/build/cjs/src/utils/testUtil.js +1 -1
  64. package/build/cjs/src/utils/time.js +30 -0
  65. package/build/cjs/src/utils/tokens.js +16 -2
  66. package/build/cjs/src/utils/tradeHistory.js +4 -4
  67. package/build/cjs/src/utils/twap/index.js +53 -0
  68. package/build/cjs/src/utils/twap/uiFeeReceiver.js +31 -0
  69. package/build/cjs/src/utils/types.js +13 -0
  70. package/build/esm/src/abis/ArbitrumNodeInterface.json +105 -0
  71. package/build/esm/src/abis/CustomErrors.json +613 -16
  72. package/build/esm/src/abis/ERC20PermitInterface.json +118 -0
  73. package/build/esm/src/abis/GelatoRelayRouter.json +1426 -0
  74. package/build/esm/src/abis/RelayParams.json +110 -0
  75. package/build/esm/src/abis/SubaccountApproval.json +17 -0
  76. package/build/esm/src/abis/SubaccountGelatoRelayRouter.json +1885 -0
  77. package/build/esm/src/abis/SyntheticsReader.json +1 -131
  78. package/build/esm/src/abis/__tests__/abis.spec.js +35 -0
  79. package/build/esm/src/abis/index.js +8 -0
  80. package/build/esm/src/configs/__tests__/permits.spec.js +107 -0
  81. package/build/esm/src/configs/__tests__/tokens.spec.js +3 -3
  82. package/build/esm/src/configs/chains.js +33 -3
  83. package/build/esm/src/configs/contracts.js +15 -3
  84. package/build/esm/src/configs/dataStore.js +19 -1
  85. package/build/esm/src/configs/express.js +29 -0
  86. package/build/esm/src/configs/factors.js +1 -3
  87. package/build/esm/src/configs/tokens.js +50 -0
  88. package/build/esm/src/configs/twap.js +7 -0
  89. package/build/esm/src/index.js +4 -4
  90. package/build/esm/src/modules/markets/index.js +1 -0
  91. package/build/esm/src/modules/markets/query-builders.js +4 -0
  92. package/build/esm/src/modules/orders/helpers.js +3 -1
  93. package/build/esm/src/modules/orders/transactions/createDecreaseOrderTxn.js +1 -1
  94. package/build/esm/src/modules/orders/transactions/createIncreaseOrderTxn.js +6 -3
  95. package/build/esm/src/modules/orders/transactions/createSwapOrderTxn.js +1 -1
  96. package/build/esm/src/modules/utils/utils.js +13 -3
  97. package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +119 -0
  98. package/build/esm/src/test/mock.js +28 -0
  99. package/build/esm/src/types/subsquid.js +2300 -0
  100. package/build/esm/src/types/twap.js +1 -0
  101. package/build/esm/src/utils/__tests__/numbers.spec.js +219 -2
  102. package/build/esm/src/utils/__tests__/orderTransactions/batchUtils.spec.js +239 -0
  103. package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +593 -0
  104. package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +294 -0
  105. package/build/esm/src/utils/__tests__/orderTransactions/externalCalls.spec.js +116 -0
  106. package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +760 -0
  107. package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +467 -0
  108. package/build/esm/src/utils/__tests__/orderTransactions/updateOrder.spec.js +78 -0
  109. package/build/esm/src/utils/__tests__/parseError.spec.js +261 -0
  110. package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +43 -0
  111. package/build/esm/src/utils/bigmath.js +3 -0
  112. package/build/esm/src/utils/callContract.js +3 -3
  113. package/build/esm/src/utils/errors/index.js +2 -0
  114. package/build/esm/src/utils/errors/parseError.js +141 -0
  115. package/build/esm/src/utils/{contracts.js → errors/transactionsErrors.js} +30 -1
  116. package/build/esm/src/utils/fees/executionFee.js +48 -1
  117. package/build/esm/src/utils/fees/index.js +8 -4
  118. package/build/esm/src/utils/gelatoRelay.js +2 -0
  119. package/build/esm/src/utils/hash.js +5 -1
  120. package/build/esm/src/utils/marketKeysAndConfigs.js +5 -1
  121. package/build/esm/src/utils/markets.js +5 -2
  122. package/build/esm/src/utils/numbers.js +517 -1
  123. package/build/esm/src/utils/orderTransactions.js +607 -0
  124. package/build/esm/src/utils/orders.js +5 -0
  125. package/build/esm/src/utils/simulateExecuteOrder.js +6 -2
  126. package/build/esm/src/utils/swap/__tests__/mockRouting.spec.js +11 -6
  127. package/build/esm/src/utils/swap/__tests__/swapRouting.spec.js +4 -4
  128. package/build/esm/src/utils/swap/__tests__/swapStats.spec.js +9 -0
  129. package/build/esm/src/utils/swap/swapPath.js +30 -13
  130. package/build/esm/src/utils/swap/swapRouting.js +4 -2
  131. package/build/esm/src/utils/swap/swapStats.js +6 -5
  132. package/build/esm/src/utils/testUtil.js +2 -2
  133. package/build/esm/src/utils/time.js +23 -0
  134. package/build/esm/src/utils/tokens.js +14 -1
  135. package/build/esm/src/utils/tradeHistory.js +4 -4
  136. package/build/esm/src/utils/twap/index.js +44 -0
  137. package/build/esm/src/utils/twap/uiFeeReceiver.js +24 -0
  138. package/build/esm/src/utils/types.js +8 -0
  139. package/build/types/src/abis/__tests__/abis.spec.d.ts +1 -0
  140. package/build/types/src/abis/index.d.ts +1 -1
  141. package/build/types/src/configs/__tests__/permits.spec.d.ts +1 -0
  142. package/build/types/src/configs/chains.d.ts +29 -1
  143. package/build/types/src/configs/contracts.d.ts +238 -1
  144. package/build/types/src/configs/dataStore.d.ts +10 -0
  145. package/build/types/src/configs/express.d.ts +12 -0
  146. package/build/types/src/configs/factors.d.ts +1 -3
  147. package/build/types/src/configs/tokens.d.ts +2 -2
  148. package/build/types/src/configs/twap.d.ts +7 -0
  149. package/build/types/src/modules/markets/query-builders.d.ts +1 -1
  150. package/build/types/src/modules/markets/types.d.ts +2 -2
  151. package/build/types/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +1 -1
  152. package/build/types/src/test/mock.d.ts +16 -1
  153. package/build/types/src/types/fees.d.ts +9 -0
  154. package/build/types/src/types/markets.d.ts +1 -0
  155. package/build/types/src/types/orders.d.ts +3 -0
  156. package/build/types/src/types/subsquid.d.ts +6916 -0
  157. package/build/types/src/types/tokens.d.ts +27 -0
  158. package/build/types/src/types/trade.d.ts +2 -19
  159. package/build/types/src/types/tradeHistory.d.ts +0 -40
  160. package/build/types/src/types/twap.d.ts +11 -0
  161. package/build/types/src/utils/__tests__/orderTransactions/batchUtils.spec.d.ts +1 -0
  162. package/build/types/src/utils/__tests__/orderTransactions/decreaseOrders.spec.d.ts +1 -0
  163. package/build/types/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.d.ts +1 -0
  164. package/build/types/src/utils/__tests__/orderTransactions/externalCalls.spec.d.ts +1 -0
  165. package/build/types/src/utils/__tests__/orderTransactions/increaseOrders.spec.d.ts +1 -0
  166. package/build/types/src/utils/__tests__/orderTransactions/swapOrders.spec.d.ts +1 -0
  167. package/build/types/src/utils/__tests__/orderTransactions/updateOrder.spec.d.ts +1 -0
  168. package/build/types/src/utils/__tests__/parseError.spec.d.ts +1 -0
  169. package/build/types/src/utils/__tests__/uiFeeReceiver.spec.d.ts +1 -0
  170. package/build/types/src/utils/bigmath.d.ts +1 -0
  171. package/build/types/src/utils/errors/index.d.ts +2 -0
  172. package/build/types/src/utils/errors/parseError.d.ts +50 -0
  173. package/build/types/src/utils/errors/transactionsErrors.d.ts +34 -0
  174. package/build/types/src/utils/fees/executionFee.d.ts +35 -2
  175. package/build/types/src/utils/fees/index.d.ts +1 -1
  176. package/build/types/src/utils/gelatoRelay.d.ts +2 -0
  177. package/build/types/src/utils/hash.d.ts +2 -0
  178. package/build/types/src/utils/marketKeysAndConfigs.d.ts +1 -0
  179. package/build/types/src/utils/markets.d.ts +2 -1
  180. package/build/types/src/utils/numbers.d.ts +111 -1
  181. package/build/types/src/utils/orderTransactions.d.ts +231 -0
  182. package/build/types/src/utils/orders.d.ts +2 -1
  183. package/build/types/src/utils/simulateExecuteOrder.d.ts +4 -0
  184. package/build/types/src/utils/swap/swapPath.d.ts +5 -5
  185. package/build/types/src/utils/swap/swapRouting.d.ts +2 -2
  186. package/build/types/src/utils/swap/swapStats.d.ts +2 -0
  187. package/build/types/src/utils/time.d.ts +14 -0
  188. package/build/types/src/utils/tokens.d.ts +6 -5
  189. package/build/types/src/utils/tradeHistory.d.ts +2 -2
  190. package/build/types/src/utils/twap/index.d.ts +17 -0
  191. package/build/types/src/utils/twap/uiFeeReceiver.d.ts +9 -0
  192. package/build/types/src/utils/types.d.ts +5 -0
  193. package/package.json +9 -2
  194. package/build/types/src/utils/contracts.d.ts +0 -19
@@ -34,6 +34,11 @@ const baseGasLimits = {
34
34
  singleSwap: 1000000n,
35
35
  swapOrder: 3000000n,
36
36
  withdrawalMultiToken: 1500000n,
37
+ createOrderGasLimit: 1000000n,
38
+ updateOrderGasLimit: 1000000n,
39
+ cancelOrderGasLimit: 1000000n,
40
+ gelatoRelayFeeMultiplierFactor: 1000000000000000000000000000000n,
41
+ tokenPermitGasLimit: 1000000n,
37
42
  };
38
43
  const baseGasPrice = 1650000002n;
39
44
  describe("mockRouting", () => {
@@ -54,7 +59,7 @@ describe("mockRouting", () => {
54
59
  },
55
60
  });
56
61
  const tokenSwapPaths = getTokenSwapPathsForTokenPair(swapPaths, "USDC", "DAI");
57
- const estimator = createNaiveSwapEstimator(marketsInfoData);
62
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
58
63
  const paths = getNaiveBestMarketSwapPathsFromTokenSwapPaths({
59
64
  graph: marketAdjacencyGraph,
60
65
  tokenSwapPaths,
@@ -88,7 +93,7 @@ describe("mockRouting", () => {
88
93
  },
89
94
  });
90
95
  const tokenSwapPaths = getTokenSwapPathsForTokenPair(swapPaths, "USDC", "DAI");
91
- const estimator = createNaiveSwapEstimator(marketsInfoData);
96
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
92
97
  const paths = getNaiveBestMarketSwapPathsFromTokenSwapPaths({
93
98
  graph: marketAdjacencyGraph,
94
99
  tokenSwapPaths,
@@ -138,7 +143,7 @@ describe("mockRouting", () => {
138
143
  },
139
144
  });
140
145
  const tokenSwapPaths = getTokenSwapPathsForTokenPair(swapPaths, "BTC", "DAI");
141
- const estimator = createNaiveSwapEstimator(marketsInfoData);
146
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
142
147
  const paths = getNaiveBestMarketSwapPathsFromTokenSwapPaths({
143
148
  graph: marketAdjacencyGraph,
144
149
  tokenSwapPaths,
@@ -182,7 +187,7 @@ describe("mockRouting", () => {
182
187
  },
183
188
  });
184
189
  const tokenSwapPaths = getTokenSwapPathsForTokenPair(swapPaths, "USDC", "BTC");
185
- const estimator = createNaiveSwapEstimator(marketsInfoData);
190
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
186
191
  const paths = getNaiveBestMarketSwapPathsFromTokenSwapPaths({
187
192
  graph: marketAdjacencyGraph,
188
193
  tokenSwapPaths,
@@ -233,7 +238,7 @@ describe("mockRouting", () => {
233
238
  },
234
239
  });
235
240
  const tokenSwapPaths = getTokenSwapPathsForTokenPair(swapPaths, "USDC", "BTC");
236
- const estimator = createNaiveSwapEstimator(marketsInfoData);
241
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
237
242
  const paths = getNaiveBestMarketSwapPathsFromTokenSwapPaths({
238
243
  graph: marketAdjacencyGraph,
239
244
  tokenSwapPaths,
@@ -283,7 +288,7 @@ describe("mockRouting", () => {
283
288
  },
284
289
  });
285
290
  const tokenSwapPaths = getTokenSwapPathsForTokenPair(swapPaths, "BTC", "DAI");
286
- const estimator = createNaiveSwapEstimator(marketsInfoData);
291
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
287
292
  const fakeMultiplier = 100n;
288
293
  const networkEstimator = createNaiveNetworkEstimator({
289
294
  chainId: 1,
@@ -524,7 +524,7 @@ describe("createSwapEstimator", () => {
524
524
  isDisabled: true,
525
525
  },
526
526
  });
527
- const estimator = createSwapEstimator(marketsInfoData);
527
+ const estimator = createSwapEstimator(marketsInfoData, false);
528
528
  const result = estimator({
529
529
  marketAddress: "ETH-ETH-USDC",
530
530
  from: "ETH",
@@ -538,7 +538,7 @@ describe("createSwapEstimator", () => {
538
538
  const tokensData = mockTokensData();
539
539
  const marketKeys = ["ETH-ETH-USDC"];
540
540
  const marketsInfoData = mockMarketsInfoData(tokensData, marketKeys);
541
- const estimator = createSwapEstimator(marketsInfoData);
541
+ const estimator = createSwapEstimator(marketsInfoData, false);
542
542
  const result = estimator({
543
543
  marketAddress: "NON-EXISTENT",
544
544
  from: "ETH",
@@ -588,7 +588,7 @@ describe("createNaiveSwapEstimator", () => {
588
588
  isDisabled: true,
589
589
  },
590
590
  });
591
- const estimator = createNaiveSwapEstimator(marketsInfoData);
591
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
592
592
  const result = estimator({
593
593
  marketAddress: "ETH-ETH-USDC",
594
594
  from: "ETH",
@@ -602,7 +602,7 @@ describe("createNaiveSwapEstimator", () => {
602
602
  const tokensData = mockTokensData();
603
603
  const marketKeys = ["ETH-ETH-USDC"];
604
604
  const marketsInfoData = mockMarketsInfoData(tokensData, marketKeys);
605
- const estimator = createNaiveSwapEstimator(marketsInfoData);
605
+ const estimator = createNaiveSwapEstimator(marketsInfoData, false);
606
606
  const result = estimator({
607
607
  marketAddress: "NON-EXISTENT",
608
608
  from: "ETH",
@@ -253,6 +253,7 @@ describe("getSwapPathStats", () => {
253
253
  usdIn: 100n * dollar,
254
254
  shouldUnwrapNativeToken: false,
255
255
  shouldApplyPriceImpact: true,
256
+ isAtomicSwap: false,
256
257
  });
257
258
  expect(result).toBeUndefined();
258
259
  });
@@ -265,6 +266,7 @@ describe("getSwapPathStats", () => {
265
266
  usdIn: 100n * dollar,
266
267
  shouldUnwrapNativeToken: false,
267
268
  shouldApplyPriceImpact: true,
269
+ isAtomicSwap: false,
268
270
  });
269
271
  expect(result).toBeDefined();
270
272
  expect(result?.swapPath).toEqual(["ETH-WETH-USDC"]);
@@ -286,6 +288,7 @@ describe("getSwapPathStats", () => {
286
288
  usdIn: 100n * dollar,
287
289
  shouldUnwrapNativeToken: false,
288
290
  shouldApplyPriceImpact: true,
291
+ isAtomicSwap: false,
289
292
  });
290
293
  expect(result).toBeDefined();
291
294
  expect(result?.swapPath).toEqual(["BTC-BTC-WETH", "BTC-BTC-USDC"]);
@@ -307,6 +310,7 @@ describe("getSwapPathStats", () => {
307
310
  usdIn: 100n * dollar,
308
311
  shouldUnwrapNativeToken: true,
309
312
  shouldApplyPriceImpact: true,
313
+ isAtomicSwap: false,
310
314
  });
311
315
  expect(result).toBeDefined();
312
316
  expect(result?.tokenOutAddress).toBe(NATIVE_TOKEN_ADDRESS);
@@ -320,6 +324,7 @@ describe("getSwapPathStats", () => {
320
324
  usdIn: 100n * dollar,
321
325
  shouldUnwrapNativeToken: false,
322
326
  shouldApplyPriceImpact: true,
327
+ isAtomicSwap: false,
323
328
  });
324
329
  expect(result).toBeUndefined();
325
330
  });
@@ -332,6 +337,7 @@ describe("getSwapPathStats", () => {
332
337
  usdIn: 100n * dollar,
333
338
  shouldUnwrapNativeToken: false,
334
339
  shouldApplyPriceImpact: true,
340
+ isAtomicSwap: false,
335
341
  });
336
342
  const resultWithoutImpact = getSwapPathStats({
337
343
  marketsInfoData: testMarketsInfoData,
@@ -341,6 +347,7 @@ describe("getSwapPathStats", () => {
341
347
  usdIn: 100n * dollar,
342
348
  shouldUnwrapNativeToken: false,
343
349
  shouldApplyPriceImpact: false,
350
+ isAtomicSwap: false,
344
351
  });
345
352
  if (!resultWithImpact || !resultWithoutImpact) {
346
353
  throw new Error("Results should be defined");
@@ -356,6 +363,7 @@ describe("getSwapPathStats", () => {
356
363
  usdIn: 100n * dollar,
357
364
  shouldUnwrapNativeToken: false,
358
365
  shouldApplyPriceImpact: true,
366
+ isAtomicSwap: false,
359
367
  });
360
368
  expect(result).toBeDefined();
361
369
  expect(result?.swapSteps).toHaveLength(2);
@@ -380,6 +388,7 @@ describe("getSwapPathStats", () => {
380
388
  usdIn: 100n * dollar,
381
389
  shouldUnwrapNativeToken: false,
382
390
  shouldApplyPriceImpact: true,
391
+ isAtomicSwap: false,
383
392
  });
384
393
  expect(result).toBeUndefined();
385
394
  });
@@ -1,6 +1,7 @@
1
1
  import { MARKETS } from "../../configs/markets";
2
2
  import { convertTokenAddress, getWrappedToken, NATIVE_TOKEN_ADDRESS } from "../../configs/tokens";
3
3
  import { LRUCache } from "../LruCache";
4
+ import { getIsMarketAvailableForExpressSwaps } from "../markets";
4
5
  import { buildMarketsAdjacencyGraph } from "./buildMarketsAdjacencyGraph";
5
6
  import { createMarketEdgeLiquidityGetter, createNaiveNetworkEstimator, createNaiveSwapEstimator, createSwapEstimator, getBestSwapPath, getMarketAdjacencyGraph, getMaxLiquidityMarketSwapPathFromTokenSwapPaths, getNaiveBestMarketSwapPathsFromTokenSwapPaths, getTokenSwapPathsForTokenPairPrebuilt, marketRouteToMarketEdges, } from "./swapRouting";
6
7
  import { getSwapPathStats } from "./swapStats";
@@ -8,16 +9,16 @@ export const getWrappedAddress = (chainId, address) => {
8
9
  return address ? convertTokenAddress(chainId, address, "wrapped") : undefined;
9
10
  };
10
11
  const DEBUG_MARKET_ADJACENCY_GRAPH_CACHE = new LRUCache(100);
11
- function buildDebugMarketAdjacencyGraph(chainId, debugSwapMarketsConfig) {
12
- if (!debugSwapMarketsConfig?.disabledSwapMarkets?.length) {
12
+ function buildMarketAdjacencyGraph(chainId, disabledMarkets) {
13
+ if (!disabledMarkets?.length) {
13
14
  return getMarketAdjacencyGraph(chainId);
14
15
  }
15
- const cacheKey = `${chainId}-${JSON.stringify(debugSwapMarketsConfig)}`;
16
+ const cacheKey = `${chainId}-${JSON.stringify(disabledMarkets)}`;
16
17
  const cachedGraph = DEBUG_MARKET_ADJACENCY_GRAPH_CACHE.get(cacheKey);
17
18
  if (cachedGraph) {
18
19
  return cachedGraph;
19
20
  }
20
- const disabledMarketAddresses = debugSwapMarketsConfig.disabledSwapMarkets;
21
+ const disabledMarketAddresses = disabledMarkets;
21
22
  const strippedMarkets = Object.fromEntries(Object.entries(MARKETS[chainId]).filter(([marketAddress]) => !disabledMarketAddresses.includes(marketAddress)));
22
23
  const graph = buildMarketsAdjacencyGraph(strippedMarkets);
23
24
  DEBUG_MARKET_ADJACENCY_GRAPH_CACHE.set(cacheKey, graph);
@@ -25,22 +26,37 @@ function buildDebugMarketAdjacencyGraph(chainId, debugSwapMarketsConfig) {
25
26
  }
26
27
  const FALLBACK_FIND_SWAP_PATH = () => undefined;
27
28
  export const createFindSwapPath = (params) => {
28
- const { chainId, fromTokenAddress, toTokenAddress, marketsInfoData, debugSwapMarketsConfig, gasEstimationParams } = params;
29
+ const { chainId, fromTokenAddress, toTokenAddress, marketsInfoData, disabledMarkets, manualPath, gasEstimationParams, isExpressFeeSwap, maxSwapPathLength, } = params;
29
30
  const wrappedFromAddress = getWrappedAddress(chainId, fromTokenAddress);
30
31
  const wrappedToAddress = getWrappedAddress(chainId, toTokenAddress);
31
32
  const wrappedToken = getWrappedToken(chainId);
32
- const tokenSwapPaths = wrappedFromAddress && wrappedToAddress
33
+ let tokenSwapPaths = wrappedFromAddress && wrappedToAddress
33
34
  ? getTokenSwapPathsForTokenPairPrebuilt(chainId, wrappedFromAddress, wrappedToAddress)
34
35
  : [];
35
- const marketAdjacencyGraph = debugSwapMarketsConfig?.disabledSwapMarkets?.length
36
- ? buildDebugMarketAdjacencyGraph(chainId, debugSwapMarketsConfig)
37
- : getMarketAdjacencyGraph(chainId);
36
+ if (maxSwapPathLength) {
37
+ /**
38
+ * As tokenSwapPath contains what tokens can we between input and output token,
39
+ * restricting intermediate tokens to 0 would mean we filter out any non-direct market swaps,
40
+ * length of 1 would mean all 2-step swaps
41
+ */
42
+ const nonDirectPathLength = maxSwapPathLength - 1;
43
+ tokenSwapPaths = tokenSwapPaths.filter((path) => path.length <= nonDirectPathLength);
44
+ }
45
+ const finalDisabledMarkets = [...(disabledMarkets ?? [])];
46
+ if (isExpressFeeSwap) {
47
+ const expressSwapUnavailableMarkets = Object.values(marketsInfoData ?? {})
48
+ .filter((market) => !getIsMarketAvailableForExpressSwaps(market))
49
+ .map((market) => market.marketTokenAddress);
50
+ finalDisabledMarkets.push(...expressSwapUnavailableMarkets);
51
+ }
52
+ const isAtomicSwap = Boolean(isExpressFeeSwap);
53
+ const marketAdjacencyGraph = buildMarketAdjacencyGraph(chainId, finalDisabledMarkets);
38
54
  const cache = {};
39
55
  if (!marketsInfoData) {
40
56
  return FALLBACK_FIND_SWAP_PATH;
41
57
  }
42
58
  const marketEdgeLiquidityGetter = createMarketEdgeLiquidityGetter(marketsInfoData);
43
- const naiveEstimator = createNaiveSwapEstimator(marketsInfoData);
59
+ const naiveEstimator = createNaiveSwapEstimator(marketsInfoData, isAtomicSwap);
44
60
  const naiveNetworkEstimator = gasEstimationParams
45
61
  ? createNaiveNetworkEstimator({
46
62
  gasLimits: gasEstimationParams.gasLimits,
@@ -49,7 +65,7 @@ export const createFindSwapPath = (params) => {
49
65
  chainId,
50
66
  })
51
67
  : undefined;
52
- const estimator = createSwapEstimator(marketsInfoData);
68
+ const estimator = createSwapEstimator(marketsInfoData, isAtomicSwap);
53
69
  const findSwapPath = (usdIn, opts) => {
54
70
  if (tokenSwapPaths.length === 0 || !fromTokenAddress || !wrappedFromAddress || !wrappedToAddress) {
55
71
  return undefined;
@@ -59,8 +75,8 @@ export const createFindSwapPath = (params) => {
59
75
  return cache[cacheKey];
60
76
  }
61
77
  let swapPath = undefined;
62
- if (debugSwapMarketsConfig?.manualPath !== undefined) {
63
- swapPath = debugSwapMarketsConfig.manualPath;
78
+ if (manualPath !== undefined) {
79
+ swapPath = manualPath;
64
80
  }
65
81
  else if (opts?.order || usdIn === 0n) {
66
82
  const primaryOrder = opts?.order?.at(0) === "length" ? "length" : "liquidity";
@@ -119,6 +135,7 @@ export const createFindSwapPath = (params) => {
119
135
  shouldUnwrapNativeToken: toTokenAddress === NATIVE_TOKEN_ADDRESS,
120
136
  shouldApplyPriceImpact: true,
121
137
  usdIn,
138
+ isAtomicSwap,
122
139
  });
123
140
  cache[cacheKey] = result;
124
141
  return result;
@@ -8,7 +8,7 @@ import { getByKey } from "../objects";
8
8
  import { DEFAULT_NAIVE_TOP_PATHS_COUNT } from "./constants";
9
9
  import { MARKETS_ADJACENCY_GRAPH, REACHABLE_TOKENS, TOKEN_SWAP_PATHS } from "./preparedSwapData";
10
10
  import { getSwapStats } from "./swapStats";
11
- export const createSwapEstimator = (marketsInfoData) => {
11
+ export const createSwapEstimator = (marketsInfoData, isAtomicSwap) => {
12
12
  return (e, usdIn) => {
13
13
  const marketInfo = marketsInfoData[e.marketAddress];
14
14
  if (!marketInfo || marketInfo.isDisabled) {
@@ -22,6 +22,7 @@ export const createSwapEstimator = (marketsInfoData) => {
22
22
  tokenInAddress: e.from,
23
23
  tokenOutAddress: e.to,
24
24
  shouldApplyPriceImpact: true,
25
+ isAtomicSwap,
25
26
  });
26
27
  const isOutLiquidity = swapStats?.isOutLiquidity;
27
28
  const isOutCapacity = swapStats?.isOutCapacity;
@@ -47,7 +48,7 @@ export const createMarketEdgeLiquidityGetter = (marketsInfoData) => {
47
48
  return liquidity;
48
49
  };
49
50
  };
50
- export const createNaiveSwapEstimator = (marketsInfoData) => {
51
+ export const createNaiveSwapEstimator = (marketsInfoData, isAtomicSwap) => {
51
52
  return (e, usdIn) => {
52
53
  let marketInfo = marketsInfoData[e.marketAddress];
53
54
  if (marketInfo === undefined || marketInfo.isDisabled) {
@@ -59,6 +60,7 @@ export const createNaiveSwapEstimator = (marketsInfoData) => {
59
60
  tokenInAddress: e.from,
60
61
  tokenOutAddress: e.to,
61
62
  shouldApplyPriceImpact: true,
63
+ isAtomicSwap,
62
64
  });
63
65
  const usdOut = swapStats?.usdOut;
64
66
  if (usdOut === undefined || usdOut === 0n || swapStats.isOutCapacity || swapStats.isOutLiquidity) {
@@ -78,7 +78,7 @@ export function getSwapPathOutputAddresses(p) {
78
78
  };
79
79
  }
80
80
  export function getSwapPathStats(p) {
81
- const { marketsInfoData, swapPath, initialCollateralAddress, usdIn, shouldUnwrapNativeToken, shouldApplyPriceImpact, wrappedNativeTokenAddress, } = p;
81
+ const { marketsInfoData, swapPath, initialCollateralAddress, usdIn, shouldUnwrapNativeToken, shouldApplyPriceImpact, wrappedNativeTokenAddress, isAtomicSwap, } = p;
82
82
  if (swapPath.length === 0) {
83
83
  return undefined;
84
84
  }
@@ -108,6 +108,7 @@ export function getSwapPathStats(p) {
108
108
  tokenOutAddress,
109
109
  usdIn: usdOut,
110
110
  shouldApplyPriceImpact,
111
+ isAtomicSwap,
111
112
  });
112
113
  tokenInAddress = swapStep.tokenOutAddress;
113
114
  usdOut = swapStep.usdOut;
@@ -133,7 +134,7 @@ export function getSwapPathStats(p) {
133
134
  };
134
135
  }
135
136
  export function getSwapStats(p) {
136
- const { marketInfo, tokenInAddress, tokenOutAddress, usdIn, shouldApplyPriceImpact } = p;
137
+ const { marketInfo, tokenInAddress, tokenOutAddress, usdIn, shouldApplyPriceImpact, isAtomicSwap } = p;
137
138
  const isWrap = tokenInAddress === NATIVE_TOKEN_ADDRESS;
138
139
  const isUnwrap = tokenOutAddress === NATIVE_TOKEN_ADDRESS;
139
140
  const tokenIn = getTokenPoolType(marketInfo, tokenInAddress) === "long" ? marketInfo.longToken : marketInfo.shortToken;
@@ -148,7 +149,7 @@ export function getSwapStats(p) {
148
149
  catch (e) {
149
150
  // Approximate if the market would be out of capacity
150
151
  const capacityUsd = getSwapCapacityUsd(marketInfo, getTokenPoolType(marketInfo, tokenInAddress) === "long");
151
- const swapFeeUsd = getSwapFee(marketInfo, usdIn, false);
152
+ const swapFeeUsd = getSwapFee(marketInfo, usdIn, false, isAtomicSwap);
152
153
  const usdInAfterFees = usdIn - swapFeeUsd;
153
154
  const isOutCapacity = capacityUsd < usdInAfterFees;
154
155
  return {
@@ -169,8 +170,8 @@ export function getSwapStats(p) {
169
170
  isOutCapacity,
170
171
  };
171
172
  }
172
- const swapFeeAmount = getSwapFee(marketInfo, amountIn, priceImpactDeltaUsd > 0);
173
- const swapFeeUsd = getSwapFee(marketInfo, usdIn, priceImpactDeltaUsd > 0);
173
+ const swapFeeAmount = getSwapFee(marketInfo, amountIn, priceImpactDeltaUsd > 0, isAtomicSwap);
174
+ const swapFeeUsd = getSwapFee(marketInfo, usdIn, priceImpactDeltaUsd > 0, isAtomicSwap);
174
175
  const amountInAfterFees = amountIn - swapFeeAmount;
175
176
  const usdInAfterFees = usdIn - swapFeeUsd;
176
177
  let usdOut = usdInAfterFees;
@@ -1,8 +1,8 @@
1
1
  import { createTestClient, http, publicActions, walletActions } from "viem";
2
- import { ARBITRUM, getChain } from "../configs/chains";
2
+ import { ARBITRUM, getViemChain } from "../configs/chains";
3
3
  import { GmxSdk } from "../index";
4
4
  const client = createTestClient({
5
- chain: getChain(ARBITRUM),
5
+ chain: getViemChain(ARBITRUM),
6
6
  mode: "hardhat",
7
7
  transport: http(),
8
8
  })
@@ -0,0 +1,23 @@
1
+ const SECONDS_IN_PERIOD = {
2
+ "1m": 60,
3
+ "5m": 60 * 5,
4
+ "15m": 60 * 15,
5
+ "1h": 60 * 60,
6
+ "4h": 60 * 60 * 4,
7
+ "1d": 60 * 60 * 24,
8
+ "1y": 60 * 60 * 24 * 365,
9
+ };
10
+ export function secondsFrom(period) {
11
+ return SECONDS_IN_PERIOD[period];
12
+ }
13
+ export function secondsToPeriod(seconds, period, roundUp = false) {
14
+ const secondsInPeriod = secondsFrom(period);
15
+ const roundedSeconds = roundUp ? Math.ceil(seconds / secondsInPeriod) : Math.floor(seconds / secondsInPeriod);
16
+ return roundedSeconds;
17
+ }
18
+ export function periodToSeconds(periodsCount, period) {
19
+ return periodsCount * secondsFrom(period);
20
+ }
21
+ export function nowInSeconds() {
22
+ return Math.floor(Date.now() / 1000);
23
+ }
@@ -6,7 +6,7 @@ export function parseContractPrice(price, tokenDecimals) {
6
6
  return price * expandDecimals(1, tokenDecimals);
7
7
  }
8
8
  export function convertToContractPrice(price, tokenDecimals) {
9
- return price / expandDecimals(1, tokenDecimals);
9
+ return (price / expandDecimals(1, tokenDecimals));
10
10
  }
11
11
  export function convertToContractTokenPrices(prices, tokenDecimals) {
12
12
  return {
@@ -26,6 +26,19 @@ export function convertToUsd(tokenAmount, tokenDecimals, price) {
26
26
  }
27
27
  return (tokenAmount * price) / expandDecimals(1, tokenDecimals);
28
28
  }
29
+ export function convertBetweenTokens(tokenAmount, fromToken, toToken, maximize) {
30
+ if (tokenAmount === undefined || fromToken === undefined || toToken === undefined) {
31
+ return undefined;
32
+ }
33
+ if (getIsEquivalentTokens(fromToken, toToken)) {
34
+ return tokenAmount;
35
+ }
36
+ const fromPrice = maximize ? fromToken.prices.maxPrice : fromToken.prices.minPrice;
37
+ const toPrice = maximize ? toToken.prices.minPrice : toToken.prices.maxPrice;
38
+ const usd = convertToUsd(tokenAmount, fromToken.decimals, fromPrice);
39
+ const amount = convertToTokenAmount(usd, toToken.decimals, toPrice);
40
+ return amount;
41
+ }
29
42
  export function getMidPrice(prices) {
30
43
  return (prices.minPrice + prices.maxPrice) / 2n;
31
44
  }
@@ -38,8 +38,8 @@ export function createRawTradeActionTransformer(marketsInfoData, wrappedToken, t
38
38
  initialCollateralToken,
39
39
  timestamp: rawAction.timestamp,
40
40
  transaction: rawAction.transaction,
41
- reason: rawAction.reason,
42
- reasonBytes: rawAction.reasonBytes,
41
+ reason: rawAction.reason ?? undefined,
42
+ reasonBytes: rawAction.reasonBytes ?? undefined,
43
43
  twapParams: rawAction.twapGroupId && rawAction.numberOfParts
44
44
  ? {
45
45
  twapGroupId: rawAction.twapGroupId,
@@ -112,8 +112,8 @@ export function createRawTradeActionTransformer(marketsInfoData, wrappedToken, t
112
112
  borrowingFeeAmount: rawAction.borrowingFeeAmount ? BigInt(rawAction.borrowingFeeAmount) : undefined,
113
113
  fundingFeeAmount: rawAction.fundingFeeAmount ? BigInt(rawAction.fundingFeeAmount) : undefined,
114
114
  liquidationFeeAmount: rawAction.liquidationFeeAmount ? BigInt(rawAction.liquidationFeeAmount) : undefined,
115
- reason: rawAction.reason,
116
- reasonBytes: rawAction.reasonBytes,
115
+ reason: rawAction.reason ?? undefined,
116
+ reasonBytes: rawAction.reasonBytes ?? undefined,
117
117
  transaction: rawAction.transaction,
118
118
  timestamp: rawAction.timestamp,
119
119
  shouldUnwrapNativeToken: rawAction.shouldUnwrapNativeToken,
@@ -0,0 +1,44 @@
1
+ import { DEFAULT_TWAP_NUMBER_OF_PARTS, MAX_TWAP_NUMBER_OF_PARTS, MIN_TWAP_NUMBER_OF_PARTS } from "../../configs/twap";
2
+ import { isSwapOrderType } from "../orders";
3
+ export function getIsValidTwapParams(duration, numberOfParts) {
4
+ return (duration.hours >= 0 &&
5
+ duration.minutes >= 0 &&
6
+ numberOfParts >= MIN_TWAP_NUMBER_OF_PARTS &&
7
+ numberOfParts <= MAX_TWAP_NUMBER_OF_PARTS);
8
+ }
9
+ export function getTwapDurationInSeconds(duration) {
10
+ return duration.hours * 60 * 60 + duration.minutes * 60;
11
+ }
12
+ export function getTwapValidFromTime(duration, numberOfParts, partIndex) {
13
+ const durationMinutes = duration.hours * 60 + duration.minutes;
14
+ const durationMs = durationMinutes * 60;
15
+ const startTime = Math.ceil(Date.now() / 1000);
16
+ return BigInt(Math.floor(startTime + (durationMs / (numberOfParts - 1)) * partIndex));
17
+ }
18
+ export function changeTwapNumberOfPartsValue(value) {
19
+ if (value < MIN_TWAP_NUMBER_OF_PARTS) {
20
+ return MIN_TWAP_NUMBER_OF_PARTS;
21
+ }
22
+ if (value > MAX_TWAP_NUMBER_OF_PARTS) {
23
+ return MAX_TWAP_NUMBER_OF_PARTS;
24
+ }
25
+ if (isNaN(value)) {
26
+ return DEFAULT_TWAP_NUMBER_OF_PARTS;
27
+ }
28
+ return value;
29
+ }
30
+ export function getTwapOrderKey({ twapId, orderType, pool, isLong, collateralTokenSymbol, swapPath, account, initialCollateralToken, }) {
31
+ if (isSwapOrderType(orderType)) {
32
+ return `${twapId}-${swapPath.join("-")}-${account}-${initialCollateralToken}`;
33
+ }
34
+ const type = isLong ? "long" : "short";
35
+ return `${twapId}-${type}-${pool}-${collateralTokenSymbol}`;
36
+ }
37
+ export function makeTwapValidFromTimeGetter(duration, numberOfParts) {
38
+ const durationMinutes = duration.hours * 60 + duration.minutes;
39
+ const durationMs = durationMinutes * 60;
40
+ const startTime = Math.ceil(Date.now() / 1000);
41
+ return (part) => {
42
+ return BigInt(Math.floor(startTime + (durationMs / (numberOfParts - 1)) * part));
43
+ };
44
+ }
@@ -0,0 +1,24 @@
1
+ import { isAddress } from "viem";
2
+ const VERSION = "01";
3
+ const PREFIX = "0xff";
4
+ export function generateTwapId() {
5
+ return Math.floor(Math.random() * 256 * 256)
6
+ .toString(16)
7
+ .padStart(4, "0");
8
+ }
9
+ export function createTwapUiFeeReceiver({ numberOfParts }) {
10
+ const twapId = generateTwapId();
11
+ const numberOfPartsInHex = numberOfParts.toString(16).padStart(2, "0");
12
+ return `${PREFIX}00${"00".repeat(14)}${numberOfPartsInHex}${twapId}${VERSION}`;
13
+ }
14
+ export function decodeTwapUiFeeReceiver(address) {
15
+ const twapId = address.slice(36, 40);
16
+ if (!isValidTwapUiFeeReceiver(address) || twapId === "0000") {
17
+ return;
18
+ }
19
+ const numberOfParts = parseInt(address.slice(34, 36), 16);
20
+ return { twapId, numberOfParts };
21
+ }
22
+ export function isValidTwapUiFeeReceiver(address) {
23
+ return isAddress(address) && address.toLowerCase().startsWith(PREFIX.toLowerCase());
24
+ }
@@ -0,0 +1,8 @@
1
+ export const mustNeverExist = (x) => {
2
+ throw new Error(`Must never exist: ${x}`);
3
+ };
4
+ export const assertDefined = (x) => {
5
+ if (x === undefined)
6
+ throw new Error(`Expected defined value, got undefined`);
7
+ return x;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { Abi } from "viem";
2
+ export type AbiId = "CustomErrors" | "DataStore" | "ERC721" | "ERC20" | "EventEmitter" | "ExchangeRouter" | "GlpManager" | "GlvReader" | "GlvRouter" | "GMT" | "GmxMigrator" | "GovToken" | "MintableBaseToken" | "Multicall" | "OrderBook" | "OrderBookReader" | "OrderExecutor" | "PositionManager" | "PositionRouter" | "Reader" | "ReaderV2" | "ReferralStorage" | "RewardReader" | "RewardRouter" | "RewardTracker" | "Router-v2" | "Router" | "SubaccountRouter" | "SyntheticsReader" | "SyntheticsRouter" | "Timelock" | "Token" | "Treasury" | "UniPool" | "UniswapV2" | "Vault" | "VaultReader" | "VaultV2" | "VaultV2b" | "Vester" | "WETH" | "YieldFarm" | "YieldToken" | "SubaccountGelatoRelayRouter" | "ERC20PermitInterface" | "GelatoRelayRouter" | "ArbitrumNodeInterface";
2
3
  /** Copied from ethers to enable compatibility with GMX UI */
3
4
  interface JsonFragmentType {
4
5
  readonly name?: string;
@@ -18,6 +19,5 @@ interface JsonFragment {
18
19
  readonly outputs?: ReadonlyArray<JsonFragmentType>;
19
20
  readonly gas?: string;
20
21
  }
21
- export type AbiId = "CustomErrors" | "DataStore" | "ERC721" | "ERC20" | "EventEmitter" | "ExchangeRouter" | "GlpManager" | "GlvReader" | "GlvRouter" | "GMT" | "GmxMigrator" | "GovToken" | "MintableBaseToken" | "Multicall" | "OrderBook" | "OrderBookReader" | "OrderExecutor" | "PositionManager" | "PositionRouter" | "Reader" | "ReaderV2" | "ReferralStorage" | "RewardReader" | "RewardRouter" | "RewardTracker" | "Router-v2" | "Router" | "SubaccountRouter" | "SyntheticsReader" | "SyntheticsRouter" | "Timelock" | "Token" | "Treasury" | "UniPool" | "UniswapV2" | "Vault" | "VaultReader" | "VaultV2" | "VaultV2b" | "Vester" | "WETH" | "YieldFarm" | "YieldToken";
22
22
  export declare const abis: Record<AbiId, readonly (Abi[number] & JsonFragment)[]>;
23
23
  export {};
@@ -7,13 +7,21 @@ export declare const BSС_TESTNET = 97;
7
7
  export declare const ETH_MAINNET = 1;
8
8
  export declare const SUPPORTED_CHAIN_IDS: number[];
9
9
  export declare const SUPPORTED_CHAIN_IDS_DEV: number[];
10
+ export declare const CHAIN_NAMES_MAP: {
11
+ 56: string;
12
+ 97: string;
13
+ 42161: string;
14
+ 43114: string;
15
+ 43113: string;
16
+ };
10
17
  export declare const HIGH_EXECUTION_FEES_MAP: Record<number, number>;
11
18
  export declare const MAX_FEE_PER_GAS_MAP: Record<number, bigint>;
12
19
  export declare const GAS_PRICE_PREMIUM_MAP: Record<number, bigint>;
13
20
  export declare const MAX_PRIORITY_FEE_PER_GAS_MAP: Record<number, bigint | undefined>;
14
21
  export declare const EXCESSIVE_EXECUTION_FEES_MAP: Record<number, number>;
15
22
  export declare const GAS_PRICE_BUFFER_MAP: Record<number, bigint>;
16
- export declare const getChain: (chainId: number) => Chain;
23
+ export declare function getChainName(chainId: number): any;
24
+ export declare const getViemChain: (chainId: number) => Chain;
17
25
  export declare function getHighExecutionFee(chainId: number): number;
18
26
  export declare function getExcessiveExecutionFee(chainId: number): number;
19
27
  export declare function isSupportedChain(chainId: number, dev?: boolean): boolean;
@@ -23,3 +31,23 @@ export declare const EXECUTION_FEE_CONFIG_V2: {
23
31
  defaultBufferBps?: number;
24
32
  };
25
33
  };
34
+ export declare const GAS_LIMITS_STATIC_CONFIG: {
35
+ 42161: {
36
+ createOrderGasLimit: bigint;
37
+ updateOrderGasLimit: bigint;
38
+ cancelOrderGasLimit: bigint;
39
+ tokenPermitGasLimit: bigint;
40
+ };
41
+ 43114: {
42
+ createOrderGasLimit: bigint;
43
+ updateOrderGasLimit: bigint;
44
+ cancelOrderGasLimit: bigint;
45
+ tokenPermitGasLimit: bigint;
46
+ };
47
+ 43113: {
48
+ createOrderGasLimit: bigint;
49
+ updateOrderGasLimit: bigint;
50
+ cancelOrderGasLimit: bigint;
51
+ tokenPermitGasLimit: bigint;
52
+ };
53
+ };