@curvefi/api 2.4.2 → 2.5.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.
@@ -197,8 +197,9 @@ function setCryptoFactoryCoinsContracts(coinAddresses) {
197
197
  }
198
198
  function getCryptoFactoryUnderlyingCoinAddresses(coinAddresses) {
199
199
  return __awaiter(this, void 0, void 0, function () {
200
+ var _this = this;
200
201
  return __generator(this, function (_a) {
201
- return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === constants_1.WETH_ADDRESS ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : c; }); })];
202
+ return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === constants_1.NATIVE_TOKENS[_this.chainId].wrappedAddress ? constants_1.NATIVE_TOKEN_ADDRESS : c; }); })];
202
203
  });
203
204
  });
204
205
  }
@@ -221,11 +222,13 @@ function getExistingCoinAddressNameDict() {
221
222
  _loop_1(poolData);
222
223
  }
223
224
  if (this.chainId === 1)
224
- dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "ETH";
225
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "ETH";
225
226
  if (this.chainId === 137)
226
- dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "MATIC";
227
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "MATIC";
228
+ if (this.chainId === 250)
229
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "FTM";
227
230
  if (this.chainId === 43114)
228
- dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "AVAX";
231
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "AVAX";
229
232
  return dict;
230
233
  }
231
234
  function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
@@ -259,6 +262,7 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
259
262
  newCoinAddresses.forEach(function (addr, i) {
260
263
  coinAddrNamesDict[addr] = names[i];
261
264
  });
265
+ coinAddrNamesDict[constants_1.NATIVE_TOKEN_ADDRESS] = constants_1.NATIVE_TOKENS[this.chainId].symbol;
262
266
  return [2 /*return*/, coinAddrNamesDict];
263
267
  }
264
268
  });
@@ -266,18 +270,18 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
266
270
  }
267
271
  function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDict) {
268
272
  return __awaiter(this, void 0, void 0, function () {
269
- var flattenedCoinAddresses, newCoinAddresses, coinAddrNamesDict, _i, flattenedCoinAddresses_3, addr, calls, decimals;
273
+ var flattenedCoinAddresses, newCoinAddresses, coinAddressDecimalsDict, _i, flattenedCoinAddresses_3, addr, calls, decimals;
270
274
  var _this = this;
271
275
  return __generator(this, function (_a) {
272
276
  switch (_a.label) {
273
277
  case 0:
274
278
  flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses)));
275
279
  newCoinAddresses = [];
276
- coinAddrNamesDict = {};
280
+ coinAddressDecimalsDict = {};
277
281
  for (_i = 0, flattenedCoinAddresses_3 = flattenedCoinAddresses; _i < flattenedCoinAddresses_3.length; _i++) {
278
282
  addr = flattenedCoinAddresses_3[_i];
279
283
  if (addr in existingCoinAddressDecimalsDict) {
280
- coinAddrNamesDict[addr] = existingCoinAddressDecimalsDict[addr];
284
+ coinAddressDecimalsDict[addr] = existingCoinAddressDecimalsDict[addr];
281
285
  }
282
286
  else {
283
287
  newCoinAddresses.push(addr);
@@ -290,10 +294,10 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
290
294
  case 1:
291
295
  decimals = (_a.sent()).map(function (_d) { return Number(ethers_1.ethers.utils.formatUnits(_d, 0)); });
292
296
  newCoinAddresses.forEach(function (addr, i) {
293
- coinAddrNamesDict[addr] = decimals[i];
297
+ coinAddressDecimalsDict[addr] = decimals[i];
294
298
  });
295
- coinAddrNamesDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 18;
296
- return [2 /*return*/, coinAddrNamesDict];
299
+ coinAddressDecimalsDict[constants_1.NATIVE_TOKEN_ADDRESS] = 18;
300
+ return [2 /*return*/, coinAddressDecimalsDict];
297
301
  }
298
302
  });
299
303
  });
