@curvefi/api 2.24.1 → 2.24.3

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.
@@ -125,6 +125,10 @@
125
125
  {
126
126
  "name": "_min_dy",
127
127
  "type": "uint256"
128
+ },
129
+ {
130
+ "name": "_use_eth",
131
+ "type": "bool"
128
132
  }
129
133
  ],
130
134
  "outputs": [
@@ -179,6 +183,10 @@
179
183
  {
180
184
  "name": "_min_mint_amount",
181
185
  "type": "uint256"
186
+ },
187
+ {
188
+ "name": "_use_eth",
189
+ "type": "bool"
182
190
  }
183
191
  ],
184
192
  "outputs": [
@@ -225,6 +233,10 @@
225
233
  {
226
234
  "name": "_min_amounts",
227
235
  "type": "uint256[4]"
236
+ },
237
+ {
238
+ "name": "_use_eth",
239
+ "type": "bool"
228
240
  }
229
241
  ],
230
242
  "outputs": [
@@ -254,6 +266,10 @@
254
266
  {
255
267
  "name": "_min_amount",
256
268
  "type": "uint256"
269
+ },
270
+ {
271
+ "name": "_use_eth",
272
+ "type": "bool"
257
273
  }
258
274
  ],
259
275
  "outputs": [
@@ -50,6 +50,10 @@
50
50
  {
51
51
  "name": "_min_dy",
52
52
  "type": "uint256"
53
+ },
54
+ {
55
+ "name": "_use_eth",
56
+ "type": "bool"
53
57
  }
54
58
  ],
55
59
  "outputs": [
@@ -104,6 +108,10 @@
104
108
  {
105
109
  "name": "_min_mint_amount",
106
110
  "type": "uint256"
111
+ },
112
+ {
113
+ "name": "_use_eth",
114
+ "type": "bool"
107
115
  }
108
116
  ],
109
117
  "outputs": [
@@ -150,6 +158,10 @@
150
158
  {
151
159
  "name": "_min_amounts",
152
160
  "type": "uint256[6]"
161
+ },
162
+ {
163
+ "name": "_use_eth",
164
+ "type": "bool"
153
165
  }
154
166
  ],
155
167
  "outputs": [
@@ -179,6 +191,10 @@
179
191
  {
180
192
  "name": "_min_amount",
181
193
  "type": "uint256"
194
+ },
195
+ {
196
+ "name": "_use_eth",
197
+ "type": "bool"
182
198
  }
183
199
  ],
184
200
  "outputs": [
@@ -117,6 +117,10 @@
117
117
  {
118
118
  "name": "_min_dy",
119
119
  "type": "uint256"
120
+ },
121
+ {
122
+ "name": "_use_eth",
123
+ "type": "bool"
120
124
  }
121
125
  ],
122
126
  "outputs": [
@@ -171,6 +175,10 @@
171
175
  {
172
176
  "name": "_min_mint_amount",
173
177
  "type": "uint256"
178
+ },
179
+ {
180
+ "name": "_use_eth",
181
+ "type": "bool"
174
182
  }
175
183
  ],
176
184
  "outputs": [
@@ -217,6 +225,10 @@
217
225
  {
218
226
  "name": "_min_amounts",
219
227
  "type": "uint256[3]"
228
+ },
229
+ {
230
+ "name": "_use_eth",
231
+ "type": "bool"
220
232
  }
221
233
  ],
222
234
  "outputs": [
@@ -246,6 +258,10 @@
246
258
  {
247
259
  "name": "_min_amount",
248
260
  "type": "uint256"
261
+ },
262
+ {
263
+ "name": "_use_eth",
264
+ "type": "bool"
249
265
  }
250
266
  ],
