@swapkit/helpers 2.5.0 → 3.0.0-beta.0

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 (106) hide show
  1. package/dist/api/index.cjs +3 -0
  2. package/dist/api/index.cjs.map +16 -0
  3. package/dist/api/index.js +3 -0
  4. package/dist/api/index.js.map +16 -0
  5. package/dist/chunk-fazw0jvt.js +3 -0
  6. package/dist/chunk-fazw0jvt.js.map +9 -0
  7. package/dist/chunk-nm00d52v.js +4 -0
  8. package/dist/chunk-nm00d52v.js.map +9 -0
  9. package/dist/contracts/index.cjs +3 -0
  10. package/dist/contracts/index.cjs.map +38 -0
  11. package/dist/contracts/index.js +3 -0
  12. package/dist/contracts/index.js.map +38 -0
  13. package/dist/index.cjs +6 -0
  14. package/dist/index.cjs.map +29 -0
  15. package/dist/index.js +3 -3
  16. package/dist/index.js.map +19 -20
  17. package/dist/tokens/index.cjs +3 -0
  18. package/dist/tokens/index.cjs.map +23 -0
  19. package/dist/tokens/index.js +3 -0
  20. package/dist/tokens/index.js.map +23 -0
  21. package/package.json +31 -15
  22. package/src/api/index.ts +19 -0
  23. package/src/api/microgard/endpoints.ts +83 -0
  24. package/src/api/microgard/types.ts +60 -0
  25. package/src/api/midgard/endpoints.ts +166 -0
  26. package/src/api/midgard/types.ts +155 -0
  27. package/src/api/swapkitApi/endpoints.ts +266 -0
  28. package/src/api/swapkitApi/types.ts +772 -0
  29. package/src/api/thornode/endpoints.ts +78 -0
  30. package/src/api/thornode/types.ts +241 -0
  31. package/src/api/thorswapStatic/endpoints.ts +30 -0
  32. package/src/api/thorswapStatic/types.ts +18 -0
  33. package/src/contracts/abis/avaxGeneric.ts +92 -0
  34. package/src/contracts/abis/avaxWoofi.ts +145 -0
  35. package/src/contracts/abis/bscGeneric.ts +106 -0
  36. package/src/contracts/abis/chainflipGateway.ts +330 -0
  37. package/src/contracts/abis/erc20.ts +99 -0
  38. package/src/contracts/abis/ethGeneric.ts +92 -0
  39. package/src/contracts/abis/mayaEvmVaults.ts +331 -0
  40. package/src/contracts/abis/pancakeV2.ts +145 -0
  41. package/src/contracts/abis/pangolin.ts +120 -0
  42. package/src/contracts/abis/sushiswap.ts +120 -0
  43. package/src/contracts/abis/tcEthVault.ts +650 -0
  44. package/src/contracts/abis/traderJoe.ts +120 -0
  45. package/src/contracts/abis/uniswapV2.ts +120 -0
  46. package/src/contracts/abis/uniswapV2Leg.ts +128 -0
  47. package/src/contracts/abis/uniswapV3_100.ts +128 -0
  48. package/src/contracts/abis/uniswapV3_10000.ts +128 -0
  49. package/src/contracts/abis/uniswapV3_3000.ts +128 -0
  50. package/src/contracts/abis/uniswapV3_500.ts +128 -0
  51. package/src/contracts/index.ts +95 -0
  52. package/src/contracts/routers/index.ts +58 -0
  53. package/src/contracts/routers/kyber.ts +402 -0
  54. package/src/contracts/routers/oneinch.ts +2188 -0
  55. package/src/contracts/routers/pancakeswap.ts +340 -0
  56. package/src/contracts/routers/pangolin.ts +340 -0
  57. package/src/contracts/routers/sushiswap.ts +340 -0
  58. package/src/contracts/routers/traderJoe.ts +340 -0
  59. package/src/contracts/routers/uniswapv2.ts +340 -0
  60. package/src/contracts/routers/uniswapv3.ts +254 -0
  61. package/src/contracts/routers/woofi.ts +171 -0
  62. package/src/index.ts +11 -12
  63. package/src/modules/__tests__/assetValue.test.ts +0 -2
  64. package/src/modules/__tests__/swapKitConfig.test.ts +37 -0
  65. package/src/modules/assetValue.ts +26 -92
  66. package/src/modules/bigIntArithmetics.ts +6 -2
  67. package/src/modules/requestClient.ts +26 -35
  68. package/src/modules/swapKitConfig.ts +131 -0
  69. package/src/modules/swapKitError.ts +6 -6
  70. package/src/tokens/index.ts +15 -0
  71. package/src/tokens/lists/camelot_v3.ts +15920 -0
  72. package/src/tokens/lists/caviar_v1.ts +1694 -0
  73. package/src/tokens/lists/chainflip.ts +104 -0
  74. package/src/tokens/lists/index.ts +13 -0
  75. package/src/tokens/lists/jupiter.ts +29606 -0
  76. package/src/tokens/lists/mayachain.ts +513 -0
  77. package/src/tokens/lists/oneinch.ts +14238 -0
  78. package/src/tokens/lists/openocean_v2.ts +11514 -0
  79. package/src/tokens/lists/pancakeswap.ts +4296 -0
  80. package/src/tokens/lists/pangolin_v1.ts +175 -0
  81. package/src/tokens/lists/sushiswap_v2.ts +965 -0
  82. package/src/tokens/lists/thorchain.ts +669 -0
  83. package/src/tokens/lists/traderjoe_v2.ts +1384 -0
  84. package/src/tokens/lists/uniswap_v2.ts +5596 -0
  85. package/src/tokens/lists/uniswap_v3.ts +5946 -0
  86. package/src/types/chains.ts +26 -46
  87. package/src/types/commonTypes.ts +3 -90
  88. package/src/types/index.ts +3 -4
  89. package/src/types/sdk.ts +0 -30
  90. package/src/types/tokens.ts +2 -2
  91. package/src/types/wallet.ts +37 -21
  92. package/src/{helpers → utils}/asset.ts +49 -19
  93. package/src/{helpers → utils}/derivationPath.ts +7 -2
  94. package/src/{helpers → utils}/memo.ts +0 -65
  95. package/src/{helpers → utils}/others.ts +12 -5
  96. package/src/utils/plugin.ts +13 -0
  97. package/src/{helpers/web3wallets.ts → utils/wallets.ts} +175 -139
  98. package/src/modules/walletUtils.ts +0 -30
  99. package/src/types/network.ts +0 -49
  100. /package/src/{helpers → utils}/__tests__/asset.test.ts +0 -0
  101. /package/src/{helpers/__tests__/derivationPath.ts → utils/__tests__/derivationPath.test.ts} +0 -0
  102. /package/src/{helpers → utils}/__tests__/memo.test.ts +0 -0
  103. /package/src/{helpers → utils}/__tests__/others.test.ts +0 -0
  104. /package/src/{helpers → utils}/__tests__/validators.test.ts +0 -0
  105. /package/src/{helpers → utils}/liquidity.ts +0 -0
  106. /package/src/{helpers → utils}/validators.ts +0 -0