@@ -63,6 +63,7 @@ var BLACK_LIST = {
63
63
  "0xe4199bc5c5c1f63dba47b56b6db7144c51cf0bf8",
64
64
  "0x88c4d6534165510b2e2caf0a130d4f70aa4b6d71",
65
65
  ],
66
+ 250: [],
66
67
  43114: [],
67
68
  };
68
69
  var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
@@ -255,6 +256,8 @@ function getExistingCoinAddressNameDict() {
255
256
  dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "ETH";
256
257
  if (this.chainId === 137)
257
258
  dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "MATIC";
259
+ if (this.chainId === 250)
260
+ dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "FTM";
258
261
  if (this.chainId === 43114)
259
262
  dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "AVAX";
260
263
  return dict;
@@ -47,7 +47,7 @@ export declare class PoolTemplate {
47
47
  withdrawImbalanceApprove: (amounts: (number | string)[]) => Promise<number>;
48
48
  withdrawImbalance: (amounts: (number | string)[]) => Promise<number>;
49
49
  withdrawImbalanceWrapped: (amounts: (number | string)[]) => Promise<number>;
50
- withdrawOneCoinApprove: (lpTokenAmount: number | string, coin: string | number) => Promise<number>;
50
+ withdrawOneCoinApprove: (lpTokenAmount: number | string) => Promise<number>;
51
51
  withdrawOneCoin: (lpTokenAmount: number | string, coin: string | number) => Promise<number>;
52
52
  withdrawOneCoinWrapped: (lpTokenAmount: number | string, coin: string | number) => Promise<number>;
53
53
  swapApprove: (inputCoin: string | number, amount: number | string) => Promise<number>;
@@ -86,6 +86,7 @@ export declare class PoolTemplate {
86
86
  allCoinBalances: (...addresses: string[] | string[][]) => Promise<IDict<IDict<string>> | IDict<string>>;
87
87
  };
88
88
  constructor(id: string);
89
+ rewardsOnly(): boolean;
89
90
  private statsParameters;
90
91
  private statsWrappedBalances;
91
92
  private statsUnderlyingBalances;
@@ -203,8 +203,8 @@ var PoolTemplate = /** @class */ (function () {
203
203
  return __generator(this, function (_e) {
204
204
  switch (_e.label) {
205
205
  case 0:
206
- if (this.gauge === ethers_1.ethers.constants.AddressZero)
207
- throw Error("".concat(this.name, " doesn't have gauge"));
206
+ if (this.rewardsOnly())
207
+ throw Error("".concat(this.name, " has Rewards-Only Gauge. Use getRewardsApy instead"));
208
208
  return [4 /*yield*/, this.statsTotalLiquidity()];
209
209
  case 1:
210
210
  totalLiquidityUSD = _e.sent();
@@ -255,12 +255,14 @@ var PoolTemplate = /** @class */ (function () {
255
255
  });
256
256
  }); };
257
257
  this.statsRewardsApy = function () { return __awaiter(_this, void 0, void 0, function () {
258
- var apy, rewardTokens, _i, rewardTokens_1, rewardToken, gaugeContract, totalLiquidityUSD, rewardRate, rewardData, periodFinish, inflation, baseApy, network, promises, _a, mainPoolsRewards, allTypesExtendedPoolData, rewards, _c, _d, extendedPoolData, _e, _f, pool;
258
+ var apy, rewardTokens, _i, rewardTokens_1, rewardToken, contract, totalLiquidityUSD, rewardRate, rewardData, periodFinish, inflation, baseApy, network, promises, _a, mainPoolsRewards, allTypesExtendedPoolData, rewards, _c, _d, extendedPoolData, _e, _f, pool;
259
259
  var _g;
260
260
  return __generator(this, function (_h) {
261
261
  switch (_h.label) {
262
262
  case 0:
263
- if (![137, 43114].includes(curve_1.curve.chainId)) return [3 /*break*/, 8];
263
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
264
+ return [2 /*return*/, []];
265
+ if (![137, 250, 43114].includes(curve_1.curve.chainId)) return [3 /*break*/, 8];
264
266
  apy = [];
265
267
  return [4 /*yield*/, this.rewardTokens()];
266
268
  case 1:
@@ -270,14 +272,14 @@ var PoolTemplate = /** @class */ (function () {
270
272
  case 2:
271
273
  if (!(_i < rewardTokens_1.length)) return [3 /*break*/, 7];
272
274
  rewardToken = rewardTokens_1[_i];
273
- gaugeContract = curve_1.curve.contracts[this.gauge].contract;
275
+ contract = curve_1.curve.contracts[this.sRewardContract || this.gauge].contract;
274
276
  return [4 /*yield*/, this.statsTotalLiquidity()];
275
277
  case 3:
276
278
  totalLiquidityUSD = _h.sent();
277
279
  return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken.token)];
278
280
  case 4:
279
281
  rewardRate = _h.sent();
280
- return [4 /*yield*/, gaugeContract.reward_data(rewardToken.token, curve_1.curve.constantOptions)];
282
+ return [4 /*yield*/, contract.reward_data(rewardToken.token, curve_1.curve.constantOptions)];
281
283
  case 5:
282
284
  rewardData = _h.sent();
283
285
  periodFinish = Number(ethers_1.ethers.utils.formatUnits(rewardData.period_finish, 0)) * 1000;
@@ -329,8 +331,8 @@ var PoolTemplate = /** @class */ (function () {
329
331
  return __generator(this, function (_e) {
330
332
  switch (_e.label) {
331
333
  case 0:
332
- if (this.gauge === ethers_1.ethers.constants.AddressZero)
333
- throw Error("".concat(this.name, " doesn't have gauge"));
334
+ if (this.rewardsOnly())
335
+ throw Error("".concat(this.name, " has Rewards-Only Gauge. Use rewardsProfit instead"));
334
336
  address = address || curve_1.curve.signerAddress;
335
337
  if (!address)
336
338
  throw Error("Need to connect wallet or pass address into args");
@@ -948,6 +950,12 @@ var PoolTemplate = /** @class */ (function () {
948
950
  allCoinBalances: this.walletAllCoinBalances.bind(this),
949
951
  };
950
952
  }
953
+ PoolTemplate.prototype.rewardsOnly = function () {
954
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
955
+ throw Error("".concat(this.name, " doesn't have gauge"));
956
+ var gaugeContract = curve_1.curve.contracts[this.gauge].contract;
957
+ return !('inflation_rate()' in gaugeContract || 'inflation_rate(uint256)' in gaugeContract);
958
+ };
951
959
  PoolTemplate.prototype.statsWrappedBalances = function () {
952
960
  return __awaiter(this, void 0, void 0, function () {
953
961
  var swapContract, contractCalls, _wrappedBalances;
@@ -1336,9 +1344,8 @@ var PoolTemplate = /** @class */ (function () {
1336
1344
  return __generator(this, function (_d) {
1337
1345
  switch (_d.label) {
1338
1346
  case 0:
1339
- if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1340
- throw Error("claimableCrv method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1341
- }
1347
+ if (this.rewardsOnly())
1348
+ throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimableRewards instead"));
1342
1349
  address = address || curve_1.curve.signerAddress;
1343
1350
  if (!address)
1344
1351
  throw Error("Need to connect wallet or pass address into args");
@@ -1354,9 +1361,8 @@ var PoolTemplate = /** @class */ (function () {
1354
1361
  return __generator(this, function (_a) {
1355
1362
  switch (_a.label) {
1356
1363
  case 0:
1357
- if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1358
- throw Error("claimCrv method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1359
- }
1364
+ if (this.rewardsOnly())
1365
+ throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
1360
1366
  return [4 /*yield*/, curve_1.curve.contracts[curve_1.curve.constants.ALIASES.minter].contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
1361
1367
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
1362
1368
  }
@@ -1369,9 +1375,8 @@ var PoolTemplate = /** @class */ (function () {
1369
1375
  return __generator(this, function (_a) {
1370
1376
  switch (_a.label) {
1371
1377
  case 0:
1372
- if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1373
- throw Error("claimCrv method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1374
- }
1378
+ if (this.rewardsOnly())
1379
+ throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
1375
1380
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.minter].contract;
1376
1381
  return [4 /*yield*/, contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
1377
1382
  case 1:
@@ -1625,7 +1630,7 @@ var PoolTemplate = /** @class */ (function () {
1625
1630
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1626
1631
  throw Error("depositAndStakeWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1627
1632
  }
1628
- if (this.isFake)
1633
+ if (this.isPlain || this.isFake)
1629
1634
  throw Error("depositAndStakeWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1630
1635
  return [4 /*yield*/, this.depositWrappedExpected(amounts)];
1631
1636
  case 1: return [2 /*return*/, _a.sent()];
@@ -1641,7 +1646,7 @@ var PoolTemplate = /** @class */ (function () {
1641
1646
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1642
1647
  throw Error("depositAndStakeWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1643
1648
  }
1644
- if (this.isFake)
1649
+ if (this.isPlain || this.isFake)
1645
1650
  throw Error("depositAndStakeWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1646
1651
  return [4 /*yield*/, this.depositWrappedBonus(amounts)];
1647
1652
  case 1: return [2 /*return*/, _a.sent()];
@@ -1658,7 +1663,7 @@ var PoolTemplate = /** @class */ (function () {
1658
1663
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1659
1664
  throw Error("depositAndStakeWrappedIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1660
1665
  }
1661
- if (this.isFake)
1666
+ if (this.isPlain || this.isFake)
1662
1667
  throw Error("depositAndStakeWrappedIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1663
1668
  return [4 /*yield*/, (0, utils_1.hasAllowance)(this.wrappedCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.curve.constants.ALIASES.deposit_and_stake)];
1664
1669
  case 1:
@@ -1683,7 +1688,7 @@ var PoolTemplate = /** @class */ (function () {
1683
1688
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1684
1689
  throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1685
1690
  }
1686
- if (this.isFake)
1691
+ if (this.isPlain || this.isFake)
1687
1692
  throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1688
1693
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.wrappedCoinAddresses, amounts, curve_1.curve.constants.ALIASES.deposit_and_stake)];
1689
1694
  case 1:
@@ -1712,7 +1717,7 @@ var PoolTemplate = /** @class */ (function () {
1712
1717
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1713
1718
  throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1714
1719
  }
1715
- if (this.isFake)
1720
+ if (this.isPlain || this.isFake)
1716
1721
  throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1717
1722
  return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.wrappedCoinAddresses, amounts, curve_1.curve.constants.ALIASES.deposit_and_stake)];
1718
1723
  case 1:
@@ -1743,7 +1748,7 @@ var PoolTemplate = /** @class */ (function () {
1743
1748
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1744
1749
  throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1745
1750
  }
1746
- if (this.isFake)
1751
+ if (this.isPlain || this.isFake)
1747
1752
  throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1748
1753
  return [4 /*yield*/, this._depositAndStake(amounts, false, true)];
1749
1754
  case 1: return [2 /*return*/, _a.sent()];
@@ -1759,7 +1764,7 @@ var PoolTemplate = /** @class */ (function () {
1759
1764
  if (this.gauge === ethers_1.ethers.constants.AddressZero) {
1760
1765
  throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1761
1766
  }
1762
- if (this.isFake)
1767
+ if (this.isPlain || this.isFake)
1763
1768
  throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
1764
1769
  return [4 /*yield*/, this._depositAndStake(amounts, false, false)];
1765
1770
  case 1: return [2 /*return*/, _a.sent()];
@@ -2536,7 +2541,7 @@ var PoolTemplate = /** @class */ (function () {
2536
2541
  });
2537
2542
  };
2538
2543
  PoolTemplate.prototype._swapContractAddress = function () {
2539
- return (this.isCrypto && this.isMeta) || ([137, 43114].includes(curve_1.curve.chainId) && this.isMetaFactory) ? this.zap : this.address;
2544
+ return (this.isCrypto && this.isMeta) || (this.isMetaFactory && (new PoolTemplate(this.basePool).isLending)) ? this.zap : this.address;
2540
2545
  };
2541
2546
  PoolTemplate.prototype.swapIsApproved = function (inputCoin, amount) {
2542
2547
  return __awaiter(this, void 0, void 0, function () {
@@ -16,7 +16,6 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.getPool = void 0;
19
- var curve_1 = require("../curve");
20
19
  var PoolTemplate_1 = require("./PoolTemplate");
21
20
  var poolBalancesMixin_1 = require("./mixins/poolBalancesMixin");
22
21
  var depositBalancedAmountsMixins_1 = require("./mixins/depositBalancedAmountsMixins");
@@ -230,7 +229,7 @@ var getPool = function (poolId) {
230
229
  if (poolId === 'tricrypto2') {
231
230
  Object.assign(Pool.prototype, swapMixins_1.swapTricrypto2Mixin);
232
231
  }
233
- else if ([137, 43114].includes(curve_1.curve.chainId) && poolDummy.isMetaFactory) {
232
+ else if (poolDummy.isMetaFactory && (0, exports.getPool)(poolDummy.basePool).isLending) {
234
233
  Object.assign(Pool.prototype, swapMixins_1.swapMetaFactoryMixin);
235
234
  }
236
235
  else {
package/lib/router.js CHANGED
@@ -71,7 +71,7 @@ var pools_1 = require("./pools");
71
71
  var IMBALANCED_POOLS = [];
72
72
  // Inspired by Dijkstra's algorithm
73
73
  var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __awaiter(void 0, void 0, void 0, function () {
74
- var ALL_POOLS, basePoolsSet, _i, ALL_POOLS_1, pool, basePoolIds, markedCoins, curCoins, nextCoins, routes, step, _a, curCoins_1, inCoin, _b, ALL_POOLS_2, _c, poolId, poolData, wrapped_coin_addresses, underlying_coin_addresses, meta_coin_addresses, token_address, is_lending, inCoinIndexes, j, swapType, _d, _e, inCoinRoute, swapType, _f, _h, inCoinRoute, j, tvl, _j, swapType, _k, _l, inCoinRoute, poolAddress, j, tvl, _m, swapType, _o, _p, inCoinRoute, j, tvl, _q, swapType, _r, _s, inCoinRoute, tvl, _t, swapType, _u, _v, inCoinRoute;
74
+ var ALL_POOLS, basePoolsSet, _i, ALL_POOLS_1, pool, basePoolIds, markedCoins, curCoins, nextCoins, routes, step, _a, curCoins_1, inCoin, _b, ALL_POOLS_2, _c, poolId, poolData, wrapped_coin_addresses, underlying_coin_addresses, base_pool, meta_coin_addresses, token_address, is_lending, inCoinIndexes, j, swapType, _d, _e, inCoinRoute, swapType, _f, _h, inCoinRoute, j, tvl, _j, swapType, _k, _l, inCoinRoute, poolAddress, j, tvl, _m, swapType, _o, _p, inCoinRoute, j, tvl, _q, swapType, _r, _s, inCoinRoute, tvl, _t, swapType, _u, _v, inCoinRoute;
75
75
  var _w;
76
76
  var _x, _y, _z, _0, _1, _2, _3, _4;
77
77
  return __generator(this, function (_5) {
@@ -109,8 +109,8 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
109
109
  _c = ALL_POOLS_2[_b], poolId = _c[0], poolData = _c[1];
110
110
  wrapped_coin_addresses = poolData.wrapped_coin_addresses.map(function (a) { return a.toLowerCase(); });
111
111
  underlying_coin_addresses = poolData.underlying_coin_addresses.map(function (a) { return a.toLowerCase(); });
112
- meta_coin_addresses = poolData.is_meta ?
113
- curve_1.curve.constants.POOLS_DATA[poolData.base_pool].underlying_coin_addresses.map(function (a) { return a.toLowerCase(); }) : [];
112
+ base_pool = poolData.is_meta ? curve_1.curve.constants.POOLS_DATA[poolData.base_pool] : null;
113
+ meta_coin_addresses = base_pool ? base_pool.underlying_coin_addresses.map(function (a) { return a.toLowerCase(); }) : [];
114
114
  token_address = poolData.token_address.toLowerCase();
115
115
  is_lending = (_x = poolData.is_lending) !== null && _x !== void 0 ? _x : false;
116
116
  inCoinIndexes = {
@@ -214,7 +214,7 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
214
214
  j++;
215
215
  return [3 /*break*/, 4];
216
216
  case 7:
217
- poolAddress = (poolData.is_crypto && poolData.is_meta) || ([137, 43114].includes(curve_1.curve.chainId) && poolData.is_factory) ?
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
219
  if (!(wrapped_coin_addresses.join("|") !== underlying_coin_addresses.join("|") && inCoinIndexes.underlying_coin >= 0)) return [3 /*break*/, 11];
220
220
  j = 0;
@@ -279,7 +279,7 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
279
279
  // Skip imbalanced pools
280
280
  if (IMBALANCED_POOLS.includes(poolId))
281
281
  return [3 /*break*/, 14];
282
- swapType = ([137, 43114].includes(curve_1.curve.chainId) && poolData.is_factory) ? 5 : poolData.is_crypto ? 4 : 2;
282
+ swapType = (base_pool && base_pool.is_meta && poolData.is_factory) ? 5 : poolData.is_crypto ? 4 : 2;
283
283
  for (_r = 0, _s = routes[inCoin]; _r < _s.length; _r++) {
284
284
  inCoinRoute = _s[_r];
285
285
  routes[meta_coin_addresses[j]] = ((_2 = routes[meta_coin_addresses[j]]) !== null && _2 !== void 0 ? _2 : []).concat([__spreadArray(__spreadArray([], inCoinRoute, true), [
@@ -316,7 +316,7 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
316
316
  // Skip imbalanced pools
317
317
  if (IMBALANCED_POOLS.includes(poolId))
318
318
  return [3 /*break*/, 17];
319
- swapType = ([137, 43114].includes(curve_1.curve.chainId) && poolData.is_factory) ? 5 : poolData.is_crypto ? 4 : 2;
319
+ swapType = (base_pool && base_pool.is_meta && poolData.is_factory) ? 5 : poolData.is_crypto ? 4 : 2;
320
320
  for (_u = 0, _v = routes[inCoin]; _u < _v.length; _u++) {
321
321
  inCoinRoute = _v[_u];
322
322
  routes[wrapped_coin_addresses[0]] = ((_3 = routes[wrapped_coin_addresses[0]]) !== null && _3 !== void 0 ? _3 : []).concat([__spreadArray(__spreadArray([], inCoinRoute, true), [
package/lib/utils.js CHANGED
@@ -453,11 +453,13 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
453
453
  chainName = {
454
454
  1: 'ethereum',
455
455
  137: 'polygon-pos',
456
+ 250: 'fantom',
456
457
  43114: 'avalanche',
457
458
  }[curve_1.curve.chainId];
458
459
  nativeTokenName = {
459
460
  1: 'ethereum',
460
461
  137: 'matic-network',
462
+ 250: 'fantom',
461
463
  43114: 'avalanche-2',
462
464
  }[curve_1.curve.chainId];
463
465
  if (chainName === undefined) {
@@ -522,6 +524,7 @@ var getTVL = function (chainId) {
522
524
  network = (_a = {
523
525
  1: "ethereum",
524
526
  137: "polygon",
527
+ 250: "fantom",
525
528
  43114: "avalanche",
526
529
  }[chainId]) !== null && _a !== void 0 ? _a : "ethereum";
527
530
  promises = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.4.2",
3
+ "version": "2.5.1",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",