251
267
  "outputs": [
@@ -34,7 +34,7 @@ exports.USD_COINS_POLYGON = {
34
34
  amusdt: "0x60D55F02A771d515e077c9C2403a1ef324885CeC",
35
35
  am3crv: "0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171", // am3CRV
36
36
  };
37
- exports.COINS_POLYGON = (0, utils_1.lowerCaseValues)(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_POLYGON), exports.ETH_COINS_POLYGON), exports.EUR_COINS_POLYGON), exports.USD_COINS_POLYGON), { crv: "0x172370d5cd63279efa6d502dab29171933a610af", matic: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" }));
37
+ exports.COINS_POLYGON = (0, utils_1.lowerCaseValues)(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_POLYGON), exports.ETH_COINS_POLYGON), exports.EUR_COINS_POLYGON), exports.USD_COINS_POLYGON), { crv: "0x172370d5cd63279efa6d502dab29171933a610af", matic: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" }));
38
38
  var DECIMALS_POLYGON = {
39
39
  "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063": 18,
40
40
  "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": 6,
@@ -1598,11 +1598,14 @@ var PoolTemplate = /** @class */ (function () {
1598
1598
  return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.gauge)];
1599
1599
  case 1:
1600
1600
  _c.sent();
1601
- return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
1601
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
1602
1602
  case 2:
1603
+ _c.sent();
1604
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
1605
+ case 3:
1603
1606
  gasLimit = (_c.sent()).mul(150).div(100);
1604
1607
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.deposit(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1605
- case 3: return [2 /*return*/, (_c.sent()).hash];
1608
+ case 4: return [2 /*return*/, (_c.sent()).hash];
1606
1609
  }
1607
1610
  });
1608
1611
  });
@@ -1633,11 +1636,14 @@ var PoolTemplate = /** @class */ (function () {
1633
1636
  throw Error("unstake method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
1634
1637
  }
1635
1638
  _lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
1636
- return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1639
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
1637
1640
  case 1:
1641
+ _c.sent();
1642
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1643
+ case 2:
1638
1644
  gasLimit = (_c.sent()).mul(200).div(100);
1639
1645
  return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1640
- case 2: return [2 /*return*/, (_c.sent()).hash];
1646
+ case 3: return [2 /*return*/, (_c.sent()).hash];
1641
1647
  }
1642
1648
  });
1643
1649
  });
@@ -1,5 +1,6 @@
1
1
  import { PoolTemplate } from "../PoolTemplate";
2
2
  export declare const depositMetaFactoryMixin: PoolTemplate;
3
+ export declare const depositCryptoMetaFactoryMixin: PoolTemplate;
3
4
  export declare const depositZapMixin: PoolTemplate;
4
5
  export declare const depositLendingOrCryptoMixin: PoolTemplate;
5
6
  export declare const depositPlainMixin: PoolTemplate;
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.depositPlainMixin = exports.depositLendingOrCryptoMixin = exports.depositZapMixin = exports.depositMetaFactoryMixin = void 0;
50
+ exports.depositPlainMixin = exports.depositLendingOrCryptoMixin = exports.depositZapMixin = exports.depositCryptoMetaFactoryMixin = exports.depositMetaFactoryMixin = void 0;
51
51
  var utils_1 = require("../../utils");
52
52
  var curve_1 = require("../../curve");
53
53
  var ethers_1 = require("ethers");
@@ -174,6 +174,72 @@ exports.depositMetaFactoryMixin = {
174
174
  },
175
175
  };
176
176
  // @ts-ignore
