@curvefi/api 1.10.0 → 1.11.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
@@ -62,9 +62,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
62
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;
63
63
  var ethers_1 = require("ethers");
64
64
  var utils_1 = require("./utils");
65
- var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
66
65
  var curve_1 = require("./curve");
67
- var coins_1 = require("./constants/coins");
68
66
  var axios_1 = __importDefault(require("axios"));
69
67
  var Pool = /** @class */ (function () {
70
68
  function Pool(name) {
@@ -83,7 +81,7 @@ var Pool = /** @class */ (function () {
83
81
  _amounts = amounts.map(function (amount, i) {
84
82
  return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]);
85
83
  });
86
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 2];
84
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
87
85
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, isDeposit)];
88
86
  case 1:
89
87
  _expected = _a.sent(); // Lending pools
@@ -111,6 +109,9 @@ var Pool = /** @class */ (function () {
111
109
  return __generator(this, function (_a) {
112
110
  switch (_a.label) {
113
111
  case 0:
112
+ if (this.isFake) {
113
+ throw Error("".concat(this.name, " pool doesn't have this method"));
114
+ }
114
115
  if (amounts.length !== this.coinAddresses.length) {
115
116
  throw Error("".concat(this.name, " pool has ").concat(this.coinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
116
117
  }
@@ -146,19 +147,21 @@ var Pool = /** @class */ (function () {
146
147
  contractCalls = this.coins.map(function (_, i) { return swapContract.balances(i); });
147
148
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
148
149
  case 1:
149
- _poolWrappedBalances = (_a.sent());
150
+ _poolWrappedBalances = _a.sent();
150
151
  _poolUnderlyingBalances = [];
151
152
  if (!this.isMeta) return [3 /*break*/, 3];
152
- _poolWrappedBalances.unshift(_poolWrappedBalances.pop());
153
+ if (this.name !== 'atricrypto3') {
154
+ _poolWrappedBalances.unshift(_poolWrappedBalances.pop());
155
+ }
153
156
  _poolMetaCoinBalance = _poolWrappedBalances[0], _poolUnderlyingBalance = _poolWrappedBalances.slice(1);
154
157
  basePool = new Pool(this.basePool);
155
158
  return [4 /*yield*/, basePool._calcExpectedAmounts(_poolMetaCoinBalance)];
156
159
  case 2:
157
160
  _basePoolExpectedAmounts = _a.sent();
158
- _poolUnderlyingBalances = __spreadArray(__spreadArray([], _poolUnderlyingBalance, true), _basePoolExpectedAmounts, true);
161
+ _poolUnderlyingBalances = this.name !== 'atricrypto3' ? __spreadArray(__spreadArray([], _poolUnderlyingBalance, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _poolUnderlyingBalance, true);
159
162
  return [3 /*break*/, 6];
160
163
  case 3:
161
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 5];
164
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
162
165
  return [4 /*yield*/, this._getRates()];
163
166
  case 4:
164
167
  _rates_1 = _a.sent();
@@ -172,15 +175,20 @@ var Pool = /** @class */ (function () {
172
175
  });
173
176
  }); };
174
177
  this.getPoolWrappedBalances = function () { return __awaiter(_this, void 0, void 0, function () {
175
- var swapContract, contractCalls;
178
+ var swapContract, contractCalls, _wrappedBalances;
176
179
  var _this = this;
177
180
  return __generator(this, function (_a) {
178
181
  switch (_a.label) {
179
182
  case 0:
183
+ if (this.isFake) {
184
+ throw Error("".concat(this.name, " pool doesn't have this method"));
185
+ }
180
186
  swapContract = curve_1.curve.contracts[this.swap].multicallContract;
181
187
  contractCalls = this.coins.map(function (_, i) { return swapContract.balances(i); });
182
188
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
183
- case 1: return [2 /*return*/, (_a.sent()).map(function (_b, i) { return ethers_1.ethers.utils.formatUnits(_b, _this.decimals[i]); })];
189
+ case 1:
190
+ _wrappedBalances = _a.sent();
191
+ return [2 /*return*/, _wrappedBalances.map(function (_b, i) { return ethers_1.ethers.utils.formatUnits(_b, _this.decimals[i]); })];
184
192
  }
185
193
  });
186
194
  }); };
@@ -273,7 +281,7 @@ var Pool = /** @class */ (function () {
273
281
  return [4 /*yield*/, this._addLiquidityZap(_amounts, true)];
274
282
  case 3: return [2 /*return*/, _d.sent()];
275
283
  case 4:
276
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 6];
284
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 6];
277
285
  return [4 /*yield*/, this._addLiquidity(_amounts, true, true)];
278
286
  case 5: return [2 /*return*/, _d.sent()];
279
287
  case 6:
@@ -321,7 +329,7 @@ var Pool = /** @class */ (function () {
321
329
  return [4 /*yield*/, this._addLiquidityZap(_amounts)];
322
330
  case 2: return [2 /*return*/, _a.sent()];
323
331
  case 3:
324
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 5];
332
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
325
333
  return [4 /*yield*/, this._addLiquidity(_amounts, true)];
326
334
  case 4: return [2 /*return*/, _a.sent()];
327
335
  case 5:
@@ -339,7 +347,11 @@ var Pool = /** @class */ (function () {
339
347
  var poolBalances, walletBalances, _a, _c;
340
348
  return __generator(this, function (_d) {
341
349
  switch (_d.label) {
342
- case 0: return [4 /*yield*/, this.getPoolWrappedBalances()];
350
+ case 0:
351
+ if (this.isFake) {
352
+ throw Error("".concat(this.name, " pool doesn't have this method"));
353
+ }
354
+ return [4 /*yield*/, this.getPoolWrappedBalances()];
343
355
  case 1:
344
356
  poolBalances = (_d.sent()).map(Number);
345
357
  _c = (_a = Object).values;
@@ -355,6 +367,9 @@ var Pool = /** @class */ (function () {
355
367
  return __generator(this, function (_a) {
356
368
  switch (_a.label) {
357
369
  case 0:
370
+ if (this.isFake) {
371
+ throw Error("".concat(this.name, " pool doesn't have this method"));
372
+ }
358
373
  amounts = amounts.map(function (a, i) { return Number(a).toFixed(_this.decimals[i]); });
359
374
  return [4 /*yield*/, this.calcLpTokenAmountWrapped(amounts)];
360
375
  case 1: return [2 /*return*/, _a.sent()];
@@ -366,6 +381,9 @@ var Pool = /** @class */ (function () {
366
381
  return __generator(this, function (_c) {
367
382
  switch (_c.label) {
368
383
  case 0:
384
+ if (this.isFake) {
385
+ throw Error("".concat(this.name, " pool doesn't have this method"));
386
+ }
369
387
  totalAmount = amounts.reduce(function (s, a) { return s + Number(a); }, 0);
370
388
  _a = Number;
371
389
  return [4 /*yield*/, this.addLiquidityWrappedExpected(amounts)];
@@ -379,7 +397,11 @@ var Pool = /** @class */ (function () {
379
397
  this.addLiquidityWrappedIsApproved = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
380
398
  return __generator(this, function (_a) {
381
399
  switch (_a.label) {
382
- case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)(this.coinAddresses, amounts, curve_1.curve.signerAddress, this.swap)];
400
+ case 0:
401
+ if (this.isFake) {
402
+ throw Error("".concat(this.name, " pool doesn't have this method"));
403
+ }
404
+ return [4 /*yield*/, (0, utils_1.hasAllowance)(this.coinAddresses, amounts, curve_1.curve.signerAddress, this.swap)];
383
405
  case 1: return [2 /*return*/, _a.sent()];
384
406
  }
385
407
  });
@@ -387,7 +409,11 @@ var Pool = /** @class */ (function () {
387
409
  this.addLiquidityWrappedApproveEstimateGas = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
388
410
  return __generator(this, function (_a) {
389
411
  switch (_a.label) {
390
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.coinAddresses, amounts, this.swap)];
412
+ case 0:
413
+ if (this.isFake) {
414
+ throw Error("".concat(this.name, " pool doesn't have this method"));
415
+ }
416
+ return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.coinAddresses, amounts, this.swap)];
391
417
  case 1: return [2 /*return*/, _a.sent()];
392
418
  }
393
419
  });
@@ -395,7 +421,11 @@ var Pool = /** @class */ (function () {
395
421
  this.addLiquidityWrappedApprove = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
396
422
  return __generator(this, function (_a) {
397
423
  switch (_a.label) {
398
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.coinAddresses, amounts, this.swap)];
424
+ case 0:
425
+ if (this.isFake) {
426
+ throw Error("".concat(this.name, " pool doesn't have this method"));
427
+ }
428
+ return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.coinAddresses, amounts, this.swap)];
399
429
  case 1: return [2 /*return*/, _a.sent()];
400
430
  }
401
431
  });
@@ -406,6 +436,9 @@ var Pool = /** @class */ (function () {
406
436
  return __generator(this, function (_d) {
407
437
  switch (_d.label) {
408
438
  case 0:
439
+ if (this.isFake) {
440
+ throw Error("".concat(this.name, " pool doesn't have this method"));
441
+ }
409
442
  if (amounts.length !== this.coinAddresses.length) {
410
443
  throw Error("".concat(this.name, " pool has ").concat(this.coinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
411
444
  }
@@ -426,7 +459,7 @@ var Pool = /** @class */ (function () {
426
459
  _amounts = amounts.map(function (amount, i) {
427
460
  return ethers_1.ethers.utils.parseUnits(amount, _this.decimals[i]);
428
461
  });
429
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 4];
462
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
430
463
  return [4 /*yield*/, this._addLiquidity(_amounts, false, true)];
431
464
  case 3: return [2 /*return*/, _d.sent()];
432
465
  case 4: return [4 /*yield*/, this._addLiquiditySwap(_amounts, true)];
@@ -442,6 +475,9 @@ var Pool = /** @class */ (function () {
442
475
  return __generator(this, function (_a) {
443
476
  switch (_a.label) {
444
477
  case 0:
478
+ if (this.isFake) {
479
+ throw Error("".concat(this.name, " pool doesn't have this method"));
480
+ }
445
481
  if (amounts.length !== this.coinAddresses.length) {
446
482
  throw Error("".concat(this.name, " pool has ").concat(this.coinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
447
483
  }
@@ -451,7 +487,7 @@ var Pool = /** @class */ (function () {
451
487
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
452
488
  case 1:
453
489
  _a.sent();
454
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 3];
490
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
455
491
  return [4 /*yield*/, this._addLiquidity(_amounts, false)];
456
492
  case 2: return [2 /*return*/, _a.sent()];
457
493
  case 3: return [4 /*yield*/, this._addLiquiditySwap(_amounts)];
@@ -468,7 +504,7 @@ var Pool = /** @class */ (function () {
468
504
  switch (_a.label) {
469
505
  case 0:
470
506
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
471
- if (!['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 2];
507
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
472
508
  return [4 /*yield*/, this._calcExpectedUnderlyingAmounts(_lpTokenAmount)];
473
509
  case 1:
474
510
  _expected = _a.sent(); // Lending pools
@@ -545,7 +581,7 @@ var Pool = /** @class */ (function () {
545
581
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount, true)];
546
582
  case 4: return [2 /*return*/, _c.sent()];
547
583
  case 5:
548
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 7];
584
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
549
585
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true, true)];
550
586
  case 6: return [2 /*return*/, _c.sent()];
551
587
  case 7:
@@ -570,7 +606,7 @@ var Pool = /** @class */ (function () {
570
606
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount)];
571
607
  case 2: return [2 /*return*/, _a.sent()];
572
608
  case 3:
573
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 5];
609
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
574
610
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true)];
575
611
  case 4: return [2 /*return*/, _a.sent()];
576
612
  case 5:
@@ -588,6 +624,9 @@ var Pool = /** @class */ (function () {
588
624
  return __generator(this, function (_a) {
589
625
  switch (_a.label) {
590
626
  case 0:
627
+ if (this.isFake) {
628
+ throw Error("".concat(this.name, " pool doesn't have this method"));
629
+ }
591
630
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
592
631
  return [4 /*yield*/, this._calcExpectedAmounts(_lpTokenAmount)];
593
632
  case 1:
@@ -601,6 +640,9 @@ var Pool = /** @class */ (function () {
601
640
  return __generator(this, function (_a) {
602
641
  switch (_a.label) {
603
642
  case 0:
643
+ if (this.isFake) {
644
+ throw Error("".concat(this.name, " pool doesn't have this method"));
645
+ }
604
646
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
605
647
  return [4 /*yield*/, this.lpTokenBalances()];
606
648
  case 1:
@@ -608,7 +650,7 @@ var Pool = /** @class */ (function () {
608
650
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
609
651
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
610
652
  }
611
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 3];
653
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
612
654
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false, true)];
613
655
  case 2: return [2 /*return*/, _a.sent()];
614
656
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount, true)];
@@ -621,11 +663,14 @@ var Pool = /** @class */ (function () {
621
663
  return __generator(this, function (_a) {
622
664
  switch (_a.label) {
623
665
  case 0:
666
+ if (this.isFake) {
667
+ throw Error("".concat(this.name, " pool doesn't have this method"));
668
+ }
624
669
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
625
670
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
626
671
  case 1:
627
672
  _a.sent();
628
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 3];
673
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
629
674
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false)];
630
675
  case 2: return [2 /*return*/, _a.sent()];
631
676
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount)];
@@ -779,7 +824,7 @@ var Pool = /** @class */ (function () {
779
824
  return [4 /*yield*/, this._removeLiquidityImbalanceZap(_amounts, true)];
780
825
  case 5: return [2 /*return*/, _c.sent()];
781
826
  case 6:
782
- if (!['aave', 'saave', 'ib'].includes(this.name)) return [3 /*break*/, 8];
827
+ if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 8];
783
828
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, true, true)];
784
829
  case 7: return [2 /*return*/, _c.sent()];
785
830
  case 8:
@@ -808,7 +853,7 @@ var Pool = /** @class */ (function () {
808
853
  return [4 /*yield*/, this._removeLiquidityImbalanceZap(_amounts)];
809
854
  case 2: return [2 /*return*/, _a.sent()];
810
855
  case 3:
811
- if (!['aave', 'saave', 'ib'].includes(this.name)) return [3 /*break*/, 5];
856
+ if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
812
857
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, true)];
813
858
  case 4: return [2 /*return*/, _a.sent()];
814
859
  case 5:
@@ -871,7 +916,7 @@ var Pool = /** @class */ (function () {
871
916
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
872
917
  }
873
918
  _amounts = amounts.map(function (amount, i) { return ethers_1.ethers.utils.parseUnits(amount, _this.decimals[i]); });
874
- if (!['aave', 'saave', 'ib'].includes(this.name)) return [3 /*break*/, 4];
919
+ if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
875
920
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, false, true)];
876
921
  case 3: return [2 /*return*/, _a.sent()];
877
922
  case 4: return [4 /*yield*/, this._removeLiquidityImbalanceSwap(_amounts, true)];
@@ -894,7 +939,7 @@ var Pool = /** @class */ (function () {
894
939
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
895
940
  case 1:
896
941
  _a.sent();
897
- if (!['aave', 'saave', 'ib'].includes(this.name)) return [3 /*break*/, 3];
942
+ if (!(['aave', 'saave', 'ib'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
898
943
  return [4 /*yield*/, this._removeLiquidityImbalance(_amounts, false, estimateGas)];
899
944
  case 2: return [2 /*return*/, _a.sent()];
900
945
  case 3: return [4 /*yield*/, this._removeLiquidityImbalanceSwap(_amounts, estimateGas)];
@@ -1002,7 +1047,7 @@ var Pool = /** @class */ (function () {
1002
1047
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i, true)];
1003
1048
  case 4: return [2 /*return*/, _c.sent()];
1004
1049
  case 5:
1005
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 7];
1050
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1006
1051
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true, true)];
1007
1052
  case 6: return [2 /*return*/, _c.sent()];
1008
1053
  case 7: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1026,7 +1071,7 @@ var Pool = /** @class */ (function () {
1026
1071
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i)];
1027
1072
  case 2: return [2 /*return*/, _a.sent()];
1028
1073
  case 3:
1029
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 5];
1074
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1030
1075
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true)];
1031
1076
  case 4: return [2 /*return*/, _a.sent()];
1032
1077
  case 5: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1041,6 +1086,9 @@ var Pool = /** @class */ (function () {
1041
1086
  return __generator(this, function (_a) {
1042
1087
  switch (_a.label) {
1043
1088
  case 0:
1089
+ if (this.isFake) {
1090
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1091
+ }
1044
1092
  if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) {
1045
1093
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1046
1094
  }
@@ -1064,6 +1112,9 @@ var Pool = /** @class */ (function () {
1064
1112
  return __generator(this, function (_c) {
1065
1113
  switch (_c.label) {
1066
1114
  case 0:
1115
+ if (this.isFake) {
1116
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1117
+ }
1067
1118
  _a = Number;
1068
1119
  return [4 /*yield*/, this.removeLiquidityOneCoinWrappedExpected(lpTokenAmount, coin)];
1069
1120
  case 1:
@@ -1077,7 +1128,11 @@ var Pool = /** @class */ (function () {
1077
1128
  var lpTokenBalance, i, _lpTokenAmount;
1078
1129
  return __generator(this, function (_a) {
1079
1130
  switch (_a.label) {
1080
- case 0: return [4 /*yield*/, this.lpTokenBalances()];
1131
+ case 0:
1132
+ if (this.isFake) {
1133
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1134
+ }
1135
+ return [4 /*yield*/, this.lpTokenBalances()];
1081
1136
  case 1:
1082
1137
  lpTokenBalance = (_a.sent())['lpToken'];
1083
1138
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
@@ -1088,7 +1143,7 @@ var Pool = /** @class */ (function () {
1088
1143
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1089
1144
  }
1090
1145
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1091
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 3];
1146
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1092
1147
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false, true)];
1093
1148
  case 2: return [2 /*return*/, _a.sent()];
1094
1149
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1101,6 +1156,9 @@ var Pool = /** @class */ (function () {
1101
1156
  return __generator(this, function (_a) {
1102
1157
  switch (_a.label) {
1103
1158
  case 0:
1159
+ if (this.isFake) {
1160
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1161
+ }
1104
1162
  i = this._getCoinIdx(coin, false);
1105
1163
  if (['compound', 'usdt', 'y', 'busd', 'pax'].includes(this.name)) {
1106
1164
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
@@ -1109,7 +1167,7 @@ var Pool = /** @class */ (function () {
1109
1167
  case 1:
1110
1168
  _a.sent();
1111
1169
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1112
- if (!['aave', 'saave', 'ib', 'crveth'].includes(this.name)) return [3 /*break*/, 3];
1170
+ if (!(['aave', 'saave', 'ib', 'crveth'].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1113
1171
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false)];
1114
1172
  case 2: return [2 /*return*/, _a.sent()];
1115
1173
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1278,7 +1336,7 @@ var Pool = /** @class */ (function () {
1278
1336
  return __generator(this, function (_a) {
1279
1337
  switch (_a.label) {
1280
1338
  case 0:
1281
- contractAddress = this.name === "eurtusd" ? this.zap : this.swap;
1339
+ contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1282
1340
  i = this._getCoinIdx(inputCoin);
1283
1341
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
1284
1342
  case 1: return [2 /*return*/, _a.sent()];
@@ -1290,7 +1348,7 @@ var Pool = /** @class */ (function () {
1290
1348
  return __generator(this, function (_a) {
1291
1349
  switch (_a.label) {
1292
1350
  case 0:
1293
- contractAddress = this.name === "eurtusd" ? this.zap : this.swap;
1351
+ contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1294
1352
  i = this._getCoinIdx(inputCoin);
1295
1353
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
1296
1354
  case 1: return [2 /*return*/, _a.sent()];
@@ -1302,7 +1360,7 @@ var Pool = /** @class */ (function () {
1302
1360
  return __generator(this, function (_a) {
1303
1361
  switch (_a.label) {
1304
1362
  case 0:
1305
- contractAddress = this.name === "eurtusd" ? this.zap : this.swap;
1363
+ contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1306
1364
  i = this._getCoinIdx(inputCoin);
1307
1365
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
1308
1366
  case 1: return [2 /*return*/, _a.sent()];
@@ -1312,10 +1370,11 @@ var Pool = /** @class */ (function () {
1312
1370
  this.exchangeEstimateGas = function (inputCoin, outputCoin, amount, maxSlippage) {
1313
1371
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
1314
1372
  return __awaiter(_this, void 0, void 0, function () {
1315
- var i, j, inputCoinBalance, _a, _c, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contractAddress, contract, exchangeMethod, value;
1373
+ var contractAddress, i, j, inputCoinBalance, _a, _c, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, exchangeMethod, value;
1316
1374
  return __generator(this, function (_d) {
1317
1375
  switch (_d.label) {
1318
1376
  case 0:
1377
+ contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1319
1378
  i = this._getCoinIdx(inputCoin);
1320
1379
  j = this._getCoinIdx(outputCoin);
1321
1380
  _c = (_a = Object).values;
@@ -1325,7 +1384,7 @@ var Pool = /** @class */ (function () {
1325
1384
  if (Number(inputCoinBalance) < Number(amount)) {
1326
1385
  throw Error("Not enough ".concat(this.underlyingCoins[i], ". Actual: ").concat(inputCoinBalance, ", required: ").concat(amount));
1327
1386
  }
1328
- return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, this.swap)];
1387
+ return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
1329
1388
  case 2:
1330
1389
  if (!(_d.sent())) {
1331
1390
  throw Error("Token allowance is needed to estimate gas");
@@ -1337,7 +1396,6 @@ var Pool = /** @class */ (function () {
1337
1396
  outputCoinDecimals = (0, utils_1._getCoinDecimals)(this.underlyingCoinAddresses[j])[0];
1338
1397
  minRecvAmountBN = (0, utils_1.toBN)(_expected, outputCoinDecimals).times(1 - maxSlippage);
1339
1398
  _minRecvAmount = (0, utils_1.fromBN)(minRecvAmountBN, outputCoinDecimals);
1340
- contractAddress = this.name === "eurtusd" ? this.zap : this.swap;
1341
1399
  contract = curve_1.curve.contracts[contractAddress].contract;
1342
1400
  exchangeMethod = Object.prototype.hasOwnProperty.call(contract, 'exchange_underlying') ? 'exchange_underlying' : 'exchange';
1343
1401
  value = (0, utils_1.isEth)(this.underlyingCoinAddresses[i]) ? _amount : ethers_1.ethers.BigNumber.from(0);
@@ -1353,10 +1411,11 @@ var Pool = /** @class */ (function () {
1353
1411
  this.exchange = function (inputCoin, outputCoin, amount, maxSlippage) {
1354
1412
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
1355
1413
  return __awaiter(_this, void 0, void 0, function () {
1356
- var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contractAddress, contract, exchangeMethod, value, gasLimit_1, gasLimit;
1414
+ var contractAddress, i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, exchangeMethod, value, gasLimit_1, estimatedGas, gasLimit;
1357
1415
  return __generator(this, function (_a) {
1358
1416
  switch (_a.label) {
1359
1417
  case 0:
1418
+ contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1360
1419
  i = this._getCoinIdx(inputCoin);
1361
1420
  j = this._getCoinIdx(outputCoin);
1362
1421
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.underlyingDecimals[i]);
@@ -1366,10 +1425,9 @@ var Pool = /** @class */ (function () {
1366
1425
  outputCoinDecimals = (0, utils_1._getCoinDecimals)(this.underlyingCoinAddresses[j])[0];
1367
1426
  minRecvAmountBN = (0, utils_1.toBN)(_expected, outputCoinDecimals).times(1 - maxSlippage);
1368
1427
  _minRecvAmount = (0, utils_1.fromBN)(minRecvAmountBN, outputCoinDecimals);
1369
- return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.underlyingCoinAddresses[i]], [_amount], this.swap)];
1428
+ return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.underlyingCoinAddresses[i]], [_amount], contractAddress)];
1370
1429
  case 2:
1371
1430
  _a.sent();
1372
- contractAddress = this.name === "eurtusd" ? this.zap : this.swap;
1373
1431
  contract = curve_1.curve.contracts[contractAddress].contract;
1374
1432
  exchangeMethod = Object.prototype.hasOwnProperty.call(contract, 'exchange_underlying') ? 'exchange_underlying' : 'exchange';
1375
1433
  value = (0, utils_1.isEth)(this.underlyingCoinAddresses[i]) ? _amount : ethers_1.ethers.BigNumber.from(0);
@@ -1384,7 +1442,10 @@ var Pool = /** @class */ (function () {
1384
1442
  case 5: return [2 /*return*/, (_a.sent()).hash];
1385
1443
  case 6: return [4 /*yield*/, contract.estimateGas[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
1386
1444
  case 7:
1387
- gasLimit = (_a.sent()).mul(130).div(100);
1445
+ estimatedGas = _a.sent();
1446
+ gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
1447
+ estimatedGas.mul(160).div(100) :
1448
+ estimatedGas.mul(130).div(100);
1388
1449
  return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
1389
1450
  case 8: return [2 /*return*/, (_a.sent()).hash];
1390
1451
  }
@@ -1396,6 +1457,9 @@ var Pool = /** @class */ (function () {
1396
1457
  return __generator(this, function (_a) {
1397
1458
  switch (_a.label) {
1398
1459
  case 0:
1460
+ if (this.isFake) {
1461
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1462
+ }
1399
1463
  i = this._getCoinIdx(inputCoin, false);
1400
1464
  j = this._getCoinIdx(outputCoin, false);
1401
1465
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.decimals[i]);
@@ -1411,6 +1475,9 @@ var Pool = /** @class */ (function () {
1411
1475
  return __generator(this, function (_a) {
1412
1476
  switch (_a.label) {
1413
1477
  case 0:
1478
+ if (this.isFake) {
1479
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1480
+ }
1414
1481
  i = this._getCoinIdx(inputCoin, false);
1415
1482
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.coinAddresses[i]], [amount], curve_1.curve.signerAddress, this.swap)];
1416
1483
  case 1: return [2 /*return*/, _a.sent()];
@@ -1422,6 +1489,9 @@ var Pool = /** @class */ (function () {
1422
1489
  return __generator(this, function (_a) {
1423
1490
  switch (_a.label) {
1424
1491
  case 0:
1492
+ if (this.isFake) {
1493
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1494
+ }
1425
1495
  i = this._getCoinIdx(inputCoin, false);
1426
1496
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.coinAddresses[i]], [amount], this.swap)];
1427
1497
  case 1: return [2 /*return*/, _a.sent()];
@@ -1433,6 +1503,9 @@ var Pool = /** @class */ (function () {
1433
1503
  return __generator(this, function (_a) {
1434
1504
  switch (_a.label) {
1435
1505
  case 0:
1506
+ if (this.isFake) {
1507
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1508
+ }
1436
1509
  i = this._getCoinIdx(inputCoin, false);
1437
1510
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.coinAddresses[i]], [amount], this.swap)];
1438
1511
  case 1: return [2 /*return*/, _a.sent()];
@@ -1446,6 +1519,9 @@ var Pool = /** @class */ (function () {
1446
1519
  return __generator(this, function (_d) {
1447
1520
  switch (_d.label) {
1448
1521
  case 0:
1522
+ if (this.isFake) {
1523
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1524
+ }
1449
1525
  i = this._getCoinIdx(inputCoin, false);
1450
1526
  j = this._getCoinIdx(outputCoin, false);
1451
1527
  _c = (_a = Object).values;
@@ -1481,10 +1557,13 @@ var Pool = /** @class */ (function () {
1481
1557
  this.exchangeWrapped = function (inputCoin, outputCoin, amount, maxSlippage) {
1482
1558
  if (maxSlippage === void 0) { maxSlippage = 0.01; }
1483
1559
  return __awaiter(_this, void 0, void 0, function () {
1484
- var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit_2, gasLimit;
1560
+ var i, j, _amount, _expected, outputCoinDecimals, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit_2, estimatedGas, gasLimit;
1485
1561
  return __generator(this, function (_a) {
1486
1562
  switch (_a.label) {
1487
1563
  case 0:
1564
+ if (this.isFake) {
1565
+ throw Error("".concat(this.name, " pool doesn't have this method"));
1566
+ }
1488
1567
  i = this._getCoinIdx(inputCoin, false);
1489
1568
  j = this._getCoinIdx(outputCoin, false);
1490
1569
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.decimals[i]);
@@ -1510,7 +1589,10 @@ var Pool = /** @class */ (function () {
1510
1589
  case 5: return [2 /*return*/, (_a.sent()).hash];
1511
1590
  case 6: return [4 /*yield*/, contract.estimateGas.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
1512
1591
  case 7:
1513
- gasLimit = (_a.sent()).mul(130).div(100);
1592
+ estimatedGas = _a.sent();
1593
+ gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
1594
+ estimatedGas.mul(140).div(100) :
1595
+ estimatedGas.mul(130).div(100);
1514
1596
  return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
1515
1597
  case 8: return [2 /*return*/, (_a.sent()).hash];
1516
1598
  }
@@ -1523,7 +1605,7 @@ var Pool = /** @class */ (function () {
1523
1605
  addresses[_i] = arguments[_i];
1524
1606
  }
1525
1607
  return __awaiter(_this, void 0, void 0, function () {
1526
- var votingEscrowContract, gaugeContract, contractCalls, response, _a, veTotalSupply, gaugeTotalSupply, resultBN, result, _c, _d, entry;
1608
+ var votingEscrowContract, gaugeContract, contractCalls, _response, responseBN, _a, veTotalSupplyBN, gaugeTotalSupplyBN, resultBN, result, _c, _d, entry;
1527
1609
  return __generator(this, function (_e) {
1528
1610
  switch (_e.label) {
1529
1611
  case 0:
@@ -1537,11 +1619,12 @@ var Pool = /** @class */ (function () {
1537
1619
  });
1538
1620
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
1539
1621
  case 1:
1540
- response = (_e.sent()).map(function (value) { return (0, utils_1.toBN)(value); });
1541
- _a = response.splice(0, 2), veTotalSupply = _a[0], gaugeTotalSupply = _a[1];
1622
+ _response = _e.sent();
1623
+ responseBN = _response.map(function (value) { return (0, utils_1.toBN)(value); });
1624
+ _a = responseBN.splice(0, 2), veTotalSupplyBN = _a[0], gaugeTotalSupplyBN = _a[1];
1542
1625
  resultBN = {};
1543
1626
  addresses.forEach(function (acct, i) {
1544
- resultBN[acct] = response[i].div(veTotalSupply).times(gaugeTotalSupply);
1627
+ resultBN[acct] = responseBN[i].div(veTotalSupplyBN).times(gaugeTotalSupplyBN);
1545
1628
  });
1546
1629
  result = {};
1547
1630
  for (_c = 0, _d = Object.entries(resultBN); _c < _d.length; _c++) {
@@ -1559,7 +1642,7 @@ var Pool = /** @class */ (function () {
1559
1642
  accounts[_i] = arguments[_i];
1560
1643
  }
1561
1644
  return __awaiter(_this, void 0, void 0, function () {
1562
- var votingEscrowContract, lpTokenContract, gaugeContract, contractCalls, response, _a, veTotalSupply, gaugeTotalSupply, votingPower, totalBalance, _c, accounts_1, acct, totalPower, optimalBN, _d, accounts_2, acct, amount, _e, accounts_3, acct, optimal, _f, _h, entry;
1645
+ var votingEscrowContract, lpTokenContract, gaugeContract, contractCalls, _response, response, _a, veTotalSupply, gaugeTotalSupply, votingPower, totalBalance, _c, accounts_1, acct, totalPower, optimalBN, _d, accounts_2, acct, amount, _e, accounts_3, acct, optimal, _f, _h, entry;
1563
1646
  return __generator(this, function (_j) {
1564
1647
  switch (_j.label) {
1565
1648
  case 0:
@@ -1574,7 +1657,8 @@ var Pool = /** @class */ (function () {
1574
1657
  });
1575
1658
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
1576
1659
  case 1:
1577
- response = (_j.sent()).map(function (value) { return (0, utils_1.toBN)(value); });
1660
+ _response = _j.sent();
1661
+ response = _response.map(function (value) { return (0, utils_1.toBN)(value); });
1578
1662
  _a = response.splice(0, 2), veTotalSupply = _a[0], gaugeTotalSupply = _a[1];
1579
1663
  votingPower = {};
1580
1664
  totalBalance = (0, utils_1.BN)(0);
@@ -2126,13 +2210,15 @@ var Pool = /** @class */ (function () {
2126
2210
  case 0: return [4 /*yield*/, this._calcExpectedAmounts(_lpTokenAmount)];
2127
2211
  case 1:
2128
2212
  _expectedWrappedAmounts = _a.sent();
2129
- _expectedWrappedAmounts.unshift(_expectedWrappedAmounts.pop());
2213
+ if (this.name !== 'atricrypto3') {
2214
+ _expectedWrappedAmounts.unshift(_expectedWrappedAmounts.pop());
2215
+ }
2130
2216
  _expectedMetaCoinAmount = _expectedWrappedAmounts[0], _expectedUnderlyingAmounts = _expectedWrappedAmounts.slice(1);
2131
2217
  basePool = new Pool(this.basePool);
2132
2218
  return [4 /*yield*/, basePool._calcExpectedAmounts(_expectedMetaCoinAmount)];
2133
2219
  case 2:
2134
2220
  _basePoolExpectedAmounts = _a.sent();
2135
- return [2 /*return*/, __spreadArray(__spreadArray([], _expectedUnderlyingAmounts, true), _basePoolExpectedAmounts, true)];
2221
+ return [2 /*return*/, this.name !== 'atricrypto3' ? __spreadArray(__spreadArray([], _expectedUnderlyingAmounts, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _expectedUnderlyingAmounts, true)];
2136
2222
  }
2137
2223
  });
2138
2224
  }); };
@@ -2386,7 +2472,9 @@ var Pool = /** @class */ (function () {
2386
2472
  if (estimateGas) {
2387
2473
  return [2 /*return*/, gas.toNumber()];
2388
2474
  }
2389
- gasLimit = gas.mul(130).div(100);
2475
+ gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
2476
+ gas.mul(140).div(100) :
2477
+ gas.mul(130).div(100);
2390
2478
  return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, useUnderlying, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
2391
2479
  case 6: return [2 /*return*/, (_c.sent()).hash];
2392
2480
  }
@@ -2525,7 +2613,9 @@ var Pool = /** @class */ (function () {
2525
2613
  if (estimateGas) {
2526
2614
  return [2 /*return*/, gas.toNumber()];
2527
2615
  }
2528
- gasLimit = gas.mul(130).div(100);
2616
+ gasLimit = curve_1.curve.chainId === 137 && this.name === 'ren' ?
2617
+ gas.mul(160).div(100) :
2618
+ gas.mul(130).div(100);
2529
2619
  return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, useUnderlying, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
2530
2620
  case 6: return [2 /*return*/, (_c.sent()).hash];
2531
2621
  }
@@ -2537,7 +2627,7 @@ var Pool = /** @class */ (function () {
2537
2627
  return __generator(this, function (_a) {
2538
2628
  switch (_a.label) {
2539
2629
  case 0:
2540
- contractAddress = this.name === "eurtusd" ? this.zap : this.swap;
2630
+ contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2541
2631
  contract = curve_1.curve.contracts[contractAddress].contract;
2542
2632
  if (!Object.prototype.hasOwnProperty.call(contract, 'get_dy_underlying')) return [3 /*break*/, 2];
2543
2633
  return [4 /*yield*/, contract.get_dy_underlying(i, j, _amount, curve_1.curve.constantOptions)];
@@ -2555,7 +2645,7 @@ var Pool = /** @class */ (function () {
2555
2645
  }
2556
2646
  });
2557
2647
  }); };
2558
- var poolData = abis_ethereum_1.poolsData[name];
2648
+ var poolData = curve_1.POOLS_DATA[name];
2559
2649
  this.name = name;
2560
2650
  this.swap = poolData.swap_address;
2561
2651
  this.zap = poolData.deposit_address || null;
@@ -2569,6 +2659,7 @@ var Pool = /** @class */ (function () {
2569
2659
  this.decimals = poolData.decimals;
2570
2660
  this.useLending = poolData.use_lending;
2571
2661
  this.isMeta = poolData.is_meta || false;
2662
+ this.isFake = poolData.is_fake || false;
2572
2663
  this.isCrypto = poolData.is_crypto || false;
2573
2664
  this.isFactory = poolData.is_factory || false;
2574
2665
  this.basePool = poolData.base_pool || '';
@@ -2594,7 +2685,7 @@ var Pool = /** @class */ (function () {
2594
2685
  exchangeWrappedApprove: this.exchangeWrappedApproveEstimateGas,
2595
2686
  exchangeWrapped: this.exchangeWrappedEstimateGas,
2596
2687
  };
2597
- if (this.isMeta) {
2688
+ if (this.isMeta && !this.isFake) {
2598
2689
  var metaCoins = poolData.meta_coin_addresses;
2599
2690
  var metaCoinDecimals = poolData.meta_coin_decimals;
2600
2691
  this.underlyingCoinAddresses = __spreadArray([this.underlyingCoinAddresses[0]], metaCoins, true);
@@ -2650,7 +2741,7 @@ var _getBestPoolAndOutput = function (inputCoinAddress, outputCoinAddress, amoun
2650
2741
  return __generator(this, function (_d) {
2651
2742
  switch (_d.label) {
2652
2743
  case 0:
2653
- availablePools = Object.entries(abis_ethereum_1.poolsData).map(function (pool) {
2744
+ availablePools = Object.entries(curve_1.POOLS_DATA).map(function (pool) {
2654
2745
  var _a;
2655
2746
  var coin_addresses = pool[1].coin_addresses.map(function (a) { return a.toLowerCase(); });
2656
2747
  var underlying_coin_addresses = pool[1].underlying_coin_addresses.map(function (a) { return a.toLowerCase(); });
@@ -2665,6 +2756,9 @@ var _getBestPoolAndOutput = function (inputCoinAddress, outputCoinAddress, amoun
2665
2756
  underlying_coin_addresses.indexOf(outputCoinAddress.toLowerCase()),
2666
2757
  meta_coin_addresses ? meta_coin_addresses.indexOf(outputCoinAddress.toLowerCase()) : -1,
2667
2758
  ];
2759
+ if (pool[0] === 'atricrypto3') {
2760
+ return null;
2761
+ }
2668
2762
  if (inputCoinIndexes[0] >= 0 && outputCoinIndexes[0] >= 0) {
2669
2763
  return { poolAddress: pool[1].swap_address, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 };
2670
2764
  }
@@ -2705,7 +2799,7 @@ var _getBestPoolAndOutput = function (inputCoinAddress, outputCoinAddress, amoun
2705
2799
  _estimateGasForPools(availablePools.map(function (pool) { return pool.poolAddress; }), inputCoinAddress, outputCoinAddress, _amount),
2706
2800
  (0, utils_1._getUsdRate)(outputCoinAddress),
2707
2801
  axios_1.default.get("https://api.curve.fi/api/getGas"),
2708
- (0, utils_1._getUsdRate)(coins_1.COINS.eth),
2802
+ (0, utils_1._getUsdRate)(curve_1.COINS.eth),
2709
2803
  ])];
2710
2804
  case 3:
2711
2805
  _c = _d.sent(), _expectedAmounts = _c[0], gasAmounts = _c[1], outputCoinUsdRate = _c[2], gasData = _c[3], ethUsdRate = _c[4];
@@ -2846,9 +2940,12 @@ var crossAssetExchangeAvailable = function (inputCoin, outputCoin) { return __aw
2846
2940
  return __generator(this, function (_c) {
2847
2941
  switch (_c.label) {
2848
2942
  case 0:
2943
+ if (curve_1.curve.chainId !== 1) {
2944
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
2945
+ }
2849
2946
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
2850
2947
  // TODO remove it when fixed
2851
- if (inputCoinAddress.toLowerCase() === coins_1.COINS.weth.toLowerCase() || outputCoinAddress.toLowerCase() === coins_1.COINS.weth.toLowerCase())
2948
+ if (inputCoinAddress.toLowerCase() === curve_1.COINS.weth.toLowerCase() || outputCoinAddress.toLowerCase() === curve_1.COINS.weth.toLowerCase())
2852
2949
  return [2 /*return*/, false];
2853
2950
  return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.router].contract];
2854
2951
  case 1:
@@ -2860,11 +2957,11 @@ var crossAssetExchangeAvailable = function (inputCoin, outputCoin) { return __aw
2860
2957
  exports.crossAssetExchangeAvailable = crossAssetExchangeAvailable;
2861
2958
  var _getSmallAmountForCoin = function (coinAddress) {
2862
2959
  var smallAmount = '10'; // $10 or €10
2863
- if (Object.values(coins_1.BTC_COINS_LOWER_CASE).includes(coinAddress.toLowerCase()))
2960
+ if (Object.values(curve_1.BTC_COINS_LOWER_CASE).includes(coinAddress.toLowerCase()))
2864
2961
  smallAmount = '0.00025'; // =10$ when BTC = $40k
2865
- else if (Object.values(coins_1.ETH_COINS_LOWER_CASE).includes(coinAddress.toLowerCase()))
2962
+ else if (Object.values(curve_1.ETH_COINS_LOWER_CASE).includes(coinAddress.toLowerCase()))
2866
2963
  smallAmount = '0.004'; // =10$ when ETH = $2.5k
2867
- else if (Object.values(coins_1.LINK_COINS_LOWER_CASE).includes(coinAddress.toLowerCase()))
2964
+ else if (Object.values(curve_1.LINK_COINS_LOWER_CASE).includes(coinAddress.toLowerCase()))
2868
2965
  smallAmount = '0.5'; // =10$ when LINK = $20
2869
2966
  return smallAmount;
2870
2967
  };
@@ -2901,6 +2998,9 @@ var crossAssetExchangeOutputAndSlippage = function (inputCoin, outputCoin, amoun
2901
2998
  return __generator(this, function (_e) {
2902
2999
  switch (_e.label) {
2903
3000
  case 0:
3001
+ if (curve_1.curve.chainId !== 1) {
3002
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3003
+ }
2904
3004
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
2905
3005
  _c = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _c[0], outputCoinDecimals = _c[1];
2906
3006
  return [4 /*yield*/, (0, exports._crossAssetExchangeInfo)(inputCoinAddress, outputCoinAddress, inputCoinDecimals, outputCoinDecimals, amount)];
@@ -2917,6 +3017,9 @@ var crossAssetExchangeExpected = function (inputCoin, outputCoin, amount) { retu
2917
3017
  return __generator(this, function (_e) {
2918
3018
  switch (_e.label) {
2919
3019
  case 0:
3020
+ if (curve_1.curve.chainId !== 1) {
3021
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3022
+ }
2920
3023
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
2921
3024
  _c = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _c[0], outputCoinDecimals = _c[1];
2922
3025
  return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.router].contract];
@@ -2934,7 +3037,11 @@ exports.crossAssetExchangeExpected = crossAssetExchangeExpected;
2934
3037
  var crossAssetExchangeIsApproved = function (inputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
2935
3038
  return __generator(this, function (_a) {
2936
3039
  switch (_a.label) {
2937
- case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)([inputCoin], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.router)];
3040
+ case 0:
3041
+ if (curve_1.curve.chainId !== 1) {
3042
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3043
+ }
3044
+ return [4 /*yield*/, (0, utils_1.hasAllowance)([inputCoin], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.router)];
2938
3045
  case 1: return [2 /*return*/, _a.sent()];
2939
3046
  }
2940
3047
  });
@@ -2943,7 +3050,11 @@ exports.crossAssetExchangeIsApproved = crossAssetExchangeIsApproved;
2943
3050
  var crossAssetExchangeApproveEstimateGas = function (inputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
2944
3051
  return __generator(this, function (_a) {
2945
3052
  switch (_a.label) {
2946
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([inputCoin], [amount], curve_1.ALIASES.router)];
3053
+ case 0:
3054
+ if (curve_1.curve.chainId !== 1) {
3055
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3056
+ }
3057
+ return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([inputCoin], [amount], curve_1.ALIASES.router)];
2947
3058
  case 1: return [2 /*return*/, _a.sent()];
2948
3059
  }
2949
3060
  });
@@ -2952,7 +3063,11 @@ exports.crossAssetExchangeApproveEstimateGas = crossAssetExchangeApproveEstimate
2952
3063
  var crossAssetExchangeApprove = function (inputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
2953
3064
  return __generator(this, function (_a) {
2954
3065
  switch (_a.label) {
2955
- case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)([inputCoin], [amount], curve_1.ALIASES.router)];
3066
+ case 0:
3067
+ if (curve_1.curve.chainId !== 1) {
3068
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3069
+ }
3070
+ return [4 /*yield*/, (0, utils_1.ensureAllowance)([inputCoin], [amount], curve_1.ALIASES.router)];
2956
3071
  case 1: return [2 /*return*/, _a.sent()];
2957
3072
  }
2958
3073
  });
@@ -2964,7 +3079,11 @@ var crossAssetExchangeEstimateGas = function (inputCoin, outputCoin, amount, max
2964
3079
  var _a, inputCoinAddress, outputCoinAddress, inputCoinBalance, _c, inputCoinDecimals, outputCoinDecimals, _amount, _d, route, indices, _expected, minRecvAmountBN, _minRecvAmount, value, routerContract;
2965
3080
  return __generator(this, function (_e) {
2966
3081
  switch (_e.label) {
2967
- case 0: return [4 /*yield*/, (0, exports.crossAssetExchangeAvailable)(inputCoin, outputCoin)];
3082
+ case 0:
3083
+ if (curve_1.curve.chainId !== 1) {
3084
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3085
+ }
3086
+ return [4 /*yield*/, (0, exports.crossAssetExchangeAvailable)(inputCoin, outputCoin)];
2968
3087
  case 1:
2969
3088
  if (!(_e.sent()))
2970
3089
  throw Error("Such exchange is not available");
@@ -3004,7 +3123,11 @@ var crossAssetExchange = function (inputCoin, outputCoin, amount, maxSlippage) {
3004
3123
  var _a, inputCoinAddress, outputCoinAddress, _c, inputCoinDecimals, outputCoinDecimals, _amount, _d, route, indices, _expected, minRecvAmountBN, _minRecvAmount, value, routerContract, gasLimit;
3005
3124
  return __generator(this, function (_e) {
3006
3125
  switch (_e.label) {
3007
- case 0: return [4 /*yield*/, (0, exports.crossAssetExchangeAvailable)(inputCoin, outputCoin)];
3126
+ case 0:
3127
+ if (curve_1.curve.chainId !== 1) {
3128
+ throw Error("Cross-asset swaps are not available on this network (id".concat(curve_1.curve.chainId, ")"));
3129
+ }
3130
+ return [4 /*yield*/, (0, exports.crossAssetExchangeAvailable)(inputCoin, outputCoin)];
3008
3131
  case 1:
3009
3132
  if (!(_e.sent()))
3010
3133
  throw Error("Such exchange is not available");