@curvefi/api 1.8.3 → 1.9.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 +2 -2
- package/lib/constants/abis/json/registry_exchange.json +0 -37
- package/lib/constants/abis/json/tricrypto2/deposit.json +0 -79
- package/lib/curve.d.ts +1 -0
- package/lib/curve.js +47 -9
- package/lib/pools.d.ts +0 -11
- package/lib/pools.js +360 -366
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +25 -3
- package/package.json +1 -1
- package/lib/constants/abis/json/registry.json +0 -940
package/README.md
CHANGED
|
@@ -580,12 +580,6 @@ await pool.exchangeIsApproved("DAI", "1000")
|
|
|
580
580
|
await pool.exchangeApprove("DAI", "1000")
|
|
581
581
|
|
|
582
582
|
|
|
583
|
-
// --- Exchange Tricrypto ---
|
|
584
|
-
|
|
585
|
-
await pool.exchangeIsApproved(0, "1000")
|
|
586
|
-
await pool.exchangeApprove(0, "1000")
|
|
587
|
-
|
|
588
|
-
|
|
589
583
|
// --- Exchange Wrapped ---
|
|
590
584
|
|
|
591
585
|
await pool.exchangeWrappedIsApproved("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490", "1000")
|
package/lib/boosting.js
CHANGED
|
@@ -199,7 +199,7 @@ var createLockEstimateGas = function (amount, days) { return __awaiter(void 0, v
|
|
|
199
199
|
case 1:
|
|
200
200
|
crvBalance = _a.sent();
|
|
201
201
|
if (Number(crvBalance) < Number(amount)) {
|
|
202
|
-
throw Error("Not enough . Actual: "
|
|
202
|
+
throw Error("Not enough . Actual: ".concat(crvBalance, ", required: ").concat(amount));
|
|
203
203
|
}
|
|
204
204
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
|
|
205
205
|
case 2:
|
|
@@ -245,7 +245,7 @@ var increaseAmountEstimateGas = function (amount) { return __awaiter(void 0, voi
|
|
|
245
245
|
case 1:
|
|
246
246
|
crvBalance = _a.sent();
|
|
247
247
|
if (Number(crvBalance) < Number(amount)) {
|
|
248
|
-
throw Error("Not enough. Actual: "
|
|
248
|
+
throw Error("Not enough. Actual: ".concat(crvBalance, ", required: ").concat(amount));
|
|
249
249
|
}
|
|
250
250
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
|
|
251
251
|
case 2:
|
|
@@ -1414,12 +1414,12 @@ exports.poolsData = {
|
|
|
1414
1414
|
swap_address: '0xD51a44d3FaE010294C616388b506AcdA1bfAAE46',
|
|
1415
1415
|
token_address: '0xc4AD29ba4B3c580e6D59105FFf484999997675Ff',
|
|
1416
1416
|
gauge_address: '0xDeFd8FdD20e0f34115C7018CCfb655796F6B2168',
|
|
1417
|
-
underlying_coins: ['USDT', 'WBTC', '
|
|
1417
|
+
underlying_coins: ['USDT', 'WBTC', 'ETH'],
|
|
1418
1418
|
coins: ['USDT', 'WBTC', 'WETH'],
|
|
1419
1419
|
underlying_coin_addresses: [
|
|
1420
1420
|
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
1421
1421
|
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
|
|
1422
|
-
'
|
|
1422
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
1423
1423
|
],
|
|
1424
1424
|
coin_addresses: [
|
|
1425
1425
|
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
@@ -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/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),
|
package/lib/pools.d.ts
CHANGED
|
@@ -36,8 +36,6 @@ export declare class Pool {
|
|
|
36
36
|
removeLiquidityOneCoinWrapped: (lpTokenAmount: string, coin: string | number) => Promise<number>;
|
|
37
37
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
38
38
|
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
39
|
exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
42
40
|
exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
43
41
|
};
|
|
@@ -112,11 +110,6 @@ export declare class Pool {
|
|
|
112
110
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<string[]>;
|
|
113
111
|
private exchangeEstimateGas;
|
|
114
112
|
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
113
|
exchangeWrappedExpected: (inputCoin: string | number, outputCoin: string | number, amount: string) => Promise<string>;
|
|
121
114
|
exchangeWrappedIsApproved: (inputCoin: string | number, amount: string) => Promise<boolean>;
|
|
122
115
|
private exchangeWrappedApproveEstimateGas;
|
|
@@ -163,10 +156,6 @@ export declare class Pool {
|
|
|
163
156
|
private _getExchangeOutput;
|
|
164
157
|
private _getExchangeOutputWrapped;
|
|
165
158
|
}
|
|
166
|
-
export declare const _getBestPoolAndOutput: (inputCoinAddress: string, outputCoinAddress: string, amount: string) => Promise<{
|
|
167
|
-
poolAddress: string;
|
|
168
|
-
output: string;
|
|
169
|
-
}>;
|
|
170
159
|
export declare const getBestPoolAndOutput: (inputCoin: string, outputCoin: string, amount: string) => Promise<{
|
|
171
160
|
poolAddress: string;
|
|
172
161
|
output: string;
|