@curvefi/api 2.7.0 → 2.8.2
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 -2
- package/lib/constants/abis/3pool/swap.json +0 -26
- package/lib/constants/aliases.d.ts +1 -0
- package/lib/constants/aliases.js +13 -1
- package/lib/constants/coins/xdai.d.ts +7 -0
- package/lib/constants/coins/xdai.js +17 -0
- package/lib/constants/pools/index.d.ts +2 -1
- package/lib/constants/pools/index.js +3 -1
- package/lib/constants/pools/xdai.d.ts +4 -0
- package/lib/constants/pools/xdai.js +71 -0
- package/lib/curve.js +18 -5
- package/lib/factory/common.js +7 -0
- package/lib/factory/constants.d.ts +3 -0
- package/lib/factory/constants.js +34 -1
- package/lib/factory/factory-crypto.js +2 -0
- package/lib/factory/factory.js +10 -7
- package/lib/pools/PoolTemplate.js +531 -497
- package/lib/router.js +13 -3
- package/lib/utils.js +4 -1
- package/package.json +1 -1
package/lib/router.js
CHANGED
|
@@ -216,12 +216,13 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
|
|
|
216
216
|
case 7:
|
|
217
217
|
poolAddress = (poolData.is_crypto && poolData.is_meta) || (base_pool && base_pool.is_meta && poolData.is_factory) ?
|
|
218
218
|
poolData.deposit_address : poolData.swap_address;
|
|
219
|
-
if (!(
|
|
219
|
+
if (!(!poolData.is_plain && inCoinIndexes.underlying_coin >= 0)) return [3 /*break*/, 11];
|
|
220
220
|
j = 0;
|
|
221
221
|
_5.label = 8;
|
|
222
222
|
case 8:
|
|
223
223
|
if (!(j < underlying_coin_addresses.length)) return [3 /*break*/, 11];
|
|
224
|
-
|
|
224
|
+
// Don't swap metacoins since they can be swapped directly in base pool
|
|
225
|
+
if (inCoinIndexes.meta_coin >= 0 && meta_coin_addresses.includes(underlying_coin_addresses[j]))
|
|
225
226
|
return [3 /*break*/, 10];
|
|
226
227
|
// If this coin already marked or will be marked on the current step, no need to consider it on the next step
|
|
227
228
|
if (markedCoins.includes(underlying_coin_addresses[j]) || curCoins.includes(underlying_coin_addresses[j]))
|
|
@@ -430,6 +431,13 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
|
|
|
430
431
|
case 0:
|
|
431
432
|
_a = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _a[0], outputCoinDecimals = _a[1];
|
|
432
433
|
_amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
|
|
434
|
+
if (_amount.eq(0))
|
|
435
|
+
return [2 /*return*/, {
|
|
436
|
+
steps: [],
|
|
437
|
+
_output: ethers_1.ethers.BigNumber.from(0),
|
|
438
|
+
outputUsd: 0,
|
|
439
|
+
txCostUsd: 0,
|
|
440
|
+
}];
|
|
433
441
|
return [4 /*yield*/, (0, exports._findAllRoutes)(inputCoinAddress, outputCoinAddress)];
|
|
434
442
|
case 1:
|
|
435
443
|
routesRaw = (_f.sent()).map(function (steps) { return ({ steps: steps, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 }); });
|
|
@@ -466,7 +474,7 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
|
|
|
466
474
|
res = _f.sent();
|
|
467
475
|
for (i = 0; i < res.length; i++) {
|
|
468
476
|
if (res[i].status === 'rejected') {
|
|
469
|
-
console.log("Route ".concat((routesRaw[i].steps.map(function (s) { return s.poolId; })).join(" --> "), " is
|
|
477
|
+
console.log("Route ".concat((routesRaw[i].steps.map(function (s) { return s.poolId; })).join(" --> "), " is unavailable"));
|
|
470
478
|
continue;
|
|
471
479
|
}
|
|
472
480
|
routesRaw[i]._output = res[i].value;
|
|
@@ -603,6 +611,8 @@ var swapEstimateGas = function (inputCoin, outputCoin, amount) { return __awaite
|
|
|
603
611
|
return [4 /*yield*/, _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount)];
|
|
604
612
|
case 1:
|
|
605
613
|
route = _b.sent();
|
|
614
|
+
if (route.steps.length === 0)
|
|
615
|
+
return [2 /*return*/, 0];
|
|
606
616
|
_amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
|
|
607
617
|
return [4 /*yield*/, _estimateGasForDifferentRoutes([route], inputCoinAddress, outputCoinAddress, _amount)];
|
|
608
618
|
case 2:
|
package/lib/utils.js
CHANGED
|
@@ -453,6 +453,7 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
453
453
|
chainName = {
|
|
454
454
|
1: 'ethereum',
|
|
455
455
|
10: 'optimistic-ethereum',
|
|
456
|
+
100: 'xdai',
|
|
456
457
|
137: 'polygon-pos',
|
|
457
458
|
250: 'fantom',
|
|
458
459
|
43114: 'avalanche',
|
|
@@ -460,7 +461,8 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
460
461
|
}[curve_1.curve.chainId];
|
|
461
462
|
nativeTokenName = {
|
|
462
463
|
1: 'ethereum',
|
|
463
|
-
10: '
|
|
464
|
+
10: 'ethereum',
|
|
465
|
+
100: 'xdai',
|
|
464
466
|
137: 'matic-network',
|
|
465
467
|
250: 'fantom',
|
|
466
468
|
43114: 'avalanche-2',
|
|
@@ -528,6 +530,7 @@ var getTVL = function (chainId) {
|
|
|
528
530
|
network = (_a = {
|
|
529
531
|
1: "ethereum",
|
|
530
532
|
10: 'optimism',
|
|
533
|
+
100: 'xdai',
|
|
531
534
|
137: "polygon",
|
|
532
535
|
250: "fantom",
|
|
533
536
|
43114: "avalanche",
|