@curvefi/api 2.8.0 → 2.8.1
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/router.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
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:
|