177
+ exports.depositCryptoMetaFactoryMixin = {
178
+ // @ts-ignore
179
+ _deposit: function (_amounts, slippage, estimateGas) {
180
+ if (estimateGas === void 0) { estimateGas = false; }
181
+ return __awaiter(this, void 0, void 0, function () {
182
+ var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
183
+ return __generator(this, function (_a) {
184
+ switch (_a.label) {
185
+ case 0:
186
+ if (!!estimateGas) return [3 /*break*/, 2];
187
+ return [4 /*yield*/, (0, utils_1._ensureAllowance)(this.underlyingCoinAddresses, _amounts, this.zap)];
188
+ case 1:
189
+ _a.sent();
190
+ _a.label = 2;
191
+ case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
192
+ case 3:
193
+ _minMintAmount = _a.sent();
194
+ ethIndex = (0, utils_1.getEthIndex)(this.underlyingCoinAddresses);
195
+ value = _amounts[ethIndex] || ethers_1.ethers.BigNumber.from(0);
196
+ contract = curve_1.curve.contracts[this.zap].contract;
197
+ return [4 /*yield*/, contract.estimateGas.add_liquidity(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
198
+ case 4:
199
+ gas = _a.sent();
200
+ if (estimateGas)
201
+ return [2 /*return*/, gas.toNumber()];
202
+ gasLimit = gas.mul(130).div(100);
203
+ return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit, value: value }))];
204
+ case 5: return [2 /*return*/, (_a.sent()).hash];
205
+ }
206
+ });
207
+ });
208
+ },
209
+ depositEstimateGas: function (amounts) {
210
+ return __awaiter(this, void 0, void 0, function () {
211
+ var _amounts;
212
+ return __generator(this, function (_a) {
213
+ switch (_a.label) {
214
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
215
+ case 1:
216
+ _amounts = _a.sent();
217
+ return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
218
+ case 2:
219
+ // @ts-ignore
220
+ return [2 /*return*/, _a.sent()];
221
+ }
222
+ });
223
+ });
224
+ },
225
+ deposit: function (amounts, slippage) {
226
+ return __awaiter(this, void 0, void 0, function () {
227
+ var _amounts;
228
+ return __generator(this, function (_a) {
229
+ switch (_a.label) {
230
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
231
+ case 1:
232
+ _amounts = _a.sent();
233
+ return [4 /*yield*/, this._deposit(_amounts, slippage)];
234
+ case 2:
235
+ // @ts-ignore
236
+ return [2 /*return*/, _a.sent()];
237
+ }
238
+ });
239
+ });
240
+ },
241
+ };
242
+ // @ts-ignore
177
243
  exports.depositZapMixin = {
178
244
  // @ts-ignore
179
245
  _deposit: function (_amounts, slippage, estimateGas) {
@@ -1,4 +1,5 @@
1
1
  import { PoolTemplate } from "../PoolTemplate";
2
2
  export declare const swapTricrypto2Mixin: PoolTemplate;
3
3
  export declare const swapMetaFactoryMixin: PoolTemplate;
4
+ export declare const swapCryptoMetaFactoryMixin: PoolTemplate;
4
5
  export declare const swapMixin: PoolTemplate;
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.swapMixin = exports.swapMetaFactoryMixin = exports.swapTricrypto2Mixin = void 0;
50
+ exports.swapMixin = exports.swapCryptoMetaFactoryMixin = exports.swapMetaFactoryMixin = exports.swapTricrypto2Mixin = void 0;
51
51
  var ethers_1 = require("ethers");
52
52
  var curve_1 = require("../../curve");
53
53
  var utils_1 = require("../../utils");
@@ -242,6 +242,73 @@ exports.swapMetaFactoryMixin = {
242
242
  },
243
243
  };
244
244
  // @ts-ignore
245
+ exports.swapCryptoMetaFactoryMixin = {
246
+ // @ts-ignore
247
+ _swap: function (i, j, _amount, slippage, estimateGas) {
248
+ if (estimateGas === void 0) { estimateGas = false; }
249
+ return __awaiter(this, void 0, void 0, function () {
250
+ var contractAddress, _minRecvAmount, contract, exchangeMethod, value, gas, gasLimit;
251
+ return __generator(this, function (_a) {
252
+ switch (_a.label) {
253
+ case 0:
254
+ contractAddress = this._swapContractAddress();
255
+ if (!!estimateGas) return [3 /*break*/, 2];
256
+ return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.underlyingCoinAddresses[i]], [_amount], contractAddress)];
257
+ case 1:
258
+ _a.sent();
259
+ _a.label = 2;
260
+ case 2: return [4 /*yield*/, _swapMinAmount.call(this, i, j, _amount, slippage)];
261
+ case 3:
262
+ _minRecvAmount = _a.sent();
263
+ contract = curve_1.curve.contracts[contractAddress].contract;
264
+ exchangeMethod = Object.prototype.hasOwnProperty.call(contract, 'exchange_underlying') ? 'exchange_underlying' : 'exchange';
265
+ value = (0, utils_1.isEth)(this.underlyingCoinAddresses[i]) ? _amount : ethers_1.ethers.BigNumber.from(0);
266
+ return [4 /*yield*/, contract.estimateGas[exchangeMethod](this.address, i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
267
+ case 4:
268
+ gas = _a.sent();
269
+ if (estimateGas)
270
+ return [2 /*return*/, gas.toNumber()];
271
+ gasLimit = gas.mul(140).div(100);
272
+ return [4 /*yield*/, contract[exchangeMethod](this.address, i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
273
+ case 5: return [2 /*return*/, (_a.sent()).hash];
274
+ }
275
+ });
276
+ });
277
+ },
278
+ swapEstimateGas: function (inputCoin, outputCoin, amount) {
279
+ return __awaiter(this, void 0, void 0, function () {
280
+ var _a, i, j, _amount;
281
+ return __generator(this, function (_b) {
282
+ switch (_b.label) {
283
+ case 0: return [4 /*yield*/, _swapCheck.call(this, inputCoin, outputCoin, amount, true)];
284
+ case 1:
285
+ _a = _b.sent(), i = _a[0], j = _a[1], _amount = _a[2];
286
+ return [4 /*yield*/, this._swap(i, j, _amount, 0.1, true)];
287
+ case 2:
288
+ // @ts-ignore
289
+ return [2 /*return*/, _b.sent()];
290
+ }
291
+ });
292
+ });
293
+ },
294
+ swap: function (inputCoin, outputCoin, amount, slippage) {
295
+ return __awaiter(this, void 0, void 0, function () {
296
+ var _a, i, j, _amount;
297
+ return __generator(this, function (_b) {
298
+ switch (_b.label) {
299
+ case 0: return [4 /*yield*/, _swapCheck.call(this, inputCoin, outputCoin, amount)];
300
+ case 1:
301
+ _a = _b.sent(), i = _a[0], j = _a[1], _amount = _a[2];
302
+ return [4 /*yield*/, this._swap(i, j, _amount, slippage)];
303
+ case 2:
304
+ // @ts-ignore
305
+ return [2 /*return*/, _b.sent()];
306
+ }
307
+ });
308
+ });
309
+ },
310
+ };
311
+ // @ts-ignore
245
312
  exports.swapMixin = {
246
313
  // @ts-ignore
247
314
  _swap: function (i, j, _amount, slippage, estimateGas) {
@@ -1,5 +1,6 @@
1
1
  import { PoolTemplate } from "../PoolTemplate";
2
2
  export declare const withdrawMetaFactoryMixin: PoolTemplate;
3
+ export declare const withdrawCryptoMetaFactoryMixin: PoolTemplate;
3
4
  export declare const withdrawZapMixin: PoolTemplate;
4
5
  export declare const withdrawLendingOrCryptoMixin: PoolTemplate;
5
6
  export declare const withdrawPlainMixin: PoolTemplate;
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.withdrawPlainMixin = exports.withdrawLendingOrCryptoMixin = exports.withdrawZapMixin = exports.withdrawMetaFactoryMixin = void 0;
50
+ exports.withdrawPlainMixin = exports.withdrawLendingOrCryptoMixin = exports.withdrawZapMixin = exports.withdrawCryptoMetaFactoryMixin = exports.withdrawMetaFactoryMixin = void 0;
51
51
  var ethers_1 = require("ethers");
52
52
  var curve_1 = require("../../curve");
53
53
  var utils_1 = require("../../utils");
@@ -166,6 +166,70 @@ exports.withdrawMetaFactoryMixin = {
166
166
  },
167
167
  };
168
168
  // @ts-ignore
169
+ exports.withdrawCryptoMetaFactoryMixin = {
170
+ // @ts-ignore
171
+ _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
172
+ if (estimateGas === void 0) { estimateGas = false; }
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var _minAmounts, contract, gas, gasLimit;
175
+ return __generator(this, function (_b) {
176
+ switch (_b.label) {
177
+ case 0:
178
+ if (!!estimateGas) return [3 /*break*/, 2];
179
+ return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.zap)];
180
+ case 1:
181
+ _b.sent();
182
+ _b.label = 2;
183
+ case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
184
+ case 3:
185
+ _minAmounts = _b.sent();
186
+ contract = curve_1.curve.contracts[this.zap].contract;
187
+ return [4 /*yield*/, contract.estimateGas.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, curve_1.curve.constantOptions)];
188
+ case 4:
189
+ gas = _b.sent();
190
+ if (estimateGas)
191
+ return [2 /*return*/, gas.toNumber()];
192
+ gasLimit = gas.mul(130).div(100);
193
+ return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
194
+ case 5: return [2 /*return*/, (_b.sent()).hash];
195
+ }
196
+ });
197
+ });
198
+ },
199
+ withdrawEstimateGas: function (lpTokenAmount) {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var _lpTokenAmount;
202
+ return __generator(this, function (_b) {
203
+ switch (_b.label) {
204
+ case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
205
+ case 1:
206
+ _lpTokenAmount = _b.sent();
207
+ return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
208
+ case 2:
209
+ // @ts-ignore
210
+ return [2 /*return*/, _b.sent()];
211
+ }
212
+ });
213
+ });
214
+ },
215
+ withdraw: function (lpTokenAmount, slippage) {
216
+ return __awaiter(this, void 0, void 0, function () {
217
+ var _lpTokenAmount;
218
+ return __generator(this, function (_b) {
219
+ switch (_b.label) {
220
+ case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
221
+ case 1:
222
+ _lpTokenAmount = _b.sent();
223
+ return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
224
+ case 2:
225
+ // @ts-ignore
226
+ return [2 /*return*/, _b.sent()];
227
+ }
228
+ });
229
+ });
230
+ },
231
+ };
232
+ // @ts-ignore
169
233
  exports.withdrawZapMixin = {
170
234
  // @ts-ignore
171
235
  _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
@@ -1,5 +1,6 @@
1
1
  import { PoolTemplate } from "../PoolTemplate";
2
2
  export declare const withdrawOneCoinMetaFactoryMixin: PoolTemplate;
3
+ export declare const withdrawOneCoinCryptoMetaFactoryMixin: PoolTemplate;
3
4
  export declare const withdrawOneCoinZapMixin: PoolTemplate;
4
5
  export declare const withdrawOneCoinLendingOrCryptoMixin: PoolTemplate;
5
6
  export declare const withdrawOneCoinPlainMixin: PoolTemplate;
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.withdrawOneCoinPlainMixin = exports.withdrawOneCoinLendingOrCryptoMixin = exports.withdrawOneCoinZapMixin = exports.withdrawOneCoinMetaFactoryMixin = void 0;
50
+ exports.withdrawOneCoinPlainMixin = exports.withdrawOneCoinLendingOrCryptoMixin = exports.withdrawOneCoinZapMixin = exports.withdrawOneCoinCryptoMetaFactoryMixin = exports.withdrawOneCoinMetaFactoryMixin = void 0;
51
51
  var curve_1 = require("../../curve");
52
52
  var utils_1 = require("../../utils");
53
53
  // @ts-ignore
@@ -166,6 +166,70 @@ exports.withdrawOneCoinMetaFactoryMixin = {
166
166
  },
167
167
  };
