@curvefi/api 1.17.0 → 1.19.0

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.
Files changed (42) hide show
  1. package/README.md +57 -0
  2. package/lib/constants/abis/abis-ethereum.js +6 -6
  3. package/lib/constants/abis/json/factory-crypto/factory-crypto-pool-2.json +1112 -0
  4. package/lib/constants/abis/json/factory-crypto.json +635 -0
  5. package/lib/constants/abis/json/factory-v2/DepositZapMetaBtcPolygon.json +197 -0
  6. package/lib/constants/abis/json/factory-v2/DepositZapMetaUsdPolygon.json +197 -0
  7. package/lib/constants/abis/json/factory-v2/MetaBTC.json +919 -0
  8. package/lib/constants/abis/json/factory-v2/MetaBTCBalances.json +932 -0
  9. package/lib/constants/abis/json/factory-v2/MetaBTCBalancesRen.json +932 -0
  10. package/lib/constants/abis/json/factory-v2/MetaBTCRen.json +919 -0
  11. package/lib/constants/abis/json/factory-v2/MetaUSD.json +919 -0
  12. package/lib/constants/abis/json/factory-v2/MetaUSDBalances.json +932 -0
  13. package/lib/constants/abis/json/factory-v2/Plain2Balances.json +845 -0
  14. package/lib/constants/abis/json/factory-v2/Plain2Basic.json +845 -0
  15. package/lib/constants/abis/json/factory-v2/Plain2ETH.json +845 -0
  16. package/lib/constants/abis/json/factory-v2/Plain2Optimized.json +844 -0
  17. package/lib/constants/abis/json/factory-v2/Plain3Balances.json +845 -0
  18. package/lib/constants/abis/json/factory-v2/Plain3Basic.json +845 -0
  19. package/lib/constants/abis/json/factory-v2/Plain3ETH.json +845 -0
  20. package/lib/constants/abis/json/factory-v2/Plain3Optimized.json +845 -0
  21. package/lib/constants/abis/json/factory-v2/Plain4Balances.json +845 -0
  22. package/lib/constants/abis/json/factory-v2/Plain4Basic.json +845 -0
  23. package/lib/constants/abis/json/factory-v2/Plain4ETH.json +845 -0
  24. package/lib/constants/abis/json/factory-v2/Plain4Optimized.json +845 -0
  25. package/lib/constants/abis/json/factory.json +1063 -0
  26. package/lib/constants/aliases.d.ts +4 -0
  27. package/lib/constants/aliases.js +4 -0
  28. package/lib/constants/coins-polygon.js +3 -2
  29. package/lib/curve.d.ts +5 -0
  30. package/lib/curve.js +62 -0
  31. package/lib/factory-crypto.d.ts +32 -0
  32. package/lib/factory-crypto.js +377 -0
  33. package/lib/factory.d.ts +32 -0
  34. package/lib/factory.js +607 -0
  35. package/lib/index.d.ts +7 -0
  36. package/lib/index.js +29 -0
  37. package/lib/interfaces.d.ts +16 -1
  38. package/lib/pools.d.ts +4 -0
  39. package/lib/pools.js +213 -98
  40. package/lib/utils.d.ts +9 -1
  41. package/lib/utils.js +123 -8
  42. package/package.json +4 -2
package/lib/pools.js CHANGED
@@ -81,7 +81,9 @@ var Pool = /** @class */ (function () {
81
81
  _amounts = amounts.map(function (amount, i) {
82
82
  return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]);
83
83
  });
84
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
84
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
85
+ this.isCryptoFactory ||
86
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
85
87
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, isDeposit)];
86
88
  case 1:
87
89
  _expected = _a.sent(); // Lending pools
