@curvefi/api 1.17.2 → 1.18.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 (38) hide show
  1. package/README.md +37 -0
  2. package/lib/constants/abis/abis-ethereum.js +6 -6
  3. package/lib/constants/abis/json/factory-v2/DepositZapMetaBtcPolygon.json +197 -0
  4. package/lib/constants/abis/json/factory-v2/DepositZapMetaUsdPolygon.json +197 -0
  5. package/lib/constants/abis/json/factory-v2/MetaBTC.json +919 -0
  6. package/lib/constants/abis/json/factory-v2/MetaBTCBalances.json +932 -0
  7. package/lib/constants/abis/json/factory-v2/MetaBTCBalancesRen.json +932 -0
  8. package/lib/constants/abis/json/factory-v2/MetaBTCRen.json +919 -0
  9. package/lib/constants/abis/json/factory-v2/MetaUSD.json +919 -0
  10. package/lib/constants/abis/json/factory-v2/MetaUSDBalances.json +932 -0
  11. package/lib/constants/abis/json/factory-v2/Plain2Balances.json +845 -0
  12. package/lib/constants/abis/json/factory-v2/Plain2Basic.json +845 -0
  13. package/lib/constants/abis/json/factory-v2/Plain2ETH.json +845 -0
  14. package/lib/constants/abis/json/factory-v2/Plain2Optimized.json +844 -0
  15. package/lib/constants/abis/json/factory-v2/Plain3Balances.json +845 -0
  16. package/lib/constants/abis/json/factory-v2/Plain3Basic.json +845 -0
  17. package/lib/constants/abis/json/factory-v2/Plain3ETH.json +845 -0
  18. package/lib/constants/abis/json/factory-v2/Plain3Optimized.json +845 -0
  19. package/lib/constants/abis/json/factory-v2/Plain4Balances.json +845 -0
  20. package/lib/constants/abis/json/factory-v2/Plain4Basic.json +845 -0
  21. package/lib/constants/abis/json/factory-v2/Plain4ETH.json +845 -0
  22. package/lib/constants/abis/json/factory-v2/Plain4Optimized.json +845 -0
  23. package/lib/constants/abis/json/factory.json +1063 -0
  24. package/lib/constants/aliases.d.ts +2 -0
  25. package/lib/constants/aliases.js +2 -0
  26. package/lib/constants/coins-polygon.js +3 -2
  27. package/lib/curve.d.ts +3 -0
  28. package/lib/curve.js +34 -0
  29. package/lib/factory.d.ts +32 -0
  30. package/lib/factory.js +607 -0
  31. package/lib/index.d.ts +3 -0
  32. package/lib/index.js +14 -0
  33. package/lib/interfaces.d.ts +15 -1
  34. package/lib/pools.d.ts +3 -0
  35. package/lib/pools.js +149 -62
  36. package/lib/utils.d.ts +7 -1
  37. package/lib/utils.js +109 -8
  38. package/package.json +4 -2
package/lib/pools.js CHANGED
@@ -240,17 +240,33 @@ var Pool = /** @class */ (function () {
240
240
  }
241
241
  });
242
242
  }); };
