@curvefi/api 1.20.1 → 1.22.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.
package/lib/pools.js CHANGED
@@ -59,13 +59,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
59
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
60
60
  };
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.crossAssetExchange = exports.crossAssetExchangeEstimateGas = exports.crossAssetExchangeApprove = exports.crossAssetExchangeApproveEstimateGas = exports.crossAssetExchangeIsApproved = exports.crossAssetExchangeExpected = exports.crossAssetExchangeOutputAndSlippage = exports._crossAssetExchangeInfo = exports._getSmallAmountForCoin = exports.crossAssetExchangeAvailable = exports.exchange = exports.exchangeEstimateGas = exports.exchangeApprove = exports.exchangeApproveEstimateGas = exports.exchangeIsApproved = exports.exchangeExpected = exports.getBestPoolAndOutput = exports.Pool = void 0;
62
+ exports.getUserPoolList = exports.crossAssetExchange = exports.crossAssetExchangeEstimateGas = exports.crossAssetExchangeApprove = exports.crossAssetExchangeApproveEstimateGas = exports.crossAssetExchangeIsApproved = exports.crossAssetExchangeExpected = exports.crossAssetExchangeOutputAndSlippage = exports._crossAssetExchangeInfo = exports._getSmallAmountForCoin = exports.crossAssetExchangeAvailable = exports.exchange = exports.exchangeEstimateGas = exports.exchangeApprove = exports.exchangeApproveEstimateGas = exports.exchangeIsApproved = exports.exchangeExpected = exports.getBestPoolAndOutput = exports.Pool = void 0;
63
+ var axios_1 = __importDefault(require("axios"));
63
64
  var ethers_1 = require("ethers");
65
+ var external_api_1 = require("./external-api");
64
66
  var utils_1 = require("./utils");
65
67
  var curve_1 = require("./curve");