@@ -192,7 +194,9 @@ var Pool = /** @class */ (function () {
192
194
  _poolUnderlyingBalances = this.name !== 'atricrypto3' ? __spreadArray(__spreadArray([], _poolUnderlyingBalance, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _poolUnderlyingBalance, true);
193
195
  return [3 /*break*/, 6];
194
196
  case 3:
195
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
197
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
198
+ this.isCryptoFactory ||
199
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
196
200
  return [4 /*yield*/, this._getRates()];
197
201
  case 4:
198
202
  _rates_1 = _a.sent();
@@ -236,21 +240,37 @@ var Pool = /** @class */ (function () {
236
240
  case 2:
237
241
  prices = _c.sent();
238
242
  totalLiquidity = balances.reduce(function (liquidity, b, i) { return liquidity + (Number(b) * prices[i]); }, 0);
239
- return [2 /*return*/, String(totalLiquidity)];
243
+ return [2 /*return*/, totalLiquidity.toFixed(8)];
244
+ }
245
+ });
246
+ }); };
247
+ this._getPoolStats = function () { return __awaiter(_this, void 0, void 0, function () {
248
+ var statsUrl, name, key;
249
+ return __generator(this, function (_a) {
250
+ switch (_a.label) {
251
+ case 0:
252
+ statsUrl = this.isFactory ? (0, utils_1._getFactoryStatsUrl)() : (0, utils_1._getStatsUrl)(this.isCrypto);
253
+ name = (this.name === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.name === 'sbtc' ? 'rens' : this.name;
254
+ key = this.isFactory ? this.swap.toLowerCase() : name;
255
+ if (!this.isFactory) return [3 /*break*/, 4];
256
+ if (!(curve_1.curve.chainId === 137)) return [3 /*break*/, 2];
257
+ return [4 /*yield*/, (0, utils_1._getFactoryStatsPolygon)(statsUrl)];
258
+ case 1: return [2 /*return*/, (_a.sent())[key]];
259
+ case 2: return [4 /*yield*/, (0, utils_1._getFactoryStatsEthereum)(statsUrl)];
260
+ case 3: return [2 /*return*/, (_a.sent())[key]];
261
+ case 4: return [4 /*yield*/, (0, utils_1._getStats)(statsUrl)];
262
+ case 5: return [2 /*return*/, (_a.sent())[key]];
240
263
  }
241
264
  });
242
265
  }); };
243
266
  this.getVolume = function () { return __awaiter(_this, void 0, void 0, function () {
244
- var name, statsUrl, volume, usdRate, _a;
267
+ var volume, usdRate, _a;
245
268
  return __generator(this, function (_c) {
246
269
  switch (_c.label) {
247
- case 0:
248
- name = (this.name === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.name === 'sbtc' ? 'rens' : this.name;
249
- statsUrl = (0, utils_1._getStatsUrl)(this.isCrypto);
250
- return [4 /*yield*/, axios_1.default.get(statsUrl)];
270
+ case 0: return [4 /*yield*/, this._getPoolStats()];
251
271
  case 1:
252
- volume = (_c.sent()).data.volume[name] || 0;
253
- if (!this.isCrypto) return [3 /*break*/, 2];
272
+ volume = (_c.sent()).volume;
273
+ if (!(this.isCrypto || (curve_1.curve.chainId === 1 && this.isFactory))) return [3 /*break*/, 2];
254
274
  _a = 1;
255
275
  return [3 /*break*/, 4];
256
276
  case 2: return [4 /*yield*/, (0, utils_1._getUsdRate)(this.referenceAsset)];
@@ -264,16 +284,14 @@ var Pool = /** @class */ (function () {
264
284
  });
265
285
  }); };
266
286
  this.getBaseApy = function () { return __awaiter(_this, void 0, void 0, function () {
267
- var name, statsUrl, apy, formattedApy;
287
+ var apy, multiplier, formattedApy;
268
288
  return __generator(this, function (_a) {
269
289
  switch (_a.label) {
270
- case 0:
271
- name = (this.name === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.name === 'sbtc' ? 'rens' : this.name;
272
- statsUrl = (0, utils_1._getStatsUrl)(this.isCrypto);
273
- return [4 /*yield*/, axios_1.default.get(statsUrl)];
290
+ case 0: return [4 /*yield*/, this._getPoolStats()];
274
291
  case 1:
275
- apy = (_a.sent()).data.apy;
276
- formattedApy = [apy.day[name], apy.week[name], apy.month[name], apy.total[name]].map(function (x) { return (x * 100).toFixed(4); });
292
+ apy = (_a.sent()).apy;
293
+ multiplier = this.isFactory ? 1 : 100;
294
+ formattedApy = [apy.day, apy.week, apy.month, apy.total].map(function (x) { return (x * multiplier).toFixed(4); });
277
295
  return [2 /*return*/, {
278
296
  day: formattedApy[0],
279
297
  week: formattedApy[1],
@@ -288,6 +306,8 @@ var Pool = /** @class */ (function () {
288
306
  return __generator(this, function (_c) {
289
307
  switch (_c.label) {
290
308
  case 0:
309
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
310
+ throw Error("".concat(this.name, " doesn't have gauge"));
291
311
  if (curve_1.curve.chainId === 137)
292
312
  throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use getRewardsApy instead"));
293
313
  gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
@@ -296,6 +316,8 @@ var Pool = /** @class */ (function () {
296
316
  return [4 /*yield*/, this.getTotalLiquidity()];
297
317
  case 1:
298
318
  totalLiquidityUSD = _c.sent();
319
+ if (Number(totalLiquidityUSD) === 0)
320
+ return [2 /*return*/, ["0", "0"]];
299
321
  return [4 /*yield*/, curve_1.curve.multicallProvider.all([
300
322
  gaugeContract.inflation_rate(),
301
323
  gaugeControllerContract.gauge_relative_weight(this.gauge),
@@ -304,6 +326,8 @@ var Pool = /** @class */ (function () {
304
326
  ])];
305
327
  case 2:
306
328
  _a = (_c.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), inflation = _a[0], weight = _a[1], workingSupply = _a[2], totalSupply = _a[3];
329
+ if (Number(workingSupply) === 0)
330
+ return [2 /*return*/, ["0", "0"]];
307
331
  rate = inflation.times(weight).times(31536000).times(0.4).div(workingSupply).times(totalSupply).div(Number(totalLiquidityUSD));
308
332
  return [4 /*yield*/, (0, utils_1._getUsdRate)(curve_1.ALIASES.crv)];
309
333
  case 3:
@@ -409,34 +433,25 @@ var Pool = /** @class */ (function () {
409
433
  });
410
434
  }); };
411
435
  this.addLiquidityIsApproved = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
412
- var spender;
413
436
  return __generator(this, function (_a) {
414
437
  switch (_a.label) {
415
- case 0:
416
- spender = (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name) || this.isMeta) ? this.zap : this.swap;
417
- return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, spender)];
438
+ case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, this.zap || this.swap)];
418
439
  case 1: return [2 /*return*/, _a.sent()];
419
440
  }
420
441
  });
421
442
  }); };
422
443
  this.addLiquidityApproveEstimateGas = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
423
- var spender;
424
444
  return __generator(this, function (_a) {
425
445
  switch (_a.label) {
426
- case 0:
427
- spender = (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name) || this.isMeta) ? this.zap : this.swap;
428
- return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, spender)];
446
+ case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, this.zap || this.swap)];
429
447
  case 1: return [2 /*return*/, _a.sent()];
430
448
  }
431
449
  });
432
450
  }); };
433
451
  this.addLiquidityApprove = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
434
- var spender;
435
452
  return __generator(this, function (_a) {
436
453
  switch (_a.label) {
437
- case 0:
438
- spender = (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name) || this.isMeta) ? this.zap : this.swap;
439
- return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, spender)];
454
+ case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, this.zap || this.swap)];
440
455
  case 1: return [2 /*return*/, _a.sent()];
441
456
  }
442
457
  });
@@ -471,7 +486,9 @@ var Pool = /** @class */ (function () {
471
486
  return [4 /*yield*/, this._addLiquidityZap(_amounts, true)];
472
487
  case 3: return [2 /*return*/, _d.sent()];
473
488
  case 4:
474
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 6];
489
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
490
+ this.isCryptoFactory ||
491
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 6];
475
492
  return [4 /*yield*/, this._addLiquidity(_amounts, true, true)];
476
493
  case 5: return [2 /*return*/, _d.sent()];
477
494
  case 6:
