@curvefi/api 1.8.2 → 1.10.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 +0 -6
- package/lib/boosting.js +2 -2
- package/lib/constants/abis/abis-ethereum.js +95 -3
- package/lib/constants/abis/json/crveth/swap.json +1258 -0
- package/lib/constants/abis/json/{registry.json → eurt/swap.json} +402 -497
- package/lib/constants/abis/json/eurtusd/deposit.json +257 -0
- package/lib/constants/abis/json/eurtusd/swap.json +1199 -0
- package/lib/constants/abis/json/registry_exchange.json +0 -37
- package/lib/constants/abis/json/tricrypto2/deposit.json +0 -79
- package/lib/constants/coins.js +3 -1
- package/lib/curve.d.ts +1 -0
- package/lib/curve.js +48 -10
- package/lib/interfaces.d.ts +1 -0
- package/lib/pools.d.ts +1 -11
- package/lib/pools.js +426 -405
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +25 -3
- package/package.json +1 -1
|
@@ -155,43 +155,6 @@
|
|
|
155
155
|
}
|
|
156
156
|
]
|
|
157
157
|
},
|
|
158
|
-
{
|
|
159
|
-
"stateMutability": "payable",
|
|
160
|
-
"type": "function",
|
|
161
|
-
"name": "exchange",
|
|
162
|
-
"inputs": [
|
|
163
|
-
{
|
|
164
|
-
"name": "_pool",
|
|
165
|
-
"type": "address"
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
"name": "_from",
|
|
169
|
-
"type": "address"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"name": "_to",
|
|
173
|
-
"type": "address"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"name": "_amount",
|
|
177
|
-
"type": "uint256"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"name": "_expected",
|
|
181
|
-
"type": "uint256"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"name": "_receiver",
|
|
185
|
-
"type": "address"
|
|
186
|
-
}
|
|
187
|
-
],
|
|
188
|
-
"outputs": [
|
|
189
|
-
{
|
|
190
|
-
"name": "",
|
|
191
|
-
"type": "uint256"
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
},
|
|
195
158
|
{
|
|
196
159
|
"stateMutability": "view",
|
|
197
160
|
"type": "function",
|
|
@@ -35,52 +35,6 @@
|
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
-
{
|
|
39
|
-
"stateMutability": "payable",
|
|
40
|
-
"type": "function",
|
|
41
|
-
"name": "add_liquidity",
|
|
42
|
-
"inputs": [
|
|
43
|
-
{
|
|
44
|
-
"name": "_amounts",
|
|
45
|
-
"type": "uint256[3]"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "_min_mint_amount",
|
|
49
|
-
"type": "uint256"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"name": "_receiver",
|
|
53
|
-
"type": "address"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"outputs": [
|
|
57
|
-
{
|
|
58
|
-
"name": "",
|
|
59
|
-
"type": "uint256"
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"stateMutability": "nonpayable",
|
|
65
|
-
"type": "function",
|
|
66
|
-
"name": "remove_liquidity",
|
|
67
|
-
"inputs": [
|
|
68
|
-
{
|
|
69
|
-
"name": "_amount",
|
|
70
|
-
"type": "uint256"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "_min_amounts",
|
|
74
|
-
"type": "uint256[3]"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"outputs": [
|
|
78
|
-
{
|
|
79
|
-
"name": "",
|
|
80
|
-
"type": "uint256[3]"
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
},
|
|
84
38
|
{
|
|
85
39
|
"stateMutability": "nonpayable",
|
|
86
40
|
"type": "function",
|
|
@@ -93,10 +47,6 @@
|
|
|
93
47
|
{
|
|
94
48
|
"name": "_min_amounts",
|
|
95
49
|
"type": "uint256[3]"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"name": "_receiver",
|
|
99
|
-
"type": "address"
|
|
100
50
|
}
|
|
101
51
|
],
|
|
102
52
|
"outputs": [
|
|
@@ -131,35 +81,6 @@
|
|
|
131
81
|
}
|
|
132
82
|
]
|
|
133
83
|
},
|
|
134
|
-
{
|
|
135
|
-
"stateMutability": "nonpayable",
|
|
136
|
-
"type": "function",
|
|
137
|
-
"name": "remove_liquidity_one_coin",
|
|
138
|
-
"inputs": [
|
|
139
|
-
{
|
|
140
|
-
"name": "_token_amount",
|
|
141
|
-
"type": "uint256"
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"name": "i",
|
|
145
|
-
"type": "uint256"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"name": "_min_amount",
|
|
149
|
-
"type": "uint256"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"name": "_receiver",
|
|
153
|
-
"type": "address"
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
"outputs": [
|
|
157
|
-
{
|
|
158
|
-
"name": "",
|
|
159
|
-
"type": "uint256"
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
},
|
|
163
84
|
{
|
|
164
85
|
"stateMutability": "view",
|
|
165
86
|
"type": "function",
|
package/lib/constants/coins.js
CHANGED
|
@@ -43,7 +43,8 @@ exports.LINK_COINS = {
|
|
|
43
43
|
exports.LINK_COINS_LOWER_CASE = Object.fromEntries(Object.entries(exports.LINK_COINS).map(function (entry) { return [entry[0], entry[1].toLowerCase()]; }));
|
|
44
44
|
exports.EUR_COINS = {
|
|
45
45
|
eurs: "0xdB25f211AB05b1c97D595516F45794528a807ad8",
|
|
46
|
-
seur: "0xD71eCFF9342A5Ced620049e616c5035F1dB98620",
|
|
46
|
+
seur: "0xD71eCFF9342A5Ced620049e616c5035F1dB98620",
|
|
47
|
+
eurt: "0xC581b735A1688071A1746c968e0798D642EDE491", // EURT
|
|
47
48
|
};
|
|
48
49
|
exports.USD_COINS = {
|
|
49
50
|
ycdai: "0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc",
|
|
@@ -112,6 +113,7 @@ exports.DECIMALS = {
|
|
|
112
113
|
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": 18,
|
|
113
114
|
"0xdB25f211AB05b1c97D595516F45794528a807ad8": 2,
|
|
114
115
|
"0xD71eCFF9342A5Ced620049e616c5035F1dB98620": 18,
|
|
116
|
+
"0xC581b735A1688071A1746c968e0798D642EDE491": 6,
|
|
115
117
|
"0x514910771AF9Ca656af840dff83E8264EcF986CA": 18,
|
|
116
118
|
"0xbBC455cb4F1B9e4bFC4B73970d360c8f032EfEE6": 18,
|
|
117
119
|
"0x028171bCA77440897B824Ca71D1c56caC55b68A3": 18,
|
package/lib/curve.d.ts
CHANGED
package/lib/curve.js
CHANGED
|
@@ -46,6 +46,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
60
|
};
|
|
@@ -61,6 +70,7 @@ var votingescrow_json_1 = __importDefault(require("./constants/abis/json/votinge
|
|
|
61
70
|
var address_provider_json_1 = __importDefault(require("./constants/abis/json/address_provider.json"));
|
|
62
71
|
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
|
|
63
72
|
var router_json_1 = __importDefault(require("./constants/abis/json/router.json"));
|
|
73
|
+
var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
|
|
64
74
|
var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
|
|
65
75
|
exports.ALIASES = {
|
|
66
76
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
@@ -72,6 +82,7 @@ exports.ALIASES = {
|
|
|
72
82
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
73
83
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
74
84
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
85
|
+
"registry_exchange": "",
|
|
75
86
|
};
|
|
76
87
|
var cTokens = [
|
|
77
88
|
'0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
|
|
@@ -101,6 +112,7 @@ var aTokens = [
|
|
|
101
112
|
"0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
|
|
102
113
|
"0x6c5024cd4f8a59110119c56f8933403a539555eb", // sSUSD
|
|
103
114
|
];
|
|
115
|
+
var customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
104
116
|
var Curve = /** @class */ (function () {
|
|
105
117
|
function Curve() {
|
|
106
118
|
// @ts-ignore
|
|
@@ -119,9 +131,9 @@ var Curve = /** @class */ (function () {
|
|
|
119
131
|
) {
|
|
120
132
|
if (options === void 0) { options = {}; }
|
|
121
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr;
|
|
123
|
-
return __generator(this, function (
|
|
124
|
-
switch (
|
|
134
|
+
var _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr, _g, _h, coinAddr, addressProviderContract, _j;
|
|
135
|
+
return __generator(this, function (_k) {
|
|
136
|
+
switch (_k.label) {
|
|
125
137
|
case 0:
|
|
126
138
|
// JsonRpc provider
|
|
127
139
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
@@ -160,20 +172,20 @@ var Curve = /** @class */ (function () {
|
|
|
160
172
|
this.multicallProvider = new ethers_multicall_1.Provider(this.provider);
|
|
161
173
|
return [4 /*yield*/, this.multicallProvider.init()];
|
|
162
174
|
case 2:
|
|
163
|
-
|
|
164
|
-
|
|
175
|
+
_k.sent();
|
|
176
|
+
_k.label = 3;
|
|
165
177
|
case 3:
|
|
166
178
|
if (!this.signer) return [3 /*break*/, 5];
|
|
167
179
|
_a = this;
|
|
168
180
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
169
181
|
case 4:
|
|
170
|
-
_a.signerAddress =
|
|
171
|
-
|
|
182
|
+
_a.signerAddress = _k.sent();
|
|
183
|
+
_k.label = 5;
|
|
172
184
|
case 5:
|
|
173
185
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
174
186
|
return [4 /*yield*/, this.updateFeeData()];
|
|
175
187
|
case 6:
|
|
176
|
-
|
|
188
|
+
_k.sent();
|
|
177
189
|
// TODO delete toLowerCase()
|
|
178
190
|
for (_i = 0, _b = Object.values(abis_ethereum_1.poolsData); _i < _b.length; _i++) {
|
|
179
191
|
pool = _b[_i];
|
|
@@ -224,9 +236,22 @@ var Curve = /** @class */ (function () {
|
|
|
224
236
|
multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
225
237
|
};
|
|
226
238
|
}
|
|
227
|
-
// TODO add all coins
|
|
228
239
|
for (_e = 0, _f = pool.coin_addresses; _e < _f.length; _e++) {
|
|
229
240
|
coinAddr = _f[_e];
|
|
241
|
+
if (customAbiTokens.includes(coinAddr))
|
|
242
|
+
continue;
|
|
243
|
+
this.contracts[coinAddr] = {
|
|
244
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
245
|
+
multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
246
|
+
};
|
|
247
|
+
this.contracts[coinAddr.toLowerCase()] = {
|
|
248
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
249
|
+
multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
// TODO add all coins
|
|
253
|
+
for (_g = 0, _h = pool.coin_addresses; _g < _h.length; _g++) {
|
|
254
|
+
coinAddr = _h[_g];
|
|
230
255
|
if (cTokens.includes(coinAddr)) {
|
|
231
256
|
this.contracts[coinAddr] = {
|
|
232
257
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
@@ -283,6 +308,19 @@ var Curve = /** @class */ (function () {
|
|
|
283
308
|
contract: new ethers_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
284
309
|
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
285
310
|
};
|
|
311
|
+
addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
|
|
312
|
+
_j = exports.ALIASES;
|
|
313
|
+
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
314
|
+
case 7:
|
|
315
|
+
_j.registry_exchange = _k.sent();
|
|
316
|
+
this.contracts[exports.ALIASES.registry_exchange] = {
|
|
317
|
+
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
318
|
+
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
319
|
+
};
|
|
320
|
+
this.contracts[exports.ALIASES.registry_exchange.toLowerCase()] = {
|
|
321
|
+
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
322
|
+
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
323
|
+
};
|
|
286
324
|
this.contracts[exports.ALIASES.gauge_controller] = {
|
|
287
325
|
contract: new ethers_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
288
326
|
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
@@ -342,7 +380,7 @@ var Curve = /** @class */ (function () {
|
|
|
342
380
|
feeData.maxFeePerGas;
|
|
343
381
|
this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
|
|
344
382
|
ethers_1.ethers.utils.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
|
|
345
|
-
feeData.
|
|
383
|
+
feeData.maxPriorityFeePerGas;
|
|
346
384
|
_d.label = 7;
|
|
347
385
|
case 7: return [2 /*return*/];
|
|
348
386
|
}
|
package/lib/interfaces.d.ts
CHANGED
package/lib/pools.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare class Pool {
|
|
|
15
15
|
decimals: number[];
|
|
16
16
|
useLending: boolean[];
|
|
17
17
|
isMeta: boolean;
|
|
18
|
+
isCrypto: boolean;
|
|
18
19
|
basePool: string;
|
|
19
20
|
isFactory: boolean;
|
|
20
21
|
estimateGas: {
|
|
@@ -36,8 +37,6 @@ export declare class Pool {
|
|
|
36
37
|
removeLiquidityOneCoinWrapped: (lpTokenAmount: string, coin: string | number) => Promise<number>;
|
|
37
38
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
38
39
|
exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
39
|
-
exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<number>;
|
|
40
|
-
exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number, useEth?: boolean) => Promise<number>;
|
|
41
40
|
exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
42
41
|
exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
43
42
|
};
|
|
@@ -112,11 +111,6 @@ export declare class Pool {
|
|
|
112
111
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<string[]>;
|
|
113
112
|
private exchangeEstimateGas;
|
|
114
113
|
exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number) => Promise<string>;
|
|
115
|
-
exchangeTricryptoIsApproved: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<boolean>;
|
|
116
|
-
private exchangeTricryptoApproveEstimateGas;
|
|
117
|
-
exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<string[]>;
|
|
118
|
-
private exchangeTricryptoEstimateGas;
|
|
119
|
-
exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number, useEth?: boolean) => Promise<string>;
|
|
120
114
|
exchangeWrappedExpected: (inputCoin: string | number, outputCoin: string | number, amount: string) => Promise<string>;
|
|
121
115
|
exchangeWrappedIsApproved: (inputCoin: string | number, amount: string) => Promise<boolean>;
|
|
122
116
|
private exchangeWrappedApproveEstimateGas;
|
|
@@ -163,10 +157,6 @@ export declare class Pool {
|
|
|
163
157
|
private _getExchangeOutput;
|
|
164
158
|
private _getExchangeOutputWrapped;
|
|
165
159
|
}
|
|
166
|
-
export declare const _getBestPoolAndOutput: (inputCoinAddress: string, outputCoinAddress: string, amount: string) => Promise<{
|
|
167
|
-
poolAddress: string;
|
|
168
|
-
output: string;
|
|
169
|
-
}>;
|
|
170
160
|
export declare const getBestPoolAndOutput: (inputCoin: string, outputCoin: string, amount: string) => Promise<{
|
|
171
161
|
poolAddress: string;
|
|
172
162
|
output: string;
|