66
- var axios_1 = __importDefault(require("axios"));
67
68
  var Pool = /** @class */ (function () {
68
- function Pool(name) {
69
+ function Pool(id) {
69
70
  var _this = this;
70
71
  this.calcLpTokenAmount = function (amounts, isDeposit) {
71
72
  if (isDeposit === void 0) { isDeposit = true; }
@@ -81,9 +82,9 @@ var Pool = /** @class */ (function () {
81
82
  _amounts = amounts.map(function (amount, i) {
82
83
  return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]);
83
84
  });
84
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
85
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
85
86
  this.isCryptoFactory ||
86
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
87
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 2];
87
88
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, isDeposit)];
88
89
  case 1:
89
90
  _expected = _a.sent(); // Lending pools
@@ -156,7 +157,7 @@ var Pool = /** @class */ (function () {
156
157
  ethers_1.ethers.utils.formatUnits(_A, 0),
157
158
  _gamma ? ethers_1.ethers.utils.formatUnits(_gamma) : _gamma,
158
159
  ], virtualPrice = _c[0], fee = _c[1], adminFee = _c[2], A = _c[3], gamma = _c[4];
159
- A_PRECISION = curve_1.curve.chainId === 1 && ['compound', 'usdt', 'y', 'busd', 'susd', 'pax', 'ren', 'sbtc', 'hbtc', '3pool'].includes(this.name) ? 1 : 100;
160
+ A_PRECISION = curve_1.curve.chainId === 1 && ['compound', 'usdt', 'y', 'busd', 'susd', 'pax', 'ren', 'sbtc', 'hbtc', '3pool'].includes(this.id) ? 1 : 100;
160
161
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(additionalCalls)];
161
162
  case 2:
162
163
  _d = _f.sent(), _future_A = _d[0], _initial_A = _d[1], _future_A_time = _d[2], _initial_A_time = _d[3];
@@ -183,7 +184,7 @@ var Pool = /** @class */ (function () {
183
184
  _poolWrappedBalances = _a.sent();
184
185
  _poolUnderlyingBalances = [];
185
186
  if (!this.isMeta) return [3 /*break*/, 3];
186
- if (this.name !== 'atricrypto3') {
187
+ if (this.id !== 'atricrypto3') {
187
188
  _poolWrappedBalances.unshift(_poolWrappedBalances.pop());
188
189
  }
189
190
  _poolMetaCoinBalance = _poolWrappedBalances[0], _poolUnderlyingBalance = _poolWrappedBalances.slice(1);
@@ -191,12 +192,12 @@ var Pool = /** @class */ (function () {
191
192
  return [4 /*yield*/, basePool._calcExpectedAmounts(_poolMetaCoinBalance)];
192
193
  case 2:
193
194
  _basePoolExpectedAmounts = _a.sent();
194
- _poolUnderlyingBalances = this.name !== 'atricrypto3' ? __spreadArray(__spreadArray([], _poolUnderlyingBalance, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _poolUnderlyingBalance, true);
195
+ _poolUnderlyingBalances = this.id !== 'atricrypto3' ? __spreadArray(__spreadArray([], _poolUnderlyingBalance, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _poolUnderlyingBalance, true);
195
196
  return [3 /*break*/, 6];
196
197
  case 3:
197
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
198
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
198
199
  this.isCryptoFactory ||
199
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
200
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 5];
200
201
  return [4 /*yield*/, this._getRates()];
201
202
  case 4:
202
203
  _rates_1 = _a.sent();
@@ -224,33 +225,55 @@ var Pool = /** @class */ (function () {
224
225
  }
225
226
  });
226
227
  }); };
227
- this.getTotalLiquidity = function () { return __awaiter(_this, void 0, void 0, function () {
228
- var balances, promises, _i, _a, addr, prices, totalLiquidity;
229
- return __generator(this, function (_c) {
230
- switch (_c.label) {
231
- case 0: return [4 /*yield*/, this.getPoolBalances()];
232
- case 1:
233
- balances = _c.sent();
234
- promises = [];
235
- for (_i = 0, _a = this.underlyingCoinAddresses; _i < _a.length; _i++) {
236
- addr = _a[_i];
237
- promises.push((0, utils_1._getUsdRate)(addr));
238
- }
239
- return [4 /*yield*/, Promise.all(promises)];
240
- case 2:
241
- prices = _c.sent();
242
- totalLiquidity = balances.reduce(function (liquidity, b, i) { return liquidity + (Number(b) * prices[i]); }, 0);
243
- return [2 /*return*/, totalLiquidity.toFixed(8)];
244
- }
228
+ this.getTotalLiquidity = function (useApi) {
229
+ if (useApi === void 0) { useApi = true; }
230
+ return __awaiter(_this, void 0, void 0, function () {
231
+ var network, poolType, poolsData, totalLiquidity_1, balances, promises, _i, _a, addr, prices, totalLiquidity;
232
+ var _this = this;
233
+ return __generator(this, function (_c) {
234
+ switch (_c.label) {
235
+ case 0:
236
+ if (!useApi) return [3 /*break*/, 2];
237
+ network = curve_1.curve.chainId === 137 ? "polygon" : "ethereum";
238
+ poolType = !this.isFactory && !this.isCrypto ? "main" :
239
+ !this.isFactory ? "crypto" :
240
+ !this.isCryptoFactory ? "factory" :
241
+ "factory-crypto";
242
+ return [4 /*yield*/, (0, external_api_1._getPoolsFromApi)(network, poolType)];
243
+ case 1:
244
+ poolsData = (_c.sent()).poolData;
245
+ try {
246
+ totalLiquidity_1 = poolsData.filter(function (data) { return data.address.toLowerCase() === _this.swap.toLowerCase(); })[0].usdTotal;
247
+ return [2 /*return*/, String(totalLiquidity_1)];
248
+ }
249
+ catch (err) {
250
+ console.log(err.message);
251
+ }
252
+ _c.label = 2;
253
+ case 2: return [4 /*yield*/, this.getPoolBalances()];
254
+ case 3:
255
+ balances = _c.sent();
256
+ promises = [];
257
+ for (_i = 0, _a = this.underlyingCoinAddresses; _i < _a.length; _i++) {
258
+ addr = _a[_i];
259
+ promises.push((0, utils_1._getUsdRate)(addr));
260
+ }
261
+ return [4 /*yield*/, Promise.all(promises)];
262
+ case 4:
263
+ prices = _c.sent();
264
+ totalLiquidity = balances.reduce(function (liquidity, b, i) { return liquidity + (Number(b) * prices[i]); }, 0);
265
+ return [2 /*return*/, totalLiquidity.toFixed(8)];
266
+ }
267
+ });
245
268
  });
246
- }); };
269
+ };
247
270
  this._getPoolStats = function () { return __awaiter(_this, void 0, void 0, function () {
248
271
  var statsUrl, name, key;
249
272
  return __generator(this, function (_a) {
250
273
  switch (_a.label) {
251
274
  case 0:
252
275
  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;
276
+ name = (this.id === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.id === 'sbtc' ? 'rens' : this.id;
254
277
  key = this.isFactory ? this.swap.toLowerCase() : name;
255
278
  if (!this.isFactory) return [3 /*break*/, 4];
256
279
  if (!(curve_1.curve.chainId === 137)) return [3 /*break*/, 2];
@@ -273,7 +296,7 @@ var Pool = /** @class */ (function () {
273
296
  if (!(this.isCrypto || (curve_1.curve.chainId === 1 && this.isFactory))) return [3 /*break*/, 2];
274
297
  _a = 1;
275
298
  return [3 /*break*/, 4];
276
- case 2: return [4 /*yield*/, (0, utils_1._getUsdRate)(this.referenceAsset)];
299
+ case 2: return [4 /*yield*/, (0, utils_1._getUsdRate)(this.coinAddresses[0])];
277
300
  case 3:
278
301
  _a = _c.sent();
279
302
  _c.label = 4;
@@ -482,13 +505,13 @@ var Pool = /** @class */ (function () {
482
505
  _amounts = amounts.map(function (amount, i) {
483
506
  return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]);
484
507
  });
485
- if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 4];
508
+ if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.id)) return [3 /*break*/, 4];
486
509
  return [4 /*yield*/, this._addLiquidityZap(_amounts, true)];
487
510
  case 3: return [2 /*return*/, _d.sent()];
488
511
  case 4:
489
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
512
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
490
513
  this.isCryptoFactory ||
491
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 6];
514
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 6];
492
515
  return [4 /*yield*/, this._addLiquidity(_amounts, true, true)];
493
516
  case 5: return [2 /*return*/, _d.sent()];
494
517
  case 6:
@@ -540,13 +563,13 @@ var Pool = /** @class */ (function () {
540
563
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
541
564
  case 1:
542
565
  _a.sent();
543
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name)) return [3 /*break*/, 3];
566
+ if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.id)) return [3 /*break*/, 3];
544
567
  return [4 /*yield*/, this._addLiquidityZap(_amounts)];
545
568
  case 2: return [2 /*return*/, _a.sent()];
546
569
  case 3:
547
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
570
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
548
571
  this.isCryptoFactory ||
549
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
572
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 5];
550
573
  return [4 /*yield*/, this._addLiquidity(_amounts, true)];
551
574
  case 4: return [2 /*return*/, _a.sent()];
552
575
  case 5:
@@ -725,9 +748,9 @@ var Pool = /** @class */ (function () {
725
748
  return ethers_1.ethers.utils.parseUnits(amount, decimals[i]);
726
749
  });
727
750
  contract = curve_1.curve.contracts[curve_1.ALIASES.deposit_and_stake].contract;
728
- useUnderlying = isUnderlying && (['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
751
+ useUnderlying = isUnderlying && (['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
729
752
  this.isCryptoFactory ||
730
- (curve_1.curve.chainId === 137 && this.name === 'ren'));
753
+ (curve_1.curve.chainId === 137 && this.id === 'ren'));
731
754
  if (!isUnderlying) return [3 /*break*/, 14];
732
755
  _l = (_k = ethers_1.ethers.utils).parseUnits;
733
756
  return [4 /*yield*/, this.depositAndStakeExpected(amounts)];
@@ -898,9 +921,9 @@ var Pool = /** @class */ (function () {
898
921
  _amounts = amounts.map(function (amount, i) {
899
922
  return ethers_1.ethers.utils.parseUnits(amount, _this.decimals[i]);
900
923
  });
901
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
924
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
902
925
  this.isCryptoFactory ||
903
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
926
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 4];
904
927
  return [4 /*yield*/, this._addLiquidity(_amounts, false, true)];
905
928
  case 3: return [2 /*return*/, _d.sent()];
906
929
  case 4: return [4 /*yield*/, this._addLiquiditySwap(_amounts, true)];
@@ -928,9 +951,9 @@ var Pool = /** @class */ (function () {
928
951
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
929
952
  case 1:
930
953
  _a.sent();
931
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
954
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
932
955
  this.isCryptoFactory ||
933
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
956
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 3];
934
957
  return [4 /*yield*/, this._addLiquidity(_amounts, false)];
935
958
  case 2: return [2 /*return*/, _a.sent()];
936
959
  case 3: return [4 /*yield*/, this._addLiquiditySwap(_amounts)];
@@ -1072,9 +1095,9 @@ var Pool = /** @class */ (function () {
1072
1095
  switch (_a.label) {
1073
1096
  case 0:
1074
1097
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1075
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1098
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1076
1099
  this.isCryptoFactory ||
1077
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
1100
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 2];
1078
1101
  return [4 /*yield*/, this._calcExpectedUnderlyingAmounts(_lpTokenAmount)];
1079
1102
  case 1:
1080
1103
  _expected = _a.sent(); // Lending pools
@@ -1147,13 +1170,13 @@ var Pool = /** @class */ (function () {
1147
1170
  throw Error("Token allowance is needed to estimate gas");
1148
1171
  }
1149
1172
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1150
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name)) return [3 /*break*/, 5];
1173
+ if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.id)) return [3 /*break*/, 5];
1151
1174
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount, true)];
1152
1175
  case 4: return [2 /*return*/, _c.sent()];
1153
1176
  case 5:
1154
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1177
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1155
1178
  this.isCryptoFactory ||
1156
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1179
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 7];
1157
1180
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true, true)];
1158
1181
  case 6: return [2 /*return*/, _c.sent()];
1159
1182
  case 7:
@@ -1174,13 +1197,13 @@ var Pool = /** @class */ (function () {
1174
1197
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1175
1198
  case 1:
1176
1199
  _a.sent();
1177
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name)) return [3 /*break*/, 3];
1200
+ if (!['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.id)) return [3 /*break*/, 3];
1178
1201
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount)];
1179
1202
  case 2: return [2 /*return*/, _a.sent()];
1180
1203
  case 3:
1181
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1204
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1182
1205
  this.isCryptoFactory ||
1183
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1206
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 5];
1184
1207
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true)];
1185
1208
  case 4: return [2 /*return*/, _a.sent()];
1186
1209
  case 5:
@@ -1224,9 +1247,9 @@ var Pool = /** @class */ (function () {
1224
1247
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
1225
1248
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
1226
1249
  }
1227
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1250
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1228
1251
  this.isCryptoFactory ||
1229
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1252
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 3];
1230
1253
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false, true)];
1231
1254
  case 2: return [2 /*return*/, _a.sent()];