@@ -527,7 +544,9 @@ var Pool = /** @class */ (function () {
527
544
  return [4 /*yield*/, this._addLiquidityZap(_amounts)];
528
545
  case 2: return [2 /*return*/, _a.sent()];
529
546
  case 3:
530
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
547
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
548
+ this.isCryptoFactory ||
549
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
531
550
  return [4 /*yield*/, this._addLiquidity(_amounts, true)];
532
551
  case 4: return [2 /*return*/, _a.sent()];
533
552
  case 5:
@@ -561,7 +580,10 @@ var Pool = /** @class */ (function () {
561
580
  var coinsAllowance, gaugeContract, gaugeAllowance;
562
581
  return __generator(this, function (_a) {
563
582
  switch (_a.label) {
564
- case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.ALIASES.deposit_and_stake)];
583
+ case 0:
584
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
585
+ throw Error("".concat(this.name, " doesn't have gauge"));
586
+ return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.ALIASES.deposit_and_stake)];
565
587
  case 1:
566
588
  coinsAllowance = _a.sent();
567
589
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -578,7 +600,10 @@ var Pool = /** @class */ (function () {
578
600
  var approveCoinsGas, gaugeContract, gaugeAllowance, approveGaugeGas;
579
601
  return __generator(this, function (_a) {
580
602
  switch (_a.label) {
581
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
603
+ case 0:
604
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
605
+ throw Error("".concat(this.name, " doesn't have gauge"));
606
+ return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
582
607
  case 1:
583
608
  approveCoinsGas = _a.sent();
584
609
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -599,7 +624,10 @@ var Pool = /** @class */ (function () {
599
624
  var approveCoinsTx, gaugeContract, gaugeAllowance, gasLimit, approveGaugeTx;
600
625
  return __generator(this, function (_a) {
601
626
  switch (_a.label) {
602
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
627
+ case 0:
628
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
629
+ throw Error("".concat(this.name, " doesn't have gauge"));
630
+ return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
603
631
  case 1:
604
632
  approveCoinsTx = _a.sent();
605
633
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -640,6 +668,8 @@ var Pool = /** @class */ (function () {
640
668
  return __generator(this, function (_p) {
641
669
  switch (_p.label) {
642
670
  case 0:
671
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
672
+ throw Error("".concat(this.name, " doesn't have gauge"));
643
673
  coinAddresses = isUnderlying ? __spreadArray([], this.underlyingCoinAddresses, true) : __spreadArray([], this.coinAddresses, true);
644
674
  coins = isUnderlying ? this.underlyingCoins : this.coinAddresses;
645
675
  decimals = isUnderlying ? this.underlyingDecimals : this.decimals;
@@ -695,7 +725,9 @@ var Pool = /** @class */ (function () {
695
725
  return ethers_1.ethers.utils.parseUnits(amount, decimals[i]);
696
726
  });
697
727
  contract = curve_1.curve.contracts[curve_1.ALIASES.deposit_and_stake].contract;
698
- useUnderlying = isUnderlying && (['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'));
728
+ useUnderlying = isUnderlying && (['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
729
+ this.isCryptoFactory ||
730
+ (curve_1.curve.chainId === 137 && this.name === 'ren'));
699
731
  if (!isUnderlying) return [3 /*break*/, 14];
700
732
  _l = (_k = ethers_1.ethers.utils).parseUnits;
701
733
  return [4 /*yield*/, this.depositAndStakeExpected(amounts)];
@@ -716,7 +748,7 @@ var Pool = /** @class */ (function () {
716
748
  coinAddresses[i] = coinAddresses[i] || ethers_1.ethers.constants.AddressZero;
717
749
  _amounts[i] = _amounts[i] || ethers_1.ethers.BigNumber.from(0);
718
750
  }
719
- return [4 /*yield*/, contract.estimateGas.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isFactory && isUnderlying ? this.swap : ethers_1.ethers.constants.AddressZero, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
751
+ return [4 /*yield*/, contract.estimateGas.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isMetaFactory && isUnderlying ? this.swap : ethers_1.ethers.constants.AddressZero, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
720
752
  case 17:
721
753
  _gas = (_p.sent());
722
754
  if (estimateGas)
@@ -725,7 +757,7 @@ var Pool = /** @class */ (function () {
725
757
  case 18:
726
758
  _p.sent();
727
759
  gasLimit = _gas.mul(200).div(100);
728
- return [4 /*yield*/, contract.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isFactory && isUnderlying ? this.swap : ethers_1.ethers.constants.AddressZero, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit, value: value }))];
760
+ return [4 /*yield*/, contract.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isMetaFactory && isUnderlying ? this.swap : ethers_1.ethers.constants.AddressZero, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit, value: value }))];
729
761
  case 19: return [2 /*return*/, (_p.sent()).hash];
730
762
  }
731
763
  });
@@ -866,7 +898,9 @@ var Pool = /** @class */ (function () {
866
898
  _amounts = amounts.map(function (amount, i) {
867
899
  return ethers_1.ethers.utils.parseUnits(amount, _this.decimals[i]);
868
900
  });
869
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
901
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
902
+ this.isCryptoFactory ||
903
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
870
904
  return [4 /*yield*/, this._addLiquidity(_amounts, false, true)];
871
905
  case 3: return [2 /*return*/, _d.sent()];
872
906
  case 4: return [4 /*yield*/, this._addLiquiditySwap(_amounts, true)];
@@ -894,7 +928,9 @@ var Pool = /** @class */ (function () {
894
928
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
895
929
  case 1:
896
930
  _a.sent();
897
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
931
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
932
+ this.isCryptoFactory ||
933
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
898
934
  return [4 /*yield*/, this._addLiquidity(_amounts, false)];
899
935
  case 2: return [2 /*return*/, _a.sent()];
900
936
  case 3: return [4 /*yield*/, this._addLiquiditySwap(_amounts)];
@@ -933,9 +969,10 @@ var Pool = /** @class */ (function () {
933
969
  return __generator(this, function (_a) {
934
970
  switch (_a.label) {
935
971
  case 0:
936
- if (this.isFake) {
972
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
973
+ throw Error("".concat(this.name, " doesn't have gauge"));
974
+ if (this.isFake)
937
975
  throw Error("".concat(this.name, " pool doesn't have this method"));
938
- }
939
976
  return [4 /*yield*/, (0, utils_1.hasAllowance)(this.coinAddresses, amounts, curve_1.curve.signerAddress, curve_1.ALIASES.deposit_and_stake)];
940
977
  case 1:
941
978
  coinsAllowance = _a.sent();
@@ -954,9 +991,10 @@ var Pool = /** @class */ (function () {
954
991
  return __generator(this, function (_a) {
955
992
  switch (_a.label) {
956
993
  case 0:
957
- if (this.isFake) {
994
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
995
+ throw Error("".concat(this.name, " doesn't have gauge"));
996
+ if (this.isFake)
958
997
  throw Error("".concat(this.name, " pool doesn't have this method"));
959
- }
960
998
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.coinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
961
999
  case 1:
962
1000
  approveCoinsGas = _a.sent();
@@ -979,9 +1017,10 @@ var Pool = /** @class */ (function () {
979
1017
  return __generator(this, function (_a) {
980
1018
  switch (_a.label) {
981
1019
  case 0:
982
- if (this.isFake) {
1020
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1021
+ throw Error("".concat(this.name, " doesn't have gauge"));
1022
+ if (this.isFake)
983
1023
  throw Error("".concat(this.name, " pool doesn't have this method"));
984
- }
985
1024
  return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.coinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
986
1025
  case 1:
987
1026
  approveCoinsTx = _a.sent();
@@ -1033,7 +1072,9 @@ var Pool = /** @class */ (function () {
1033
1072
  switch (_a.label) {
1034
1073
  case 0:
1035
1074
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1036
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
1075
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1076
+ this.isCryptoFactory ||
1077
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
1037
1078
  return [4 /*yield*/, this._calcExpectedUnderlyingAmounts(_lpTokenAmount)];
1038
1079
  case 1:
1039
1080
  _expected = _a.sent(); // Lending pools
@@ -1056,7 +1097,7 @@ var Pool = /** @class */ (function () {
1056
1097
  return __generator(this, function (_a) {
1057
1098
  switch (_a.label) {
1058
1099
  case 0:
1059
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) && !this.isMeta)
1100
+ if (!this.zap)
1060
1101
  return [2 /*return*/, true];
1061
1102
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.zap)];
1062
1103
  case 1: return [2 /*return*/, _a.sent()];
@@ -1067,7 +1108,7 @@ var Pool = /** @class */ (function () {
1067
1108
  return __generator(this, function (_a) {
1068
1109
  switch (_a.label) {
1069
1110
  case 0:
1070
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) && !this.isMeta)
1111
+ if (!this.zap)
1071
1112
  return [2 /*return*/, 0];
1072
1113
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.zap)];
1073
1114
  case 1: return [2 /*return*/, _a.sent()];
@@ -1078,7 +1119,7 @@ var Pool = /** @class */ (function () {
1078
1119
  return __generator(this, function (_a) {
1079
1120
  switch (_a.label) {
1080
1121
  case 0:
1081
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) && !this.isMeta)
1122
+ if (!this.zap)
1082
1123
  return [2 /*return*/, []];
1083
1124
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.zap)];
1084
1125
  case 1: return [2 /*return*/, _a.sent()];
@@ -1110,7 +1151,9 @@ var Pool = /** @class */ (function () {
1110
1151
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount, true)];
1111
1152
  case 4: return [2 /*return*/, _c.sent()];
1112
1153
  case 5:
1113
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1154
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1155
+ this.isCryptoFactory ||
1156
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1114
1157
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true, true)];
1115
1158
  case 6: return [2 /*return*/, _c.sent()];
1116
1159
  case 7:
@@ -1135,7 +1178,9 @@ var Pool = /** @class */ (function () {
1135
1178
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount)];
1136
1179
  case 2: return [2 /*return*/, _a.sent()];
1137
1180
  case 3:
1138
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1181
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1182
+ this.isCryptoFactory ||
1183
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1139
1184
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true)];
1140
1185
  case 4: return [2 /*return*/, _a.sent()];
1141
1186
  case 5:
@@ -1179,7 +1224,9 @@ var Pool = /** @class */ (function () {
1179
1224
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
1180
1225
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
1181
1226
  }
1182
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1227
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1228
+ this.isCryptoFactory ||
1229
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1183
1230
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false, true)];
1184
1231
  case 2: return [2 /*return*/, _a.sent()];
1185
1232
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount, true)];
@@ -1199,7 +1246,9 @@ var Pool = /** @class */ (function () {
1199
1246
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1200
1247
  case 1:
1201
1248
  _a.sent();
1202
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1249
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1250
+ this.isCryptoFactory ||
1251
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1203
1252
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false)];
1204
1253
  case 2: return [2 /*return*/, _a.sent()];
1205
1254
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount)];
@@ -1527,7 +1576,7 @@ var Pool = /** @class */ (function () {
1527
1576
  return __generator(this, function (_a) {
1528
1577
  switch (_a.label) {
1529
1578
  case 0:
1530
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) && !(this.name === 'susd') && !this.isMeta)
1579
+ if (!this.zap)
1531
1580
  return [2 /*return*/, true];
1532
1581
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.zap)];
1533
1582
  case 1: return [2 /*return*/, _a.sent()];
@@ -1538,7 +1587,7 @@ var Pool = /** @class */ (function () {
1538
1587
  return __generator(this, function (_a) {
1539
1588
  switch (_a.label) {
1540
1589
  case 0:
1541
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) && !(this.name === 'susd') && !this.isMeta)
1590
+ if (!this.zap)
1542
1591
  return [2 /*return*/, 0];
1543
1592
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.zap)];
1544
1593
  case 1: return [2 /*return*/, _a.sent()];
@@ -1549,7 +1598,7 @@ var Pool = /** @class */ (function () {
1549
1598
  return __generator(this, function (_a) {
1550
1599
  switch (_a.label) {
1551
1600
  case 0:
1552
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) && !(this.name === 'susd') && !this.isMeta)
1601
+ if (!this.zap)
1553
1602
  return [2 /*return*/, []];
1554
1603
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.zap)];
1555
1604
  case 1: return [2 /*return*/, _a.sent()];
@@ -1582,7 +1631,9 @@ var Pool = /** @class */ (function () {
1582
1631
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i, true)];
1583
1632
  case 4: return [2 /*return*/, _c.sent()];
1584
1633
  case 5:
1585
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1634
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1635
+ this.isCryptoFactory ||
1636
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1586
1637
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true, true)];
1587
1638
  case 6: return [2 /*return*/, _c.sent()];
1588
1639
  case 7: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1606,7 +1657,9 @@ var Pool = /** @class */ (function () {
1606
1657
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i)];
1607
1658
  case 2: return [2 /*return*/, _a.sent()];
1608
1659
  case 3:
1609
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1660
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1661
+ this.isCryptoFactory ||
1662
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1610
1663
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true)];
1611
1664
  case 4: return [2 /*return*/, _a.sent()];
1612
1665
  case 5: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1684,7 +1737,9 @@ var Pool = /** @class */ (function () {
1684
1737
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1685
1738
  }
1686
1739
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1687
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1740
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1741
+ this.isCryptoFactory ||
1742
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1688
1743
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false, true)];
1689
1744
  case 2: return [2 /*return*/, _a.sent()];
1690
1745
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1708,7 +1763,9 @@ var Pool = /** @class */ (function () {
1708
1763
  case 1:
1709
1764
  _a.sent();
1710
1765
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1711
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1766
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1767
+ this.isCryptoFactory ||
1768
+ (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1712
1769
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false)];
1713
1770
  case 2: return [2 /*return*/, _a.sent()];
1714
1771
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1719,7 +1776,10 @@ var Pool = /** @class */ (function () {
1719
1776
  this.gaugeDepositIsApproved = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1720
1777
  return __generator(this, function (_a) {
1721
1778
  switch (_a.label) {
1722
- case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.gauge)];
1779
+ case 0:
1780
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1781
+ throw Error("".concat(this.name, " doesn't have gauge"));
1782
+ return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.gauge)];
1723
1783
  case 1: return [2 /*return*/, _a.sent()];
1724
1784
  }
1725
1785
  });
@@ -1727,7 +1787,10 @@ var Pool = /** @class */ (function () {
1727
1787
  this.gaugeDepositApproveEstimateGas = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1728
1788
  return __generator(this, function (_a) {
1729
1789
  switch (_a.label) {
1730
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.gauge)];
1790
+ case 0:
1791
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1792
+ throw Error("".concat(this.name, " doesn't have gauge"));
1793
+ return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.gauge)];
1731
1794
  case 1: return [2 /*return*/, _a.sent()];
1732
1795
  }
1733
1796
  });
@@ -1735,7 +1798,10 @@ var Pool = /** @class */ (function () {
1735
1798
  this.gaugeDepositApprove = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1736
1799
  return __generator(this, function (_a) {
1737
1800
  switch (_a.label) {
1738
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.gauge)];
1801
+ case 0:
1802
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1803
+ throw Error("".concat(this.name, " doesn't have gauge"));
1804
+ return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.gauge)];
1739
1805
  case 1: return [2 /*return*/, _a.sent()];
1740
1806
  }
1741
1807
  });
@@ -1745,6 +1811,8 @@ var Pool = /** @class */ (function () {
1745
1811
  return __generator(this, function (_a) {
1746
1812
  switch (_a.label) {
1747
1813
  case 0:
1814
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1815
+ throw Error("".concat(this.name, " doesn't have gauge"));
1748
1816
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1749
1817
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
1750
1818
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
@@ -1756,6 +1824,8 @@ var Pool = /** @class */ (function () {
1756
1824
  return __generator(this, function (_a) {
1757
1825
  switch (_a.label) {
1758
1826
  case 0:
1827
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1828
+ throw Error("".concat(this.name, " doesn't have gauge"));
1759
1829
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1760
1830
  return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.gauge)];
1761
1831
  case 1:
@@ -1773,6 +1843,8 @@ var Pool = /** @class */ (function () {
1773
1843
  return __generator(this, function (_a) {
1774
1844
  switch (_a.label) {
1775
1845
  case 0:
1846
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1847
+ throw Error("".concat(this.name, " doesn't have gauge"));
1776
1848
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1777
1849
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1778
1850
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
@@ -1784,10 +1856,12 @@ var Pool = /** @class */ (function () {
1784
1856
  return __generator(this, function (_a) {
1785
1857
  switch (_a.label) {
1786
1858
  case 0:
1859
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1860
+ throw Error("".concat(this.name, " doesn't have gauge"));
1787
1861
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1788
1862
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1789
1863
  case 1:
1790
- gasLimit = (_a.sent()).mul(180).div(100);
1864
+ gasLimit = (_a.sent()).mul(200).div(100);
1791
1865
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1792
1866
  case 2: return [2 /*return*/, (_a.sent()).hash];
1793
1867
  }
@@ -1800,6 +1874,8 @@ var Pool = /** @class */ (function () {
1800
1874
  return __generator(this, function (_d) {
1801
1875
  switch (_d.label) {
1802
1876
  case 0:
1877
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1878
+ throw Error("".concat(this.name, " doesn't have gauge"));
1803
1879
  if (curve_1.curve.chainId !== 1)
1804
1880
  throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use gaugeClaimableRewards instead"));
1805
1881
  address = address || curve_1.curve.signerAddress;
@@ -1817,6 +1893,8 @@ var Pool = /** @class */ (function () {
1817
1893
  return __generator(this, function (_a) {
1818
1894
  switch (_a.label) {
1819
1895
  case 0:
1896
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1897
+ throw Error("".concat(this.name, " doesn't have gauge"));
1820
1898
  if (curve_1.curve.chainId !== 1)
1821
1899
  throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use gaugeClaimRewards instead"));
1822
1900
  return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.minter].contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
@@ -1836,6 +1914,8 @@ var Pool = /** @class */ (function () {
1836
1914
  return __generator(this, function (_h) {
1837
1915
  switch (_h.label) {
1838
1916
  case 0:
1917
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1918
+ throw Error("".concat(this.name, " doesn't have gauge"));
1839
1919
  address = address || curve_1.curve.signerAddress;
1840
1920
  if (!address)
1841
1921
  throw Error("Need to connect wallet or pass address into args");
@@ -1899,6 +1979,8 @@ var Pool = /** @class */ (function () {
1899
1979
  return __generator(this, function (_a) {
1900
1980
  switch (_a.label) {
1901
1981
  case 0:
1982
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1983
+ throw Error("".concat(this.name, " doesn't have gauge"));
1902
1984
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
1903
1985
  if (!("claim_rewards()" in gaugeContract))
1904
1986
  throw Error("".concat(this.name, " pool doesn't have such method"));
@@ -1918,8 +2000,12 @@ var Pool = /** @class */ (function () {
1918
2000
  return __awaiter(_this, void 0, void 0, function () {
1919
2001
  return __generator(this, function (_a) {
1920
2002
  switch (_a.label) {
1921
- case 0: return [4 /*yield*/, this._balances.apply(this, __spreadArray([__spreadArray(__spreadArray(['lpToken', 'gauge'], this.underlyingCoins, true), this.coins, true), __spreadArray(__spreadArray([this.lpToken, this.gauge], this.underlyingCoinAddresses, true), this.coinAddresses, true)], addresses, false))];
2003
+ case 0:
2004
+ if (!(this.gauge === ethers_1.ethers.constants.AddressZero)) return [3 /*break*/, 2];
2005
+ return [4 /*yield*/, this._balances.apply(this, __spreadArray([__spreadArray(__spreadArray(['lpToken'], this.underlyingCoins, true), this.coins, true), __spreadArray(__spreadArray([this.lpToken], this.underlyingCoinAddresses, true), this.coinAddresses, true)], addresses, false))];
1922
2006
  case 1: return [2 /*return*/, _a.sent()];
2007
+ case 2: return [4 /*yield*/, this._balances.apply(this, __spreadArray([__spreadArray(__spreadArray(['lpToken', 'gauge'], this.underlyingCoins, true), this.coins, true), __spreadArray(__spreadArray([this.lpToken, this.gauge], this.underlyingCoinAddresses, true), this.coinAddresses, true)], addresses, false))];
2008
+ case 3: return [2 /*return*/, _a.sent()];
1923
2009
  }
1924
2010
  });
1925
2011
  });
@@ -1932,8 +2018,12 @@ var Pool = /** @class */ (function () {
1932
2018
  return __awaiter(_this, void 0, void 0, function () {
1933
2019
  return __generator(this, function (_a) {
1934
2020
  switch (_a.label) {
1935
- case 0: return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken', 'gauge'], [this.lpToken, this.gauge]], addresses, false))];
2021
+ case 0:
2022
+ if (!(this.gauge === ethers_1.ethers.constants.AddressZero)) return [3 /*break*/, 2];
2023
+ return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken'], [this.lpToken]], addresses, false))];
1936
2024
  case 1: return [2 /*return*/, _a.sent()];
2025
+ case 2: return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken', 'gauge'], [this.lpToken, this.gauge]], addresses, false))];
2026
+ case 3: return [2 /*return*/, _a.sent()];
1937
2027
  }
1938
2028
  });
1939
2029
  });
@@ -2000,7 +2090,8 @@ var Pool = /** @class */ (function () {
2000
2090
  return __generator(this, function (_a) {
2001
2091
  switch (_a.label) {
2002
2092
  case 0:
2003
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2093
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2094
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2004
2095
  i = this._getCoinIdx(inputCoin);
2005
2096
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
2006
2097
  case 1: return [2 /*return*/, _a.sent()];
@@ -2012,7 +2103,8 @@ var Pool = /** @class */ (function () {
2012
2103
  return __generator(this, function (_a) {
2013
2104
  switch (_a.label) {
2014
2105
  case 0:
2015
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2106
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2107
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2016
2108
  i = this._getCoinIdx(inputCoin);
2017
2109
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
2018
2110
  case 1: return [2 /*return*/, _a.sent()];
@@ -2024,7 +2116,8 @@ var Pool = /** @class */ (function () {
2024
2116
  return __generator(this, function (_a) {
2025
2117
  switch (_a.label) {
2026
2118
  case 0:
2027
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2119
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2120
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2028
2121
  i = this._getCoinIdx(inputCoin);
2029
2122
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
2030
2123
  case 1: return [2 /*return*/, _a.sent()];
@@ -2038,7 +2131,8 @@ var Pool = /** @class */ (function () {
2038
2131
  return __generator(this, function (_d) {
2039
2132
  switch (_d.label) {
2040
2133
  case 0:
2041
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2134
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2135
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2042
2136
  i = this._getCoinIdx(inputCoin);
2043
2137
  j = this._getCoinIdx(outputCoin);
2044
2138
  _c = (_a = Object).values;
@@ -2066,8 +2160,12 @@ var Pool = /** @class */ (function () {
2066
2160
  if (!(this.name === "tricrypto2")) return [3 /*break*/, 5];
2067
2161
  return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2068
2162
  case 4: return [2 /*return*/, (_d.sent()).toNumber()];
2069
- case 5: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2163
+ case 5:
2164
+ if (!(curve_1.curve.chainId === 137 && this.isFactory)) return [3 /*break*/, 7];
2165
+ return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2070
2166
  case 6: return [2 /*return*/, (_d.sent()).toNumber()];
2167
+ case 7: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2168
+ case 8: return [2 /*return*/, (_d.sent()).toNumber()];
2071
2169
  }
2072
2170
  });
2073
2171
  });
@@ -2075,11 +2173,12 @@ var Pool = /** @class */ (function () {
2075
2173
  this.exchange = function (inputCoin, outputCoin, amount, maxSlippage) {
2076
2174
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
2077
2175
  return __awaiter(_this, void 0, void 0, function () {
2078
- var contractAddress, i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, exchangeMethod, value, gasLimit_1, estimatedGas, gasLimit;
2176
+ var contractAddress, i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, exchangeMethod, value, gasLimit_1, gasLimit_2, estimatedGas, gasLimit;
2079
2177
  return __generator(this, function (_a) {
2080
2178
  switch (_a.label) {
2081
2179
  case 0:
2082
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2180
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2181
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2083
2182
  i = this._getCoinIdx(inputCoin);
2084
2183
  j = this._getCoinIdx(outputCoin);
2085
2184
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.underlyingDecimals[i]);
@@ -2104,14 +2203,21 @@ var Pool = /** @class */ (function () {
2104
2203
  gasLimit_1 = (_a.sent()).mul(130).div(100);
2105
2204
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_1 }))];
2106
2205
  case 5: return [2 /*return*/, (_a.sent()).hash];
2107
- case 6: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2206
+ case 6:
2207
+ if (!(curve_1.curve.chainId === 137 && this.isFactory)) return [3 /*break*/, 9];
2208
+ return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2108
2209
  case 7:
2210
+ gasLimit_2 = (_a.sent()).mul(140).div(100);
2211
+ return [4 /*yield*/, contract[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_2 }))];
2212
+ case 8: return [2 /*return*/, (_a.sent()).hash];
2213
+ case 9: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2214
+ case 10:
2109
2215
  estimatedGas = _a.sent();
2110
2216
  gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
2111
2217
  estimatedGas.mul(160).div(100) :
2112
2218
  estimatedGas.mul(130).div(100);
2113
2219
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
2114
- case 8: return [2 /*return*/, (_a.sent()).hash];
2220
+ case 11: return [2 /*return*/, (_a.sent()).hash];
2115
2221
  }
2116
2222
  });
2117
2223
  });
@@ -2221,7 +2327,7 @@ var Pool = /** @class */ (function () {
2221
2327
  this.exchangeWrapped = function (inputCoin, outputCoin, amount, maxSlippage) {
2222
2328
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
2223
2329
  return __awaiter(_this, void 0, void 0, function () {
2224
- var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit_2, estimatedGas, gasLimit;
2330
+ var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit_3, estimatedGas, gasLimit;
2225
2331
  return __generator(this, function (_a) {
2226
2332
  switch (_a.label) {
2227
2333
  case 0:
@@ -2248,8 +2354,8 @@ var Pool = /** @class */ (function () {
2248
2354
  if (!(this.name === 'tricrypto2')) return [3 /*break*/, 6];
2249
2355
  return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2250
2356
  case 4:
2251
- gasLimit_2 = (_a.sent()).mul(130).div(100);
2252
- return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_2 }))];
2357
+ gasLimit_3 = (_a.sent()).mul(130).div(100);
2358
+ return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_3 }))];
2253
2359
  case 5: return [2 /*return*/, (_a.sent()).hash];
2254
2360
  case 6: return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2255
2361
  case 7:
@@ -2273,6 +2379,8 @@ var Pool = /** @class */ (function () {
2273
2379
  return __generator(this, function (_e) {
2274
2380
  switch (_e.label) {
2275
2381
  case 0:
2382
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
2383
+ throw Error("".concat(this.name, " doesn't have gauge"));
2276
2384
  if (addresses.length == 1 && Array.isArray(addresses[0]))
2277
2385
  addresses = addresses[0];
2278
2386
  votingEscrowContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
@@ -2310,6 +2418,8 @@ var Pool = /** @class */ (function () {
2310
2418
  return __generator(this, function (_j) {
2311
2419
  switch (_j.label) {
2312
2420
  case 0:
2421
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
2422
+ throw Error("".concat(this.name, " doesn't have gauge"));
2313
2423
  if (accounts.length == 1 && Array.isArray(accounts[0]))
2314
2424
  accounts = accounts[0];
2315
2425
  votingEscrowContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
@@ -2370,6 +2480,8 @@ var Pool = /** @class */ (function () {
2370
2480
  return __generator(this, function (_c) {
2371
2481
  switch (_c.label) {
2372
2482
  case 0:
2483
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
2484
+ throw Error("".concat(this.name, " doesn't have gauge"));
2373
2485
  gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
2374
2486
  return [4 /*yield*/, curve_1.curve.multicallProvider.all([
2375
2487
  gaugeContract.working_balances(address),
@@ -2704,7 +2816,7 @@ var Pool = /** @class */ (function () {
2704
2816
  switch (_a.label) {
2705
2817
  case 0:
2706
2818
  contract = curve_1.curve.contracts[this.swap].contract;
2707
- if (!["eurtusd", "xautusd", "crveth", "cvxeth", "spelleth", "teth"].includes(this.name)) return [3 /*break*/, 2];
2819
+ if (!(["eurtusd", "xautusd", "crveth", "cvxeth", "spelleth", "teth"].includes(this.name) || this.isCryptoFactory)) return [3 /*break*/, 2];
2708
2820
  return [4 /*yield*/, contract.calc_token_amount(_amounts, curve_1.curve.constantOptions)];
2709
2821
  case 1: return [2 /*return*/, _a.sent()];
2710
2822
  case 2: return [4 /*yield*/, contract.calc_token_amount(_amounts, isDeposit, curve_1.curve.constantOptions)];
@@ -2721,7 +2833,7 @@ var Pool = /** @class */ (function () {
2721
2833
  switch (_a.label) {
2722
2834
  case 0:
2723
2835
  contract = curve_1.curve.contracts[this.zap].contract;
2724
- if (!this.isFactory) return [3 /*break*/, 2];
2836
+ if (!this.isMetaFactory) return [3 /*break*/, 2];
2725
2837
  return [4 /*yield*/, contract.calc_token_amount(this.swap, _amounts, isDeposit, curve_1.curve.constantOptions)];
2726
2838
  case 1: return [2 /*return*/, _a.sent()];
2727
2839
  case 2:
@@ -2817,7 +2929,7 @@ var Pool = /** @class */ (function () {
2817
2929
  this._addLiquidityMetaZap = function (_amounts, estimateGas) {
2818
2930
  if (estimateGas === void 0) { estimateGas = false; }
2819
2931
  return __awaiter(_this, void 0, void 0, function () {
2820
- var _minMintAmount, ethIndex, value, contract, gas_1, gasLimit_3, gas, gasLimit;
2932
+ var _minMintAmount, ethIndex, value, contract, gas_1, gasLimit_4, gas, gasLimit;
2821
2933
  return __generator(this, function (_a) {
2822
2934
  switch (_a.label) {
2823
2935
  case 0:
@@ -2832,15 +2944,15 @@ var Pool = /** @class */ (function () {
2832
2944
  ethIndex = (0, utils_1.getEthIndex)(this.underlyingCoinAddresses);
2833
2945
  value = _amounts[ethIndex] || ethers_1.ethers.BigNumber.from(0);
2834
2946
  contract = curve_1.curve.contracts[this.zap].contract;
2835
- if (!this.isFactory) return [3 /*break*/, 6];
2947
+ if (!this.isMetaFactory) return [3 /*break*/, 6];
2836
2948
  return [4 /*yield*/, contract.estimateGas.add_liquidity(this.swap, _amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2837
2949
  case 4:
2838
2950
  gas_1 = _a.sent();
2839
2951
  if (estimateGas) {
2840
2952
  return [2 /*return*/, gas_1.toNumber()];
2841
2953
  }
2842
- gasLimit_3 = gas_1.mul(130).div(100);
2843
- return [4 /*yield*/, contract.add_liquidity(this.swap, _amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_3, value: value }))];
2954
+ gasLimit_4 = gas_1.mul(130).div(100);
2955
+ return [4 /*yield*/, contract.add_liquidity(this.swap, _amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_4, value: value }))];
2844
2956
  case 5: return [2 /*return*/, (_a.sent()).hash];
2845
2957
  case 6: return [4 /*yield*/, contract.estimateGas.add_liquidity(_amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2846
2958
  case 7:
@@ -3043,7 +3155,7 @@ var Pool = /** @class */ (function () {
3043
3155
  this._removeLiquidityMetaZap = function (_lpTokenAmount, estimateGas) {
3044
3156
  if (estimateGas === void 0) { estimateGas = false; }
3045
3157
  return __awaiter(_this, void 0, void 0, function () {
3046
- var _minAmounts, contract, gas_2, gasLimit_4, gas, gasLimit;
3158
+ var _minAmounts, contract, gas_2, gasLimit_5, gas, gasLimit;
3047
3159
  return __generator(this, function (_a) {
3048
3160
  switch (_a.label) {
3049
3161
  case 0:
@@ -3056,15 +3168,15 @@ var Pool = /** @class */ (function () {
3056
3168
  case 3:
3057
3169
  _minAmounts = _a.sent();
3058
3170
  contract = curve_1.curve.contracts[this.zap].contract;
3059
- if (!this.isFactory) return [3 /*break*/, 6];
3171
+ if (!this.isMetaFactory) return [3 /*break*/, 6];
3060
3172
  return [4 /*yield*/, contract.estimateGas.remove_liquidity(this.swap, _lpTokenAmount, _minAmounts, curve_1.curve.constantOptions)];
3061
3173
  case 4:
3062
3174
  gas_2 = _a.sent();
3063
3175
  if (estimateGas) {
3064
3176
  return [2 /*return*/, gas_2.toNumber()];
3065
3177
  }
3066
- gasLimit_4 = gas_2.mul(130).div(100);
3067
- return [4 /*yield*/, contract.remove_liquidity(this.swap, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_4 }))];
3178
+ gasLimit_5 = gas_2.mul(130).div(100);
3179
+ return [4 /*yield*/, contract.remove_liquidity(this.swap, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_5 }))];
3068
3180
  case 5: return [2 /*return*/, (_a.sent()).hash];
3069
3181
  case 6: return [4 /*yield*/, contract.estimateGas.remove_liquidity(_lpTokenAmount, _minAmounts, curve_1.curve.constantOptions)];
3070
3182
  case 7:
@@ -3167,7 +3279,7 @@ var Pool = /** @class */ (function () {
3167
3279
  this._removeLiquidityImbalanceMetaZap = function (_amounts, estimateGas) {
3168
3280
  if (estimateGas === void 0) { estimateGas = false; }
3169
3281
  return __awaiter(_this, void 0, void 0, function () {
3170
- var _maxBurnAmount, contract, gas_3, gasLimit_5, gas, gasLimit;
3282
+ var _maxBurnAmount, contract, gas_3, gasLimit_6, gas, gasLimit;
3171
3283
  return __generator(this, function (_a) {
3172
3284
  switch (_a.label) {
3173
3285
  case 0: return [4 /*yield*/, this._calcLpTokenAmountZap(_amounts, false)];
@@ -3180,15 +3292,15 @@ var Pool = /** @class */ (function () {
3180
3292
  _a.label = 3;
3181
3293
  case 3:
3182
3294
  contract = curve_1.curve.contracts[this.zap].contract;
3183
- if (!this.isFactory) return [3 /*break*/, 6];
3295
+ if (!this.isMetaFactory) return [3 /*break*/, 6];
3184
3296
  return [4 /*yield*/, contract.estimateGas.remove_liquidity_imbalance(this.swap, _amounts, _maxBurnAmount, curve_1.curve.constantOptions)];
3185
3297
  case 4:
3186
3298
  gas_3 = _a.sent();
3187
3299
  if (estimateGas) {
3188
3300
  return [2 /*return*/, gas_3.toNumber()];
3189
3301
  }
3190
- gasLimit_5 = gas_3.mul(130).div(100);
3191
- return [4 /*yield*/, contract.remove_liquidity_imbalance(this.swap, _amounts, _maxBurnAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_5 }))];
3302
+ gasLimit_6 = gas_3.mul(130).div(100);
3303
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(this.swap, _amounts, _maxBurnAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_6 }))];
3192
3304
  case 5: return [2 /*return*/, (_a.sent())];
3193
3305
  case 6: return [4 /*yield*/, contract.estimateGas.remove_liquidity_imbalance(_amounts, _maxBurnAmount, curve_1.curve.constantOptions)];
3194
3306
  case 7:
@@ -3253,7 +3365,7 @@ var Pool = /** @class */ (function () {
3253
3365
  switch (_a.label) {
3254
3366
  case 0:
3255
3367
  contract = curve_1.curve.contracts[this.zap].contract;
3256
- if (!this.isFactory) return [3 /*break*/, 2];
3368
+ if (!this.isMetaFactory) return [3 /*break*/, 2];
3257
3369
  return [4 /*yield*/, contract.calc_withdraw_one_coin(this.swap, _lpTokenAmount, i, curve_1.curve.constantOptions)];
3258
3370
  case 1: return [2 /*return*/, (_a.sent())];
3259
3371
  case 2: return [4 /*yield*/, contract.calc_withdraw_one_coin(_lpTokenAmount, i, curve_1.curve.constantOptions)];
@@ -3298,7 +3410,7 @@ var Pool = /** @class */ (function () {
3298
3410
  this._removeLiquidityOneCoinZap = function (_lpTokenAmount, i, estimateGas) {
3299
3411
  if (estimateGas === void 0) { estimateGas = false; }
3300
3412
  return __awaiter(_this, void 0, void 0, function () {
3301
- var _minAmount, _a, contract, gas_4, gasLimit_6, gas, gasLimit;
3413
+ var _minAmount, _a, contract, gas_4, gasLimit_7, gas, gasLimit;
3302
3414
  return __generator(this, function (_c) {
3303
3415
  switch (_c.label) {
3304
3416
  case 0:
@@ -3321,15 +3433,15 @@ var Pool = /** @class */ (function () {
3321
3433
  _minAmount = _a;
3322
3434
  _minAmount = _minAmount.mul(99).div(100);
3323
3435
  contract = curve_1.curve.contracts[this.zap].contract;
3324
- if (!this.isFactory) return [3 /*break*/, 9];
3436
+ if (!this.isMetaFactory) return [3 /*break*/, 9];
3325
3437
  return [4 /*yield*/, contract.estimateGas.remove_liquidity_one_coin(this.swap, _lpTokenAmount, i, _minAmount, curve_1.curve.constantOptions)];
3326
3438
  case 7:
3327
3439
  gas_4 = _c.sent();
3328
3440
  if (estimateGas) {
3329
3441
  return [2 /*return*/, gas_4.toNumber()];
3330
3442
  }
3331
- gasLimit_6 = gas_4.mul(130).div(100);
3332
- return [4 /*yield*/, contract.remove_liquidity_one_coin(this.swap, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_6 }))];
3443
+ gasLimit_7 = gas_4.mul(130).div(100);
3444
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(this.swap, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_7 }))];
3333
3445
  case 8: return [2 /*return*/, (_c.sent()).hash];
3334
3446
  case 9: return [4 /*yield*/, contract.estimateGas.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, curve_1.curve.constantOptions)];
3335
3447
  case 10:
@@ -3403,7 +3515,7 @@ var Pool = /** @class */ (function () {
3403
3515
  }
3404
3516
  });
3405
3517
  }); };
3406
- var poolData = curve_1.POOLS_DATA[name];
3518
+ var poolData = __assign(__assign(__assign({}, curve_1.POOLS_DATA), (curve_1.curve.constants.FACTORY_POOLS_DATA || {})), (curve_1.curve.constants.CRYPTO_FACTORY_POOLS_DATA || {}))[name];
3407
3519
  this.name = name;
3408
3520
  this.referenceAsset = poolData.reference_asset;
3409
3521
  this.swap = poolData.swap_address;
@@ -3422,6 +3534,9 @@ var Pool = /** @class */ (function () {
3422
3534
  this.isFake = poolData.is_fake || false;
3423
3535
  this.isCrypto = poolData.is_crypto || false;
3424
3536
  this.isFactory = poolData.is_factory || false;
3537
+ this.isMetaFactory = poolData.is_meta_factory || false;
3538
+ this.isPlainFactory = poolData.is_plain_factory || false;
3539
+ this.isCryptoFactory = poolData.is_crypto_factory || false;
3425
3540
  this.basePool = poolData.base_pool || '';
3426
3541
  this.rewardTokens = poolData.reward_tokens || [];
3427
3542
  this.estimateGas = {