@curvefi/api 2.34.1 → 2.34.3

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/curve.js CHANGED
@@ -390,7 +390,7 @@ var Curve = /** @class */ (function () {
390
390
  case 0:
391
391
  if (this.chainId === 1313161554)
392
392
  return [2 /*return*/, []];
393
- currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
393
+ currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA).filter(function (id) { return !id.includes('crvusd'); });
394
394
  lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
395
395
  _a = lowerCasePoolDataAddresses;
396
396
  return [4 /*yield*/, getFactoryPoolData.call(this, lastPoolIdx + 1)];
package/lib/router.js CHANGED
@@ -424,9 +424,9 @@ var _estimateGasForDifferentRoutes = function (routes, inputCoinAddress, outputC
424
424
  });
425
425
  }); };
426
426
  var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
427
- var _a, inputCoinDecimals, outputCoinDecimals, _amount, routesRaw, routes, calls, multicallContract, _i, routesRaw_1, r, _b, _route, _swapParams, _factorySwapAddresses, _outputAmounts, i, err_2, promises, contract, _c, routesRaw_2, r, _d, _route, _swapParams, _factorySwapAddresses, res, i, _e, gasAmounts, outputCoinUsdRate, gasData, ethUsdRate, gasPrice, expectedAmounts, expectedAmountsUsd, txCostsUsd;
428
- return __generator(this, function (_f) {
429
- switch (_f.label) {
427
+ var _a, inputCoinDecimals, outputCoinDecimals, _amount, routesRaw, routes, calls, multicallContract, _i, routesRaw_1, r, _b, _route, _swapParams, _factorySwapAddresses, _outputAmounts, i, err_2, contract, _outputs, _c, routesRaw_2, r, _d, _route, _swapParams, _factorySwapAddresses, _e, _f, e_1, i, _h, gasAmounts, outputCoinUsdRate, gasData, ethUsdRate, gasPrice, expectedAmounts, expectedAmountsUsd, txCostsUsd;
428
+ return __generator(this, function (_j) {
429
+ switch (_j.label) {
430
430
  case 0:
431
431
  _a = _getCoinDecimals(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _a[0], outputCoinDecimals = _a[1];
432
432
  _amount = parseUnits(amount, inputCoinDecimals);
@@ -434,11 +434,11 @@ var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amoun
434
434
  return [2 /*return*/, []];
435
435
  return [4 /*yield*/, _findAllRoutes(inputCoinAddress, outputCoinAddress)];
436
436
  case 1:
437
- routesRaw = (_f.sent()).map(function (route) { return ({ route: route, _output: curve.parseUnits("0"), outputUsd: 0, txCostUsd: 0 }); });
437
+ routesRaw = (_j.sent()).map(function (route) { return ({ route: route, _output: curve.parseUnits("0"), outputUsd: 0, txCostUsd: 0 }); });
438
438
  routes = [];
439
- _f.label = 2;
439
+ _j.label = 2;
440
440
  case 2:
441
- _f.trys.push([2, 4, , 6]);
441
+ _j.trys.push([2, 4, , 11]);
442
442
  calls = [];
443
443
  multicallContract = curve.contracts[curve.constants.ALIASES.registry_exchange].multicallContract;
444
444
  for (_i = 0, routesRaw_1 = routesRaw; _i < routesRaw_1.length; _i++) {
@@ -448,34 +448,48 @@ var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amoun
448
448
  }
449
449
  return [4 /*yield*/, curve.multicallProvider.all(calls)];
450
450
  case 3:
451
- _outputAmounts = _f.sent();
451
+ _outputAmounts = _j.sent();
452
452
  for (i = 0; i < _outputAmounts.length; i++) {
453
453
  routesRaw[i]._output = _outputAmounts[i];
454
454
  routes.push(routesRaw[i]);
455
455
  }
456
- return [3 /*break*/, 6];
456
+ return [3 /*break*/, 11];
457
457
  case 4:
458
- err_2 = _f.sent();
459
- promises = [];
458
+ err_2 = _j.sent();
460
459
  contract = curve.contracts[curve.constants.ALIASES.registry_exchange].contract;
461
- for (_c = 0, routesRaw_2 = routesRaw; _c < routesRaw_2.length; _c++) {
462
- r = routesRaw_2[_c];
463
- _d = _getExchangeMultipleArgs(r.route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
464
- promises.push(contract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses, curve.constantOptions));
465
- }
466
- return [4 /*yield*/, Promise.allSettled(promises)];
460
+ _outputs = [];
461
+ _c = 0, routesRaw_2 = routesRaw;
462
+ _j.label = 5;
467
463
  case 5:
468
- res = _f.sent();
469
- for (i = 0; i < res.length; i++) {
470
- if (res[i].status === 'rejected') {
464
+ if (!(_c < routesRaw_2.length)) return [3 /*break*/, 10];
465
+ r = routesRaw_2[_c];
466
+ _d = _getExchangeMultipleArgs(r.route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
467
+ _j.label = 6;
468
+ case 6:
469
+ _j.trys.push([6, 8, , 9]);
470
+ _f = (_e = _outputs).push;
471
+ return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses, curve.constantOptions)];
472
+ case 7:
473
+ _f.apply(_e, [_j.sent()]);
474
+ return [3 /*break*/, 9];
475
+ case 8:
476
+ e_1 = _j.sent();
477
+ _outputs.push(curve.parseUnits('-1', 0));
478
+ return [3 /*break*/, 9];
479
+ case 9:
480
+ _c++;
481
+ return [3 /*break*/, 5];
482
+ case 10:
483
+ for (i = 0; i < _outputs.length; i++) {
484
+ if (_outputs[i] < 0) {
471
485
  console.log("Route ".concat((routesRaw[i].route.map(function (s) { return s.poolId; })).join(" --> "), " is unavailable"));
472
486
  continue;
473
487
  }
474
- routesRaw[i]._output = res[i].value;
488
+ routesRaw[i]._output = _outputs[i];
475
489
  routes.push(routesRaw[i]);
476
490
  }
477
- return [3 /*break*/, 6];
478
- case 6:
491
+ return [3 /*break*/, 11];
492
+ case 11:
479
493
  if (routes.length === 0)
480
494
  return [2 /*return*/, []];
481
495
  if (routes.length === 1)
@@ -486,8 +500,8 @@ var _getBestRoute = memoize(function (inputCoinAddress, outputCoinAddress, amoun
486
500
  axios.get("https://api.curve.fi/api/getGas"),
487
501
  _getUsdRate(ETH_ADDRESS),
488
502
  ])];
489
- case 7:
490
- _e = _f.sent(), gasAmounts = _e[0], outputCoinUsdRate = _e[1], gasData = _e[2], ethUsdRate = _e[3];
503
+ case 12:
504
+ _h = _j.sent(), gasAmounts = _h[0], outputCoinUsdRate = _h[1], gasData = _h[2], ethUsdRate = _h[3];
491
505
  gasPrice = gasData.data.data.gas.standard;
492
506
  expectedAmounts = (routes).map(function (route) { return Number(curve.formatUnits(route._output, outputCoinDecimals)); });
493
507
  expectedAmountsUsd = expectedAmounts.map(function (a) { return a * outputCoinUsdRate; });
@@ -553,7 +567,7 @@ export var swapExpected = function (inputCoin, outputCoin, amount) { return __aw
553
567
  });
554
568
  }); };
555
569
  export var swapPriceImpact = function (inputCoin, outputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
556
- var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _amount, _output, smallAmountIntBN, amountIntBN, contract, _smallAmount, _d, _route, _swapParams, _factorySwapAddresses, _smallOutput, e_1, priceImpactBN;
570
+ var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _amount, _output, smallAmountIntBN, amountIntBN, contract, _smallAmount, _d, _route, _swapParams, _factorySwapAddresses, _smallOutput, e_2, priceImpactBN;
557
571
  return __generator(this, function (_e) {
558
572
  switch (_e.label) {
559
573
  case 0:
@@ -579,7 +593,7 @@ export var swapPriceImpact = function (inputCoin, outputCoin, amount) { return _
579
593
  _smallOutput = _e.sent();
580
594
  return [3 /*break*/, 6];
581
595
  case 4:
582
- e_1 = _e.sent();
596
+ e_2 = _e.sent();
583
597
  _smallAmount = curve.parseUnits("1", inputCoinDecimals); // Dirty hack
584
598
  return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _smallAmount, _factorySwapAddresses, curve.constantOptions)];
585
599
  case 5:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.34.1",
3
+ "version": "2.34.3",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",