@curvefi/api 2.63.0 → 2.63.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/boosting.js +247 -645
  2. package/lib/constants/L2Networks.js +1 -1
  3. package/lib/constants/aliases.js +19 -19
  4. package/lib/constants/coins/arbitrum.js +5 -5
  5. package/lib/constants/coins/aurora.js +5 -5
  6. package/lib/constants/coins/avalanche.js +6 -6
  7. package/lib/constants/coins/base.js +5 -5
  8. package/lib/constants/coins/bsc.js +5 -5
  9. package/lib/constants/coins/celo.js +5 -5
  10. package/lib/constants/coins/ethereum.js +9 -9
  11. package/lib/constants/coins/fantom.js +7 -7
  12. package/lib/constants/coins/fraxtal.js +5 -5
  13. package/lib/constants/coins/kava.js +5 -5
  14. package/lib/constants/coins/mantle.js +5 -5
  15. package/lib/constants/coins/moonbeam.js +5 -5
  16. package/lib/constants/coins/optimism.js +5 -5
  17. package/lib/constants/coins/polygon.js +6 -6
  18. package/lib/constants/coins/xdai.js +5 -5
  19. package/lib/constants/coins/xlayer.js +5 -5
  20. package/lib/constants/coins/zksync.js +5 -5
  21. package/lib/constants/pools/arbitrum.js +1 -1
  22. package/lib/constants/pools/aurora.js +1 -1
  23. package/lib/constants/pools/avalanche.js +1 -1
  24. package/lib/constants/pools/base.js +1 -1
  25. package/lib/constants/pools/bsc.js +1 -1
  26. package/lib/constants/pools/celo.js +1 -1
  27. package/lib/constants/pools/ethereum.js +2 -2
  28. package/lib/constants/pools/fantom.js +1 -1
  29. package/lib/constants/pools/fraxtal.js +1 -1
  30. package/lib/constants/pools/kava.js +1 -1
  31. package/lib/constants/pools/mantle.js +1 -1
  32. package/lib/constants/pools/moonbeam.js +1 -1
  33. package/lib/constants/pools/optimism.js +1 -1
  34. package/lib/constants/pools/polygon.js +1 -1
  35. package/lib/constants/pools/xdai.js +1 -1
  36. package/lib/constants/pools/xlayer.js +1 -1
  37. package/lib/constants/pools/zksync.js +1 -1
  38. package/lib/constants/tricryptoDeployImplementations.js +1 -1
  39. package/lib/constants/utils.js +18 -19
  40. package/lib/constants/volumeNetworks.js +1 -1
  41. package/lib/curve.d.ts +10 -6
  42. package/lib/curve.js +534 -909
  43. package/lib/dao.js +351 -705
  44. package/lib/external-api.js +127 -256
  45. package/lib/factory/common.js +4 -4
  46. package/lib/factory/constants-crypto.js +33 -33
  47. package/lib/factory/constants.js +34 -34
  48. package/lib/factory/deploy.js +542 -907
  49. package/lib/factory/factory-api.js +205 -269
  50. package/lib/factory/factory-crypto.js +202 -342
  51. package/lib/factory/factory-tricrypto.js +164 -286
  52. package/lib/factory/factory-twocrypto.js +151 -269
  53. package/lib/factory/factory.js +245 -385
  54. package/lib/index.js +109 -198
  55. package/lib/interfaces.d.ts +46 -6
  56. package/lib/pools/PoolTemplate.js +1774 -3027
  57. package/lib/pools/gaugePool.js +112 -251
  58. package/lib/pools/mixins/common.js +22 -93
  59. package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
  60. package/lib/pools/mixins/depositMixins.js +160 -386
  61. package/lib/pools/mixins/depositWrappedMixins.js +79 -205
  62. package/lib/pools/mixins/poolBalancesMixin.js +24 -87
  63. package/lib/pools/mixins/swapMixins.js +139 -324
  64. package/lib/pools/mixins/swapWrappedMixins.js +111 -265
  65. package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
  66. package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
  67. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
  68. package/lib/pools/mixins/withdrawMixins.js +139 -359
  69. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
  70. package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
  71. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
  72. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
  73. package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
  74. package/lib/pools/poolConstructor.js +11 -31
  75. package/lib/pools/utils.js +301 -469
  76. package/lib/route-finder.worker.d.ts +9 -0
  77. package/lib/route-finder.worker.js +112 -0
  78. package/lib/route-graph.worker.d.ts +11 -0
  79. package/lib/route-graph.worker.js +334 -0
  80. package/lib/router.js +323 -912
  81. package/lib/utils.d.ts +8 -7
  82. package/lib/utils.js +540 -927
  83. package/package.json +3 -2
