@swapkit/core 1.0.0-rc.12 → 1.0.0-rc.120

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 +7324 -0
  2. package/dist/index.js.map +41 -0
  3. package/package.json +33 -47
  4. package/src/__tests__/helpers.test.ts +53 -0
  5. package/src/aggregator/contracts/avaxGeneric.ts +50 -50
  6. package/src/aggregator/contracts/avaxWoofi.ts +80 -80
  7. package/src/aggregator/contracts/bscGeneric.ts +59 -59
  8. package/src/aggregator/contracts/ethGeneric.ts +50 -50
  9. package/src/aggregator/contracts/index.ts +30 -28
  10. package/src/aggregator/contracts/pancakeV2.ts +80 -80
  11. package/src/aggregator/contracts/pangolin.ts +65 -65
  12. package/src/aggregator/contracts/routers/index.ts +58 -0
  13. package/src/aggregator/contracts/routers/kyber.ts +402 -0
  14. package/src/aggregator/contracts/routers/oneinch.ts +2188 -0
  15. package/src/aggregator/contracts/routers/pancakeswap.ts +340 -0
  16. package/src/aggregator/contracts/routers/pangolin.ts +340 -0
  17. package/src/aggregator/contracts/routers/sushiswap.ts +340 -0
  18. package/src/aggregator/contracts/routers/traderJoe.ts +340 -0
  19. package/src/aggregator/contracts/routers/uniswapv2.ts +340 -0
  20. package/src/aggregator/contracts/routers/uniswapv3.ts +254 -0
  21. package/src/aggregator/contracts/routers/woofi.ts +171 -0
  22. package/src/aggregator/contracts/sushiswap.ts +65 -65
  23. package/src/aggregator/contracts/traderJoe.ts +65 -65
  24. package/src/aggregator/contracts/uniswapV2.ts +65 -65
  25. package/src/aggregator/contracts/uniswapV2Leg.ts +70 -70
  26. package/src/aggregator/contracts/uniswapV3_100.ts +70 -70
  27. package/src/aggregator/contracts/uniswapV3_10000.ts +70 -70
  28. package/src/aggregator/contracts/uniswapV3_3000.ts +70 -70
  29. package/src/aggregator/contracts/uniswapV3_500.ts +70 -70
  30. package/src/aggregator/getSwapParams.ts +12 -12
  31. package/src/client/index.ts +206 -646
  32. package/src/client/old.ts +854 -0
  33. package/src/helpers/explorerUrls.ts +38 -0
  34. package/src/index.ts +6 -4
  35. package/src/types.ts +149 -0
  36. package/LICENSE +0 -201
  37. package/dist/index-9e36735e.cjs +0 -1
  38. package/dist/index-cf1865cd.js +0 -649
  39. package/dist/index.cjs +0 -2
  40. package/dist/index.d.ts +0 -216
  41. package/dist/index.es.js +0 -3818
  42. package/src/client/__tests__/helpers.test.ts +0 -69
  43. package/src/client/explorerUrls.ts +0 -62
  44. package/src/client/thornode.ts +0 -31
  45. package/src/client/types.ts +0 -103
