@swapkit/core 1.0.0-rc.8 → 1.0.0-rc.81

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.
package/package.json CHANGED
@@ -1,30 +1,27 @@
1
1
  {
2
2
  "author": "swapkit-oss-team",
3
3
  "dependencies": {
4
- "@swapkit/types": "1.0.0-rc.3",
5
- "@swapkit/helpers": "1.0.0-rc.4"
4
+ "@swapkit/helpers": "1.0.0-rc.59",
5
+ "@swapkit/types": "1.0.0-rc.31"
6
6
  },
7
7
  "description": "SwapKit Lib core",
8
8
  "devDependencies": {
9
- "@vitest/coverage-istanbul": "0.34.4",
10
- "ethers": "6.7.1",
11
- "vite": "4.4.9",
12
- "vite-plugin-top-level-await": "1.3.1",
13
- "vite-plugin-wasm": "3.2.2",
14
- "vitest": "0.34.4",
15
- "@internal/config": "0.0.0-internal.0",
16
- "@swapkit/api": "1.0.0-rc.3",
17
- "@swapkit/tokens": "1.0.0-rc.3",
18
- "@swapkit/toolbox-cosmos": "1.0.0-rc.6",
19
- "@swapkit/toolbox-evm": "1.0.0-rc.5",
20
- "@swapkit/toolbox-utxo": "1.0.0-rc.5"
9
+ "@vitest/coverage-istanbul": "1.0.4",
10
+ "vite": "5.0.7",
11
+ "vitest": "1.0.4",
12
+ "@internal/config": "null-rc.0",
13
+ "@swapkit/api": "1.0.0-rc.32",
14
+ "@swapkit/tokens": "1.0.0-rc.32",
15
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.66",
16
+ "@swapkit/toolbox-evm": "1.0.0-rc.64",
17
+ "@swapkit/toolbox-utxo": "1.0.0-rc.62"
21
18
  },
22
19
  "peerDependencies": {
23
- "@swapkit/api": "1.0.0-rc.3",
24
- "@swapkit/tokens": "1.0.0-rc.3",
25
- "@swapkit/toolbox-cosmos": "1.0.0-rc.6",
26
- "@swapkit/toolbox-evm": "1.0.0-rc.5",
27
- "@swapkit/toolbox-utxo": "1.0.0-rc.5"
20
+ "@swapkit/api": "1.0.0-rc.32",
21
+ "@swapkit/tokens": "1.0.0-rc.32",
22
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.66",
23
+ "@swapkit/toolbox-evm": "1.0.0-rc.64",
24
+ "@swapkit/toolbox-utxo": "1.0.0-rc.62"
28
25
  },
29
26
  "eslintConfig": {
30
27
  "extends": "../../../internal/eslint-config"
@@ -45,14 +42,14 @@
45
42
  "main": "./dist/index.cjs",
46
43
  "module": "./dist/index.es.js",
47
44
  "name": "@swapkit/core",
48
- "publishConfig": {
49
- "access": "public"
50
- },
51
45
  "react-native": "./src/index.ts",
52
- "repository": "https://github.com/thorswap/SwapKit.git",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/thorswap/SwapKit.git"
49
+ },
53
50
  "type": "module",
54
51
  "types": "./dist/index.d.ts",
55
- "version": "1.0.0-rc.8",
52
+ "version": "1.0.0-rc.81",
56
53
  "scripts": {
57
54
  "build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
58
55
  "clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
@@ -4,6 +4,7 @@ import { bscGeneric } from './bscGeneric.ts';
4
4
  import { ethGeneric } from './ethGeneric.ts';
5
5
  import { pancakeV2 } from './pancakeV2.ts';
6
6
  import { pangolin } from './pangolin.ts';
7
+ import { lowercasedRouterAbiMapping } from './routers/index.ts';
7
8
  import { sushiswap } from './sushiswap.ts';
8
9
  import { traderJoe } from './traderJoe.ts';
9
10
  import { uniswapV2 } from './uniswapV2.ts';
@@ -56,6 +57,7 @@ export const lowercasedGenericAbiMappings = {
56
57
  };
57
58
 
58
59
  export const lowercasedContractAbiMapping = {
60
+ ...lowercasedRouterAbiMapping,
59
61
  ...lowercasedGenericAbiMappings,
60
62
  // AVAX
61
63
  [AGG_CONTRACT_ADDRESS.PANGOLIN.toLowerCase()]: pangolin,
@@ -0,0 +1,58 @@
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>;
@@ -0,0 +1,402 @@
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
+ ];