@curvefi/api 2.43.1 → 2.45.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.
- package/README.md +10 -0
- package/lib/constants/abis/crypto_calc.json +1 -0
- package/lib/constants/abis/stable_calc.json +1 -151
- package/lib/constants/aliases.js +23 -12
- package/lib/curve.js +29 -16
- package/lib/pools/PoolTemplate.d.ts +3 -0
- package/lib/pools/PoolTemplate.js +69 -0
- package/lib/pools/mixins/swapWrappedMixins.d.ts +1 -0
- package/lib/pools/mixins/swapWrappedMixins.js +20 -0
- package/lib/pools/poolConstructor.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -881,6 +881,11 @@ import curve from "@curvefi/api";
|
|
|
881
881
|
// OR const underlyingExpected = await pool.swapExpected(0, 1, '10');
|
|
882
882
|
console.log(underlyingExpected);
|
|
883
883
|
// 9.984619933234026875
|
|
884
|
+
const underlyingRequired = await pool.swapRequired('MIM', 'DAI', 10);
|
|
885
|
+
// OR const underlyingRequired = await pool.swapRequired('0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3', '0x6B175474E89094C44Da98b954EedeAC495271d0F', '10');
|
|
886
|
+
// OR const underlyingRequired = await pool.swapRequired(0, 1, '10');
|
|
887
|
+
console.log(underlyingRequired);
|
|
888
|
+
//10.049378645129545758
|
|
884
889
|
const underlyingPriceImpact = await pool.swapPriceImpact('MIM','DAI', 10);
|
|
885
890
|
// OR const underlyingPriceImpact = await pool.swapPriceImpact('0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3', '0x6B175474E89094C44Da98b954EedeAC495271d0F', '10');
|
|
886
891
|
// OR const underlyingPriceImpact = await pool.swapPriceImpact(0, 1, '10');
|
|
@@ -918,6 +923,11 @@ import curve from "@curvefi/api";
|
|
|
918
923
|
// OR const wrappedExpected = await pool.swapWrappedExpected(1, 0, '10');
|
|
919
924
|
console.log(wrappedExpected);
|
|
920
925
|
// 10.217756467720521951
|
|
926
|
+
const wrappedRequired = await pool.swapWrappedRequired('3crv', 'MIM', 10);
|
|
927
|
+
// OR const wrappedRequired = await pool.swapWrappedRequired('0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3', '10');
|
|
928
|
+
// OR const wrappedRequired = await pool.swapWrappedRequired(1, 0, '10');
|
|
929
|
+
console.log(wrappedRequired);
|
|
930
|
+
//9.702940994847188442
|
|
921
931
|
const wrappedPriceImpact = await pool.swapWrappedPriceImpact('3crv','MIM', 10);
|
|
922
932
|
// OR const wrappedPriceImpact = await pool.swapWrappedPriceImpact('0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3', '10');
|
|
923
933
|
// OR const wrappedPriceImpact = await pool.swapWrappedPriceImpact(1, 0, '10');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{ "stateMutability": "view", "type": "function", "name": "get_dx", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "uint256" }, { "name": "j", "type": "uint256" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx_meta_underlying", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "uint256" }, { "name": "j", "type": "uint256" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }, { "name": "base_pool", "type": "address" }, { "name": "base_token", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx_tricrypto_meta_underlying", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "uint256" }, { "name": "j", "type": "uint256" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }, { "name": "base_pool", "type": "address" }, { "name": "base_token", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx_double_meta_underlying", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "uint256" }, { "name": "j", "type": "uint256" }, { "name": "dy", "type": "uint256" }, { "name": "base_pool", "type": "address" }, { "name": "base_pool_zap", "type": "address" }, { "name": "second_base_pool", "type": "address" }, { "name": "second_base_token", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }]
|
|
@@ -1,151 +1 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"stateMutability": "nonpayable",
|
|
4
|
-
"type": "constructor",
|
|
5
|
-
"inputs": [
|
|
6
|
-
{
|
|
7
|
-
"name": "_use_int128",
|
|
8
|
-
"type": "address[20]"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "_pool_type_addresses",
|
|
12
|
-
"type": "address[20]"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "_pool_types",
|
|
16
|
-
"type": "uint8[20]"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"name": "_use_rate",
|
|
20
|
-
"type": "bool[5][20]"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"outputs": []
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"stateMutability": "view",
|
|
27
|
-
"type": "function",
|
|
28
|
-
"name": "calc_token_amount",
|
|
29
|
-
"inputs": [
|
|
30
|
-
{
|
|
31
|
-
"name": "pool",
|
|
32
|
-
"type": "address"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"name": "token",
|
|
36
|
-
"type": "address"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"name": "amounts",
|
|
40
|
-
"type": "uint256[5]"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"name": "n_coins",
|
|
44
|
-
"type": "uint256"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"name": "deposit",
|
|
48
|
-
"type": "bool"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"name": "use_underlying",
|
|
52
|
-
"type": "bool"
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"outputs": [
|
|
56
|
-
{
|
|
57
|
-
"name": "",
|
|
58
|
-
"type": "uint256"
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"stateMutability": "view",
|
|
64
|
-
"type": "function",
|
|
65
|
-
"name": "calc_token_amount_meta",
|
|
66
|
-
"inputs": [
|
|
67
|
-
{
|
|
68
|
-
"name": "pool",
|
|
69
|
-
"type": "address"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"name": "token",
|
|
73
|
-
"type": "address"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"name": "amounts",
|
|
77
|
-
"type": "uint256[5]"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"name": "n_coins",
|
|
81
|
-
"type": "uint256"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"name": "base_pool",
|
|
85
|
-
"type": "address"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"name": "base_token",
|
|
89
|
-
"type": "address"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"name": "deposit",
|
|
93
|
-
"type": "bool"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"name": "use_underlying",
|
|
97
|
-
"type": "bool"
|
|
98
|
-
}
|
|
99
|
-
],
|
|
100
|
-
"outputs": [
|
|
101
|
-
{
|
|
102
|
-
"name": "",
|
|
103
|
-
"type": "uint256"
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"stateMutability": "nonpayable",
|
|
109
|
-
"type": "function",
|
|
110
|
-
"name": "set_int128",
|
|
111
|
-
"inputs": [
|
|
112
|
-
{
|
|
113
|
-
"name": "_use_int128",
|
|
114
|
-
"type": "address[20]"
|
|
115
|
-
}
|
|
116
|
-
],
|
|
117
|
-
"outputs": []
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"stateMutability": "nonpayable",
|
|
121
|
-
"type": "function",
|
|
122
|
-
"name": "set_pool_type",
|
|
123
|
-
"inputs": [
|
|
124
|
-
{
|
|
125
|
-
"name": "_pool_type_addresses",
|
|
126
|
-
"type": "address[20]"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"name": "_pool_types",
|
|
130
|
-
"type": "uint8[20]"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"name": "_use_rate",
|
|
134
|
-
"type": "bool[5][20]"
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
"outputs": []
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"stateMutability": "view",
|
|
141
|
-
"type": "function",
|
|
142
|
-
"name": "admin",
|
|
143
|
-
"inputs": [],
|
|
144
|
-
"outputs": [
|
|
145
|
-
{
|
|
146
|
-
"name": "",
|
|
147
|
-
"type": "address"
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
]
|
|
1
|
+
[{ "stateMutability": "nonpayable", "type": "constructor", "inputs": [{ "name": "_use_int128", "type": "address[20]" }, { "name": "_pool_type_addresses", "type": "address[20]" }, { "name": "_pool_types", "type": "uint8[20]" }, { "name": "_use_rate", "type": "bool[10][20]" }, { "name": "_factory", "type": "address" }, { "name": "_eth_implementation", "type": "address" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "calc_token_amount", "inputs": [{ "name": "pool", "type": "address" }, { "name": "token", "type": "address" }, { "name": "amounts", "type": "uint256[10]" }, { "name": "n_coins", "type": "uint256" }, { "name": "deposit", "type": "bool" }, { "name": "use_underlying", "type": "bool" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "calc_token_amount_meta", "inputs": [{ "name": "pool", "type": "address" }, { "name": "token", "type": "address" }, { "name": "amounts", "type": "uint256[10]" }, { "name": "n_coins", "type": "uint256" }, { "name": "base_pool", "type": "address" }, { "name": "base_token", "type": "address" }, { "name": "deposit", "type": "bool" }, { "name": "use_underlying", "type": "bool" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "int128" }, { "name": "j", "type": "int128" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx_underlying", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "int128" }, { "name": "j", "type": "int128" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx_meta", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "int128" }, { "name": "j", "type": "int128" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }, { "name": "base_pool", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "get_dx_meta_underlying", "inputs": [{ "name": "pool", "type": "address" }, { "name": "i", "type": "int128" }, { "name": "j", "type": "int128" }, { "name": "dy", "type": "uint256" }, { "name": "n_coins", "type": "uint256" }, { "name": "base_pool", "type": "address" }, { "name": "base_token", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }]
|
package/lib/constants/aliases.js
CHANGED
|
@@ -8,7 +8,8 @@ export var ALIASES_ETHEREUM = lowerCaseValues({
|
|
|
8
8
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
9
9
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
10
10
|
"deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
|
|
11
|
-
"stable_calc": "
|
|
11
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
12
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
12
13
|
"factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
|
|
13
14
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
14
15
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -26,7 +27,8 @@ export var ALIASES_POLYGON = lowerCaseValues({
|
|
|
26
27
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
27
28
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
28
29
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
29
|
-
"stable_calc": "
|
|
30
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
31
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
30
32
|
"factory": '0x722272d36ef0da72ff51c5a65db7b870e2e8d4ee',
|
|
31
33
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
32
34
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -44,7 +46,8 @@ export var ALIASES_FANTOM = lowerCaseValues({
|
|
|
44
46
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
45
47
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
46
48
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
47
|
-
"stable_calc": "
|
|
49
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
50
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
48
51
|
"factory": "0x686d67265703d1f124c45e33d47d794c566889ba",
|
|
49
52
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
50
53
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -62,7 +65,8 @@ export var ALIASES_AVALANCHE = lowerCaseValues({
|
|
|
62
65
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
63
66
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
64
67
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
65
|
-
"stable_calc": "
|
|
68
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
69
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
66
70
|
"factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
|
|
67
71
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
68
72
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -80,12 +84,13 @@ export var ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
80
84
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
81
85
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
82
86
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
83
|
-
"stable_calc": "
|
|
87
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
88
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
84
89
|
"factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
|
|
85
90
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
86
91
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
87
92
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
88
|
-
"tricrypto_factory": '
|
|
93
|
+
"tricrypto_factory": '0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8',
|
|
89
94
|
"registry_exchange": "",
|
|
90
95
|
"factory_admin": "",
|
|
91
96
|
});
|
|
@@ -98,7 +103,8 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
98
103
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
99
104
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
100
105
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
101
|
-
"stable_calc": "
|
|
106
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
107
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
102
108
|
"factory": '0x2db0E83599a91b508Ac268a6197b8B14F5e72840',
|
|
103
109
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
104
110
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -116,7 +122,8 @@ export var ALIASES_XDAI = lowerCaseValues({
|
|
|
116
122
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
117
123
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
118
124
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
119
|
-
"stable_calc": "
|
|
125
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
126
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
120
127
|
"factory": '0xD19Baeadc667Cf2015e395f2B08668Ef120f41F5',
|
|
121
128
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
122
129
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -134,7 +141,8 @@ export var ALIASES_MOONBEAM = lowerCaseValues({
|
|
|
134
141
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
135
142
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
136
143
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
137
|
-
"stable_calc": "
|
|
144
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
145
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
138
146
|
"factory": '0x4244eB811D6e0Ef302326675207A95113dB4E1F8',
|
|
139
147
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
140
148
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -152,7 +160,8 @@ export var ALIASES_AURORA = lowerCaseValues({
|
|
|
152
160
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
153
161
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
154
162
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
155
|
-
"stable_calc": "
|
|
163
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
164
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
156
165
|
"factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
|
|
157
166
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
158
167
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -170,7 +179,8 @@ export var ALIASES_KAVA = lowerCaseValues({
|
|
|
170
179
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
171
180
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
172
181
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
173
|
-
"stable_calc": "
|
|
182
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
183
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
174
184
|
"factory": '0x40bc62805471eF53DdD5C5cF99ed3d9e5aa81b48',
|
|
175
185
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
176
186
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
@@ -188,7 +198,8 @@ export var ALIASES_CELO = lowerCaseValues({
|
|
|
188
198
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
189
199
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
190
200
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
191
|
-
"stable_calc": "
|
|
201
|
+
"stable_calc": "0xCA8d0747B5573D69653C3aC22242e6341C36e4b4",
|
|
202
|
+
"crypto_calc": '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC',
|
|
192
203
|
"factory": '0x5277A0226d10392295E8D383E9724D6E416d6e6C',
|
|
193
204
|
"crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
|
|
194
205
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
package/lib/curve.js
CHANGED
|
@@ -74,6 +74,7 @@ import addressProviderABI from './constants/abis/address_provider.json' assert {
|
|
|
74
74
|
import gaugeControllerABI from './constants/abis/gaugecontroller.json' assert { type: 'json' };
|
|
75
75
|
import routerABI from './constants/abis/router.json' assert { type: 'json' };
|
|
76
76
|
import depositAndStakeABI from './constants/abis/deposit_and_stake.json' assert { type: 'json' };
|
|
77
|
+
import cryptoCalcZapABI from './constants/abis/crypto_calc.json' assert { type: 'json' };
|
|
77
78
|
import depositAndStake6CoinsABI from './constants/abis/deposit_and_stake_6coins.json' assert { type: 'json' };
|
|
78
79
|
import StableCalcZapABI from './constants/abis/stable_calc.json' assert { type: 'json' };
|
|
79
80
|
import registryExchangeABI from './constants/abis/registry_exchange.json' assert { type: 'json' };
|
|
@@ -481,41 +482,52 @@ var Curve = /** @class */ (function () {
|
|
|
481
482
|
this.fetchTricryptoFactoryPools = function (useApi) {
|
|
482
483
|
if (useApi === void 0) { useApi = true; }
|
|
483
484
|
return __awaiter(_this, void 0, void 0, function () {
|
|
484
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
485
|
-
return __generator(this, function (
|
|
486
|
-
switch (
|
|
485
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
486
|
+
return __generator(this, function (_k) {
|
|
487
|
+
switch (_k.label) {
|
|
487
488
|
case 0:
|
|
488
|
-
if (![1].includes(this.chainId))
|
|
489
|
-
return [2 /*return*/];
|
|
489
|
+
if (![1, 42161].includes(this.chainId))
|
|
490
|
+
return [2 /*return*/]; // Ethereum, Arbitrum
|
|
490
491
|
if (!useApi) return [3 /*break*/, 2];
|
|
491
492
|
_a = this.constants;
|
|
492
493
|
_b = lowerCasePoolDataAddresses;
|
|
493
494
|
return [4 /*yield*/, getFactoryPoolsDataFromApi.call(this, "factory-tricrypto")];
|
|
494
495
|
case 1:
|
|
495
|
-
_a.TRICRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [
|
|
496
|
+
_a.TRICRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_k.sent()]);
|
|
496
497
|
return [3 /*break*/, 4];
|
|
497
498
|
case 2:
|
|
498
499
|
_c = this.constants;
|
|
499
500
|
_d = lowerCasePoolDataAddresses;
|
|
500
501
|
return [4 /*yield*/, getTricryptoFactoryPoolData.call(this)];
|
|
501
502
|
case 3:
|
|
502
|
-
_c.TRICRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [
|
|
503
|
-
|
|
503
|
+
_c.TRICRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_k.sent()]);
|
|
504
|
+
_k.label = 4;
|
|
504
505
|
case 4:
|
|
505
506
|
_e = this.constants;
|
|
506
507
|
return [4 /*yield*/, this._filterHiddenPools(this.constants.TRICRYPTO_FACTORY_POOLS_DATA)];
|
|
507
508
|
case 5:
|
|
508
|
-
_e.TRICRYPTO_FACTORY_POOLS_DATA =
|
|
509
|
+
_e.TRICRYPTO_FACTORY_POOLS_DATA = _k.sent();
|
|
509
510
|
this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
510
511
|
return [4 /*yield*/, _killGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA)];
|
|
511
512
|
case 6:
|
|
512
|
-
|
|
513
|
+
_k.sent();
|
|
514
|
+
if (!(this.chainId === 1)) return [3 /*break*/, 8];
|
|
513
515
|
_f = this.constants.FACTORY_GAUGE_IMPLEMENTATIONS;
|
|
514
516
|
_g = "factory-tricrypto";
|
|
515
517
|
return [4 /*yield*/, this.contracts[this.constants.ALIASES.tricrypto_factory].contract.gauge_implementation(this.constantOptions)];
|
|
516
518
|
case 7:
|
|
517
|
-
_f[_g] =
|
|
518
|
-
|
|
519
|
+
_f[_g] =
|
|
520
|
+
_k.sent();
|
|
521
|
+
return [3 /*break*/, 10];
|
|
522
|
+
case 8:
|
|
523
|
+
_h = this.constants.FACTORY_GAUGE_IMPLEMENTATIONS;
|
|
524
|
+
_j = "factory-tricrypto";
|
|
525
|
+
return [4 /*yield*/, this.contracts[this.constants.ALIASES.minter].contract.get_implementation(this.constantOptions)];
|
|
526
|
+
case 9:
|
|
527
|
+
_h[_j] =
|
|
528
|
+
_k.sent();
|
|
529
|
+
_k.label = 10;
|
|
530
|
+
case 10: return [2 /*return*/];
|
|
519
531
|
}
|
|
520
532
|
});
|
|
521
533
|
});
|
|
@@ -563,8 +575,8 @@ var Curve = /** @class */ (function () {
|
|
|
563
575
|
return __generator(this, function (_b) {
|
|
564
576
|
switch (_b.label) {
|
|
565
577
|
case 0:
|
|
566
|
-
if (![1].includes(this.chainId))
|
|
567
|
-
return [2 /*return*/, []];
|
|
578
|
+
if (![1, 42161].includes(this.chainId))
|
|
579
|
+
return [2 /*return*/, []]; // Ethereum, Arbitrum
|
|
568
580
|
currentPoolIds = Object.keys(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
569
581
|
lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
|
|
570
582
|
_a = lowerCasePoolDataAddresses;
|
|
@@ -616,8 +628,8 @@ var Curve = /** @class */ (function () {
|
|
|
616
628
|
return __generator(this, function (_b) {
|
|
617
629
|
switch (_b.label) {
|
|
618
630
|
case 0:
|
|
619
|
-
if (![1].includes(this.chainId))
|
|
620
|
-
return [2 /*return*/, ''];
|
|
631
|
+
if (![1, 42161].includes(this.chainId))
|
|
632
|
+
return [2 /*return*/, '']; // Ethereum, Arbitrum
|
|
621
633
|
_a = lowerCasePoolDataAddresses;
|
|
622
634
|
return [4 /*yield*/, getTricryptoFactoryPoolData.call(this, 0, poolAddress)];
|
|
623
635
|
case 1:
|
|
@@ -884,6 +896,7 @@ var Curve = /** @class */ (function () {
|
|
|
884
896
|
else {
|
|
885
897
|
this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
|
|
886
898
|
}
|
|
899
|
+
this.setContract(this.constants.ALIASES.crypto_calc, cryptoCalcZapABI);
|
|
887
900
|
this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
|
|
888
901
|
this.setContract(this.constants.ALIASES.factory, factoryABI);
|
|
889
902
|
if (!(this.chainId !== 1313161554)) return [3 /*break*/, 22];
|
|
@@ -231,6 +231,9 @@ export declare class PoolTemplate {
|
|
|
231
231
|
}>;
|
|
232
232
|
private _swapExpected;
|
|
233
233
|
swapExpected(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
|
|
234
|
+
private _swapRequired;
|
|
235
|
+
swapRequired(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
|
|
236
|
+
swapWrappedRequired(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
|
|
234
237
|
swapPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
235
238
|
private _swapContractAddress;
|
|
236
239
|
swapIsApproved(inputCoin: string | number, amount: number | string): Promise<boolean>;
|
|
@@ -2969,6 +2969,75 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2969
2969
|
});
|
|
2970
2970
|
});
|
|
2971
2971
|
};
|
|
2972
|
+
PoolTemplate.prototype._swapRequired = function (i, j, _amount, isUnderlying) {
|
|
2973
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2974
|
+
var poolAddress, contract, basePool, secondPool, basePool;
|
|
2975
|
+
return __generator(this, function (_c) {
|
|
2976
|
+
switch (_c.label) {
|
|
2977
|
+
case 0:
|
|
2978
|
+
poolAddress = this.address;
|
|
2979
|
+
contract = this.isCrypto ? curve.contracts[curve.constants.ALIASES.crypto_calc].contract : curve.contracts[curve.constants.ALIASES.stable_calc].contract;
|
|
2980
|
+
if (!this.isCrypto) return [3 /*break*/, 9];
|
|
2981
|
+
if (!(this.isMeta && isUnderlying)) return [3 /*break*/, 6];
|
|
2982
|
+
basePool = new PoolTemplate(this.basePool);
|
|
2983
|
+
if (!(this.wrappedCoins.length === 3)) return [3 /*break*/, 2];
|
|
2984
|
+
return [4 /*yield*/, contract.get_dx_tricrypto_meta_underlying(poolAddress, i, j, _amount, this.wrappedCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
|
|
2985
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2986
|
+
case 2:
|
|
2987
|
+
if (!basePool.isFake) return [3 /*break*/, 4];
|
|
2988
|
+
secondPool = new PoolTemplate(basePool.basePool);
|
|
2989
|
+
return [4 /*yield*/, contract.get_dx_double_meta_underlying(poolAddress, i, j, _amount, basePool.address, basePool.zap, secondPool.address, secondPool.lpToken, curve.constantOptions)];
|
|
2990
|
+
case 3: return [2 /*return*/, _c.sent()];
|
|
2991
|
+
case 4: return [4 /*yield*/, contract.get_dx_meta_underlying(poolAddress, i, j, _amount, this.underlyingCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
|
|
2992
|
+
case 5: return [2 /*return*/, _c.sent()];
|
|
2993
|
+
case 6: return [4 /*yield*/, contract.get_dx(poolAddress, i, j, _amount, this.wrappedCoins.length, curve.constantOptions)];
|
|
2994
|
+
case 7: return [2 /*return*/, _c.sent()];
|
|
2995
|
+
case 8: return [3 /*break*/, 18];
|
|
2996
|
+
case 9:
|
|
2997
|
+
if (!this.isMeta) return [3 /*break*/, 14];
|
|
2998
|
+
basePool = new PoolTemplate(this.basePool);
|
|
2999
|
+
if (!isUnderlying) return [3 /*break*/, 11];
|
|
3000
|
+
return [4 /*yield*/, contract.get_dx_meta_underlying(poolAddress, i, j, _amount, this.underlyingCoins.length, basePool.address, basePool.lpToken, curve.constantOptions)];
|
|
3001
|
+
case 10: return [2 /*return*/, _c.sent()];
|
|
3002
|
+
case 11: return [4 /*yield*/, contract.get_dx_meta(poolAddress, i, j, _amount, this.wrappedCoins.length, basePool.address, curve.constantOptions)];
|
|
3003
|
+
case 12: return [2 /*return*/, _c.sent()];
|
|
3004
|
+
case 13: return [3 /*break*/, 18];
|
|
3005
|
+
case 14:
|
|
3006
|
+
if (!(isUnderlying && this.isLending)) return [3 /*break*/, 16];
|
|
3007
|
+
return [4 /*yield*/, contract.get_dx_underlying(poolAddress, i, j, _amount, this.underlyingCoins.length, curve.constantOptions)];
|
|
3008
|
+
case 15: return [2 /*return*/, _c.sent()];
|
|
3009
|
+
case 16: return [4 /*yield*/, contract.get_dx(poolAddress, i, j, _amount, this.wrappedCoins.length, curve.constantOptions)];
|
|
3010
|
+
case 17: return [2 /*return*/, _c.sent()];
|
|
3011
|
+
case 18: return [2 /*return*/];
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3014
|
+
});
|
|
3015
|
+
};
|
|
3016
|
+
PoolTemplate.prototype.swapRequired = function (inputCoin, outputCoin, amount) {
|
|
3017
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3018
|
+
var i, j, _amount, _required;
|
|
3019
|
+
return __generator(this, function (_c) {
|
|
3020
|
+
switch (_c.label) {
|
|
3021
|
+
case 0:
|
|
3022
|
+
i = this._getCoinIdx(inputCoin);
|
|
3023
|
+
j = this._getCoinIdx(outputCoin);
|
|
3024
|
+
_amount = parseUnits(amount, this.underlyingDecimals[j]);
|
|
3025
|
+
return [4 /*yield*/, this._swapRequired(i, j, _amount, true)];
|
|
3026
|
+
case 1:
|
|
3027
|
+
_required = _c.sent();
|
|
3028
|
+
return [2 /*return*/, curve.formatUnits(_required, this.underlyingDecimals[i])];
|
|
3029
|
+
}
|
|
3030
|
+
});
|
|
3031
|
+
});
|
|
3032
|
+
};
|
|
3033
|
+
// OVERRIDE
|
|
3034
|
+
PoolTemplate.prototype.swapWrappedRequired = function (inputCoin, outputCoin, amount) {
|
|
3035
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3036
|
+
return __generator(this, function (_c) {
|
|
3037
|
+
throw Error("swapWrappedRequired method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
3038
|
+
});
|
|
3039
|
+
});
|
|
3040
|
+
};
|
|
2972
3041
|
PoolTemplate.prototype.swapPriceImpact = function (inputCoin, outputCoin, amount) {
|
|
2973
3042
|
return __awaiter(this, void 0, void 0, function () {
|
|
2974
3043
|
var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, smallAmountIntBN, amountIntBN, _smallAmount, _smallOutput, priceImpactBN;
|
|
@@ -2,3 +2,4 @@ import { PoolTemplate } from "../PoolTemplate.js";
|
|
|
2
2
|
export declare const swapWrappedTricrypto2Mixin: PoolTemplate;
|
|
3
3
|
export declare const swapWrappedMixin: PoolTemplate;
|
|
4
4
|
export declare const swapWrappedExpectedAndApproveMixin: PoolTemplate;
|
|
5
|
+
export declare const swapWrappedRequiredMixin: PoolTemplate;
|
|
@@ -291,3 +291,23 @@ export var swapWrappedExpectedAndApproveMixin = {
|
|
|
291
291
|
});
|
|
292
292
|
},
|
|
293
293
|
};
|
|
294
|
+
// @ts-ignore
|
|
295
|
+
export var swapWrappedRequiredMixin = {
|
|
296
|
+
swapWrappedRequired: function (inputCoin, outputCoin, amount) {
|
|
297
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
298
|
+
var i, j, _amount, _required;
|
|
299
|
+
return __generator(this, function (_a) {
|
|
300
|
+
switch (_a.label) {
|
|
301
|
+
case 0:
|
|
302
|
+
i = this._getCoinIdx(inputCoin, false);
|
|
303
|
+
j = this._getCoinIdx(outputCoin, false);
|
|
304
|
+
_amount = parseUnits(amount, this.wrappedDecimals[j]);
|
|
305
|
+
return [4 /*yield*/, this._swapRequired(i, j, _amount, false)];
|
|
306
|
+
case 1:
|
|
307
|
+
_required = _a.sent();
|
|
308
|
+
return [2 /*return*/, curve.formatUnits(_required, this.wrappedDecimals[i])];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
};
|
|
@@ -29,7 +29,7 @@ import { withdrawOneCoinMetaFactoryMixin, withdrawOneCoinCryptoMetaFactoryMixin,
|
|
|
29
29
|
import { withdrawOneCoinWrappedExpected2argsMixin, withdrawOneCoinWrappedExpected3argsMixin } from "./mixins/withdrawOneCoinWrappedExpectedMixins.js";
|
|
30
30
|
import { withdrawOneCoinWrappedLendingOrCryptoMixin, withdrawOneCoinWrappedMixin } from "./mixins/withdrawOneCoinWrappedMixins.js";
|
|
31
31
|
import { swapTricrypto2Mixin, swapMetaFactoryMixin, swapCryptoMetaFactoryMixin, swapMixin } from "./mixins/swapMixins.js";
|
|
32
|
-
import { swapWrappedExpectedAndApproveMixin, swapWrappedTricrypto2Mixin, swapWrappedMixin } from "./mixins/swapWrappedMixins.js";
|
|
32
|
+
import { swapWrappedExpectedAndApproveMixin, swapWrappedTricrypto2Mixin, swapWrappedMixin, swapWrappedRequiredMixin } from "./mixins/swapWrappedMixins.js";
|
|
33
33
|
export var getPool = function (poolId) {
|
|
34
34
|
var poolDummy = new PoolTemplate(poolId);
|
|
35
35
|
var Pool = /** @class */ (function (_super) {
|
|
@@ -220,6 +220,7 @@ export var getPool = function (poolId) {
|
|
|
220
220
|
// swapWrapped and swapWrappedEstimateGas
|
|
221
221
|
if (!poolDummy.isPlain && !poolDummy.isFake) {
|
|
222
222
|
Object.assign(Pool.prototype, swapWrappedExpectedAndApproveMixin);
|
|
223
|
+
Object.assign(Pool.prototype, swapWrappedRequiredMixin);
|
|
223
224
|
if ('exchange(uint256,uint256,uint256,uint256,bool)' in curve.contracts[poolDummy.address].contract) { // tricrypto2 (eth), tricrypto (arbitrum)
|
|
224
225
|
Object.assign(Pool.prototype, swapWrappedTricrypto2Mixin);
|
|
225
226
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curvefi/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"description": "JavaScript library for curve.fi",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Macket",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"axios": "^0.21.1",
|
|
36
36
|
"bignumber.js": "^9.0.1",
|
|
37
37
|
"ethcall": "^6.0.1",
|
|
38
|
-
"ethers": "^6.
|
|
38
|
+
"ethers": "^6.7.0",
|
|
39
39
|
"memoizee": "^0.4.15"
|
|
40
40
|
}
|
|
41
41
|
}
|