@@ -1,106 +1,106 @@
1
1
  export const bscGeneric = [
2
2
  {
3
- inputs: [{ internalType: 'address', name: '_ttp', type: 'address' }],
4
- stateMutability: 'nonpayable',
5
- type: 'constructor',
3
+ inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
4
+ stateMutability: "nonpayable",
5
+ type: "constructor",
6
6
  },
7
7
  {
8
8
  anonymous: false,
9
9
  inputs: [
10
- { indexed: false, internalType: 'uint256', name: 'fee', type: 'uint256' },
11
- { indexed: false, internalType: 'address', name: 'feeRecipient', type: 'address' },
10
+ { indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
11
+ { indexed: false, internalType: "address", name: "feeRecipient", type: "address" },
12
12
  ],
13
- name: 'FeeSet',
14
- type: 'event',
13
+ name: "FeeSet",
14
+ type: "event",
15
15
  },
16
16
  {
17
17
  anonymous: false,
18
18
  inputs: [
19
- { indexed: true, internalType: 'address', name: 'owner', type: 'address' },
20
- { indexed: false, internalType: 'bool', name: 'active', type: 'bool' },
19
+ { indexed: true, internalType: "address", name: "owner", type: "address" },
20
+ { indexed: false, internalType: "bool", name: "active", type: "bool" },
21
21
  ],
22
- name: 'OwnerSet',
23
- type: 'event',
22
+ name: "OwnerSet",
23
+ type: "event",
24
24
  },
25
25
  {
26
26
  anonymous: false,
27
27
  inputs: [
28
- { indexed: false, internalType: 'address', name: 'from', type: 'address' },
29
- { indexed: false, internalType: 'address', name: 'token', type: 'address' },
30
- { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
31
- { indexed: false, internalType: 'uint256', name: 'out', type: 'uint256' },
32
- { indexed: false, internalType: 'uint256', name: 'fee', type: 'uint256' },
33
- { indexed: false, internalType: 'address', name: 'vault', type: 'address' },
34
- { indexed: false, internalType: 'string', name: 'memo', type: 'string' },
28
+ { indexed: false, internalType: "address", name: "from", type: "address" },
29
+ { indexed: false, internalType: "address", name: "token", type: "address" },
30
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
31
+ { indexed: false, internalType: "uint256", name: "out", type: "uint256" },
32
+ { indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
33
+ { indexed: false, internalType: "address", name: "vault", type: "address" },
34
+ { indexed: false, internalType: "string", name: "memo", type: "string" },
35
35
  ],
36
- name: 'SwapIn',
37
- type: 'event',
36
+ name: "SwapIn",
37
+ type: "event",
38
38
  },
39
39
  {
40
40
  inputs: [],
41
- name: 'fee',
42
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
43
- stateMutability: 'view',
44
- type: 'function',
41
+ name: "fee",
42
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
43
+ stateMutability: "view",
44
+ type: "function",
45
45
  },
46
46
  {
47
47
  inputs: [],
48
- name: 'feeRecipient',
49
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
50
- stateMutability: 'view',
51
- type: 'function',
48
+ name: "feeRecipient",
49
+ outputs: [{ internalType: "address", name: "", type: "address" }],
50
+ stateMutability: "view",
51
+ type: "function",
52
52
  },
53
53
  {
54
- inputs: [{ internalType: 'address', name: '', type: 'address' }],
55
- name: 'owners',
56
- outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
57
- stateMutability: 'view',
58
- type: 'function',
54
+ inputs: [{ internalType: "address", name: "", type: "address" }],
55
+ name: "owners",
56
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
57
+ stateMutability: "view",
58
+ type: "function",
59
59
  },
60
60
  {
61
61
  inputs: [
62
- { internalType: 'uint256', name: '_fee', type: 'uint256' },
63
- { internalType: 'address', name: '_feeRecipient', type: 'address' },
62
+ { internalType: "uint256", name: "_fee", type: "uint256" },
63
+ { internalType: "address", name: "_feeRecipient", type: "address" },
64
64
  ],
65
- name: 'setFee',
65
+ name: "setFee",
66
66
  outputs: [],
67
- stateMutability: 'nonpayable',
68
- type: 'function',
67
+ stateMutability: "nonpayable",
68
+ type: "function",
69
69
  },
70
70
  {
71
71
  inputs: [
72
- { internalType: 'address', name: 'owner', type: 'address' },
73
- { internalType: 'bool', name: 'active', type: 'bool' },
72
+ { internalType: "address", name: "owner", type: "address" },
73
+ { internalType: "bool", name: "active", type: "bool" },
74
74
  ],
75
- name: 'setOwner',
75
+ name: "setOwner",
76
76
  outputs: [],
77
- stateMutability: 'nonpayable',
78
- type: 'function',
77
+ stateMutability: "nonpayable",
78
+ type: "function",
79
79
  },
80
80
  {
81
81
  inputs: [
82
- { internalType: 'address', name: 'router', type: 'address' },
83
- { internalType: 'address', name: 'vault', type: 'address' },
84
- { internalType: 'string', name: 'memo', type: 'string' },
85
- { internalType: 'address', name: 'token', type: 'address' },
86
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
87
- { internalType: 'address', name: 'swapRouter', type: 'address' },
88
- { internalType: 'bytes', name: 'data', type: 'bytes' },
89
- { internalType: 'uint256', name: 'deadline', type: 'uint256' },
82
+ { internalType: "address", name: "router", type: "address" },
83
+ { internalType: "address", name: "vault", type: "address" },
84
+ { internalType: "string", name: "memo", type: "string" },
85
+ { internalType: "address", name: "token", type: "address" },
86
+ { internalType: "uint256", name: "amount", type: "uint256" },
87
+ { internalType: "address", name: "swapRouter", type: "address" },
88
+ { internalType: "bytes", name: "data", type: "bytes" },
89
+ { internalType: "uint256", name: "deadline", type: "uint256" },
90
90
  ],
91
- name: 'swapIn',
91
+ name: "swapIn",
92
92
  outputs: [],
93
- stateMutability: 'nonpayable',
94
- type: 'function',
93
+ stateMutability: "nonpayable",
94
+ type: "function",
95
95
  },
96
96
  {
97
97
  inputs: [],
98
- name: 'tokenTransferProxy',
98
+ name: "tokenTransferProxy",
99
99
  outputs: [
100
- { internalType: 'contract TSAggregatorTokenTransferProxy', name: '', type: 'address' },
100
+ { internalType: "contract TSAggregatorTokenTransferProxy", name: "", type: "address" },
101
101
  ],
102
- stateMutability: 'view',
103
- type: 'function',
102
+ stateMutability: "view",
103
+ type: "function",
104
104
  },
105
- { stateMutability: 'payable', type: 'receive' },
105
+ { stateMutability: "payable", type: "receive" },
106
106
  ];
@@ -1,92 +1,92 @@
1
1
  export const ethGeneric = [
2
2
  {
3
- inputs: [{ internalType: 'address', name: '_ttp', type: 'address' }],
4
- stateMutability: 'nonpayable',
5
- type: 'constructor',
3
+ inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
4
+ stateMutability: "nonpayable",
5
+ type: "constructor",
6
6
  },
7
7
  {
8
8
  anonymous: false,
9
9
  inputs: [
10
- { indexed: false, internalType: 'uint256', name: 'fee', type: 'uint256' },
11
- { indexed: false, internalType: 'address', name: 'feeRecipient', type: 'address' },
10
+ { indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
11
+ { indexed: false, internalType: "address", name: "feeRecipient", type: "address" },
12
12
  ],
13
- name: 'FeeSet',
14
- type: 'event',
13
+ name: "FeeSet",
14
+ type: "event",
15
15
  },
16
16
  {
17
17
  anonymous: false,
18
18
  inputs: [
19
- { indexed: true, internalType: 'address', name: 'owner', type: 'address' },
20
- { indexed: false, internalType: 'bool', name: 'active', type: 'bool' },
19
+ { indexed: true, internalType: "address", name: "owner", type: "address" },
20
+ { indexed: false, internalType: "bool", name: "active", type: "bool" },
21
21
  ],
22
- name: 'OwnerSet',
23
- type: 'event',
22
+ name: "OwnerSet",
23
+ type: "event",
24
24
  },
25
25
  {
26
26
  inputs: [],
27
- name: 'fee',
28
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
29
- stateMutability: 'view',
30
- type: 'function',
27
+ name: "fee",
28
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
29
+ stateMutability: "view",
30
+ type: "function",
31
31
  },
32
32
  {
33
33
  inputs: [],
34
- name: 'feeRecipient',
35
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
36
- stateMutability: 'view',
37
- type: 'function',
34
+ name: "feeRecipient",
35
+ outputs: [{ internalType: "address", name: "", type: "address" }],
36
+ stateMutability: "view",
37
+ type: "function",
38
38
  },
39
39
  {
40
- inputs: [{ internalType: 'address', name: '', type: 'address' }],
41
- name: 'owners',
42
- outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
43
- stateMutability: 'view',
44
- type: 'function',
40
+ inputs: [{ internalType: "address", name: "", type: "address" }],
41
+ name: "owners",
42
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
43
+ stateMutability: "view",
44
+ type: "function",
45
45
  },
46
46
  {
47
47
  inputs: [
48
- { internalType: 'uint256', name: '_fee', type: 'uint256' },
49
- { internalType: 'address', name: '_feeRecipient', type: 'address' },
48
+ { internalType: "uint256", name: "_fee", type: "uint256" },
49
+ { internalType: "address", name: "_feeRecipient", type: "address" },
50
50
  ],
51
- name: 'setFee',
51
+ name: "setFee",
52
52
  outputs: [],
53
- stateMutability: 'nonpayable',
54
- type: 'function',
53
+ stateMutability: "nonpayable",
54
+ type: "function",
55
55
  },
56
56
  {
57
57
  inputs: [
58
- { internalType: 'address', name: 'owner', type: 'address' },
59
- { internalType: 'bool', name: 'active', type: 'bool' },
58
+ { internalType: "address", name: "owner", type: "address" },
59
+ { internalType: "bool", name: "active", type: "bool" },
60
60
  ],
61
- name: 'setOwner',
61
+ name: "setOwner",
62
62
  outputs: [],
63
- stateMutability: 'nonpayable',
64
- type: 'function',
63
+ stateMutability: "nonpayable",
64
+ type: "function",
65
65
  },
66
66
  {
67
67
  inputs: [
68
- { internalType: 'address', name: 'tcRouter', type: 'address' },
69
- { internalType: 'address', name: 'tcVault', type: 'address' },
70
- { internalType: 'string', name: 'tcMemo', type: 'string' },
71
- { internalType: 'address', name: 'token', type: 'address' },
72
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
73
- { internalType: 'address', name: 'router', type: 'address' },
74
- { internalType: 'bytes', name: 'data', type: 'bytes' },
75
- { internalType: 'uint256', name: 'deadline', type: 'uint256' },
68
+ { internalType: "address", name: "tcRouter", type: "address" },
69
+ { internalType: "address", name: "tcVault", type: "address" },
70
+ { internalType: "string", name: "tcMemo", type: "string" },
71
+ { internalType: "address", name: "token", type: "address" },
72
+ { internalType: "uint256", name: "amount", type: "uint256" },
73
+ { internalType: "address", name: "router", type: "address" },
74
+ { internalType: "bytes", name: "data", type: "bytes" },
75
+ { internalType: "uint256", name: "deadline", type: "uint256" },
76
76
  ],
77
- name: 'swapIn',
77
+ name: "swapIn",
78
78
  outputs: [],
79
- stateMutability: 'nonpayable',
80
- type: 'function',
79
+ stateMutability: "nonpayable",
80
+ type: "function",
81
81
  },
82
82
  {
83
83
  inputs: [],
84
- name: 'tokenTransferProxy',
84
+ name: "tokenTransferProxy",
85
85
  outputs: [
86
- { internalType: 'contract TSAggregatorTokenTransferProxy', name: '', type: 'address' },
86
+ { internalType: "contract TSAggregatorTokenTransferProxy", name: "", type: "address" },
87
87
  ],
88
- stateMutability: 'view',
89
- type: 'function',
88
+ stateMutability: "view",
89
+ type: "function",
90
90
  },
91
- { stateMutability: 'payable', type: 'receive' },
91
+ { stateMutability: "payable", type: "receive" },
92
92
  ];
@@ -1,17 +1,18 @@
1
- import { avaxGeneric } from './avaxGeneric.ts';
2
- import { avaxWoofi } from './avaxWoofi.ts';
3
- import { bscGeneric } from './bscGeneric.ts';
4
- import { ethGeneric } from './ethGeneric.ts';
5
- import { pancakeV2 } from './pancakeV2.ts';
6
- import { pangolin } from './pangolin.ts';
7
- import { sushiswap } from './sushiswap.ts';
8
- import { traderJoe } from './traderJoe.ts';
9
- import { uniswapV2 } from './uniswapV2.ts';
10
- import { uniswapV2Leg } from './uniswapV2Leg.ts';
11
- import { uniswapV3_100 } from './uniswapV3_100.ts';
12
- import { uniswapV3_500 } from './uniswapV3_500.ts';
13
- import { uniswapV3_3000 } from './uniswapV3_3000.ts';
14
- import { uniswapV3_10000 } from './uniswapV3_10000.ts';
1
+ import { avaxGeneric } from "./avaxGeneric.ts";
2
+ import { avaxWoofi } from "./avaxWoofi.ts";
3
+ import { bscGeneric } from "./bscGeneric.ts";
4
+ import { ethGeneric } from "./ethGeneric.ts";
5
+ import { pancakeV2 } from "./pancakeV2.ts";
6
+ import { pangolin } from "./pangolin.ts";
7
+ import { lowercasedRouterAbiMapping } from "./routers/index.ts";
8
+ import { sushiswap } from "./sushiswap.ts";
9
+ import { traderJoe } from "./traderJoe.ts";
10
+ import { uniswapV2 } from "./uniswapV2.ts";
11
+ import { uniswapV2Leg } from "./uniswapV2Leg.ts";
12
+ import { uniswapV3_100 } from "./uniswapV3_100.ts";
13
+ import { uniswapV3_500 } from "./uniswapV3_500.ts";
14
+ import { uniswapV3_3000 } from "./uniswapV3_3000.ts";
15
+ import { uniswapV3_10000 } from "./uniswapV3_10000.ts";
15
16
 
16
17
  type AbiTypes =
17
18
  | typeof avaxGeneric
@@ -29,24 +30,24 @@ type AbiTypes =
29
30
 
30
31
  export enum AGG_CONTRACT_ADDRESS {
31
32
  // AVAX
32
- PANGOLIN = '0x942c6dA485FD6cEf255853ef83a149d43A73F18a',
33
- AVAX_GENERIC = '0x7C38b8B2efF28511ECc14a621e263857Fb5771d3',
34
- AVAX_WOOFI = '0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a',
35
- AVAX_TRADER_JOE = '0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212',
33
+ PANGOLIN = "0x942c6dA485FD6cEf255853ef83a149d43A73F18a",
34
+ AVAX_GENERIC = "0x7C38b8B2efF28511ECc14a621e263857Fb5771d3",
35
+ AVAX_WOOFI = "0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a",
36
+ AVAX_TRADER_JOE = "0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212",
36
37
 
37
38
  // BSC
38
- BSC_GENERIC = '0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c',
39
- BSC_PANCAKE_V2 = '0x30912B38618D3D37De3191A4FFE982C65a9aEC2E',
39
+ BSC_GENERIC = "0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c",
40
+ BSC_PANCAKE_V2 = "0x30912B38618D3D37De3191A4FFE982C65a9aEC2E",
40
41
 
41
42
  // ETH
42
- ETH_GENERIC = '0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2',
43
- UNISWAP_V2 = '0x86904Eb2b3c743400D03f929F2246EfA80B91215',
44
- SUSHISWAP = '0xbf365e79aA44A2164DA135100C57FDB6635ae870',
45
- UNISWAP_V3_100 = '0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8',
46
- UNISWAP_V3_500 = '0xe4ddca21881bac219af7f217703db0475d2a9f02',
47
- UNISWAP_V3_3000 = '0x11733abf0cdb43298f7e949c930188451a9a9ef2',
48
- UNISWAP_V3_10000 = '0xb33874810e5395eb49d8bd7e912631db115d5a03',
49
- UNISWAP_V2_LEG = '0x3660dE6C56cFD31998397652941ECe42118375DA',
43
+ ETH_GENERIC = "0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2",
44
+ UNISWAP_V2 = "0x86904Eb2b3c743400D03f929F2246EfA80B91215",
45
+ SUSHISWAP = "0xbf365e79aA44A2164DA135100C57FDB6635ae870",
46
+ UNISWAP_V3_100 = "0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8",
47
+ UNISWAP_V3_500 = "0xe4ddca21881bac219af7f217703db0475d2a9f02",
48
+ UNISWAP_V3_3000 = "0x11733abf0cdb43298f7e949c930188451a9a9ef2",
49
+ UNISWAP_V3_10000 = "0xb33874810e5395eb49d8bd7e912631db115d5a03",
50
+ UNISWAP_V2_LEG = "0x3660dE6C56cFD31998397652941ECe42118375DA",
50
51
  }
51
52
 
52
53
  export const lowercasedGenericAbiMappings = {
@@ -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,