1232
1255
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount, true)];
@@ -1246,9 +1269,9 @@ var Pool = /** @class */ (function () {
1246
1269
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1247
1270
  case 1:
1248
1271
  _a.sent();
1249
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1272
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1250
1273
  this.isCryptoFactory ||
1251
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1274
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 3];
1252
1275
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false)];
1253
1276
  case 2: return [2 /*return*/, _a.sent()];
1254
1277
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount)];
@@ -1298,7 +1321,7 @@ var Pool = /** @class */ (function () {
1298
1321
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_imbalance method"));
1299
1322
  }
1300
1323
  _amounts = amounts.map(function (amount, i) { return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]); });
1301
- if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 3];
1324
+ if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 3];
1302
1325
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, false)];
1303
1326
  case 1:
1304
1327
  _maxBurnAmount = (_a.sent()).mul(101).div(100);
@@ -1325,7 +1348,7 @@ var Pool = /** @class */ (function () {
1325
1348
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_imbalance method"));
1326
1349
  }
1327
1350
  _amounts = amounts.map(function (amount, i) { return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]); });
1328
- if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 3];
1351
+ if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 3];
1329
1352
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, false)];
1330
1353
  case 1:
1331
1354
  _maxBurnAmount = (_a.sent()).mul(101).div(100);