@@ -1,14 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18,403 +7,194 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
19
8
  });
20
9
  };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
10
  import { curve } from "../../curve.js";
58
11
  import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
59
12
  // @ts-ignore
60
- function _withdrawCheck(lpTokenAmount, estimateGas) {
61
- if (estimateGas === void 0) { estimateGas = false; }
62
- return __awaiter(this, void 0, void 0, function () {
63
- var lpTokenBalance, _b;
64
- return __generator(this, function (_c) {
65
- switch (_c.label) {
66
- case 0: return [4 /*yield*/, this.wallet.lpTokenBalances()];
67
- case 1:
68
- lpTokenBalance = (_c.sent())['lpToken'];
69
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
70
- throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
71
- }
72
- _b = estimateGas && this.zap;
73
- if (!_b) return [3 /*break*/, 3];
74
- return [4 /*yield*/, hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap)];
75
- case 2:
76
- _b = !(_c.sent());
77
- _c.label = 3;
78
- case 3:
79
- if (_b) {
80
- throw Error("Token allowance is needed to estimate gas");
81
- }
82
- if (!!estimateGas) return [3 /*break*/, 5];
83
- return [4 /*yield*/, curve.updateFeeData()];
84
- case 4:
85
- _c.sent();
86
- _c.label = 5;
87
- case 5: return [2 /*return*/, parseUnits(lpTokenAmount)];
88
- }
89
- });
13
+ function _withdrawCheck(lpTokenAmount, estimateGas = false) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
16
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
17
+ throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
18
+ }
19
+ if (estimateGas && this.zap && !(yield hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
20
+ throw Error("Token allowance is needed to estimate gas");
21
+ }
22
+ if (!estimateGas)
23
+ yield curve.updateFeeData();
24
+ return parseUnits(lpTokenAmount);
90
25
  });
91
26
  }
92
- function _withdrawMinAmounts(_lpTokenAmount, slippage) {
93
- if (slippage === void 0) { slippage = 0.5; }
94
- return __awaiter(this, void 0, void 0, function () {
95
- var expectedAmounts, _expectedAmounts, minRecvAmountsBN;
96
- var _this = this;
97
- return __generator(this, function (_b) {
98
- switch (_b.label) {
99
- case 0: return [4 /*yield*/, this.withdrawExpected(curve.formatUnits(_lpTokenAmount))];
100
- case 1:
101
- expectedAmounts = _b.sent();
102
- _expectedAmounts = expectedAmounts.map(function (a, i) { return curve.parseUnits(a, _this.underlyingDecimals[i]); });
103
- minRecvAmountsBN = _expectedAmounts.map(function (_a, i) { return toBN(_a, _this.underlyingDecimals[i]).times(100 - slippage).div(100); });
104
- return [2 /*return*/, minRecvAmountsBN.map(function (a, i) { return fromBN(a, _this.underlyingDecimals[i]); })];
105
- }
106
- });
27
+ function _withdrawMinAmounts(_lpTokenAmount, slippage = 0.5) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const expectedAmounts = yield this.withdrawExpected(curve.formatUnits(_lpTokenAmount));
30
+ const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.underlyingDecimals[i]));
31
+ const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.underlyingDecimals[i]).times(100 - slippage).div(100));
32
+ return minRecvAmountsBN.map((a, i) => fromBN(a, this.underlyingDecimals[i]));
107
33
  });
108
34
  }
109
35
  // @ts-ignore
110
- export var withdrawMetaFactoryMixin = {
36
+ export const withdrawMetaFactoryMixin = {
111
37
  // @ts-ignore
112
- _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
113
- if (estimateGas === void 0) { estimateGas = false; }
114
- return __awaiter(this, void 0, void 0, function () {
115
- var _minAmounts, contract, gas, gasLimit;
116
- return __generator(this, function (_b) {
117
- switch (_b.label) {
118
- case 0:
119
- if (!!estimateGas) return [3 /*break*/, 2];
120
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
121
- case 1:
122
- _b.sent();
123
- _b.label = 2;
124
- case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
125
- case 3:
126
- _minAmounts = _b.sent();
127
- contract = curve.contracts[this.zap].contract;
128
- return [4 /*yield*/, contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, curve.constantOptions)];
129
- case 4:
130
- gas = _b.sent();
131
- if (estimateGas)
132
- return [2 /*return*/, smartNumber(gas)];
133
- gasLimit = mulBy1_3(DIGas(gas));
134
- return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
135
- case 5: return [2 /*return*/, (_b.sent()).hash];
136
- }
137
- });
38
+ _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (!estimateGas)
41
+ yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
42
+ const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
43
+ const contract = curve.contracts[this.zap].contract;
44
+ const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, curve.constantOptions);
45
+ if (estimateGas)
46
+ return smartNumber(gas);
47
+ const gasLimit = mulBy1_3(DIGas(gas));
48
+ return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
138
49
  });
