@swapkit/core 1.0.0-rc.99 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/index.js +3 -0
  2. package/dist/index.js.map +12 -0
  3. package/package.json +23 -44
  4. package/src/__tests__/helpers.test.ts +65 -0
  5. package/src/client.ts +415 -0
  6. package/src/helpers/explorerUrls.ts +44 -0
  7. package/src/index.ts +6 -4
  8. package/src/types.ts +44 -0
  9. package/LICENSE +0 -201
  10. package/dist/index.cjs +0 -3
  11. package/dist/index.cjs.map +0 -1
  12. package/dist/index.d.ts +0 -230
  13. package/dist/index.es.js +0 -9119
  14. package/dist/index.es.js.map +0 -1
  15. package/src/aggregator/contracts/avaxGeneric.ts +0 -92
  16. package/src/aggregator/contracts/avaxWoofi.ts +0 -145
  17. package/src/aggregator/contracts/bscGeneric.ts +0 -106
  18. package/src/aggregator/contracts/ethGeneric.ts +0 -92
  19. package/src/aggregator/contracts/index.ts +0 -76
  20. package/src/aggregator/contracts/pancakeV2.ts +0 -145
  21. package/src/aggregator/contracts/pangolin.ts +0 -120
  22. package/src/aggregator/contracts/routers/index.ts +0 -58
  23. package/src/aggregator/contracts/routers/kyber.ts +0 -402
  24. package/src/aggregator/contracts/routers/oneinch.ts +0 -2188
  25. package/src/aggregator/contracts/routers/pancakeswap.ts +0 -340
  26. package/src/aggregator/contracts/routers/pangolin.ts +0 -340
  27. package/src/aggregator/contracts/routers/sushiswap.ts +0 -340
  28. package/src/aggregator/contracts/routers/traderJoe.ts +0 -340
  29. package/src/aggregator/contracts/routers/uniswapv2.ts +0 -340
  30. package/src/aggregator/contracts/routers/uniswapv3.ts +0 -254
  31. package/src/aggregator/contracts/routers/woofi.ts +0 -171
  32. package/src/aggregator/contracts/sushiswap.ts +0 -120
  33. package/src/aggregator/contracts/traderJoe.ts +0 -120
  34. package/src/aggregator/contracts/uniswapV2.ts +0 -120
  35. package/src/aggregator/contracts/uniswapV2Leg.ts +0 -128
  36. package/src/aggregator/contracts/uniswapV3_100.ts +0 -128
  37. package/src/aggregator/contracts/uniswapV3_10000.ts +0 -128
  38. package/src/aggregator/contracts/uniswapV3_3000.ts +0 -128
  39. package/src/aggregator/contracts/uniswapV3_500.ts +0 -128
  40. package/src/aggregator/getSwapParams.ts +0 -70
  41. package/src/client/__tests__/helpers.test.ts +0 -77
  42. package/src/client/explorerUrls.ts +0 -61
  43. package/src/client/index.ts +0 -769
  44. package/src/client/thornode.ts +0 -31
  45. package/src/client/types.ts +0 -115