@@ -0,0 +1,340 @@
1
+ export const sushiswapRouter = [
2
+ {
3
+ inputs: [
4
+ { internalType: "address", name: "_factory", type: "address" },
5
+ { internalType: "address", name: "_WETH", type: "address" },
6
+ ],
7
+ stateMutability: "nonpayable",
8
+ type: "constructor",
9
+ },
10
+ {
11
+ inputs: [],
12
+ name: "WETH",
13
+ outputs: [{ internalType: "address", name: "", type: "address" }],
14
+ stateMutability: "view",
15
+ type: "function",
16
+ },
17
+ {
18
+ inputs: [
19
+ { internalType: "address", name: "tokenA", type: "address" },
20
+ { internalType: "address", name: "tokenB", type: "address" },
21
+ { internalType: "uint256", name: "amountADesired", type: "uint256" },
22
+ { internalType: "uint256", name: "amountBDesired", type: "uint256" },
23
+ { internalType: "uint256", name: "amountAMin", type: "uint256" },
24
+ { internalType: "uint256", name: "amountBMin", type: "uint256" },
25
+ { internalType: "address", name: "to", type: "address" },
26
+ { internalType: "uint256", name: "deadline", type: "uint256" },
27
+ ],
28
+ name: "addLiquidity",
29
+ outputs: [
30
+ { internalType: "uint256", name: "amountA", type: "uint256" },
31
+ { internalType: "uint256", name: "amountB", type: "uint256" },
32
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
33
+ ],
34
+ stateMutability: "nonpayable",
35
+ type: "function",
36
+ },
37
+ {
38
+ inputs: [
39
+ { internalType: "address", name: "token", type: "address" },
40
+ { internalType: "uint256", name: "amountTokenDesired", type: "uint256" },
41
+ { internalType: "uint256", name: "amountTokenMin", type: "uint256" },
42
+ { internalType: "uint256", name: "amountETHMin", type: "uint256" },
43
+ { internalType: "address", name: "to", type: "address" },
44
+ { internalType: "uint256", name: "deadline", type: "uint256" },
45
+ ],
46
+ name: "addLiquidityETH",
47
+ outputs: [
48
+ { internalType: "uint256", name: "amountToken", type: "uint256" },
49
+ { internalType: "uint256", name: "amountETH", type: "uint256" },
50
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
51
+ ],
52
+ stateMutability: "payable",
53
+ type: "function",
54
+ },
55
+ {
56
+ inputs: [],
57
+ name: "factory",
58
+ outputs: [{ internalType: "address", name: "", type: "address" }],
59
+ stateMutability: "view",
60
+ type: "function",
61
+ },
62
+ {
63
+ inputs: [
64
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
65
+ { internalType: "uint256", name: "reserveIn", type: "uint256" },
66
+ { internalType: "uint256", name: "reserveOut", type: "uint256" },
67
+ ],
68
+ name: "getAmountIn",
69
+ outputs: [{ internalType: "uint256", name: "amountIn", type: "uint256" }],
70
+ stateMutability: "pure",
71
+ type: "function",
72
+ },
73
+ {
74
+ inputs: [
75
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
76
+ { internalType: "uint256", name: "reserveIn", type: "uint256" },
77
+ { internalType: "uint256", name: "reserveOut", type: "uint256" },
78
+ ],
79
+ name: "getAmountOut",
80
+ outputs: [{ internalType: "uint256", name: "amountOut", type: "uint256" }],
81
+ stateMutability: "pure",
82
+ type: "function",
83
+ },
84
+ {
85
+ inputs: [
86
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
87
+ { internalType: "address[]", name: "path", type: "address[]" },
88
+ ],
89
+ name: "getAmountsIn",
90
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
91
+ stateMutability: "view",
92
+ type: "function",
93
+ },
94
+ {
95
+ inputs: [
96
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
97
+ { internalType: "address[]", name: "path", type: "address[]" },
98
+ ],
99
+ name: "getAmountsOut",
100
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
101
+ stateMutability: "view",
102
+ type: "function",
103
+ },
104
+ {
105
+ inputs: [
106
+ { internalType: "uint256", name: "amountA", type: "uint256" },
107
+ { internalType: "uint256", name: "reserveA", type: "uint256" },
108
+ { internalType: "uint256", name: "reserveB", type: "uint256" },
109
+ ],
110
+ name: "quote",
111
+ outputs: [{ internalType: "uint256", name: "amountB", type: "uint256" }],
112
+ stateMutability: "pure",
113
+ type: "function",
114
+ },
115
+ {
116
+ inputs: [
117
+ { internalType: "address", name: "tokenA", type: "address" },
118
+ { internalType: "address", name: "tokenB", type: "address" },
119
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
120
+ { internalType: "uint256", name: "amountAMin", type: "uint256" },
121
+ { internalType: "uint256", name: "amountBMin", type: "uint256" },
122
+ { internalType: "address", name: "to", type: "address" },
123
+ { internalType: "uint256", name: "deadline", type: "uint256" },
124
+ ],
125
+ name: "removeLiquidity",
126
+ outputs: [
127
+ { internalType: "uint256", name: "amountA", type: "uint256" },
128
+ { internalType: "uint256", name: "amountB", type: "uint256" },
129
+ ],
130
+ stateMutability: "nonpayable",
131
+ type: "function",
132
+ },
133
+ {
134
+ inputs: [
135
+ { internalType: "address", name: "token", type: "address" },
136
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
137
+ { internalType: "uint256", name: "amountTokenMin", type: "uint256" },
138
+ { internalType: "uint256", name: "amountETHMin", type: "uint256" },
139
+ { internalType: "address", name: "to", type: "address" },
140
+ { internalType: "uint256", name: "deadline", type: "uint256" },
141
+ ],
142
+ name: "removeLiquidityETH",
143
+ outputs: [
144
+ { internalType: "uint256", name: "amountToken", type: "uint256" },
145
+ { internalType: "uint256", name: "amountETH", type: "uint256" },
146
+ ],
147
+ stateMutability: "nonpayable",
148
+ type: "function",
149
+ },
150
+ {
151
+ inputs: [
152
+ { internalType: "address", name: "token", type: "address" },
153
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
154
+ { internalType: "uint256", name: "amountTokenMin", type: "uint256" },
155
+ { internalType: "uint256", name: "amountETHMin", type: "uint256" },
156
+ { internalType: "address", name: "to", type: "address" },
157
+ { internalType: "uint256", name: "deadline", type: "uint256" },
158
+ ],
159
+ name: "removeLiquidityETHSupportingFeeOnTransferTokens",
160
+ outputs: [{ internalType: "uint256", name: "amountETH", type: "uint256" }],
161
+ stateMutability: "nonpayable",
162
+ type: "function",
163
+ },
164
+ {
165
+ inputs: [
166
+ { internalType: "address", name: "token", type: "address" },
167
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
168
+ { internalType: "uint256", name: "amountTokenMin", type: "uint256" },
169
+ { internalType: "uint256", name: "amountETHMin", type: "uint256" },
170
+ { internalType: "address", name: "to", type: "address" },
171
+ { internalType: "uint256", name: "deadline", type: "uint256" },
172
+ { internalType: "bool", name: "approveMax", type: "bool" },
173
+ { internalType: "uint8", name: "v", type: "uint8" },
174
+ { internalType: "bytes32", name: "r", type: "bytes32" },
175
+ { internalType: "bytes32", name: "s", type: "bytes32" },
176
+ ],
177
+ name: "removeLiquidityETHWithPermit",
178
+ outputs: [
179
+ { internalType: "uint256", name: "amountToken", type: "uint256" },
180
+ { internalType: "uint256", name: "amountETH", type: "uint256" },
181
+ ],
182
+ stateMutability: "nonpayable",
183
+ type: "function",
184
+ },
185
+ {
186
+ inputs: [
187
+ { internalType: "address", name: "token", type: "address" },
188
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
189
+ { internalType: "uint256", name: "amountTokenMin", type: "uint256" },
190
+ { internalType: "uint256", name: "amountETHMin", type: "uint256" },
191
+ { internalType: "address", name: "to", type: "address" },
192
+ { internalType: "uint256", name: "deadline", type: "uint256" },
193
+ { internalType: "bool", name: "approveMax", type: "bool" },
194
+ { internalType: "uint8", name: "v", type: "uint8" },
195
+ { internalType: "bytes32", name: "r", type: "bytes32" },
196
+ { internalType: "bytes32", name: "s", type: "bytes32" },
197
+ ],
198
+ name: "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens",
199
+ outputs: [{ internalType: "uint256", name: "amountETH", type: "uint256" }],
200
+ stateMutability: "nonpayable",
201
+ type: "function",
202
+ },
203
+ {
204
+ inputs: [
205
+ { internalType: "address", name: "tokenA", type: "address" },
206
+ { internalType: "address", name: "tokenB", type: "address" },
207
+ { internalType: "uint256", name: "liquidity", type: "uint256" },
208
+ { internalType: "uint256", name: "amountAMin", type: "uint256" },
209
+ { internalType: "uint256", name: "amountBMin", type: "uint256" },
210
+ { internalType: "address", name: "to", type: "address" },
211
+ { internalType: "uint256", name: "deadline", type: "uint256" },
212
+ { internalType: "bool", name: "approveMax", type: "bool" },
213
+ { internalType: "uint8", name: "v", type: "uint8" },
214
+ { internalType: "bytes32", name: "r", type: "bytes32" },
215
+ { internalType: "bytes32", name: "s", type: "bytes32" },
216
+ ],
217
+ name: "removeLiquidityWithPermit",
218
+ outputs: [
219
+ { internalType: "uint256", name: "amountA", type: "uint256" },
220
+ { internalType: "uint256", name: "amountB", type: "uint256" },
221
+ ],
222
+ stateMutability: "nonpayable",
223
+ type: "function",
224
+ },
225
+ {
226
+ inputs: [
227
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
228
+ { internalType: "address[]", name: "path", type: "address[]" },
229
+ { internalType: "address", name: "to", type: "address" },
230
+ { internalType: "uint256", name: "deadline", type: "uint256" },
231
+ ],
232
+ name: "swapETHForExactTokens",
233
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
234
+ stateMutability: "payable",
235
+ type: "function",
236
+ },
237
+ {
238
+ inputs: [
239
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
240
+ { internalType: "address[]", name: "path", type: "address[]" },
241
+ { internalType: "address", name: "to", type: "address" },
242
+ { internalType: "uint256", name: "deadline", type: "uint256" },
243
+ ],
244
+ name: "swapExactETHForTokens",
245
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
246
+ stateMutability: "payable",
247
+ type: "function",
248
+ },
249
+ {
250
+ inputs: [
251
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
252
+ { internalType: "address[]", name: "path", type: "address[]" },
253
+ { internalType: "address", name: "to", type: "address" },
254
+ { internalType: "uint256", name: "deadline", type: "uint256" },
255
+ ],
256
+ name: "swapExactETHForTokensSupportingFeeOnTransferTokens",
257
+ outputs: [],
258
+ stateMutability: "payable",
259
+ type: "function",
260
+ },
261
+ {
262
+ inputs: [
263
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
264
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
265
+ { internalType: "address[]", name: "path", type: "address[]" },
266
+ { internalType: "address", name: "to", type: "address" },
267
+ { internalType: "uint256", name: "deadline", type: "uint256" },
268
+ ],
269
+ name: "swapExactTokensForETH",
270
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
271
+ stateMutability: "nonpayable",
272
+ type: "function",
273
+ },
274
+ {
275
+ inputs: [
276
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
277
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
278
+ { internalType: "address[]", name: "path", type: "address[]" },
279
+ { internalType: "address", name: "to", type: "address" },
280
+ { internalType: "uint256", name: "deadline", type: "uint256" },
281
+ ],
282
+ name: "swapExactTokensForETHSupportingFeeOnTransferTokens",
283
+ outputs: [],
284
+ stateMutability: "nonpayable",
285
+ type: "function",
286
+ },
287
+ {
288
+ inputs: [
289
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
290
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
291
+ { internalType: "address[]", name: "path", type: "address[]" },
292
+ { internalType: "address", name: "to", type: "address" },
293
+ { internalType: "uint256", name: "deadline", type: "uint256" },
294
+ ],
295
+ name: "swapExactTokensForTokens",
296
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
297
+ stateMutability: "nonpayable",
298
+ type: "function",
299
+ },
300
+ {
301
+ inputs: [
302
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
303
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
304
+ { internalType: "address[]", name: "path", type: "address[]" },
305
+ { internalType: "address", name: "to", type: "address" },
306
+ { internalType: "uint256", name: "deadline", type: "uint256" },
307
+ ],
308
+ name: "swapExactTokensForTokensSupportingFeeOnTransferTokens",
309
+ outputs: [],
310
+ stateMutability: "nonpayable",
311
+ type: "function",
312
+ },
313
+ {
314
+ inputs: [
315
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
316
+ { internalType: "uint256", name: "amountInMax", type: "uint256" },
317
+ { internalType: "address[]", name: "path", type: "address[]" },
318
+ { internalType: "address", name: "to", type: "address" },
319
+ { internalType: "uint256", name: "deadline", type: "uint256" },
320
+ ],
321
+ name: "swapTokensForExactETH",
322
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
323
+ stateMutability: "nonpayable",
324
+ type: "function",
325
+ },
326
+ {
327
+ inputs: [
328
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
329
+ { internalType: "uint256", name: "amountInMax", type: "uint256" },
330
+ { internalType: "address[]", name: "path", type: "address[]" },
331
+ { internalType: "address", name: "to", type: "address" },
332
+ { internalType: "uint256", name: "deadline", type: "uint256" },
333
+ ],
334
+ name: "swapTokensForExactTokens",
335
+ outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }],
336
+ stateMutability: "nonpayable",
337
+ type: "function",
338
+ },
339
+ { stateMutability: "payable", type: "receive" },
340
+ ];