@curvefi/api 1.24.1 → 1.24.4
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/lib/constants/coins-ethereum.js +15 -1
- package/lib/curve.js +109 -128
- package/lib/external-api.js +7 -13
- package/lib/factory/factory-api.js +3 -1
- package/lib/pools.js +2 -0
- package/package.json +1 -1
|
@@ -164,7 +164,21 @@ exports.DECIMALS_ETHEREUM = {
|
|
|
164
164
|
"0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b": 18,
|
|
165
165
|
"0x68749665ff8d2d112fa859aa293f07a622782f38": 6,
|
|
166
166
|
"0x090185f2135308bad17527004364ebcc2d37e5f6": 18,
|
|
167
|
-
"0xCdF7028ceAB81fA0C6971208e83fa7872994beE5": 18,
|
|
167
|
+
"0xCdF7028ceAB81fA0C6971208e83fa7872994beE5": 18,
|
|
168
|
+
// --- REWARD TOKENS ---
|
|
169
|
+
"0xa3BeD4E1c75D00fa6f4E5E6922DB7261B5E9AcD2": 18,
|
|
170
|
+
"0x8762db106B2c2A0bccB3A80d1Ed41273552616E8": 18,
|
|
171
|
+
"0x20c36f062a31865bED8a5B1e512D9a1A20AA333A": 18,
|
|
172
|
+
"0x89Ab32156e46F46D02ade3FEcbe5Fc4243B9AAeD": 18,
|
|
173
|
+
"0x3c9d6c1C73b31c837832c72E04D3152f051fc1A9": 18,
|
|
174
|
+
"0x4da27a545c0c5b758a6ba100e3a049001de870f5": 18,
|
|
175
|
+
"0x5a98fcbea516cf06857215779fd812ca3bef1b32": 18,
|
|
176
|
+
"0xe0ad1806fd3e7edf6ff52fdb822432e847411033": 18,
|
|
177
|
+
"0x8290333cef9e6d528dd5618fb97a76f268f3edd4": 18,
|
|
178
|
+
"0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0": 18,
|
|
179
|
+
"0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d": 18,
|
|
180
|
+
"0xef3a930e1ffffacd2fc13434ac81bd278b0ecc8d": 18,
|
|
181
|
+
"0xdbdb4d16eda451d0503b854cf79d55697f90c8df": 18, // ALCX
|
|
168
182
|
};
|
|
169
183
|
// @ts-ignore
|
|
170
184
|
exports.DECIMALS_LOWER_CASE_ETHEREUM = Object.fromEntries(Object.entries(exports.DECIMALS_ETHEREUM).map(function (entry) { return [entry[0].toLowerCase(), entry[1]]; }));
|
package/lib/curve.js
CHANGED
|
@@ -115,9 +115,9 @@ var Curve = /** @class */ (function () {
|
|
|
115
115
|
) {
|
|
116
116
|
if (options === void 0) { options = {}; }
|
|
117
117
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var cTokens, yTokens, ycTokens, aTokens, network, _a, customAbiTokens, _b, _i, _c, pool, _d, _e, coinAddr, _f, _g, coinAddr, _h, _j, coinAddr, _k, _l, rewardTokenAddr,
|
|
119
|
-
return __generator(this, function (
|
|
120
|
-
switch (
|
|
118
|
+
var cTokens, yTokens, ycTokens, aTokens, network, _a, customAbiTokens, _b, _i, _c, pool, _d, _e, coinAddr, _f, _g, coinAddr, _h, _j, coinAddr, _k, _l, rewardTokenAddr, addressProviderContract, _m;
|
|
119
|
+
return __generator(this, function (_o) {
|
|
120
|
+
switch (_o.label) {
|
|
121
121
|
case 0:
|
|
122
122
|
// JsonRpc provider
|
|
123
123
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
@@ -160,8 +160,8 @@ var Curve = /** @class */ (function () {
|
|
|
160
160
|
if (_a) return [3 /*break*/, 2];
|
|
161
161
|
return [4 /*yield*/, this.provider._networkPromise];
|
|
162
162
|
case 1:
|
|
163
|
-
_a = (
|
|
164
|
-
|
|
163
|
+
_a = (_o.sent());
|
|
164
|
+
_o.label = 2;
|
|
165
165
|
case 2:
|
|
166
166
|
network = _a;
|
|
167
167
|
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
@@ -217,100 +217,62 @@ var Curve = /** @class */ (function () {
|
|
|
217
217
|
this.multicallProvider = new ethcall_1.Provider();
|
|
218
218
|
return [4 /*yield*/, this.multicallProvider.init(this.provider)];
|
|
219
219
|
case 3:
|
|
220
|
-
|
|
220
|
+
_o.sent();
|
|
221
221
|
if (!this.signer) return [3 /*break*/, 5];
|
|
222
222
|
_b = this;
|
|
223
223
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
224
224
|
case 4:
|
|
225
|
-
_b.signerAddress =
|
|
225
|
+
_b.signerAddress = _o.sent();
|
|
226
226
|
return [3 /*break*/, 6];
|
|
227
227
|
case 5:
|
|
228
228
|
this.signerAddress = '';
|
|
229
|
-
|
|
229
|
+
_o.label = 6;
|
|
230
230
|
case 6:
|
|
231
231
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
232
232
|
return [4 /*yield*/, this.updateFeeData()];
|
|
233
233
|
case 7:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
242
|
-
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
243
|
-
};
|
|
244
|
-
this.contracts[pool.swap_address.toLowerCase()] = {
|
|
245
|
-
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
246
|
-
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
247
|
-
};
|
|
248
|
-
if (pool.token_address !== pool.swap_address) {
|
|
249
|
-
this.contracts[pool.token_address] = {
|
|
250
|
-
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
251
|
-
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
252
|
-
};
|
|
253
|
-
this.contracts[pool.token_address.toLowerCase()] = {
|
|
254
|
-
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
255
|
-
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
this.contracts[pool.gauge_address] = {
|
|
259
|
-
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
260
|
-
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
261
|
-
};
|
|
262
|
-
this.contracts[pool.gauge_address.toLowerCase()] = {
|
|
263
|
-
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
264
|
-
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
265
|
-
};
|
|
266
|
-
if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
|
|
267
|
-
this.contracts[pool.deposit_address] = {
|
|
268
|
-
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
269
|
-
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
270
|
-
};
|
|
271
|
-
this.contracts[pool.deposit_address.toLowerCase()] = {
|
|
272
|
-
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
273
|
-
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
234
|
+
_o.sent();
|
|
235
|
+
// TODO delete toLowerCase()
|
|
236
|
+
for (_i = 0, _c = Object.values(exports.POOLS_DATA); _i < _c.length; _i++) {
|
|
237
|
+
pool = _c[_i];
|
|
238
|
+
this.contracts[pool.swap_address] = {
|
|
239
|
+
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
240
|
+
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
274
241
|
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
this.contracts[coinAddr] = {
|
|
279
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
280
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
281
|
-
};
|
|
282
|
-
this.contracts[coinAddr.toLowerCase()] = {
|
|
283
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
284
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
242
|
+
this.contracts[pool.swap_address.toLowerCase()] = {
|
|
243
|
+
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
244
|
+
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
285
245
|
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
246
|
+
if (pool.token_address !== pool.swap_address) {
|
|
247
|
+
this.contracts[pool.token_address] = {
|
|
248
|
+
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
249
|
+
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
250
|
+
};
|
|
251
|
+
this.contracts[pool.token_address.toLowerCase()] = {
|
|
252
|
+
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
253
|
+
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
this.contracts[pool.gauge_address] = {
|
|
257
|
+
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
258
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
294
259
|
};
|
|
295
|
-
this.contracts[
|
|
296
|
-
contract: new ethers_1.Contract(
|
|
297
|
-
multicallContract: new ethcall_1.Contract(
|
|
260
|
+
this.contracts[pool.gauge_address.toLowerCase()] = {
|
|
261
|
+
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
262
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
298
263
|
};
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (cTokens.includes(coinAddr)) {
|
|
304
|
-
this.contracts[coinAddr] = {
|
|
305
|
-
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
306
|
-
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
264
|
+
if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
|
|
265
|
+
this.contracts[pool.deposit_address] = {
|
|
266
|
+
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
267
|
+
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
307
268
|
};
|
|
308
|
-
this.contracts[
|
|
309
|
-
contract: new ethers_1.Contract(
|
|
310
|
-
multicallContract: new ethcall_1.Contract(
|
|
269
|
+
this.contracts[pool.deposit_address.toLowerCase()] = {
|
|
270
|
+
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
271
|
+
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
311
272
|
};
|
|
312
273
|
}
|
|
313
|
-
|
|
274
|
+
for (_d = 0, _e = pool.underlying_coin_addresses; _d < _e.length; _d++) {
|
|
275
|
+
coinAddr = _e[_d];
|
|
314
276
|
this.contracts[coinAddr] = {
|
|
315
277
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
316
278
|
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
@@ -320,56 +282,75 @@ var Curve = /** @class */ (function () {
|
|
|
320
282
|
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
321
283
|
};
|
|
322
284
|
}
|
|
323
|
-
|
|
285
|
+
for (_f = 0, _g = pool.coin_addresses; _f < _g.length; _f++) {
|
|
286
|
+
coinAddr = _g[_f];
|
|
287
|
+
if (customAbiTokens.includes(coinAddr))
|
|
288
|
+
continue;
|
|
324
289
|
this.contracts[coinAddr] = {
|
|
325
|
-
contract: new ethers_1.Contract(coinAddr,
|
|
326
|
-
multicallContract: new ethcall_1.Contract(coinAddr,
|
|
290
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
291
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
327
292
|
};
|
|
328
293
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
329
|
-
contract: new ethers_1.Contract(coinAddr,
|
|
330
|
-
multicallContract: new ethcall_1.Contract(coinAddr,
|
|
294
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
295
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
// TODO add all coins
|
|
299
|
+
for (_h = 0, _j = pool.coin_addresses; _h < _j.length; _h++) {
|
|
300
|
+
coinAddr = _j[_h];
|
|
301
|
+
if (cTokens.includes(coinAddr)) {
|
|
302
|
+
this.contracts[coinAddr] = {
|
|
303
|
+
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
304
|
+
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
305
|
+
};
|
|
306
|
+
this.contracts[coinAddr.toLowerCase()] = {
|
|
307
|
+
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
308
|
+
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
if (aTokens.includes(coinAddr)) {
|
|
312
|
+
this.contracts[coinAddr] = {
|
|
313
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
314
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
315
|
+
};
|
|
316
|
+
this.contracts[coinAddr.toLowerCase()] = {
|
|
317
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
318
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
322
|
+
this.contracts[coinAddr] = {
|
|
323
|
+
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
324
|
+
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
325
|
+
};
|
|
326
|
+
this.contracts[coinAddr.toLowerCase()] = {
|
|
327
|
+
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
328
|
+
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (pool.reward_contract) {
|
|
333
|
+
this.contracts[pool.reward_contract] = {
|
|
334
|
+
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
335
|
+
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
336
|
+
};
|
|
337
|
+
this.contracts[pool.reward_contract.toLowerCase()] = {
|
|
338
|
+
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
339
|
+
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
for (_k = 0, _l = pool.reward_tokens || []; _k < _l.length; _k++) {
|
|
343
|
+
rewardTokenAddr = _l[_k];
|
|
344
|
+
this.contracts[rewardTokenAddr] = {
|
|
345
|
+
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
346
|
+
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
347
|
+
};
|
|
348
|
+
this.contracts[rewardTokenAddr.toLowerCase()] = {
|
|
349
|
+
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
350
|
+
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
331
351
|
};
|
|
332
352
|
}
|
|
333
353
|
}
|
|
334
|
-
if (pool.reward_contract) {
|
|
335
|
-
this.contracts[pool.reward_contract] = {
|
|
336
|
-
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
337
|
-
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
338
|
-
};
|
|
339
|
-
this.contracts[pool.reward_contract.toLowerCase()] = {
|
|
340
|
-
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
341
|
-
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
_k = 0, _l = pool.reward_tokens || [];
|
|
345
|
-
_t.label = 9;
|
|
346
|
-
case 9:
|
|
347
|
-
if (!(_k < _l.length)) return [3 /*break*/, 12];
|
|
348
|
-
rewardTokenAddr = _l[_k];
|
|
349
|
-
this.contracts[rewardTokenAddr] = {
|
|
350
|
-
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
351
|
-
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
352
|
-
};
|
|
353
|
-
this.contracts[rewardTokenAddr.toLowerCase()] = {
|
|
354
|
-
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
355
|
-
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
356
|
-
};
|
|
357
|
-
_m = exports.DECIMALS_LOWER_CASE;
|
|
358
|
-
_o = rewardTokenAddr.toLowerCase();
|
|
359
|
-
_p = Number;
|
|
360
|
-
_r = (_q = ethers_1.ethers.utils).formatUnits;
|
|
361
|
-
return [4 /*yield*/, this.contracts[rewardTokenAddr].contract.decimals()];
|
|
362
|
-
case 10:
|
|
363
|
-
_m[_o] =
|
|
364
|
-
_p.apply(void 0, [_r.apply(_q, [_t.sent(), 0])]);
|
|
365
|
-
_t.label = 11;
|
|
366
|
-
case 11:
|
|
367
|
-
_k++;
|
|
368
|
-
return [3 /*break*/, 9];
|
|
369
|
-
case 12:
|
|
370
|
-
_i++;
|
|
371
|
-
return [3 /*break*/, 8];
|
|
372
|
-
case 13:
|
|
373
354
|
this.contracts[exports.ALIASES.crv] = {
|
|
374
355
|
contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
375
356
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
|
|
@@ -403,10 +384,10 @@ var Curve = /** @class */ (function () {
|
|
|
403
384
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
404
385
|
};
|
|
405
386
|
addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
|
|
406
|
-
|
|
387
|
+
_m = exports.ALIASES;
|
|
407
388
|
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
408
|
-
case
|
|
409
|
-
|
|
389
|
+
case 8:
|
|
390
|
+
_m.registry_exchange = _o.sent();
|
|
410
391
|
this.contracts[exports.ALIASES.registry_exchange] = {
|
|
411
392
|
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
412
393
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
package/lib/external-api.js
CHANGED
|
@@ -43,22 +43,16 @@ exports._getPoolsFromApi = void 0;
|
|
|
43
43
|
var axios_1 = __importDefault(require("axios"));
|
|
44
44
|
var memoizee_1 = __importDefault(require("memoizee"));
|
|
45
45
|
exports._getPoolsFromApi = (0, memoizee_1.default)(function (network, poolType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var url, response
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
var url, response;
|
|
47
|
+
var _a;
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
49
50
|
case 0:
|
|
50
51
|
url = "https://api.curve.fi/api/getPools/".concat(network, "/").concat(poolType);
|
|
51
|
-
|
|
52
|
+
return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
|
|
52
53
|
case 1:
|
|
53
|
-
|
|
54
|
-
return [
|
|
55
|
-
case 2:
|
|
56
|
-
response = _a.sent();
|
|
57
|
-
return [2 /*return*/, response.data.data];
|
|
58
|
-
case 3:
|
|
59
|
-
err_1 = _a.sent();
|
|
60
|
-
return [2 /*return*/, { poolData: [], tvl: 0, tvlAll: 0 }];
|
|
61
|
-
case 4: return [2 /*return*/];
|
|
54
|
+
response = _b.sent();
|
|
55
|
+
return [2 /*return*/, (_a = response.data.data) !== null && _a !== void 0 ? _a : { poolData: [], tvl: 0, tvlAll: 0 }];
|
|
62
56
|
}
|
|
63
57
|
});
|
|
64
58
|
}); }, {
|
|
@@ -145,7 +145,7 @@ function setFactoryZapContracts() {
|
|
|
145
145
|
}
|
|
146
146
|
function getFactoryPoolsDataFromApi(isCrypto) {
|
|
147
147
|
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
-
var network, factoryType, url, response, rawPoolList, FACTORY_POOLS_DATA;
|
|
148
|
+
var network, factoryType, url, response, rawPoolList, mainAddresses, FACTORY_POOLS_DATA;
|
|
149
149
|
var _this = this;
|
|
150
150
|
return __generator(this, function (_a) {
|
|
151
151
|
switch (_a.label) {
|
|
@@ -157,6 +157,8 @@ function getFactoryPoolsDataFromApi(isCrypto) {
|
|
|
157
157
|
case 1:
|
|
158
158
|
response = _a.sent();
|
|
159
159
|
rawPoolList = response.data.data.poolData;
|
|
160
|
+
mainAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address.toLowerCase(); });
|
|
161
|
+
rawPoolList = rawPoolList.filter(function (p) { return !mainAddresses.includes(p.address.toLowerCase()); });
|
|
160
162
|
setFactorySwapContracts.call(this, rawPoolList, isCrypto);
|
|
161
163
|
if (isCrypto)
|
|
162
164
|
setCryptoFactoryTokenContracts.call(this, rawPoolList);
|
package/lib/pools.js
CHANGED
|
@@ -294,6 +294,8 @@ var Pool = /** @class */ (function () {
|
|
|
294
294
|
case 0: return [4 /*yield*/, this._getPoolStats()];
|
|
295
295
|
case 1:
|
|
296
296
|
volume = (_c.sent()).volume;
|
|
297
|
+
if (volume === 0)
|
|
298
|
+
return [2 /*return*/, "0"];
|
|
297
299
|
if (!(this.isCrypto || (curve_1.curve.chainId === 1 && this.isFactory))) return [3 /*break*/, 2];
|
|
298
300
|
_a = 1;
|
|
299
301
|
return [3 /*break*/, 4];
|