@@ -1,120 +0,0 @@
1
- export const pangolin = [
2
- {
3
- inputs: [
4
- { internalType: 'address', name: '_ttp', type: 'address' },
5
- { internalType: 'address', name: '_weth', type: 'address' },
6
- { internalType: 'address', name: '_swapRouter', type: 'address' },
7
- ],
8
- stateMutability: 'nonpayable',
9
- type: 'constructor',
10
- },
11
- {
12
- anonymous: false,
13
- inputs: [
14
- { indexed: false, internalType: 'uint256', name: 'fee', type: 'uint256' },
15
- { indexed: false, internalType: 'address', name: 'feeRecipient', type: 'address' },
16
- ],
17
- name: 'FeeSet',
18
- type: 'event',
19
- },
20
- {
21
- anonymous: false,
22
- inputs: [
23
- { indexed: true, internalType: 'address', name: 'owner', type: 'address' },
24
- { indexed: false, internalType: 'bool', name: 'active', type: 'bool' },
25
- ],
26
- name: 'OwnerSet',
27
- type: 'event',
28
- },
29
- {
30
- inputs: [],
31
- name: 'fee',
32
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
33
- stateMutability: 'view',
34
- type: 'function',
35
- },
36
- {
37
- inputs: [],
38
- name: 'feeRecipient',
39
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
40
- stateMutability: 'view',
41
- type: 'function',
42
- },
43
- {
44
- inputs: [{ internalType: 'address', name: '', type: 'address' }],
45
- name: 'owners',
46
- outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
47
- stateMutability: 'view',
48
- type: 'function',
49
- },
50
- {
51
- inputs: [
52
- { internalType: 'uint256', name: '_fee', type: 'uint256' },
53
- { internalType: 'address', name: '_feeRecipient', type: 'address' },
54
- ],
55
- name: 'setFee',
56
- outputs: [],
57
- stateMutability: 'nonpayable',
58
- type: 'function',
59
- },
60
- {
61
- inputs: [
62
- { internalType: 'address', name: 'owner', type: 'address' },
63
- { internalType: 'bool', name: 'active', type: 'bool' },
64
- ],
65
- name: 'setOwner',
66
- outputs: [],
67
- stateMutability: 'nonpayable',
68
- type: 'function',
69
- },
70
- {
71
- inputs: [
72
- { internalType: 'address', name: 'tcRouter', type: 'address' },
73
- { internalType: 'address', name: 'tcVault', type: 'address' },
74
- { internalType: 'string', name: 'tcMemo', type: 'string' },
75
- { internalType: 'address', name: 'token', type: 'address' },
76
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
77
- { internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
78
- { internalType: 'uint256', name: 'deadline', type: 'uint256' },
79
- ],
80
- name: 'swapIn',
81
- outputs: [],
82
- stateMutability: 'nonpayable',
83
- type: 'function',
84
- },
85
- {
86
- inputs: [
87
- { internalType: 'address', name: 'token', type: 'address' },
88
- { internalType: 'address', name: 'to', type: 'address' },
89
- { internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
90
- ],
91
- name: 'swapOut',
92
- outputs: [],
93
- stateMutability: 'payable',
94
- type: 'function',
95
- },
96
- {
97
- inputs: [],
98
- name: 'swapRouter',
99
- outputs: [{ internalType: 'contract IUniswapRouterV2AVAX', name: '', type: 'address' }],
100
- stateMutability: 'view',
101
- type: 'function',
102
- },
103
- {
104
- inputs: [],
105
- name: 'tokenTransferProxy',
106
- outputs: [
107
- { internalType: 'contract TSAggregatorTokenTransferProxy', name: '', type: 'address' },
108
- ],
109
- stateMutability: 'view',
110
- type: 'function',
111
- },
112
- {
113
- inputs: [],
114
- name: 'weth',
115
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
116
- stateMutability: 'view',
117
- type: 'function',
118
- },
119
- { stateMutability: 'payable', type: 'receive' },
120
- ];
@@ -1,58 +0,0 @@
1
- import { kyberRouter } from './kyber.ts';
2
- import { oneInchRouter } from './oneinch.ts';
3
- import { pancakeSwapRouter } from './pancakeswap.ts';
4
- import { pangolinRouter } from './pangolin.ts';
5
- import { sushiswapRouter } from './sushiswap.ts';
6
- import { traderJoeRouter } from './traderJoe.ts';
7
- import { uniswapv2Router } from './uniswapv2.ts';
8
- import { uniswapv3Router } from './uniswapv3.ts';
9
- import { woofiRouter } from './woofi.ts';
10
-
11
- type AbiTypes =
12
- | typeof kyberRouter
13
- | typeof oneInchRouter
14
- | typeof pancakeSwapRouter
15
- | typeof pangolinRouter
16
- | typeof sushiswapRouter
17
- | typeof traderJoeRouter
18
- | typeof uniswapv2Router
19
- | typeof uniswapv3Router
20
- | typeof woofiRouter;
21
-
22
- export enum DEX_CONTRACT_ADDRESS {
23
- // AVAX
24
- TRADERJOE = '0x60aE616a2155Ee3d9A68541Ba4544862310933d4',
25
- PANGOLIN = '0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106',
26
- WOOFI = '0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9',
27
- ONEINCH_AVAX = '0x1111111254fb6c44bAC0beD2854e76F90643097d',
28
- KYBER_AVAX = '0x6131B5fae19EA4f9D964eAc0408E4408b66337b5',
29
-
30
- // BSC
31
- PANCAKESWAP_BSC = '0x10ED43C718714eb63d5aA57B78B54704E256024E',
32
-
33
- // ETH
34
- ONEINCH_ETH = '0x1111111254fb6c44bac0bed2854e76f90643097d',
35
- PANCAKESWAP_ETH = '0xEfF92A263d31888d860bD50809A8D171709b7b1c',
36
- KYBER_ETH = '0x6131B5fae19EA4f9D964eAc0408E4408b66337b5',
37
- SUSHISWAP = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f',
38
- UNISWAP_V2 = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
39
- UNISWAP_V3 = '0xE592427A0AEce92De3Edee1F18E0157C05861564',
40
- }
41
-
42
- export const lowercasedRouterAbiMapping = {
43
- // AVAX
44
- [DEX_CONTRACT_ADDRESS.PANGOLIN.toLowerCase()]: pangolinRouter,
45
- [DEX_CONTRACT_ADDRESS.WOOFI.toLowerCase()]: woofiRouter,
46
- [DEX_CONTRACT_ADDRESS.TRADERJOE.toLowerCase()]: traderJoeRouter,
47
- [DEX_CONTRACT_ADDRESS.ONEINCH_AVAX.toLowerCase()]: oneInchRouter,
48
- [DEX_CONTRACT_ADDRESS.KYBER_AVAX.toLowerCase()]: kyberRouter,
49
- // BSC
50
- [DEX_CONTRACT_ADDRESS.PANCAKESWAP_BSC.toLowerCase()]: pancakeSwapRouter,
51
- // ETH
52
- [DEX_CONTRACT_ADDRESS.KYBER_ETH.toLowerCase()]: kyberRouter,
53
- [DEX_CONTRACT_ADDRESS.SUSHISWAP.toLowerCase()]: sushiswapRouter,
54
- [DEX_CONTRACT_ADDRESS.PANCAKESWAP_ETH.toLowerCase()]: pancakeSwapRouter,
55
- [DEX_CONTRACT_ADDRESS.UNISWAP_V2.toLowerCase()]: uniswapv2Router,
56
- [DEX_CONTRACT_ADDRESS.UNISWAP_V3.toLowerCase()]: uniswapv3Router,
57
- [DEX_CONTRACT_ADDRESS.ONEINCH_ETH.toLowerCase()]: oneInchRouter,
58
- } as Record<string, AbiTypes>;
@@ -1,402 +0,0 @@
1
- export const kyberRouter = [
2
- {
3
- inputs: [{ internalType: 'address', name: '_WETH', type: 'address' }],
4
- stateMutability: 'nonpayable',
5
- type: 'constructor',
6
- },
7
- {
8
- anonymous: false,
9
- inputs: [
10
- {
11
- indexed: false,
12
- internalType: 'bytes',
13
- name: 'clientData',
14
- type: 'bytes',
15
- },
16
- ],
17
- name: 'ClientData',
18
- type: 'event',
19
- },
20
- {
21
- anonymous: false,
22
- inputs: [
23
- {
24
- indexed: false,
25
- internalType: 'string',
26
- name: 'reason',
27
- type: 'string',
28
- },
29
- ],
30
- name: 'Error',
31
- type: 'event',
32
- },
33
- {
34
- anonymous: false,
35
- inputs: [
36
- {
37
- indexed: false,
38
- internalType: 'address',
39
- name: 'pair',
40
- type: 'address',
41
- },
42
- {
43
- indexed: false,
44
- internalType: 'uint256',
45
- name: 'amountOut',
46
- type: 'uint256',
47
- },
48
- {
49
- indexed: false,
50
- internalType: 'address',
51
- name: 'output',
52
- type: 'address',
53
- },
54
- ],
55
- name: 'Exchange',
56
- type: 'event',
57
- },
58
- {
59
- anonymous: false,
60
- inputs: [
61
- {
62
- indexed: false,
63
- internalType: 'address',
64
- name: 'token',
65
- type: 'address',
66
- },
67
- {
68
- indexed: false,
69
- internalType: 'uint256',
70
- name: 'totalAmount',
71
- type: 'uint256',
72
- },
73
- {
74
- indexed: false,
75
- internalType: 'uint256',
76
- name: 'totalFee',
77
- type: 'uint256',
78
- },
79
- {
80
- indexed: false,
81
- internalType: 'address[]',
82
- name: 'recipients',
83
- type: 'address[]',
84
- },
85
- {
86
- indexed: false,
87
- internalType: 'uint256[]',
88
- name: 'amounts',
89
- type: 'uint256[]',
90
- },
91
- { indexed: false, internalType: 'bool', name: 'isBps', type: 'bool' },
92
- ],
93
- name: 'Fee',
94
- type: 'event',
95
- },
96
- {
97
- anonymous: false,
98
- inputs: [
99
- {
100
- indexed: true,
101
- internalType: 'address',
102
- name: 'previousOwner',
103
- type: 'address',
104
- },
105
- {
106
- indexed: true,
107
- internalType: 'address',
108
- name: 'newOwner',
109
- type: 'address',
110
- },
111
- ],
112
- name: 'OwnershipTransferred',
113
- type: 'event',
114
- },
115
- {
116
- anonymous: false,
117
- inputs: [
118
- {
119
- indexed: false,
120
- internalType: 'address',
121
- name: 'sender',
122
- type: 'address',
123
- },
124
- {
125
- indexed: false,
126
- internalType: 'contract IERC20',
127
- name: 'srcToken',
128
- type: 'address',
129
- },
130
- {
131
- indexed: false,
132
- internalType: 'contract IERC20',
133
- name: 'dstToken',
134
- type: 'address',
135
- },
136
- {
137
- indexed: false,
138
- internalType: 'address',
139
- name: 'dstReceiver',
140
- type: 'address',
141
- },
142
- {
143
- indexed: false,
144
- internalType: 'uint256',
145
- name: 'spentAmount',
146
- type: 'uint256',
147
- },
148
- {
149
- indexed: false,
150
- internalType: 'uint256',
151
- name: 'returnAmount',
152
- type: 'uint256',
153
- },
154
- ],
155
- name: 'Swapped',
156
- type: 'event',
157
- },
158
- {
159
- inputs: [],
160
- name: 'WETH',
161
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
162
- stateMutability: 'view',
163
- type: 'function',
164
- },
165
- {
166
- inputs: [{ internalType: 'address', name: '', type: 'address' }],
167
- name: 'isWhitelist',
168
- outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
169
- stateMutability: 'view',
170
- type: 'function',
171
- },
172
- {
173
- inputs: [],
174
- name: 'owner',
175
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
176
- stateMutability: 'view',
177
- type: 'function',
178
- },
179
- {
180
- inputs: [],
181
- name: 'renounceOwnership',
182
- outputs: [],
183
- stateMutability: 'nonpayable',
184
- type: 'function',
185
- },
186
- {
187
- inputs: [
188
- { internalType: 'address', name: 'token', type: 'address' },
189
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
190
- ],
191
- name: 'rescueFunds',
192
- outputs: [],
193
- stateMutability: 'nonpayable',
194
- type: 'function',
195
- },
196
- {
197
- inputs: [
198
- {
199
- components: [
200
- { internalType: 'address', name: 'callTarget', type: 'address' },
201
- { internalType: 'address', name: 'approveTarget', type: 'address' },
202
- { internalType: 'bytes', name: 'targetData', type: 'bytes' },
203
- {
204
- components: [
205
- {
206
- internalType: 'contract IERC20',
207
- name: 'srcToken',
208
- type: 'address',
209
- },
210
- {
211
- internalType: 'contract IERC20',
212
- name: 'dstToken',
213
- type: 'address',
214
- },
215
- {
216
- internalType: 'address[]',
217
- name: 'srcReceivers',
218
- type: 'address[]',
219
- },
220
- {
221
- internalType: 'uint256[]',
222
- name: 'srcAmounts',
223
- type: 'uint256[]',
224
- },
225
- {
226
- internalType: 'address[]',
227
- name: 'feeReceivers',
228
- type: 'address[]',
229
- },
230
- {
231
- internalType: 'uint256[]',
232
- name: 'feeAmounts',
233
- type: 'uint256[]',
234
- },
235
- { internalType: 'address', name: 'dstReceiver', type: 'address' },
236
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
237
- {
238
- internalType: 'uint256',
239
- name: 'minReturnAmount',
240
- type: 'uint256',
241
- },
242
- { internalType: 'uint256', name: 'flags', type: 'uint256' },
243
- { internalType: 'bytes', name: 'permit', type: 'bytes' },
244
- ],
245
- internalType: 'struct MetaAggregationRouterV2.SwapDescriptionV2',
246
- name: 'desc',
247
- type: 'tuple',
248
- },
249
- { internalType: 'bytes', name: 'clientData', type: 'bytes' },
250
- ],
251
- internalType: 'struct MetaAggregationRouterV2.SwapExecutionParams',
252
- name: 'execution',
253
- type: 'tuple',
254
- },
255
- ],
256
- name: 'swap',
257
- outputs: [
258
- { internalType: 'uint256', name: 'returnAmount', type: 'uint256' },
259
- { internalType: 'uint256', name: 'gasUsed', type: 'uint256' },
260
- ],
261
- stateMutability: 'payable',
262
- type: 'function',
263
- },
264
- {
265
- inputs: [
266
- {
267
- components: [
268
- { internalType: 'address', name: 'callTarget', type: 'address' },
269
- { internalType: 'address', name: 'approveTarget', type: 'address' },
270
- { internalType: 'bytes', name: 'targetData', type: 'bytes' },
271
- {
272
- components: [
273
- {
274
- internalType: 'contract IERC20',
275
- name: 'srcToken',
276
- type: 'address',
277
- },
278
- {
279
- internalType: 'contract IERC20',
280
- name: 'dstToken',
281
- type: 'address',
282
- },
283
- {
284
- internalType: 'address[]',
285
- name: 'srcReceivers',
286
- type: 'address[]',
287
- },
288
- {
289
- internalType: 'uint256[]',
290
- name: 'srcAmounts',
291
- type: 'uint256[]',
292
- },
293
- {
294
- internalType: 'address[]',
295
- name: 'feeReceivers',
296
- type: 'address[]',
297
- },
298
- {
299
- internalType: 'uint256[]',
300
- name: 'feeAmounts',
301
- type: 'uint256[]',
302
- },
303
- { internalType: 'address', name: 'dstReceiver', type: 'address' },
304
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
305
- {
306
- internalType: 'uint256',
307
- name: 'minReturnAmount',
308
- type: 'uint256',
309
- },
310
- { internalType: 'uint256', name: 'flags', type: 'uint256' },
311
- { internalType: 'bytes', name: 'permit', type: 'bytes' },
312
- ],
313
- internalType: 'struct MetaAggregationRouterV2.SwapDescriptionV2',
314
- name: 'desc',
315
- type: 'tuple',
316
- },
317
- { internalType: 'bytes', name: 'clientData', type: 'bytes' },
318
- ],
319
- internalType: 'struct MetaAggregationRouterV2.SwapExecutionParams',
320
- name: 'execution',
321
- type: 'tuple',
322
- },
323
- ],
324
- name: 'swapGeneric',
325
- outputs: [
326
- { internalType: 'uint256', name: 'returnAmount', type: 'uint256' },
327
- { internalType: 'uint256', name: 'gasUsed', type: 'uint256' },
328
- ],
329
- stateMutability: 'payable',
330
- type: 'function',
331
- },
332
- {
333
- inputs: [
334
- {
335
- internalType: 'contract IAggregationExecutor',
336
- name: 'caller',
337
- type: 'address',
338
- },
339
- {
340
- components: [
341
- {
342
- internalType: 'contract IERC20',
343
- name: 'srcToken',
344
- type: 'address',
345
- },
346
- {
347
- internalType: 'contract IERC20',
348
- name: 'dstToken',
349
- type: 'address',
350
- },
351
- {
352
- internalType: 'address[]',
353
- name: 'srcReceivers',
354
- type: 'address[]',
355
- },
356
- { internalType: 'uint256[]', name: 'srcAmounts', type: 'uint256[]' },
357
- {
358
- internalType: 'address[]',
359
- name: 'feeReceivers',
360
- type: 'address[]',
361
- },
362
- { internalType: 'uint256[]', name: 'feeAmounts', type: 'uint256[]' },
363
- { internalType: 'address', name: 'dstReceiver', type: 'address' },
364
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
365
- { internalType: 'uint256', name: 'minReturnAmount', type: 'uint256' },
366
- { internalType: 'uint256', name: 'flags', type: 'uint256' },
367
- { internalType: 'bytes', name: 'permit', type: 'bytes' },
368
- ],
369
- internalType: 'struct MetaAggregationRouterV2.SwapDescriptionV2',
370
- name: 'desc',
371
- type: 'tuple',
372
- },
373
- { internalType: 'bytes', name: 'executorData', type: 'bytes' },
374
- { internalType: 'bytes', name: 'clientData', type: 'bytes' },
375
- ],
376
- name: 'swapSimpleMode',
377
- outputs: [
378
- { internalType: 'uint256', name: 'returnAmount', type: 'uint256' },
379
- { internalType: 'uint256', name: 'gasUsed', type: 'uint256' },
380
- ],
381
- stateMutability: 'nonpayable',
382
- type: 'function',
383
- },
384
- {
385
- inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
386
- name: 'transferOwnership',
387
- outputs: [],
388
- stateMutability: 'nonpayable',
389
- type: 'function',
390
- },
391
- {
392
- inputs: [
393
- { internalType: 'address[]', name: 'addr', type: 'address[]' },
394
- { internalType: 'bool[]', name: 'value', type: 'bool[]' },
395
- ],
396
- name: 'updateWhitelist',
397
- outputs: [],
398
- stateMutability: 'nonpayable',
399
- type: 'function',
400
- },
401
- { stateMutability: 'payable', type: 'receive' },
402
- ];