139
50
  },
140
- withdrawEstimateGas: function (lpTokenAmount) {
141
- return __awaiter(this, void 0, void 0, function () {
142
- var _lpTokenAmount;
143
- return __generator(this, function (_b) {
144
- switch (_b.label) {
145
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
146
- case 1:
147
- _lpTokenAmount = _b.sent();
148
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
149
- case 2:
150
- // @ts-ignore
151
- return [2 /*return*/, _b.sent()];
152
- }
153
- });
51
+ withdrawEstimateGas(lpTokenAmount) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ // @ts-ignore
54
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
55
+ // @ts-ignore
56
+ return yield this._withdraw(_lpTokenAmount, 0.1, true);
154
57
  });
155
58
  },
156
- withdraw: function (lpTokenAmount, slippage) {
157
- return __awaiter(this, void 0, void 0, function () {
158
- var _lpTokenAmount;
159
- return __generator(this, function (_b) {
160
- switch (_b.label) {
161
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
162
- case 1:
163
- _lpTokenAmount = _b.sent();
164
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
165
- case 2:
166
- // @ts-ignore
167
- return [2 /*return*/, _b.sent()];
168
- }
169
- });
59
+ withdraw(lpTokenAmount, slippage) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ // @ts-ignore
62
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
63
+ // @ts-ignore
64
+ return yield this._withdraw(_lpTokenAmount, slippage);
170
65
  });
171
66
  },
172
67
  };
173
68
  // @ts-ignore
174
- export var withdrawCryptoMetaFactoryMixin = {
69
+ export const withdrawCryptoMetaFactoryMixin = {
175
70
  // @ts-ignore
176
- _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
177
- if (estimateGas === void 0) { estimateGas = false; }
178
- return __awaiter(this, void 0, void 0, function () {
179
- var _minAmounts, contract, gas, gasLimit;
180
- return __generator(this, function (_b) {
181
- switch (_b.label) {
182
- case 0:
183
- if (!!estimateGas) return [3 /*break*/, 2];
184
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
185
- case 1:
186
- _b.sent();
187
- _b.label = 2;
188
- case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
189
- case 3:
190
- _minAmounts = _b.sent();
191
- contract = curve.contracts[this.zap].contract;
192
- return [4 /*yield*/, contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, curve.constantOptions)];
193
- case 4:
194
- gas = _b.sent();
195
- if (estimateGas)
196
- return [2 /*return*/, smartNumber(gas)];
197
- gasLimit = mulBy1_3(DIGas(gas));
198
- return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
199
- case 5: return [2 /*return*/, (_b.sent()).hash];
200
- }
201
- });
71
+ _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ if (!estimateGas)
74
+ yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
75
+ const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
76
+ const contract = curve.contracts[this.zap].contract;
77
+ const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, curve.constantOptions);
78
+ if (estimateGas)
79
+ return smartNumber(gas);
80
+ const gasLimit = mulBy1_3(DIGas(gas));
81
+ return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
202
82
  });
203
83
  },
204
- withdrawEstimateGas: function (lpTokenAmount) {
205
- return __awaiter(this, void 0, void 0, function () {
206
- var _lpTokenAmount;
207
- return __generator(this, function (_b) {
208
- switch (_b.label) {
209
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
210
- case 1:
211
- _lpTokenAmount = _b.sent();
212
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
213
- case 2:
214
- // @ts-ignore
215
- return [2 /*return*/, _b.sent()];
216
- }
217
- });
84
+ withdrawEstimateGas(lpTokenAmount) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ // @ts-ignore
87
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
88
+ // @ts-ignore
89
+ return yield this._withdraw(_lpTokenAmount, 0.1, true);
218
90
  });
219
91
  },
220
- withdraw: function (lpTokenAmount, slippage) {
221
- return __awaiter(this, void 0, void 0, function () {
222
- var _lpTokenAmount;
223
- return __generator(this, function (_b) {
224
- switch (_b.label) {
225
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
226
- case 1:
227
- _lpTokenAmount = _b.sent();
228
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
229
- case 2:
230
- // @ts-ignore
231
- return [2 /*return*/, _b.sent()];
232
- }
233
- });
92
+ withdraw(lpTokenAmount, slippage) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ // @ts-ignore
95
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
96
+ // @ts-ignore
97
+ return yield this._withdraw(_lpTokenAmount, slippage);
234
98
  });
235
99
  },