168
168
  // @ts-ignore
169
+ exports.withdrawOneCoinCryptoMetaFactoryMixin = {
170
+ // @ts-ignore
171
+ _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
172
+ if (estimateGas === void 0) { estimateGas = false; }
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var _minAmount, contract, gas, gasLimit;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0:
178
+ if (!!estimateGas) return [3 /*break*/, 2];
179
+ return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.zap)];
180
+ case 1:
181
+ _a.sent();
182
+ _a.label = 2;
183
+ case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
184
+ case 3:
185
+ _minAmount = _a.sent();
186
+ contract = curve_1.curve.contracts[this.zap].contract;
187
+ return [4 /*yield*/, contract.estimateGas.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, curve_1.curve.constantOptions)];
188
+ case 4:
189
+ gas = _a.sent();
190
+ if (estimateGas)
191
+ return [2 /*return*/, gas.toNumber()];
192
+ gasLimit = gas.mul(130).div(100);
193
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
194
+ case 5: return [2 /*return*/, (_a.sent()).hash];
195
+ }
196
+ });
197
+ });
198
+ },
199
+ withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var _a, _lpTokenAmount, i;
202
+ return __generator(this, function (_b) {
203
+ switch (_b.label) {
204
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
205
+ case 1:
206
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
207
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
208
+ case 2:
209
+ // @ts-ignore
210
+ return [2 /*return*/, _b.sent()];
211
+ }
212
+ });
213
+ });
214
+ },
215
+ withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
216
+ return __awaiter(this, void 0, void 0, function () {
217
+ var _a, _lpTokenAmount, i;
218
+ return __generator(this, function (_b) {
219
+ switch (_b.label) {
220
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
221
+ case 1:
222
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
223
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
224
+ case 2:
225
+ // @ts-ignore
226
+ return [2 /*return*/, _b.sent()];
227
+ }
228
+ });
229
+ });
230
+ },
231
+ };
232
+ // @ts-ignore
169
233
  exports.withdrawOneCoinZapMixin = {
170
234
  // @ts-ignore
171
235
  _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
@@ -70,7 +70,12 @@ var getPool = function (poolId) {
70
70
  }
71
71
  // deposit and depositEstimateGas
72
72
  if (poolDummy.isMetaFactory) {
73
- Object.assign(Pool.prototype, depositMixins_1.depositMetaFactoryMixin);
73
+ if (poolDummy.isCrypto) {
74
+ Object.assign(Pool.prototype, depositMixins_1.depositCryptoMetaFactoryMixin);
75
+ }
76
+ else {
77
+ Object.assign(Pool.prototype, depositMixins_1.depositMetaFactoryMixin);
78
+ }
74
79
  }
75
80
  else if (poolDummy.zap && poolId !== 'susd') {
76
81
  Object.assign(Pool.prototype, depositMixins_1.depositZapMixin);
@@ -83,7 +88,7 @@ var getPool = function (poolId) {
83
88
  }
84
89
  // depositWrapped and depositWrappedEstimateGas
85
90
  if (!poolDummy.isPlain && !poolDummy.isFake) {
86
- if ((poolDummy.isLending || poolDummy.isCrypto) && !poolDummy.zap) {
91
+ if (((poolDummy.isLending || poolDummy.isCrypto) && !poolDummy.zap) || (poolDummy.isCrypto && poolDummy.isMetaFactory)) {
87
92
  Object.assign(Pool.prototype, depositWrappedMixins_1.depositWrapped3argsMixin);
88
93
  }
89
94
  else {
@@ -105,7 +110,12 @@ var getPool = function (poolId) {
105
110
  }
106
111
  // withdraw and withdrawEstimateGas
107
112
  if (poolDummy.isMetaFactory) {
108
- Object.assign(Pool.prototype, withdrawMixins_1.withdrawMetaFactoryMixin);
113
+ if (poolDummy.isCrypto) {
114
+ Object.assign(Pool.prototype, withdrawMixins_1.withdrawCryptoMetaFactoryMixin);
115
+ }
116
+ else {
117
+ Object.assign(Pool.prototype, withdrawMixins_1.withdrawMetaFactoryMixin);
118
+ }
109
119
  }
110
120
  else if (poolDummy.zap && poolId !== 'susd') {
111
121
  Object.assign(Pool.prototype, withdrawMixins_1.withdrawZapMixin);
@@ -118,7 +128,7 @@ var getPool = function (poolId) {
118
128
  }
119
129
  // withdrawWrapped and withdrawWrappedEstimateGas
120
130
  if (!poolDummy.isPlain && !poolDummy.isFake) {
121
- if ((poolDummy.isLending || poolDummy.isCrypto) && !poolDummy.zap) {
131
+ if (((poolDummy.isLending || poolDummy.isCrypto) && !poolDummy.zap) || (poolDummy.isCrypto && poolDummy.isMetaFactory)) {
122
132
  Object.assign(Pool.prototype, withdrawWrappedMixins_1.withdrawWrapped3argsMixin);
123
133
  Object.assign(Pool.prototype, withdrawExpectedMixins_1.withdrawWrappedExpectedMixin);
124
134
  }
@@ -166,7 +176,12 @@ var getPool = function (poolId) {
166
176
  }
167
177
  // withdrawOneCoin and withdrawOneCoinEstimateGas
168
178
  if (poolDummy.isMetaFactory) {
169
- Object.assign(Pool.prototype, withdrawOneCoinMixins_1.withdrawOneCoinMetaFactoryMixin);
179
+ if (poolDummy.isCrypto) {
180
+ Object.assign(Pool.prototype, withdrawOneCoinMixins_1.withdrawOneCoinCryptoMetaFactoryMixin);
181
+ }
182
+ else {
183
+ Object.assign(Pool.prototype, withdrawOneCoinMixins_1.withdrawOneCoinMetaFactoryMixin);
184
+ }
170
185
  }
171
186
  else if (poolDummy.zap) { // including susd
172
187
  Object.assign(Pool.prototype, withdrawOneCoinMixins_1.withdrawOneCoinZapMixin);
@@ -188,7 +203,7 @@ var getPool = function (poolId) {
188
203
  }
189
204
  // withdrawOneCoinWrapped and withdrawOneCoinWrappedEstimateGas
190
205
  if (!poolDummy.isPlain && !poolDummy.isFake && !(poolDummy.isLending && poolDummy.zap)) {
191
- if ((poolDummy.isLending || poolDummy.isCrypto) && !poolDummy.zap) {
206
+ if (((poolDummy.isLending || poolDummy.isCrypto) && !poolDummy.zap) || (poolDummy.isCrypto && poolDummy.isMetaFactory)) {
192
207
  Object.assign(Pool.prototype, withdrawOneCoinWrappedMixins_1.withdrawOneCoinWrappedLendingOrCryptoMixin);
193
208
  }
194
209
  else {
@@ -201,7 +216,12 @@ var getPool = function (poolId) {
201
216
  Object.assign(Pool.prototype, swapMixins_1.swapTricrypto2Mixin);
202
217
  }
203
218
  else if (poolDummy.isMetaFactory && ((0, exports.getPool)(poolDummy.basePool).isLending || (0, exports.getPool)(poolDummy.basePool).isFake || poolDummy.isCrypto)) {
204
- Object.assign(Pool.prototype, swapMixins_1.swapMetaFactoryMixin);
219
+ if (poolDummy.isCrypto) {
220
+ Object.assign(Pool.prototype, swapMixins_1.swapCryptoMetaFactoryMixin);
221
+ }
222
+ else {
223
+ Object.assign(Pool.prototype, swapMixins_1.swapMetaFactoryMixin);
224
+ }
205
225
  }
206
226
  else {
207
227
  Object.assign(Pool.prototype, swapMixins_1.swapMixin);
package/lib/router.js CHANGED
@@ -315,6 +315,13 @@ var filterRoutes = function (routes, inputCoinAddress, sortFn) {
315
315
  };
316
316
  var sortByTvl = function (a, b) { return b.minTvl - a.minTvl || b.totalTvl - a.totalTvl || a.steps.length - b.steps.length; };
317
317
  var sortByLength = function (a, b) { return a.steps.length - b.steps.length || b.minTvl - a.minTvl || b.totalTvl - a.totalTvl; };
318
+ // TODO REMOVE IT!!!
319
+ var filterMaticFactory83Route = function (routes) {
320
+ return routes
321
+ .filter(function (r) {
322
+ return !(r.steps.length === 1 && r.steps[0].poolId === "factory-crypto-83" && r.steps[0].inputCoinAddress === curve_1.curve.constants.NATIVE_TOKEN.address);
323
+ });
324
+ };
318
325
  // Inspired by Dijkstra's algorithm
319
326
  var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return __awaiter(void 0, void 0, void 0, function () {
320
327
  var ALL_POOLS, amplificationCoefficientDict, curCoins, nextCoins, routesByTvl, routesByLength, step, _loop_1, _i, curCoins_2, inCoin, routes;
@@ -548,6 +555,9 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
548
555
  return [3 /*break*/, 2];
549
556
  case 8:
550
557
  routes = __spreadArray(__spreadArray([], ((_q = routesByTvl[outputCoinAddress]) !== null && _q !== void 0 ? _q : []), true), ((_r = routesByLength[outputCoinAddress]) !== null && _r !== void 0 ? _r : []), true);
558
+ // TODO REMOVE IT!!!
559
+ if (curve_1.curve.chainId === 137)
560
+ routes = filterMaticFactory83Route(routes);
551
561
  return [2 /*return*/, routes.map(function (r) { return r.steps; })];
552
562
  }
553
563
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.24.1",
3
+ "version": "2.24.3",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",