@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 CHANGED
@@ -324,8 +324,6 @@ import curve from "@curvefi/api";
324
324
  // [ 18, 18 ]
325
325
  pool.useLending;
326
326
  // [ false, false, false, false ]
327
- pool.rewardTokens;
328
- // []
329
327
  })()
330
328
  ````
331
329
 
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 (!(wrapped_coin_addresses.join("|") !== underlying_coin_addresses.join("|") && inCoinIndexes.underlying_coin >= 0)) return [3 /*break*/, 11];
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
- if (poolData.is_fake && inCoinIndexes.meta_coin >= 0 && meta_coin_addresses.includes(underlying_coin_addresses[j]))
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 anavailable"));
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",