@@ -1352,7 +1375,7 @@ var Pool = /** @class */ (function () {
1352
1375
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_imbalance method"));
1353
1376
  }
1354
1377
  _amounts = amounts.map(function (amount, i) { return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]); });
1355
- if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 3];
1378
+ if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 3];
1356
1379
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, false)];
1357
1380
  case 1:
1358
1381
  _maxBurnAmount = (_a.sent()).mul(101).div(100);
@@ -1398,11 +1421,11 @@ var Pool = /** @class */ (function () {
1398
1421
  throw Error("Token allowance is needed to estimate gas");
1399
1422
  }
1400
1423
  _amounts = amounts.map(function (amount, i) { return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]); });
1401
- if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 6];
1424
+ if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 6];
1402
1425
  return [4 /*yield*/, this._removeLiquidityImbalanceZap(_amounts, true)];
1403
1426
  case 5: return [2 /*return*/, _c.sent()];
1404
1427
  case 6:
1405
- if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 8];
1428
+ if (!(['aave', 'saave', 'ib'].includes(this.id) || (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 8];
1406
1429
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, true, true)];
1407
1430
  case 7: return [2 /*return*/, _c.sent()];
1408
1431
  case 8:
@@ -1427,11 +1450,11 @@ var Pool = /** @class */ (function () {
1427
1450
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1428
1451
  case 1:
1429
1452
  _a.sent();
1430
- if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 3];
1453
+ if (!['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 3];
1431
1454
  return [4 /*yield*/, this._removeLiquidityImbalanceZap(_amounts)];
1432
1455
  case 2: return [2 /*return*/, _a.sent()];
1433
1456
  case 3:
1434
- if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1457
+ if (!(['aave', 'saave', 'ib'].includes(this.id) || (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 5];
1435
1458
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, true)];
1436
1459
  case 4: return [2 /*return*/, _a.sent()];
1437
1460
  case 5:
@@ -1494,7 +1517,7 @@ var Pool = /** @class */ (function () {
1494
1517
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
1495
1518
  }
1496
1519
  _amounts = amounts.map(function (amount, i) { return ethers_1.ethers.utils.parseUnits(amount, _this.decimals[i]); });
1497
- if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
1520
+ if (!(['aave', 'saave', 'ib'].includes(this.id) || (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 4];
1498
1521
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, false, true)];
1499
1522
  case 3: return [2 /*return*/, _a.sent()];
1500
1523
  case 4: return [4 /*yield*/, this._removeLiquidityImbalanceSwap(_amounts, true)];
@@ -1517,7 +1540,7 @@ var Pool = /** @class */ (function () {
1517
1540
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1518
1541
  case 1:
1519
1542
  _a.sent();
1520
- if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1543
+ if (!(['aave', 'saave', 'ib'].includes(this.id) || (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 3];
1521
1544
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, false, estimateGas)];
1522
1545
  case 2: return [2 /*return*/, _a.sent()];
1523
1546
  case 3: return [4 /*yield*/, this._removeLiquidityImbalanceSwap(_amounts, estimateGas)];
@@ -1533,13 +1556,13 @@ var Pool = /** @class */ (function () {
1533
1556
  case 0:
1534
1557
  i = this._getCoinIdx(coin);
1535
1558
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1536
- if (!(['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name) || this.name === 'susd' || this.isMeta)) return [3 /*break*/, 2];
1559
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id) || this.id === 'susd' || this.isMeta)) return [3 /*break*/, 2];
1537
1560
  return [4 /*yield*/, this._calcWithdrawOneCoinZap(_lpTokenAmount, i)];
1538
1561
  case 1:
1539
1562
  _expected = _a.sent(); // Lending pools with zap, susd and metapools
1540
1563
  return [3 /*break*/, 6];
1541
1564
  case 2:
1542
- if (!(this.name === 'ib')) return [3 /*break*/, 4];
1565
+ if (!(this.id === 'ib')) return [3 /*break*/, 4];
1543
1566
  return [4 /*yield*/, this._calcWithdrawOneCoin(_lpTokenAmount, i, true)];
1544
1567
  case 3:
1545
1568
  _expected = _a.sent(); // ib
@@ -1627,13 +1650,13 @@ var Pool = /** @class */ (function () {
1627
1650
  }
1628
1651
  i = this._getCoinIdx(coin);
1629
1652
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1630
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) || this.name === 'susd' || this.isMeta)) return [3 /*break*/, 5];
1653
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.id) || this.id === 'susd' || this.isMeta)) return [3 /*break*/, 5];
1631
1654
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i, true)];
1632
1655
  case 4: return [2 /*return*/, _c.sent()];
1633
1656
  case 5:
1634
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1657
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1635
1658
  this.isCryptoFactory ||
1636
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1659
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 7];
1637
1660
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true, true)];
1638
1661
  case 6: return [2 /*return*/, _c.sent()];