236
100
  };
237
101
  // @ts-ignore
238
- export var withdrawZapMixin = {
102
+ export const withdrawZapMixin = {
239
103
  // @ts-ignore
240
- _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
241
- if (estimateGas === void 0) { estimateGas = false; }
242
- return __awaiter(this, void 0, void 0, function () {
243
- var _minAmounts, contract, args, gas, gasLimit;
244
- var _b;
245
- return __generator(this, function (_c) {
246
- switch (_c.label) {
247
- case 0:
248
- if (!!estimateGas) return [3 /*break*/, 2];
249
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
250
- case 1:
251
- _c.sent();
252
- _c.label = 2;
253
- case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
254
- case 3:
255
- _minAmounts = _c.sent();
256
- contract = curve.contracts[this.zap].contract;
257
- args = [_lpTokenAmount, _minAmounts];
258
- if ("remove_liquidity(uint256,uint256[".concat(this.underlyingCoinAddresses.length, "],bool)") in contract)
259
- args.push(true);
260
- return [4 /*yield*/, (_b = contract.remove_liquidity).estimateGas.apply(_b, __spreadArray(__spreadArray([], args, false), [curve.constantOptions], false))];
261
- case 4:
262
- gas = _c.sent();
263
- if (estimateGas)
264
- return [2 /*return*/, smartNumber(gas)];
265
- gasLimit = mulBy1_3(DIGas(gas));
266
- return [4 /*yield*/, contract.remove_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
267
- case 5: return [2 /*return*/, (_c.sent()).hash];
268
- }
269
- });
104
+ _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ if (!estimateGas)
107
+ yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
108
+ // @ts-ignore
109
+ const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
110
+ const contract = curve.contracts[this.zap].contract;
111
+ const args = [_lpTokenAmount, _minAmounts];
112
+ if (`remove_liquidity(uint256,uint256[${this.underlyingCoinAddresses.length}],bool)` in contract)
113
+ args.push(true);
114
+ const gas = yield contract.remove_liquidity.estimateGas(...args, curve.constantOptions);
115
+ if (estimateGas)
116
+ return smartNumber(gas);
117
+ const gasLimit = mulBy1_3(DIGas(gas));
118
+ return (yield contract.remove_liquidity(...args, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
270
119
  });
271
120
  },
272
- withdrawEstimateGas: function (lpTokenAmount) {
273
- return __awaiter(this, void 0, void 0, function () {
274
- var _lpTokenAmount;
275
- return __generator(this, function (_b) {
276
- switch (_b.label) {
277
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
278
- case 1:
279
- _lpTokenAmount = _b.sent();
280
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
281
- case 2:
282
- // @ts-ignore
283
- return [2 /*return*/, _b.sent()];
284
- }
285
- });
121
+ withdrawEstimateGas(lpTokenAmount) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ // @ts-ignore
124
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
125
+ // @ts-ignore
126
+ return yield this._withdraw(_lpTokenAmount, 0.1, true);
286
127
  });
287
128
  },
288
- withdraw: function (lpTokenAmount, slippage) {
289
- return __awaiter(this, void 0, void 0, function () {
290
- var _lpTokenAmount;
291
- return __generator(this, function (_b) {
292
- switch (_b.label) {
293
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
294
- case 1:
295
- _lpTokenAmount = _b.sent();
296
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
297
- case 2:
298
- // @ts-ignore
299
- return [2 /*return*/, _b.sent()];
300
- }
301
- });
129
+ withdraw(lpTokenAmount, slippage) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ // @ts-ignore
132
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
133
+ // @ts-ignore
134
+ return yield this._withdraw(_lpTokenAmount, slippage);
302
135
  });
303
136
  },
304
137
  };
305
138
  // @ts-ignore
306
- export var withdrawLendingOrCryptoMixin = {
139
+ export const withdrawLendingOrCryptoMixin = {
307
140
  // @ts-ignore
308
- _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
309
- if (estimateGas === void 0) { estimateGas = false; }
310
- return __awaiter(this, void 0, void 0, function () {
311
- var _minAmounts, contract, gas, gasLimit;
312
- return __generator(this, function (_b) {
313
- switch (_b.label) {
314
- case 0: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
315
- case 1:
316
- _minAmounts = _b.sent();
317
- contract = curve.contracts[this.address].contract;
318
- return [4 /*yield*/, contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions)];
319
- case 2:
320
- gas = _b.sent();
321
- if (estimateGas)
322
- return [2 /*return*/, smartNumber(gas)];
323
- gasLimit = mulBy1_3(DIGas(gas));
324
- return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
325
- case 3: return [2 /*return*/, (_b.sent()).hash];
326
- }
327
- });
141
+ _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
144
+ const contract = curve.contracts[this.address].contract;
145
+ const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions);
146
+ if (estimateGas)
147
+ return smartNumber(gas);
148
+ const gasLimit = mulBy1_3(DIGas(gas));
149
+ return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
328
150
  });
329
151
  },
330
- withdrawEstimateGas: function (lpTokenAmount) {
331
- return __awaiter(this, void 0, void 0, function () {
332
- var _lpTokenAmount;
333
- return __generator(this, function (_b) {
334
- switch (_b.label) {
335
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
336
- case 1:
337
- _lpTokenAmount = _b.sent();
338
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
339
- case 2:
340
- // @ts-ignore
341
- return [2 /*return*/, _b.sent()];
342
- }
343
- });
152
+ withdrawEstimateGas(lpTokenAmount) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ // @ts-ignore
155
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
156
+ // @ts-ignore
157
+ return yield this._withdraw(_lpTokenAmount, 0.1, true);
344
158
  });
345
159
  },
346
- withdraw: function (lpTokenAmount, slippage) {
347
- return __awaiter(this, void 0, void 0, function () {
348
- var _lpTokenAmount;
349
- return __generator(this, function (_b) {
350
- switch (_b.label) {
351
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
352
- case 1:
353
- _lpTokenAmount = _b.sent();
354
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
355
- case 2:
356
- // @ts-ignore
357
- return [2 /*return*/, _b.sent()];
358
- }
359
- });
160
+ withdraw(lpTokenAmount, slippage) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ // @ts-ignore
163
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
164
+ // @ts-ignore
165
+ return yield this._withdraw(_lpTokenAmount, slippage);
360
166
  });
361
167
  },
362
168
  };
363
169
  // @ts-ignore
364
- export var withdrawPlainMixin = {
170
+ export const withdrawPlainMixin = {
365
171
  // @ts-ignore
366
- _withdraw: function (_lpTokenAmount, slippage, estimateGas) {
367
- if (estimateGas === void 0) { estimateGas = false; }
368
- return __awaiter(this, void 0, void 0, function () {
369
- var _minAmounts, contract, gas, gasLimit;
370
- return __generator(this, function (_b) {
371
- switch (_b.label) {
372
- case 0: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
373
- case 1:
374
- _minAmounts = _b.sent();
375
- contract = curve.contracts[this.address].contract;
376
- return [4 /*yield*/, contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions)];
377
- case 2:
378
- gas = _b.sent();
379
- if (estimateGas)
380
- return [2 /*return*/, smartNumber(gas)];
381
- gasLimit = mulBy1_3(DIGas(gas));
382
- return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
383
- case 3: return [2 /*return*/, (_b.sent()).hash];
384
- }
385
- });
172
+ _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ // @ts-ignore
175
+ const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
176
+ const contract = curve.contracts[this.address].contract;
177
+ const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions);
178
+ if (estimateGas)
179
+ return smartNumber(gas);
180
+ const gasLimit = mulBy1_3(DIGas(gas));
181
+ return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
386
182
  });
387
183
  },
388
- withdrawEstimateGas: function (lpTokenAmount) {
389
- return __awaiter(this, void 0, void 0, function () {
390
- var _lpTokenAmount;
391
- return __generator(this, function (_b) {
392
- switch (_b.label) {
393
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
394
- case 1:
395
- _lpTokenAmount = _b.sent();
396
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
397
- case 2:
398
- // @ts-ignore
399
- return [2 /*return*/, _b.sent()];
400
- }
401
- });
184
+ withdrawEstimateGas(lpTokenAmount) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ // @ts-ignore
187
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
188
+ // @ts-ignore
189
+ return yield this._withdraw(_lpTokenAmount, 0.1, true);
402
190
  });
403
191
  },
404
- withdraw: function (lpTokenAmount, slippage) {
405
- return __awaiter(this, void 0, void 0, function () {
406
- var _lpTokenAmount;
407
- return __generator(this, function (_b) {
408
- switch (_b.label) {
409
- case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
410
- case 1:
411
- _lpTokenAmount = _b.sent();
412
- return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
413
- case 2:
414
- // @ts-ignore
415
- return [2 /*return*/, _b.sent()];
416
- }
417
- });
192
+ withdraw(lpTokenAmount, slippage) {
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ // @ts-ignore
195
+ const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
196
+ // @ts-ignore
197
+ return yield this._withdraw(_lpTokenAmount, slippage);
418
198
  });
419
199
  },
420
200
  };