243
+ this._getPoolStats = function () { return __awaiter(_this, void 0, void 0, function () {
244
+ var statsUrl, name, key;
245
+ return __generator(this, function (_a) {
246
+ switch (_a.label) {
247
+ case 0:
248
+ statsUrl = this.isFactory ? (0, utils_1._getFactoryStatsUrl)() : (0, utils_1._getStatsUrl)(this.isCrypto);
249
+ name = (this.name === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.name === 'sbtc' ? 'rens' : this.name;
250
+ key = this.isFactory ? this.swap.toLowerCase() : name;
251
+ if (!this.isFactory) return [3 /*break*/, 4];
252
+ if (!(curve_1.curve.chainId === 137)) return [3 /*break*/, 2];
253
+ return [4 /*yield*/, (0, utils_1._getFactoryStatsPolygon)(statsUrl)];
254
+ case 1: return [2 /*return*/, (_a.sent())[key]];
255
+ case 2: return [4 /*yield*/, (0, utils_1._getFactoryStatsEthereum)(statsUrl)];
256
+ case 3: return [2 /*return*/, (_a.sent())[key]];
257
+ case 4: return [4 /*yield*/, (0, utils_1._getStats)(statsUrl)];
258
+ case 5: return [2 /*return*/, (_a.sent())[key]];
259
+ }
260
+ });
261
+ }); };
243
262
  this.getVolume = function () { return __awaiter(_this, void 0, void 0, function () {
244
- var name, statsUrl, volume, usdRate, _a;
263
+ var volume, usdRate, _a;
245
264
  return __generator(this, function (_c) {
246
265
  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)];
266
+ case 0: return [4 /*yield*/, this._getPoolStats()];
251
267
  case 1:
252
- volume = (_c.sent()).data.volume[name] || 0;
253
- if (!this.isCrypto) return [3 /*break*/, 2];
268
+ volume = (_c.sent()).volume;
269
+ if (!(this.isCrypto || (curve_1.curve.chainId === 1 && this.isFactory))) return [3 /*break*/, 2];
254
270
  _a = 1;
255
271
  return [3 /*break*/, 4];
256
272
  case 2: return [4 /*yield*/, (0, utils_1._getUsdRate)(this.referenceAsset)];
@@ -264,16 +280,14 @@ var Pool = /** @class */ (function () {
264
280
  });
265
281
  }); };
266
282
  this.getBaseApy = function () { return __awaiter(_this, void 0, void 0, function () {
267
- var name, statsUrl, apy, formattedApy;
283
+ var apy, multiplier, formattedApy;
268
284
  return __generator(this, function (_a) {
269
285
  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)];
286
+ case 0: return [4 /*yield*/, this._getPoolStats()];
274
287
  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); });
288
+ apy = (_a.sent()).apy;
289
+ multiplier = this.isFactory ? 1 : 100;
290
+ formattedApy = [apy.day, apy.week, apy.month, apy.total].map(function (x) { return (x * multiplier).toFixed(4); });
277
291
  return [2 /*return*/, {
278
292
  day: formattedApy[0],
279
293
  week: formattedApy[1],
@@ -288,6 +302,8 @@ var Pool = /** @class */ (function () {
288
302
  return __generator(this, function (_c) {
289
303
  switch (_c.label) {
290
304
  case 0:
305
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
306
+ throw Error("".concat(this.name, " doesn't have gauge"));
291
307
  if (curve_1.curve.chainId === 137)
292
308
  throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use getRewardsApy instead"));
293
309
  gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
@@ -552,7 +568,10 @@ var Pool = /** @class */ (function () {
552
568
  var coinsAllowance, gaugeContract, gaugeAllowance;
553
569
  return __generator(this, function (_a) {
554
570
  switch (_a.label) {
555
- case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.ALIASES.deposit_and_stake)];
571
+ case 0:
572
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
573
+ throw Error("".concat(this.name, " doesn't have gauge"));
574
+ return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.ALIASES.deposit_and_stake)];
556
575
  case 1:
557
576
  coinsAllowance = _a.sent();
558
577
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -569,7 +588,10 @@ var Pool = /** @class */ (function () {
569
588
  var approveCoinsGas, gaugeContract, gaugeAllowance, approveGaugeGas;
570
589
  return __generator(this, function (_a) {
571
590
  switch (_a.label) {
572
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
591
+ case 0:
592
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
593
+ throw Error("".concat(this.name, " doesn't have gauge"));
594
+ return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
573
595
  case 1:
574
596
  approveCoinsGas = _a.sent();
575
597
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -590,7 +612,10 @@ var Pool = /** @class */ (function () {
590
612
  var approveCoinsTx, gaugeContract, gaugeAllowance, gasLimit, approveGaugeTx;
591
613
  return __generator(this, function (_a) {
592
614
  switch (_a.label) {
593
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
615
+ case 0:
616
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
617
+ throw Error("".concat(this.name, " doesn't have gauge"));
618
+ return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
594
619
  case 1:
595
620
  approveCoinsTx = _a.sent();
596
621
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -631,6 +656,8 @@ var Pool = /** @class */ (function () {
631
656
  return __generator(this, function (_p) {
632
657
  switch (_p.label) {
633
658
  case 0:
659
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
660
+ throw Error("".concat(this.name, " doesn't have gauge"));
634
661
  coinAddresses = isUnderlying ? __spreadArray([], this.underlyingCoinAddresses, true) : __spreadArray([], this.coinAddresses, true);
635
662
  coins = isUnderlying ? this.underlyingCoins : this.coinAddresses;
636
663
  decimals = isUnderlying ? this.underlyingDecimals : this.decimals;
@@ -707,7 +734,7 @@ var Pool = /** @class */ (function () {
707
734
  coinAddresses[i] = coinAddresses[i] || ethers_1.ethers.constants.AddressZero;
708
735
  _amounts[i] = _amounts[i] || ethers_1.ethers.BigNumber.from(0);
709
736
  }
710
- 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 }))];
737
+ 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 }))];
711
738
  case 17:
712
739
  _gas = (_p.sent());
713
740
  if (estimateGas)
@@ -716,7 +743,7 @@ var Pool = /** @class */ (function () {
716
743
  case 18:
717
744
  _p.sent();
718
745
  gasLimit = _gas.mul(200).div(100);
719
- 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 }))];
746
+ 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 }))];
720
747
  case 19: return [2 /*return*/, (_p.sent()).hash];
721
748
  }
722
749
  });
@@ -924,9 +951,10 @@ var Pool = /** @class */ (function () {
924
951
  return __generator(this, function (_a) {
925
952
  switch (_a.label) {
926
953
  case 0:
927
- if (this.isFake) {
954
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
955
+ throw Error("".concat(this.name, " doesn't have gauge"));
956
+ if (this.isFake)
928
957
  throw Error("".concat(this.name, " pool doesn't have this method"));
929
- }
930
958
  return [4 /*yield*/, (0, utils_1.hasAllowance)(this.coinAddresses, amounts, curve_1.curve.signerAddress, curve_1.ALIASES.deposit_and_stake)];
931
959
  case 1:
932
960
  coinsAllowance = _a.sent();
@@ -945,9 +973,10 @@ var Pool = /** @class */ (function () {
945
973
  return __generator(this, function (_a) {
946
974
  switch (_a.label) {
947
975
  case 0:
948
- if (this.isFake) {
976
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
977
+ throw Error("".concat(this.name, " doesn't have gauge"));
978
+ if (this.isFake)
949
979
  throw Error("".concat(this.name, " pool doesn't have this method"));
950
- }
951
980
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.coinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
952
981
  case 1:
953
982
  approveCoinsGas = _a.sent();
@@ -970,9 +999,10 @@ var Pool = /** @class */ (function () {
970
999
  return __generator(this, function (_a) {
971
1000
  switch (_a.label) {
972
1001
  case 0:
973
- if (this.isFake) {
1002
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1003
+ throw Error("".concat(this.name, " doesn't have gauge"));
1004
+ if (this.isFake)
974
1005
  throw Error("".concat(this.name, " pool doesn't have this method"));
975
- }
976
1006
  return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.coinAddresses, amounts, curve_1.ALIASES.deposit_and_stake)];
977
1007
  case 1:
978
1008
  approveCoinsTx = _a.sent();
@@ -1710,7 +1740,10 @@ var Pool = /** @class */ (function () {
1710
1740
  this.gaugeDepositIsApproved = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1711
1741
  return __generator(this, function (_a) {
1712
1742
  switch (_a.label) {
1713
- case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.gauge)];
1743
+ case 0:
1744
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1745
+ throw Error("".concat(this.name, " doesn't have gauge"));
1746
+ return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.gauge)];
1714
1747
  case 1: return [2 /*return*/, _a.sent()];
1715
1748
  }
1716
1749
  });
@@ -1718,7 +1751,10 @@ var Pool = /** @class */ (function () {
1718
1751
  this.gaugeDepositApproveEstimateGas = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1719
1752
  return __generator(this, function (_a) {
1720
1753
  switch (_a.label) {
1721
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.gauge)];
1754
+ case 0:
1755
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1756
+ throw Error("".concat(this.name, " doesn't have gauge"));
1757
+ return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.gauge)];
1722
1758
  case 1: return [2 /*return*/, _a.sent()];
1723
1759
  }
1724
1760
  });
@@ -1726,7 +1762,10 @@ var Pool = /** @class */ (function () {
1726
1762
  this.gaugeDepositApprove = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1727
1763
  return __generator(this, function (_a) {
1728
1764
  switch (_a.label) {
1729
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.gauge)];
1765
+ case 0:
1766
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1767
+ throw Error("".concat(this.name, " doesn't have gauge"));
1768
+ return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.gauge)];
1730
1769
  case 1: return [2 /*return*/, _a.sent()];
1731
1770
  }
1732
1771
  });
@@ -1736,6 +1775,8 @@ var Pool = /** @class */ (function () {
1736
1775
  return __generator(this, function (_a) {
1737
1776
  switch (_a.label) {
1738
1777
  case 0:
1778
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1779
+ throw Error("".concat(this.name, " doesn't have gauge"));
1739
1780
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1740
1781
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
1741
1782
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
@@ -1747,6 +1788,8 @@ var Pool = /** @class */ (function () {
1747
1788
  return __generator(this, function (_a) {
1748
1789
  switch (_a.label) {
1749
1790
  case 0:
1791
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1792
+ throw Error("".concat(this.name, " doesn't have gauge"));
1750
1793
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1751
1794
  return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.gauge)];
1752
1795
  case 1:
@@ -1764,6 +1807,8 @@ var Pool = /** @class */ (function () {
1764
1807
  return __generator(this, function (_a) {
1765
1808
  switch (_a.label) {
1766
1809
  case 0:
1810
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1811
+ throw Error("".concat(this.name, " doesn't have gauge"));
1767
1812
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1768
1813
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1769
1814
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
@@ -1775,10 +1820,12 @@ var Pool = /** @class */ (function () {
1775
1820
  return __generator(this, function (_a) {
1776
1821
  switch (_a.label) {
1777
1822
  case 0:
1823
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1824
+ throw Error("".concat(this.name, " doesn't have gauge"));
1778
1825
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1779
1826
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1780
1827
  case 1:
1781
- gasLimit = (_a.sent()).mul(180).div(100);
1828
+ gasLimit = (_a.sent()).mul(200).div(100);
1782
1829
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1783
1830
  case 2: return [2 /*return*/, (_a.sent()).hash];
1784
1831
  }
@@ -1791,6 +1838,8 @@ var Pool = /** @class */ (function () {
1791
1838
  return __generator(this, function (_d) {
1792
1839
  switch (_d.label) {
1793
1840
  case 0:
1841
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1842
+ throw Error("".concat(this.name, " doesn't have gauge"));
1794
1843
  if (curve_1.curve.chainId !== 1)
1795
1844
  throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use gaugeClaimableRewards instead"));
1796
1845
  address = address || curve_1.curve.signerAddress;
@@ -1808,6 +1857,8 @@ var Pool = /** @class */ (function () {
1808
1857
  return __generator(this, function (_a) {
1809
1858
  switch (_a.label) {
1810
1859
  case 0:
1860
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1861
+ throw Error("".concat(this.name, " doesn't have gauge"));
1811
1862
  if (curve_1.curve.chainId !== 1)
1812
1863
  throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use gaugeClaimRewards instead"));
1813
1864
  return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.minter].contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
@@ -1827,6 +1878,8 @@ var Pool = /** @class */ (function () {
1827
1878
  return __generator(this, function (_h) {
1828
1879
  switch (_h.label) {
1829
1880
  case 0:
1881
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1882
+ throw Error("".concat(this.name, " doesn't have gauge"));
1830
1883
  address = address || curve_1.curve.signerAddress;
1831
1884
  if (!address)
1832
1885
  throw Error("Need to connect wallet or pass address into args");
@@ -1890,6 +1943,8 @@ var Pool = /** @class */ (function () {
1890
1943
  return __generator(this, function (_a) {
1891
1944
  switch (_a.label) {
1892
1945
  case 0:
1946
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
1947
+ throw Error("".concat(this.name, " doesn't have gauge"));
1893
1948
  gaugeContract = curve_1.curve.contracts[this.gauge].contract;
1894
1949
  if (!("claim_rewards()" in gaugeContract))
1895
1950
  throw Error("".concat(this.name, " pool doesn't have such method"));
@@ -1909,8 +1964,12 @@ var Pool = /** @class */ (function () {
1909
1964
  return __awaiter(_this, void 0, void 0, function () {
1910
1965
  return __generator(this, function (_a) {
1911
1966
  switch (_a.label) {
1912
- 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))];
1967
+ case 0:
1968
+ if (!(this.gauge === ethers_1.ethers.constants.AddressZero)) return [3 /*break*/, 2];
1969
+ 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))];
1913
1970
  case 1: return [2 /*return*/, _a.sent()];
1971
+ 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))];
1972
+ case 3: return [2 /*return*/, _a.sent()];
1914
1973
  }
1915
1974
  });
1916
1975
  });
@@ -1923,8 +1982,12 @@ var Pool = /** @class */ (function () {
1923
1982
  return __awaiter(_this, void 0, void 0, function () {
1924
1983
  return __generator(this, function (_a) {
1925
1984
  switch (_a.label) {
1926
- case 0: return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken', 'gauge'], [this.lpToken, this.gauge]], addresses, false))];
1985
+ case 0:
1986
+ if (!(this.gauge === ethers_1.ethers.constants.AddressZero)) return [3 /*break*/, 2];
1987
+ return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken'], [this.lpToken]], addresses, false))];
1927
1988
  case 1: return [2 /*return*/, _a.sent()];
1989
+ case 2: return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken', 'gauge'], [this.lpToken, this.gauge]], addresses, false))];
1990
+ case 3: return [2 /*return*/, _a.sent()];
1928
1991
  }
1929
1992
  });
1930
1993
  });
@@ -1991,7 +2054,8 @@ var Pool = /** @class */ (function () {
1991
2054
  return __generator(this, function (_a) {
1992
2055
  switch (_a.label) {
1993
2056
  case 0:
1994
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2057
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2058
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
1995
2059
  i = this._getCoinIdx(inputCoin);
1996
2060
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
1997
2061
  case 1: return [2 /*return*/, _a.sent()];
@@ -2003,7 +2067,8 @@ var Pool = /** @class */ (function () {
2003
2067
  return __generator(this, function (_a) {
2004
2068
  switch (_a.label) {
2005
2069
  case 0:
2006
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2070
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2071
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2007
2072
  i = this._getCoinIdx(inputCoin);
2008
2073
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
2009
2074
  case 1: return [2 /*return*/, _a.sent()];
@@ -2015,7 +2080,8 @@ var Pool = /** @class */ (function () {
2015
2080
  return __generator(this, function (_a) {
2016
2081
  switch (_a.label) {
2017
2082
  case 0:
2018
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2083
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2084
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2019
2085
  i = this._getCoinIdx(inputCoin);
2020
2086
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
2021
2087
  case 1: return [2 /*return*/, _a.sent()];
@@ -2029,7 +2095,8 @@ var Pool = /** @class */ (function () {
2029
2095
  return __generator(this, function (_d) {
2030
2096
  switch (_d.label) {
2031
2097
  case 0:
2032
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2098
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2099
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2033
2100
  i = this._getCoinIdx(inputCoin);
2034
2101
  j = this._getCoinIdx(outputCoin);
2035
2102
  _c = (_a = Object).values;
@@ -2057,8 +2124,12 @@ var Pool = /** @class */ (function () {
2057
2124
  if (!(this.name === "tricrypto2")) return [3 /*break*/, 5];
2058
2125
  return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2059
2126
  case 4: return [2 /*return*/, (_d.sent()).toNumber()];
2060
- case 5: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2127
+ case 5:
2128
+ if (!(curve_1.curve.chainId === 137 && this.isFactory)) return [3 /*break*/, 7];
2129
+ return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2061
2130
  case 6: return [2 /*return*/, (_d.sent()).toNumber()];
2131
+ case 7: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2132
+ case 8: return [2 /*return*/, (_d.sent()).toNumber()];
2062
2133
  }
2063
2134
  });
2064
2135
  });
@@ -2066,11 +2137,12 @@ var Pool = /** @class */ (function () {
2066
2137
  this.exchange = function (inputCoin, outputCoin, amount, maxSlippage) {
2067
2138
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
2068
2139
  return __awaiter(_this, void 0, void 0, function () {
2069
- var contractAddress, i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, exchangeMethod, value, gasLimit_1, estimatedGas, gasLimit;
2140
+ var contractAddress, i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, exchangeMethod, value, gasLimit_1, gasLimit_2, estimatedGas, gasLimit;
2070
2141
  return __generator(this, function (_a) {
2071
2142
  switch (_a.label) {
2072
2143
  case 0:
2073
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2144
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2145
+ (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2074
2146
  i = this._getCoinIdx(inputCoin);
2075
2147
  j = this._getCoinIdx(outputCoin);
2076
2148
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.underlyingDecimals[i]);
@@ -2095,14 +2167,21 @@ var Pool = /** @class */ (function () {
2095
2167
  gasLimit_1 = (_a.sent()).mul(130).div(100);
2096
2168
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_1 }))];
2097
2169
  case 5: return [2 /*return*/, (_a.sent()).hash];
2098
- case 6: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2170
+ case 6:
2171
+ if (!(curve_1.curve.chainId === 137 && this.isFactory)) return [3 /*break*/, 9];
2172
+ return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2099
2173
  case 7:
2174
+ gasLimit_2 = (_a.sent()).mul(140).div(100);
2175
+ return [4 /*yield*/, contract[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_2 }))];
2176
+ case 8: return [2 /*return*/, (_a.sent()).hash];
2177
+ case 9: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2178
+ case 10:
2100
2179
  estimatedGas = _a.sent();
2101
2180
  gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
2102
2181
  estimatedGas.mul(160).div(100) :
2103
2182
  estimatedGas.mul(130).div(100);
2104
2183
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
2105
- case 8: return [2 /*return*/, (_a.sent()).hash];
2184
+ case 11: return [2 /*return*/, (_a.sent()).hash];
2106
2185
  }
2107
2186
  });
2108
2187
  });
@@ -2212,7 +2291,7 @@ var Pool = /** @class */ (function () {
2212
2291
  this.exchangeWrapped = function (inputCoin, outputCoin, amount, maxSlippage) {
2213
2292
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
2214
2293
  return __awaiter(_this, void 0, void 0, function () {
2215
- var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit_2, estimatedGas, gasLimit;
2294
+ var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit_3, estimatedGas, gasLimit;
2216
2295
  return __generator(this, function (_a) {
2217
2296
  switch (_a.label) {
2218
2297
  case 0:
@@ -2239,8 +2318,8 @@ var Pool = /** @class */ (function () {
2239
2318
  if (!(this.name === 'tricrypto2')) return [3 /*break*/, 6];
2240
2319
  return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2241
2320
  case 4:
2242
- gasLimit_2 = (_a.sent()).mul(130).div(100);
2243
- return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_2 }))];
2321
+ gasLimit_3 = (_a.sent()).mul(130).div(100);
2322
+ return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_3 }))];
2244
2323
  case 5: return [2 /*return*/, (_a.sent()).hash];
2245
2324
  case 6: return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2246
2325
  case 7:
@@ -2264,6 +2343,8 @@ var Pool = /** @class */ (function () {
2264
2343
  return __generator(this, function (_e) {
2265
2344
  switch (_e.label) {
2266
2345
  case 0:
2346
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
2347
+ throw Error("".concat(this.name, " doesn't have gauge"));
2267
2348
  if (addresses.length == 1 && Array.isArray(addresses[0]))
2268
2349
  addresses = addresses[0];
2269
2350
  votingEscrowContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
@@ -2301,6 +2382,8 @@ var Pool = /** @class */ (function () {
2301
2382
  return __generator(this, function (_j) {
2302
2383
  switch (_j.label) {
2303
2384
  case 0:
2385
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
2386
+ throw Error("".concat(this.name, " doesn't have gauge"));
2304
2387
  if (accounts.length == 1 && Array.isArray(accounts[0]))
2305
2388
  accounts = accounts[0];
2306
2389
  votingEscrowContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
@@ -2361,6 +2444,8 @@ var Pool = /** @class */ (function () {
2361
2444
  return __generator(this, function (_c) {
2362
2445
  switch (_c.label) {
2363
2446
  case 0:
2447
+ if (this.gauge === ethers_1.ethers.constants.AddressZero)
2448
+ throw Error("".concat(this.name, " doesn't have gauge"));
2364
2449
  gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
2365
2450
  return [4 /*yield*/, curve_1.curve.multicallProvider.all([
2366
2451
  gaugeContract.working_balances(address),
@@ -2712,7 +2797,7 @@ var Pool = /** @class */ (function () {
2712
2797
  switch (_a.label) {
2713
2798
  case 0:
2714
2799
  contract = curve_1.curve.contracts[this.zap].contract;
2715
- if (!this.isFactory) return [3 /*break*/, 2];
2800
+ if (!this.isMetaFactory) return [3 /*break*/, 2];
2716
2801
  return [4 /*yield*/, contract.calc_token_amount(this.swap, _amounts, isDeposit, curve_1.curve.constantOptions)];
2717
2802
  case 1: return [2 /*return*/, _a.sent()];
2718
2803
  case 2:
@@ -2808,7 +2893,7 @@ var Pool = /** @class */ (function () {
2808
2893
  this._addLiquidityMetaZap = function (_amounts, estimateGas) {
2809
2894
  if (estimateGas === void 0) { estimateGas = false; }
2810
2895
  return __awaiter(_this, void 0, void 0, function () {
2811
- var _minMintAmount, ethIndex, value, contract, gas_1, gasLimit_3, gas, gasLimit;
2896
+ var _minMintAmount, ethIndex, value, contract, gas_1, gasLimit_4, gas, gasLimit;
2812
2897
  return __generator(this, function (_a) {
2813
2898
  switch (_a.label) {
2814
2899
  case 0:
@@ -2823,15 +2908,15 @@ var Pool = /** @class */ (function () {
2823
2908
  ethIndex = (0, utils_1.getEthIndex)(this.underlyingCoinAddresses);
2824
2909
  value = _amounts[ethIndex] || ethers_1.ethers.BigNumber.from(0);
2825
2910
  contract = curve_1.curve.contracts[this.zap].contract;
2826
- if (!this.isFactory) return [3 /*break*/, 6];
2911
+ if (!this.isMetaFactory) return [3 /*break*/, 6];
2827
2912
  return [4 /*yield*/, contract.estimateGas.add_liquidity(this.swap, _amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2828
2913
  case 4:
2829
2914
  gas_1 = _a.sent();
2830
2915
  if (estimateGas) {
2831
2916
  return [2 /*return*/, gas_1.toNumber()];
2832
2917
  }
2833
- gasLimit_3 = gas_1.mul(130).div(100);
2834
- return [4 /*yield*/, contract.add_liquidity(this.swap, _amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_3, value: value }))];
2918
+ gasLimit_4 = gas_1.mul(130).div(100);
2919
+ return [4 /*yield*/, contract.add_liquidity(this.swap, _amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_4, value: value }))];
2835
2920
  case 5: return [2 /*return*/, (_a.sent()).hash];
2836
2921
  case 6: return [4 /*yield*/, contract.estimateGas.add_liquidity(_amounts, _minMintAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2837
2922
  case 7:
@@ -3034,7 +3119,7 @@ var Pool = /** @class */ (function () {
3034
3119
  this._removeLiquidityMetaZap = function (_lpTokenAmount, estimateGas) {
3035
3120
  if (estimateGas === void 0) { estimateGas = false; }
3036
3121
  return __awaiter(_this, void 0, void 0, function () {
3037
- var _minAmounts, contract, gas_2, gasLimit_4, gas, gasLimit;
3122
+ var _minAmounts, contract, gas_2, gasLimit_5, gas, gasLimit;
3038
3123
  return __generator(this, function (_a) {
3039
3124
  switch (_a.label) {
3040
3125
  case 0:
@@ -3047,15 +3132,15 @@ var Pool = /** @class */ (function () {
3047
3132
  case 3:
3048
3133
  _minAmounts = _a.sent();
3049
3134
  contract = curve_1.curve.contracts[this.zap].contract;
3050
- if (!this.isFactory) return [3 /*break*/, 6];
3135
+ if (!this.isMetaFactory) return [3 /*break*/, 6];
3051
3136
  return [4 /*yield*/, contract.estimateGas.remove_liquidity(this.swap, _lpTokenAmount, _minAmounts, curve_1.curve.constantOptions)];
3052
3137
  case 4:
3053
3138
  gas_2 = _a.sent();
3054
3139
  if (estimateGas) {
3055
3140
  return [2 /*return*/, gas_2.toNumber()];
3056
3141
  }
3057
- gasLimit_4 = gas_2.mul(130).div(100);
3058
- return [4 /*yield*/, contract.remove_liquidity(this.swap, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_4 }))];
3142
+ gasLimit_5 = gas_2.mul(130).div(100);
3143
+ return [4 /*yield*/, contract.remove_liquidity(this.swap, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_5 }))];
3059
3144
  case 5: return [2 /*return*/, (_a.sent()).hash];
3060
3145
  case 6: return [4 /*yield*/, contract.estimateGas.remove_liquidity(_lpTokenAmount, _minAmounts, curve_1.curve.constantOptions)];
3061
3146
  case 7:
@@ -3158,7 +3243,7 @@ var Pool = /** @class */ (function () {
3158
3243
  this._removeLiquidityImbalanceMetaZap = function (_amounts, estimateGas) {
3159
3244
  if (estimateGas === void 0) { estimateGas = false; }
3160
3245
  return __awaiter(_this, void 0, void 0, function () {
3161
- var _maxBurnAmount, contract, gas_3, gasLimit_5, gas, gasLimit;
3246
+ var _maxBurnAmount, contract, gas_3, gasLimit_6, gas, gasLimit;
3162
3247
  return __generator(this, function (_a) {
3163
3248
  switch (_a.label) {
3164
3249
  case 0: return [4 /*yield*/, this._calcLpTokenAmountZap(_amounts, false)];
@@ -3171,15 +3256,15 @@ var Pool = /** @class */ (function () {
3171
3256
  _a.label = 3;
3172
3257
  case 3:
3173
3258
  contract = curve_1.curve.contracts[this.zap].contract;
3174
- if (!this.isFactory) return [3 /*break*/, 6];
3259
+ if (!this.isMetaFactory) return [3 /*break*/, 6];
3175
3260
  return [4 /*yield*/, contract.estimateGas.remove_liquidity_imbalance(this.swap, _amounts, _maxBurnAmount, curve_1.curve.constantOptions)];
3176
3261
  case 4:
3177
3262
  gas_3 = _a.sent();
3178
3263
  if (estimateGas) {
3179
3264
  return [2 /*return*/, gas_3.toNumber()];
3180
3265
  }
3181
- gasLimit_5 = gas_3.mul(130).div(100);
3182
- return [4 /*yield*/, contract.remove_liquidity_imbalance(this.swap, _amounts, _maxBurnAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_5 }))];
3266
+ gasLimit_6 = gas_3.mul(130).div(100);
3267
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(this.swap, _amounts, _maxBurnAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_6 }))];
3183
3268
  case 5: return [2 /*return*/, (_a.sent())];
3184
3269
  case 6: return [4 /*yield*/, contract.estimateGas.remove_liquidity_imbalance(_amounts, _maxBurnAmount, curve_1.curve.constantOptions)];
3185
3270
  case 7:
@@ -3244,7 +3329,7 @@ var Pool = /** @class */ (function () {
3244
3329
  switch (_a.label) {
3245
3330
  case 0:
3246
3331
  contract = curve_1.curve.contracts[this.zap].contract;
3247
- if (!this.isFactory) return [3 /*break*/, 2];
3332
+ if (!this.isMetaFactory) return [3 /*break*/, 2];
3248
3333
  return [4 /*yield*/, contract.calc_withdraw_one_coin(this.swap, _lpTokenAmount, i, curve_1.curve.constantOptions)];
3249
3334
  case 1: return [2 /*return*/, (_a.sent())];
3250
3335
  case 2: return [4 /*yield*/, contract.calc_withdraw_one_coin(_lpTokenAmount, i, curve_1.curve.constantOptions)];
@@ -3289,7 +3374,7 @@ var Pool = /** @class */ (function () {
3289
3374
  this._removeLiquidityOneCoinZap = function (_lpTokenAmount, i, estimateGas) {
3290
3375
  if (estimateGas === void 0) { estimateGas = false; }
3291
3376
  return __awaiter(_this, void 0, void 0, function () {
3292
- var _minAmount, _a, contract, gas_4, gasLimit_6, gas, gasLimit;
3377
+ var _minAmount, _a, contract, gas_4, gasLimit_7, gas, gasLimit;
3293
3378
  return __generator(this, function (_c) {
3294
3379
  switch (_c.label) {
3295
3380
  case 0:
@@ -3312,15 +3397,15 @@ var Pool = /** @class */ (function () {
3312
3397
  _minAmount = _a;
3313
3398
  _minAmount = _minAmount.mul(99).div(100);
3314
3399
  contract = curve_1.curve.contracts[this.zap].contract;
3315
- if (!this.isFactory) return [3 /*break*/, 9];
3400
+ if (!this.isMetaFactory) return [3 /*break*/, 9];
3316
3401
  return [4 /*yield*/, contract.estimateGas.remove_liquidity_one_coin(this.swap, _lpTokenAmount, i, _minAmount, curve_1.curve.constantOptions)];
3317
3402
  case 7:
3318
3403
  gas_4 = _c.sent();
3319
3404
  if (estimateGas) {
3320
3405
  return [2 /*return*/, gas_4.toNumber()];
3321
3406
  }
3322
- gasLimit_6 = gas_4.mul(130).div(100);
3323
- return [4 /*yield*/, contract.remove_liquidity_one_coin(this.swap, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_6 }))];
3407
+ gasLimit_7 = gas_4.mul(130).div(100);
3408
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(this.swap, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit_7 }))];
3324
3409
  case 8: return [2 /*return*/, (_c.sent()).hash];
3325
3410
  case 9: return [4 /*yield*/, contract.estimateGas.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, curve_1.curve.constantOptions)];
3326
3411
  case 10:
@@ -3394,7 +3479,7 @@ var Pool = /** @class */ (function () {
3394
3479
  }
3395
3480
  });
3396
3481
  }); };
3397
- var poolData = curve_1.POOLS_DATA[name];
3482
+ var poolData = __assign(__assign({}, curve_1.POOLS_DATA), (curve_1.curve.constants.FACTORY_POOLS_DATA || {}))[name];
3398
3483
  this.name = name;
3399
3484
  this.referenceAsset = poolData.reference_asset;
3400
3485
  this.swap = poolData.swap_address;
@@ -3413,6 +3498,8 @@ var Pool = /** @class */ (function () {
3413
3498
  this.isFake = poolData.is_fake || false;
3414
3499
  this.isCrypto = poolData.is_crypto || false;
3415
3500
  this.isFactory = poolData.is_factory || false;
3501
+ this.isMetaFactory = poolData.is_meta_factory || false;
3502
+ this.isPlainFactory = poolData.is_plain_factory || false;
3416
3503
  this.basePool = poolData.base_pool || '';
3417
3504
  this.rewardTokens = poolData.reward_tokens || [];
3418
3505
  this.estimateGas = {
package/lib/utils.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import memoize from 'memoizee';
1
2
  import { ethers } from 'ethers';
2
3
  import BigNumber from 'bignumber.js';
3
- import { DictInterface } from './interfaces';
4
+ import { DictInterface, IStats } from './interfaces';
4
5
  export declare const MAX_ALLOWANCE: ethers.BigNumber;
5
6
  export declare const BN: (val: number | string) => BigNumber;
6
7
  export declare const toBN: (n: ethers.BigNumber, decimals?: number) => BigNumber;
@@ -21,6 +22,11 @@ export declare const ensureAllowanceEstimateGas: (coins: string[], amounts: stri
21
22
  export declare const ensureAllowance: (coins: string[], amounts: string[], spender: string) => Promise<string[]>;
22
23
  export declare const getPoolNameBySwapAddress: (swapAddress: string) => string;
23
24
  export declare const _getUsdRate: (assetId: string) => Promise<number>;
25
+ export declare const _getFactoryStatsUrl: () => string;
24
26
  export declare const _getStatsUrl: (isCrypto?: boolean) => string;
27
+ export declare const _getStats: ((statsUrl: string) => Promise<IStats>) & memoize.Memoized<(statsUrl: string) => Promise<IStats>>;
28
+ export declare const _getFactoryStatsEthereum: ((statsUrl: string) => Promise<IStats>) & memoize.Memoized<(statsUrl: string) => Promise<IStats>>;
29
+ export declare const _getFactoryStatsPolygon: ((statsUrl: string) => Promise<IStats>) & memoize.Memoized<(statsUrl: string) => Promise<IStats>>;
25
30
  export declare const getPoolList: () => string[];
31
+ export declare const getFactoryPoolList: () => string[];
26
32
  export declare const getUsdRate: (coin: string) => Promise<number>;