1639
1662
  case 7: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1653,13 +1676,13 @@ var Pool = /** @class */ (function () {
1653
1676
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1654
1677
  case 1:
1655
1678
  _a.sent();
1656
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.name) || this.name === 'susd' || this.isMeta)) return [3 /*break*/, 3];
1679
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'tricrypto2'].includes(this.id) || this.id === 'susd' || this.isMeta)) return [3 /*break*/, 3];
1657
1680
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i)];
1658
1681
  case 2: return [2 /*return*/, _a.sent()];
1659
1682
  case 3:
1660
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1683
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1661
1684
  this.isCryptoFactory ||
1662
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1685
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 5];
1663
1686
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true)];
1664
1687
  case 4: return [2 /*return*/, _a.sent()];
1665
1688
  case 5: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1677,12 +1700,12 @@ var Pool = /** @class */ (function () {
1677
1700
  if (this.isFake) {
1678
1701
  throw Error("".concat(this.name, " pool doesn't have this method"));
1679
1702
  }
1680
- if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) {
1703
+ if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) {
1681
1704
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1682
1705
  }
1683
1706
  i = this._getCoinIdx(coin, false);
1684
1707
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1685
- if (!(this.name === 'ib')) return [3 /*break*/, 2];
1708
+ if (!(this.id === 'ib')) return [3 /*break*/, 2];
1686
1709
  return [4 /*yield*/, this._calcWithdrawOneCoin(_lpTokenAmount, i, false)];
1687
1710
  case 1:
1688
1711
  _expected = _a.sent(); // ib
@@ -1733,13 +1756,13 @@ var Pool = /** @class */ (function () {
1733
1756
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
1734
1757
  }
1735
1758
  i = this._getCoinIdx(coin, false);
1736
- if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) {
1759
+ if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) {
1737
1760
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1738
1761
  }
1739
1762
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1740
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1763
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1741
1764
  this.isCryptoFactory ||
1742
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1765
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 3];
1743
1766
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false, true)];
1744
1767
  case 2: return [2 /*return*/, _a.sent()];
1745
1768
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1756,16 +1779,16 @@ var Pool = /** @class */ (function () {
1756
1779
  throw Error("".concat(this.name, " pool doesn't have this method"));
1757
1780
  }
1758
1781
  i = this._getCoinIdx(coin, false);
1759
- if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) {
1782
+ if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.id)) {
1760
1783
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1761
1784
  }
1762
1785
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
1763
1786
  case 1:
1764
1787
  _a.sent();
1765
1788
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1766
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) ||
1789
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.id) ||
1767
1790
  this.isCryptoFactory ||
1768
- (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1791
+ (curve_1.curve.chainId === 137 && this.id === 'ren'))) return [3 /*break*/, 3];
1769
1792
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false)];
1770
1793
  case 2: return [2 /*return*/, _a.sent()];
