@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
@@ -29,6 +29,8 @@ exports.TOKENS = {
29
29
  imageUrl: "https://assets.coingecko.com/coins/images/2518/thumb/weth.png?1628852295",
30
30
  coingeckoUrl: "https://www.coingecko.com/en/coins/ethereum",
31
31
  isV1Available: true,
32
+ isPermitSupported: true,
33
+ contractVersion: "1",
32
34
  },
33
35
  {
34
36
  name: "Wrapped Bitcoin",
@@ -43,6 +45,8 @@ exports.TOKENS = {
43
45
  coingeckoUrl: "https://www.coingecko.com/en/coins/wrapped-bitcoin",
44
46
  explorerUrl: "https://arbiscan.io/address/0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
45
47
  isV1Available: true,
48
+ isPermitSupported: true,
49
+ contractVersion: "1",
46
50
  },
47
51
  {
48
52
  name: "Arbitrum",
@@ -54,6 +58,8 @@ exports.TOKENS = {
54
58
  imageUrl: "https://assets.coingecko.com/coins/images/16547/small/photo_2023-03-29_21.47.00.jpeg?1680097630",
55
59
  coingeckoUrl: "https://www.coingecko.com/en/coins/arbitrum",
56
60
  explorerUrl: "https://arbiscan.io/token/0x912ce59144191c1204e64559fe8253a0e49e6548",
61
+ isPermitSupported: true,
62
+ contractVersion: "1",
57
63
  },
58
64
  {
59
65
  name: "Wrapped SOL (Wormhole)",
@@ -68,6 +74,9 @@ exports.TOKENS = {
68
74
  coingeckoSymbol: "SOL",
69
75
  explorerUrl: "https://arbiscan.io/token/0x2bCc6D6CdBbDC0a4071e48bb3B969b06B3330c07",
70
76
  explorerSymbol: "SOL",
77
+ isPermitSupported: true,
78
+ isPermitDisabled: true,
79
+ contractVersion: "1",
71
80
  },
72
81
  {
73
82
  name: "Chainlink",
@@ -82,6 +91,8 @@ exports.TOKENS = {
82
91
  coingeckoUrl: "https://www.coingecko.com/en/coins/chainlink",
83
92
  explorerUrl: "https://arbiscan.io/token/0xf97f4df75117a78c1a5a0dbb814af92458539fb4",
84
93
  isV1Available: true,
94
+ isPermitSupported: true,
95
+ contractVersion: "1",
85
96
  },
86
97
  {
87
98
  name: "Uniswap",
@@ -96,6 +107,8 @@ exports.TOKENS = {
96
107
  coingeckoUrl: "https://www.coingecko.com/en/coins/uniswap",
97
108
  explorerUrl: "https://arbiscan.io/token/0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0",
98
109
  isV1Available: true,
110
+ isPermitSupported: true,
111
+ contractVersion: "1",
99
112
  },
100
113
  {
101
114
  name: "Bridged USDC (USDC.e)",
@@ -107,6 +120,8 @@ exports.TOKENS = {
107
120
  coingeckoUrl: "https://www.coingecko.com/en/coins/bridged-usdc-arbitrum",
108
121
  explorerUrl: "https://arbiscan.io/token/0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
109
122
  isV1Available: true,
123
+ isPermitSupported: true,
124
+ contractVersion: "1",
110
125
  },
111
126
  {
112
127
  name: "USD Coin",
@@ -118,6 +133,7 @@ exports.TOKENS = {
118
133
  imageUrl: "https://assets.coingecko.com/coins/images/6319/thumb/USD_Coin_icon.png?1547042389",
119
134
  coingeckoUrl: "https://www.coingecko.com/en/coins/usd-coin",
120
135
  explorerUrl: "https://arbiscan.io/address/0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
136
+ isPermitSupported: true,
121
137
  },
122
138
  {
123
139
  name: "Tether",
@@ -129,6 +145,8 @@ exports.TOKENS = {
129
145
  explorerUrl: "https://arbiscan.io/address/0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
130
146
  coingeckoUrl: "https://www.coingecko.com/en/coins/tether",
131
147
  isV1Available: true,
148
+ isPermitSupported: true,
149
+ contractVersion: "1",
132
150
  },
133
151
  {
134
152
  name: "Dai",
@@ -140,6 +158,7 @@ exports.TOKENS = {
140
158
  coingeckoUrl: "https://www.coingecko.com/en/coins/dai",
141
159
  explorerUrl: "https://arbiscan.io/token/0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
142
160
  isV1Available: true,
161
+ isPermitSupported: true,
143
162
  },
144
163
  {
145
164
  name: "Frax",
@@ -151,6 +170,8 @@ exports.TOKENS = {
151
170
  coingeckoUrl: "https://www.coingecko.com/en/coins/frax",
152
171
  explorerUrl: "https://arbiscan.io/token/0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
153
172
  isV1Available: true,
173
+ isPermitSupported: true,
174
+ contractVersion: "1",
154
175
  },
155
176
  {
156
177
  name: "Magic Internet Money",
@@ -161,6 +182,7 @@ exports.TOKENS = {
161
182
  isTempHidden: true,
162
183
  imageUrl: "https://assets.coingecko.com/coins/images/16786/small/mimlogopng.png",
163
184
  isV1Available: true,
185
+ isPermitSupported: true,
164
186
  },
165
187
  {
166
188
  name: "Bitcoin",
@@ -171,6 +193,7 @@ exports.TOKENS = {
171
193
  categories: ["layer1"],
172
194
  imageUrl: "https://assets.coingecko.com/coins/images/1/small/bitcoin.png?1547033579",
173
195
  coingeckoUrl: "https://www.coingecko.com/en/coins/bitcoin",
196
+ isPermitSupported: true,
174
197
  },
175
198
  {
176
199
  name: "Dogecoin",
@@ -275,6 +298,8 @@ exports.TOKENS = {
275
298
  imageUrl: "https://assets.coingecko.com/coins/images/12645/standard/AAVE.png?1696512452",
276
299
  coingeckoUrl: "https://www.coingecko.com/en/coins/aave",
277
300
  coingeckoSymbol: "AAVE",
301
+ isPermitSupported: true,
302
+ contractVersion: "1",
278
303
  },
279
304
  {
280
305
  name: "Wrapped AVAX (Wormhole)",
@@ -288,6 +313,9 @@ exports.TOKENS = {
288
313
  coingeckoUrl: "https://www.coingecko.com/en/coins/avalanche",
289
314
  coingeckoSymbol: "AVAX",
290
315
  explorerSymbol: "WAVAX",
316
+ isPermitSupported: true,
317
+ isPermitDisabled: true,
318
+ contractVersion: "1",
291
319
  },
292
320
  {
293
321
  name: "Optimism",
@@ -319,6 +347,9 @@ exports.TOKENS = {
319
347
  categories: ["meme"],
320
348
  imageUrl: "https://assets.coingecko.com/coins/images/33566/standard/dogwifhat.jpg?1702499428",
321
349
  coingeckoUrl: "https://www.coingecko.com/en/coins/dogwifhat",
350
+ isPermitSupported: true,
351
+ isPermitDisabled: true,
352
+ contractVersion: "1",
322
353
  },
323
354
  {
324
355
  name: "ORDI",
@@ -378,6 +409,8 @@ exports.TOKENS = {
378
409
  decimals: 18,
379
410
  imageUrl: "https://assets.coingecko.com/coins/images/11224/standard/0x18084fba666a33d37592fa2633fd49a74dd93a88.png?1696511155",
380
411
  coingeckoUrl: "https://www.coingecko.com/en/coins/tbtc",
412
+ isPermitSupported: true,
413
+ contractVersion: "1",
381
414
  },
382
415
  {
383
416
  name: "Eigen",
@@ -387,6 +420,8 @@ exports.TOKENS = {
387
420
  categories: ["layer2"],
388
421
  imageUrl: "https://assets.coingecko.com/coins/images/37441/standard/eigen.jpg?1728023974",
389
422
  coingeckoUrl: "https://www.coingecko.com/en/coins/eigenlayer",
423
+ isPermitSupported: true,
424
+ contractVersion: "1",
390
425
  },
391
426
  {
392
427
  name: "Sats",
@@ -574,6 +609,9 @@ exports.TOKENS = {
574
609
  categories: ["defi"],
575
610
  imageUrl: "https://assets.coingecko.com/coins/images/15069/standard/Pendle_Logo_Normal-03.png?1696514728",
576
611
  coingeckoUrl: "https://www.coingecko.com/en/coins/pendle",
612
+ isPermitSupported: true,
613
+ isPermitDisabled: true,
614
+ contractVersion: "1",
577
615
  },
578
616
  {
579
617
  name: "ADA",
@@ -1005,6 +1043,7 @@ exports.TOKENS = {
1005
1043
  coingeckoUrl: "https://www.coingecko.com/en/coins/usd-coin",
1006
1044
  explorerUrl: "https://snowtrace.io/address/0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
1007
1045
  isV1Available: true,
1046
+ isPermitSupported: true,
1008
1047
  },
1009
1048
  {
1010
1049
  name: "Bridged USDC (USDC.e)",
@@ -1026,6 +1065,8 @@ exports.TOKENS = {
1026
1065
  imageUrl: "https://assets.coingecko.com/coins/images/325/small/Tether-logo.png",
1027
1066
  coingeckoUrl: "https://www.coingecko.com/en/coins/tether",
1028
1067
  explorerUrl: "https://snowtrace.io/address/0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
1068
+ isPermitSupported: true,
1069
+ contractVersion: "1",
1029
1070
  },
1030
1071
  {
1031
1072
  name: "Tether",
@@ -1058,6 +1099,7 @@ exports.TOKENS = {
1058
1099
  coingeckoUrl: "https://www.coingecko.com/en/coins/magic-internet-money",
1059
1100
  explorerUrl: "https://snowtrace.io/address/0x130966628846BFd36ff31a822705796e8cb8C18D",
1060
1101
  isV1Available: true,
1102
+ isPermitSupported: true,
1061
1103
  },
1062
1104
  {
1063
1105
  name: "Chainlink",
@@ -1106,6 +1148,9 @@ exports.TOKENS = {
1106
1148
  coingeckoUrl: "https://www.coingecko.com/en/coins/solana",
1107
1149
  coingeckoSymbol: "SOL",
1108
1150
  explorerUrl: "https://snowtrace.io/address/0xFE6B19286885a4F7F55AdAD09C3Cd1f906D2478F",
1151
+ isPermitSupported: true,
1152
+ isPermitDisabled: true,
1153
+ contractVersion: "1",
1109
1154
  },
1110
1155
  {
1111
1156
  name: "XRP",
@@ -1210,6 +1255,7 @@ exports.TOKENS = {
1210
1255
  imageUrl: "https://assets.coingecko.com/coins/images/12559/small/coin-round-red.png?1604021818",
1211
1256
  coingeckoUrl: "https://www.coingecko.com/en/coins/avalanche",
1212
1257
  explorerUrl: "https://testnet.snowtrace.io/address/0x1D308089a2D1Ced3f1Ce36B1FcaF815b07217be3",
1258
+ isPermitSupported: true,
1213
1259
  },
1214
1260
  {
1215
1261
  name: "Ethereum (WETH.e)",
@@ -1533,6 +1579,10 @@ function isValidToken(chainId, address) {
1533
1579
  }
1534
1580
  exports.isValidToken = isValidToken;
1535
1581
  function getToken(chainId, address) {
1582
+ // FIXME APE_deprecated token which is not in use but can be displayed
1583
+ if (chainId === chains_1.ARBITRUM && address === "0x74885b4D524d497261259B38900f54e6dbAd2210") {
1584
+ return getTokenBySymbol(chainId, "APE");
1585
+ }
1536
1586
  if (!exports.TOKENS_MAP[chainId]) {
1537
1587
  throw new Error(`Incorrect chainId ${chainId}`);
1538
1588
  }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_TWAP_DURATION = exports.MAX_TWAP_NUMBER_OF_PARTS = exports.MIN_TWAP_NUMBER_OF_PARTS = exports.DEFAULT_TWAP_NUMBER_OF_PARTS = void 0;
4
+ exports.DEFAULT_TWAP_NUMBER_OF_PARTS = 5;
5
+ exports.MIN_TWAP_NUMBER_OF_PARTS = 2;
6
+ exports.MAX_TWAP_NUMBER_OF_PARTS = 30;
7
+ exports.DEFAULT_TWAP_DURATION = {
8
+ minutes: 0,
9
+ hours: 10,
10
+ };
@@ -37,13 +37,13 @@ class GmxSdk {
37
37
  }),
38
38
  pollingInterval: undefined,
39
39
  batch: batch_1.BATCH_CONFIGS[this.config.chainId].client,
40
- chain: (0, chains_1.getChain)(this.config.chainId),
40
+ chain: (0, chains_1.getViemChain)(this.config.chainId),
41
41
  });
42
42
  this.walletClient =
43
43
  config.walletClient ??
44
44
  (0, viem_1.createWalletClient)({
45
45
  account: config.account,
46
- chain: (0, chains_1.getChain)(config.chainId),
46
+ chain: (0, chains_1.getViemChain)(config.chainId),
47
47
  transport: (0, viem_1.http)(config.rpcUrl, {
48
48
  retryCount: 0,
49
49
  retryDelay: 10000000,
@@ -66,7 +66,7 @@ class GmxSdk {
66
66
  return this.config.chainId;
67
67
  }
68
68
  get chain() {
69
- return (0, chains_1.getChain)(this.chainId);
69
+ return (0, chains_1.getViemChain)(this.chainId);
70
70
  }
71
71
  get account() {
72
72
  return this.config.account;
@@ -169,6 +169,7 @@ class Markets extends base_1.Module {
169
169
  swapFeeFactorForPositiveImpact: dataStoreValues.swapFeeFactorForPositiveImpact.returnValues[0],
170
170
  swapFeeFactorForNegativeImpact: dataStoreValues.swapFeeFactorForNegativeImpact.returnValues[0],
171
171
  swapImpactFactorPositive: dataStoreValues.swapImpactFactorPositive.returnValues[0],
172
+ atomicSwapFeeFactor: dataStoreValues.atomicSwapFeeFactor.returnValues[0],
172
173
  swapImpactFactorNegative: dataStoreValues.swapImpactFactorNegative.returnValues[0],
173
174
  swapImpactExponentFactor: dataStoreValues.swapImpactExponentFactor.returnValues[0],
174
175
  virtualMarketId: dataStoreValues.virtualMarketId.returnValues[0],
@@ -358,6 +358,10 @@ async function buildMarketsConfigsRequest(chainId, { marketsData, marketsAddress
358
358
  methodName: "getUint",
359
359
  params: [prebuiltHashedKeys.swapFeeFactorForNegativeImpact],
360
360
  },
361
+ atomicSwapFeeFactor: {
362
+ methodName: "getUint",
363
+ params: [prebuiltHashedKeys.atomicSwapFeeFactor],
364
+ },
361
365
  swapImpactFactorPositive: {
362
366
  methodName: "getUint",
363
367
  params: [prebuiltHashedKeys.swapImpactFactorPositive],
@@ -79,6 +79,7 @@ async function increaseOrderHelper(sdk, params) {
79
79
  gasPrice,
80
80
  tokensData,
81
81
  },
82
+ isExpressFeeSwap: false,
82
83
  });
83
84
  const payOrSizeAmount = "payAmount" in params ? params.payAmount : params.sizeAmount;
84
85
  const increaseAmounts = (0, amounts_1.getIncreasePositionAmounts)({
@@ -112,7 +113,7 @@ async function increaseOrderHelper(sdk, params) {
112
113
  referralCodeForTxn: params.referralCodeForTxn,
113
114
  triggerPrice: params.limitPrice,
114
115
  collateralTokenAddress: collateralToken.address,
115
- isLong: true,
116
+ isLong: params.isLong,
116
117
  receiveTokenAddress: collateralTokenAddress,
117
118
  indexToken: marketInfo.indexToken,
118
119
  marketInfo,
@@ -165,6 +166,7 @@ async function swap(sdk, params) {
165
166
  gasPrice,
166
167
  tokensData,
167
168
  },
169
+ isExpressFeeSwap: false,
168
170
  });
169
171
  const isWrapOrUnwrap = Boolean(fromToken && toToken && ((0, tokens_1.getIsWrap)(fromToken, toToken) || (0, tokens_1.getIsUnwrap)(fromToken, toToken)));
170
172
  const swapOptimizationOrder = isLimit ? ["length", "liquidity"] : undefined;
@@ -67,7 +67,7 @@ function createDecreaseEncodedPayload({ sdk, orderVaultAddress, ps, }) {
67
67
  callbackContract: viem_1.zeroAddress,
68
68
  market: p.marketAddress,
69
69
  swapPath: p.swapPath,
70
- uiFeeReceiver: viem_1.zeroAddress,
70
+ uiFeeReceiver: sdk.config.settings?.uiFeeReceiverAccount || viem_1.zeroAddress,
71
71
  },
72
72
  numbers: {
73
73
  sizeDeltaUsd: p.sizeDeltaUsd,
@@ -38,6 +38,7 @@ async function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p, creat
38
38
  acceptablePrice,
39
39
  isNativePayment,
40
40
  initialCollateralTokenAddress,
41
+ uiFeeReceiver: sdk.config.settings?.uiFeeReceiverAccount,
41
42
  });
42
43
  const simulationEncodedPayload = await createEncodedPayload({
43
44
  routerAbi: abis_1.abis.ExchangeRouter,
@@ -47,6 +48,7 @@ async function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p, creat
47
48
  acceptablePrice,
48
49
  isNativePayment,
49
50
  initialCollateralTokenAddress,
51
+ uiFeeReceiver: sdk.config.settings?.uiFeeReceiverAccount,
50
52
  });
51
53
  const decreaseEncodedPayload = (0, createDecreaseOrderTxn_1.createDecreaseEncodedPayload)({
52
54
  sdk,
@@ -91,12 +93,13 @@ async function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p, creat
91
93
  });
92
94
  }
93
95
  exports.createIncreaseOrderTxn = createIncreaseOrderTxn;
94
- async function createEncodedPayload({ routerAbi, orderVaultAddress, totalWntAmount, p, acceptablePrice, isNativePayment, initialCollateralTokenAddress, }) {
96
+ async function createEncodedPayload({ routerAbi, orderVaultAddress, totalWntAmount, p, acceptablePrice, isNativePayment, initialCollateralTokenAddress, uiFeeReceiver, }) {
95
97
  const orderParams = createOrderParams({
96
98
  p,
97
99
  acceptablePrice,
98
100
  initialCollateralTokenAddress,
99
101
  isNativePayment,
102
+ uiFeeReceiver,
100
103
  });
101
104
  const multicall = [
102
105
  { method: "sendWnt", params: [orderVaultAddress, totalWntAmount] },
@@ -114,7 +117,7 @@ async function createEncodedPayload({ routerAbi, orderVaultAddress, totalWntAmou
114
117
  args: call.params,
115
118
  }));
116
119
  }
117
- function createOrderParams({ p, acceptablePrice, initialCollateralTokenAddress, isNativePayment, }) {
120
+ function createOrderParams({ p, acceptablePrice, initialCollateralTokenAddress, isNativePayment, uiFeeReceiver, }) {
118
121
  return {
119
122
  addresses: {
120
123
  cancellationReceiver: viem_1.zeroAddress,
@@ -123,7 +126,7 @@ function createOrderParams({ p, acceptablePrice, initialCollateralTokenAddress,
123
126
  callbackContract: viem_1.zeroAddress,
124
127
  market: p.marketAddress,
125
128
  swapPath: p.swapPath,
126
- uiFeeReceiver: viem_1.zeroAddress,
129
+ uiFeeReceiver: uiFeeReceiver || viem_1.zeroAddress,
127
130
  },
128
131
  numbers: {
129
132
  sizeDeltaUsd: p.sizeDeltaUsd,
@@ -45,7 +45,7 @@ async function getParams(sdk, p) {
45
45
  callbackContract: viem_1.zeroAddress,
46
46
  market: viem_1.zeroAddress,
47
47
  swapPath: p.swapPath,
48
- uiFeeReceiver: viem_1.zeroAddress,
48
+ uiFeeReceiver: sdk.config.settings?.uiFeeReceiverAccount || viem_1.zeroAddress,
49
49
  },
50
50
  numbers: {
51
51
  sizeDeltaUsd: 0n,
@@ -79,6 +79,10 @@ class Utils extends base_1.Module {
79
79
  methodName: "getUint",
80
80
  params: [dataStore_1.GLV_PER_MARKET_GAS_LIMIT],
81
81
  },
82
+ gelatoRelayFeeMultiplierFactor: {
83
+ methodName: "getUint",
84
+ params: [dataStore_1.GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY],
85
+ },
82
86
  },
83
87
  },
84
88
  })
@@ -87,6 +91,7 @@ class Utils extends base_1.Module {
87
91
  function getBigInt(key) {
88
92
  return BigInt(results[key].returnValues[0]);
89
93
  }
94
+ const staticGasLimits = chains_1.GAS_LIMITS_STATIC_CONFIG[this.chainId];
90
95
  return {
91
96
  depositToken: getBigInt("depositToken"),
92
97
  withdrawalMultiToken: getBigInt("withdrawalMultiToken"),
@@ -101,6 +106,11 @@ class Utils extends base_1.Module {
101
106
  glvDepositGasLimit: getBigInt("glvDepositGasLimit"),
102
107
  glvWithdrawalGasLimit: getBigInt("glvWithdrawalGasLimit"),
103
108
  glvPerMarketGasLimit: getBigInt("glvPerMarketGasLimit"),
109
+ createOrderGasLimit: staticGasLimits.createOrderGasLimit,
110
+ updateOrderGasLimit: staticGasLimits.updateOrderGasLimit,
111
+ cancelOrderGasLimit: staticGasLimits.cancelOrderGasLimit,
112
+ tokenPermitGasLimit: staticGasLimits.tokenPermitGasLimit,
113
+ gelatoRelayFeeMultiplierFactor: getBigInt("gelatoRelayFeeMultiplierFactor"),
104
114
  };
105
115
  });
106
116
  this._gasLimits = gasLimits;
@@ -166,7 +176,7 @@ class Utils extends base_1.Module {
166
176
  async getGasPrice() {
167
177
  const executionFeeConfig = chains_1.EXECUTION_FEE_CONFIG_V2[this.chainId];
168
178
  const feeData = await (0, viem_1.withRetry)(() => this.sdk.publicClient.estimateFeesPerGas({
169
- chain: (0, chains_1.getChain)(this.chainId),
179
+ chain: (0, chains_1.getViemChain)(this.chainId),
170
180
  type: "legacy",
171
181
  }), {
172
182
  retryCount: 2,