1771
1794
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -2090,8 +2113,8 @@ var Pool = /** @class */ (function () {
2090
2113
  return __generator(this, function (_a) {
2091
2114
  switch (_a.label) {
2092
2115
  case 0:
2093
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2094
- (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2116
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.id) ||
2117
+ (curve_1.curve.chainId === 137 && this.isMetaFactory) ? this.zap : this.swap;
2095
2118
  i = this._getCoinIdx(inputCoin);
2096
2119
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
2097
2120
  case 1: return [2 /*return*/, _a.sent()];
@@ -2103,8 +2126,8 @@ var Pool = /** @class */ (function () {
2103
2126
  return __generator(this, function (_a) {
2104
2127
  switch (_a.label) {
2105
2128
  case 0:
2106
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2107
- (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2129
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.id) ||
2130
+ (curve_1.curve.chainId === 137 && this.isMetaFactory) ? this.zap : this.swap;
2108
2131
  i = this._getCoinIdx(inputCoin);
2109
2132
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
2110
2133
  case 1: return [2 /*return*/, _a.sent()];
@@ -2116,8 +2139,8 @@ var Pool = /** @class */ (function () {
2116
2139
  return __generator(this, function (_a) {
2117
2140
  switch (_a.label) {
2118
2141
  case 0:
2119
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2120
- (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2142
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.id) ||
2143
+ (curve_1.curve.chainId === 137 && this.isMetaFactory) ? this.zap : this.swap;
2121
2144
  i = this._getCoinIdx(inputCoin);
2122
2145
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
2123
2146
  case 1: return [2 /*return*/, _a.sent()];
@@ -2131,8 +2154,8 @@ var Pool = /** @class */ (function () {
2131
2154
  return __generator(this, function (_d) {
2132
2155
  switch (_d.label) {
2133
2156
  case 0:
2134
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2135
- (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2157
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.id) ||
2158
+ (curve_1.curve.chainId === 137 && this.isMetaFactory) ? this.zap : this.swap;
2136
2159
  i = this._getCoinIdx(inputCoin);
2137
2160
  j = this._getCoinIdx(outputCoin);
2138
2161
  _c = (_a = Object).values;
@@ -2157,11 +2180,11 @@ var Pool = /** @class */ (function () {
2157
2180
  contract = curve_1.curve.contracts[contractAddress].contract;
2158
2181
  exchangeMethod = Object.prototype.hasOwnProperty.call(contract, 'exchange_underlying') ? 'exchange_underlying' : 'exchange';
2159
2182
  value = (0, utils_1.isEth)(this.underlyingCoinAddresses[i]) ? _amount : ethers_1.ethers.BigNumber.from(0);
2160
- if (!(this.name === "tricrypto2")) return [3 /*break*/, 5];
2183
+ if (!(this.id === "tricrypto2")) return [3 /*break*/, 5];
2161
2184
  return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2162
2185
  case 4: return [2 /*return*/, (_d.sent()).toNumber()];
2163
2186
  case 5:
2164
- if (!(curve_1.curve.chainId === 137 && this.isFactory)) return [3 /*break*/, 7];
2187
+ if (!(curve_1.curve.chainId === 137 && this.isMetaFactory)) return [3 /*break*/, 7];
2165
2188
  return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2166
2189
  case 6: return [2 /*return*/, (_d.sent()).toNumber()];
2167
2190
  case 7: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
@@ -2177,8 +2200,8 @@ var Pool = /** @class */ (function () {
2177
2200
  return __generator(this, function (_a) {
2178
2201
  switch (_a.label) {
2179
2202
  case 0:
2180
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ||
2181
- (curve_1.curve.chainId === 137 && this.isFactory) ? this.zap : this.swap;
2203
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.id) ||
2204
+ (curve_1.curve.chainId === 137 && this.isMetaFactory) ? this.zap : this.swap;
2182
2205
  i = this._getCoinIdx(inputCoin);
2183
2206
  j = this._getCoinIdx(outputCoin);
2184
2207
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.underlyingDecimals[i]);
@@ -2197,14 +2220,14 @@ var Pool = /** @class */ (function () {
2197
2220
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
2198
2221
  case 3:
2199
2222
  _a.sent();
2200
- if (!(this.name === 'tricrypto2')) return [3 /*break*/, 6];
2223
+ if (!(this.id === 'tricrypto2')) return [3 /*break*/, 6];
2201
2224
  return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2202
2225
  case 4:
2203
2226
  gasLimit_1 = (_a.sent()).mul(130).div(100);
2204
2227
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit_1 }))];
2205
2228
  case 5: return [2 /*return*/, (_a.sent()).hash];
2206
2229
  case 6:
2207
- if (!(curve_1.curve.chainId === 137 && this.isFactory)) return [3 /*break*/, 9];
2230
+ if (!(curve_1.curve.chainId === 137 && this.isMetaFactory)) return [3 /*break*/, 9];
2208
2231
  return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.swap, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2209
2232
  case 7:
2210
2233
  gasLimit_2 = (_a.sent()).mul(140).div(100);
@@ -2213,7 +2236,7 @@ var Pool = /** @class */ (function () {
2213
2236
  case 9: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2214
2237
  case 10:
2215
2238
  estimatedGas = _a.sent();
2216
- gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
2239
+ gasLimit = curve_1.curve.chainId === 137 && this.id === 'ren' ?
2217
2240
  estimatedGas.mul(160).div(100) :
2218
2241
  estimatedGas.mul(130).div(100);
2219
2242
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
@@ -2315,7 +2338,7 @@ var Pool = /** @class */ (function () {
2315
2338
  _minRecvAmount = (0, utils_1.fromBN)(minRecvAmountBN, outputCoinDecimals);
2316
2339
  contract = curve_1.curve.contracts[this.swap].contract;
2317
2340
  value = (0, utils_1.isEth)(this.coinAddresses[i]) ? _amount : ethers_1.ethers.BigNumber.from(0);
2318
- if (!(this.name === 'tricrypto2')) return [3 /*break*/, 5];
2341
+ if (!(this.id === 'tricrypto2')) return [3 /*break*/, 5];
2319
2342
  return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2320
2343
  case 4: return [2 /*return*/, (_d.sent()).toNumber()];
2321
2344
  case 5: return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
@@ -2351,7 +2374,7 @@ var Pool = /** @class */ (function () {
2351
2374
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
2352
2375
  case 3:
2353
2376
  _a.sent();
2354
- if (!(this.name === 'tricrypto2')) return [3 /*break*/, 6];
2377
+ if (!(this.id === 'tricrypto2')) return [3 /*break*/, 6];
2355
2378
  return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2356
2379
  case 4:
2357
2380
  gasLimit_3 = (_a.sent()).mul(130).div(100);
@@ -2360,7 +2383,7 @@ var Pool = /** @class */ (function () {
2360
2383
  case 6: return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
2361
2384
  case 7:
2362
2385
  estimatedGas = _a.sent();
2363
- gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
2386
+ gasLimit = curve_1.curve.chainId === 137 && this.id === 'ren' ?
2364
2387
  estimatedGas.mul(140).div(100) :
2365
2388
  estimatedGas.mul(130).div(100);
2366
2389
  return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
@@ -2532,14 +2555,14 @@ var Pool = /** @class */ (function () {
2532
2555
  if (!(i < this.coinAddresses.length)) return [3 /*break*/, 9];
2533
2556
  addr = this.coinAddresses[i];
2534
2557
  if (!this.useLending[i]) return [3 /*break*/, 7];
2535
- if (!['compound', 'usdt', 'ib'].includes(this.name)) return [3 /*break*/, 3];
2558
+ if (!['compound', 'usdt', 'ib'].includes(this.id)) return [3 /*break*/, 3];
2536
2559
  _c = (_a = _rates).push;
2537
2560
  return [4 /*yield*/, curve_1.curve.contracts[addr].contract.exchangeRateStored()];
2538
2561
  case 2:
2539
2562
  _c.apply(_a, [_f.sent()]);
2540
2563
  return [3 /*break*/, 6];
2541
2564
  case 3:
2542
- if (!['y', 'busd', 'pax'].includes(this.name)) return [3 /*break*/, 5];
2565
+ if (!['y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 5];
2543
2566
  _e = (_d = _rates).push;
2544
2567
  return [4 /*yield*/, curve_1.curve.contracts[addr].contract.getPricePerFullShare()];
2545
2568
  case 4:
@@ -2816,7 +2839,7 @@ var Pool = /** @class */ (function () {
2816
2839
  switch (_a.label) {
2817
2840
  case 0:
2818
2841
  contract = curve_1.curve.contracts[this.swap].contract;
2819
- if (!(["eurtusd", "xautusd", "crveth", "cvxeth", "spelleth", "teth"].includes(this.name) || this.isCryptoFactory)) return [3 /*break*/, 2];
2842
+ if (!(["eurtusd", "xautusd", "crveth", "cvxeth", "spelleth", "teth"].includes(this.id) || this.isCryptoFactory)) return [3 /*break*/, 2];
2820
2843
  return [4 /*yield*/, contract.calc_token_amount(_amounts, curve_1.curve.constantOptions)];
2821
2844
  case 1: return [2 /*return*/, _a.sent()];
2822
2845
  case 2: return [4 /*yield*/, contract.calc_token_amount(_amounts, isDeposit, curve_1.curve.constantOptions)];
@@ -2837,7 +2860,7 @@ var Pool = /** @class */ (function () {
2837
2860
  return [4 /*yield*/, contract.calc_token_amount(this.swap, _amounts, isDeposit, curve_1.curve.constantOptions)];
2838
2861
  case 1: return [2 /*return*/, _a.sent()];
2839
2862
  case 2:
2840
- if (!["eurtusd", "xautusd"].includes(this.name)) return [3 /*break*/, 4];
2863
+ if (!["eurtusd", "xautusd"].includes(this.id)) return [3 /*break*/, 4];
2841
2864
  return [4 /*yield*/, contract.calc_token_amount(_amounts, curve_1.curve.constantOptions)];
2842
2865
  case 3: return [2 /*return*/, _a.sent()];
2843
2866
  case 4: return [4 /*yield*/, contract.calc_token_amount(_amounts, isDeposit, curve_1.curve.constantOptions)];
@@ -3080,7 +3103,7 @@ var Pool = /** @class */ (function () {
3080
3103
  case 0: return [4 /*yield*/, this._calcExpectedAmounts(_lpTokenAmount)];
3081
3104
  case 1:
3082
3105
  _expectedWrappedAmounts = _a.sent();
3083
- if (this.name !== 'atricrypto3') {
3106
+ if (this.id !== 'atricrypto3') {
3084
3107
  _expectedWrappedAmounts.unshift(_expectedWrappedAmounts.pop());
3085
3108
  }
3086
3109
  _expectedMetaCoinAmount = _expectedWrappedAmounts[0], _expectedUnderlyingAmounts = _expectedWrappedAmounts.slice(1);
@@ -3088,7 +3111,7 @@ var Pool = /** @class */ (function () {
3088
3111
  return [4 /*yield*/, basePool._calcExpectedAmounts(_expectedMetaCoinAmount)];
3089
3112
  case 2:
3090
3113
  _basePoolExpectedAmounts = _a.sent();
3091
- return [2 /*return*/, this.name !== 'atricrypto3' ? __spreadArray(__spreadArray([], _expectedUnderlyingAmounts, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _expectedUnderlyingAmounts, true)];
3114
+ return [2 /*return*/, this.id !== 'atricrypto3' ? __spreadArray(__spreadArray([], _expectedUnderlyingAmounts, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _expectedUnderlyingAmounts, true)];
3092
3115
  }
3093
3116
  });
3094
3117
  }); };
@@ -3342,7 +3365,7 @@ var Pool = /** @class */ (function () {
3342
3365
  if (estimateGas) {
3343
3366
  return [2 /*return*/, gas.toNumber()];
3344
3367
  }
3345
- gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
3368
+ gasLimit = curve_1.curve.chainId === 137 && this.id === 'ren' ?
3346
3369
  gas.mul(140).div(100) :
3347
3370
  gas.mul(130).div(100);
3348
3371
  return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, useUnderlying, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
@@ -3420,7 +3443,7 @@ var Pool = /** @class */ (function () {
3420
3443
  _c.sent();
3421
3444
  _c.label = 2;
3422
3445
  case 2:
3423
- if (!(this.name === 'tricrypto2')) return [3 /*break*/, 4];
3446
+ if (!(this.id === 'tricrypto2')) return [3 /*break*/, 4];
3424
3447
  return [4 /*yield*/, this._calcWithdrawOneCoinSwap(_lpTokenAmount, i)];
3425
3448
  case 3:
3426
3449
  _a = _c.sent();
@@ -3464,7 +3487,7 @@ var Pool = /** @class */ (function () {
3464
3487
  return __generator(this, function (_c) {
3465
3488
  switch (_c.label) {
3466
3489
  case 0:
3467
- if (!(this.name === 'ib')) return [3 /*break*/, 2];
3490
+ if (!(this.id === 'ib')) return [3 /*break*/, 2];
3468
3491
  return [4 /*yield*/, this._calcWithdrawOneCoin(_lpTokenAmount, i, useUnderlying)];
3469
3492
  case 1:
3470
3493
  _a = _c.sent();
@@ -3483,7 +3506,7 @@ var Pool = /** @class */ (function () {
3483
3506
  if (estimateGas) {
3484
3507
  return [2 /*return*/, gas.toNumber()];
3485
3508
  }
3486
- gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
3509
+ gasLimit = curve_1.curve.chainId === 137 && this.id === 'ren' ?
3487
3510
  gas.mul(160).div(100) :
3488
3511
  gas.mul(130).div(100);
3489
3512
  return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, useUnderlying, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
@@ -3497,7 +3520,7 @@ var Pool = /** @class */ (function () {
3497
3520
  return __generator(this, function (_a) {
3498
3521
  switch (_a.label) {
3499
3522
  case 0:
3500
- contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
3523
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.id) ? this.zap : this.swap;
3501
3524
  contract = curve_1.curve.contracts[contractAddress].contract;
3502
3525
  if (!Object.prototype.hasOwnProperty.call(contract, 'get_dy_underlying')) return [3 /*break*/, 2];
3503
3526
  return [4 /*yield*/, contract.get_dy_underlying(i, j, _amount, curve_1.curve.constantOptions)];
@@ -3515,8 +3538,11 @@ var Pool = /** @class */ (function () {
3515
3538
  }
3516
3539
  });
3517
3540
  }); };
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];
3519
- this.name = name;
3541
+ var poolData = __assign(__assign(__assign({}, curve_1.POOLS_DATA), (curve_1.curve.constants.FACTORY_POOLS_DATA || {})), (curve_1.curve.constants.CRYPTO_FACTORY_POOLS_DATA || {}))[id];
3542
+ this.id = id;
3543
+ this.name = poolData.name;
3544
+ this.fullName = poolData.full_name;
3545
+ this.symbol = poolData.symbol;
3520
3546
  this.referenceAsset = poolData.reference_asset;
3521
3547
  this.swap = poolData.swap_address;
3522
3548
  this.zap = poolData.deposit_address || null;
@@ -4125,3 +4151,32 @@ var crossAssetExchange = function (inputCoin, outputCoin, amount, maxSlippage) {
4125
4151
  });
4126
4152
  };
4127
4153
  exports.crossAssetExchange = crossAssetExchange;
4154
+ var getUserPoolList = function (address) { return __awaiter(void 0, void 0, void 0, function () {
4155
+ var poolNames, promises, _i, poolNames_1, poolName, pool, userPoolList, balances, i;
4156
+ return __generator(this, function (_a) {
4157
+ switch (_a.label) {
4158
+ case 0:
4159
+ if (!address)
4160
+ address = curve_1.curve.signerAddress;
4161
+ address = address;
4162
+ poolNames = __spreadArray(__spreadArray(__spreadArray([], (0, utils_1.getPoolList)(), true), (0, utils_1.getFactoryPoolList)(), true), (0, utils_1.getCryptoFactoryPoolList)(), true);
4163
+ promises = [];
4164
+ for (_i = 0, poolNames_1 = poolNames; _i < poolNames_1.length; _i++) {
4165
+ poolName = poolNames_1[_i];
4166
+ pool = new Pool(poolName);
4167
+ promises.push(pool.lpTokenBalances(address)); // TODO optimization
4168
+ }
4169
+ userPoolList = [];
4170
+ return [4 /*yield*/, Promise.all(promises)];
4171
+ case 1:
4172
+ balances = (_a.sent()).map(function (lpBalance) { return Object.values(lpBalance).map(Number).reduce(function (a, b) { return a + b; }); });
4173
+ for (i = 0; i < poolNames.length; i++) {
4174
+ if (balances[i] > 0) {
4175
+ userPoolList.push(poolNames[i]);
4176
+ }
4177
+ }
4178
+ return [2 /*return*/, userPoolList];
4179
+ }
4180
+ });
4181
+ }); };
4182
+ exports.getUserPoolList = getUserPoolList;