@curvefi/api 2.31.1 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/abis/stable_calc.json +151 -0
  3. package/lib/constants/abis/wbeth/swap.json +1086 -0
  4. package/lib/constants/aliases.js +33 -11
  5. package/lib/constants/coins/arbitrum.js +5 -5
  6. package/lib/constants/coins/aurora.js +5 -5
  7. package/lib/constants/coins/avalanche.js +6 -6
  8. package/lib/constants/coins/celo.js +5 -5
  9. package/lib/constants/coins/ethereum.js +10 -9
  10. package/lib/constants/coins/fantom.js +7 -7
  11. package/lib/constants/coins/kava.js +5 -5
  12. package/lib/constants/coins/moonbeam.js +5 -5
  13. package/lib/constants/coins/optimism.js +5 -5
  14. package/lib/constants/coins/polygon.js +6 -6
  15. package/lib/constants/coins/xdai.js +5 -5
  16. package/lib/constants/pools/arbitrum.js +1 -1
  17. package/lib/constants/pools/aurora.js +1 -1
  18. package/lib/constants/pools/avalanche.js +1 -1
  19. package/lib/constants/pools/celo.js +1 -1
  20. package/lib/constants/pools/ethereum.js +26 -1
  21. package/lib/constants/pools/fantom.js +1 -1
  22. package/lib/constants/pools/kava.js +1 -1
  23. package/lib/constants/pools/moonbeam.js +1 -1
  24. package/lib/constants/pools/optimism.js +1 -1
  25. package/lib/constants/pools/polygon.js +1 -1
  26. package/lib/constants/pools/xdai.js +1 -1
  27. package/lib/constants/utils.d.ts +1 -1
  28. package/lib/constants/utils.js +19 -18
  29. package/lib/curve.js +507 -281
  30. package/lib/external-api.js +132 -45
  31. package/lib/factory/common.js +3 -3
  32. package/lib/factory/constants-crypto.js +21 -21
  33. package/lib/factory/constants.js +32 -31
  34. package/lib/factory/deploy.js +336 -176
  35. package/lib/factory/factory-api.js +256 -180
  36. package/lib/factory/factory-crypto.js +309 -163
  37. package/lib/factory/factory.d.ts +1 -1
  38. package/lib/factory/factory.js +336 -186
  39. package/lib/index.js +98 -44
  40. package/lib/interfaces.d.ts +1 -1
  41. package/lib/pools/PoolTemplate.js +2882 -1511
  42. package/lib/pools/mixins/common.js +106 -22
  43. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  44. package/lib/pools/mixins/depositMixins.js +413 -144
  45. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  46. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  47. package/lib/pools/mixins/swapMixins.js +347 -125
  48. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  49. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  50. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  51. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  52. package/lib/pools/mixins/withdrawMixins.js +385 -122
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  54. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  55. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  56. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  57. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  58. package/lib/pools/poolConstructor.js +25 -5
  59. package/lib/pools/utils.js +488 -298
  60. package/lib/router.js +636 -378
  61. package/lib/utils.js +675 -354
  62. package/package.json +1 -1
@@ -1,126 +1,345 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
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
+ };
1
48
  import { curve } from "../../curve.js";
2
49
  import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
3
50
  // @ts-ignore
4
- async function _withdrawImbalanceCheck(amounts, estimateGas = false) {
5
- const lpTokenAmount = await this.withdrawImbalanceExpected(amounts);
6
- const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken'];
7
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
8
- throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
9
- }
10
- if (estimateGas && this.zap && !(await hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
11
- throw Error("Token allowance is needed to estimate gas");
12
- }
13
- if (!estimateGas)
14
- await curve.updateFeeData();
15
- return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
51
+ function _withdrawImbalanceCheck(amounts, estimateGas) {
52
+ if (estimateGas === void 0) { estimateGas = false; }
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ var lpTokenAmount, lpTokenBalance, _a;
55
+ var _this = this;
56
+ return __generator(this, function (_b) {
57
+ switch (_b.label) {
58
+ case 0: return [4 /*yield*/, this.withdrawImbalanceExpected(amounts)];
59
+ case 1:
60
+ lpTokenAmount = _b.sent();
61
+ return [4 /*yield*/, this.wallet.lpTokenBalances()];
62
+ case 2:
63
+ lpTokenBalance = (_b.sent())['lpToken'];
64
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
65
+ throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
66
+ }
67
+ _a = estimateGas && this.zap;
68
+ if (!_a) return [3 /*break*/, 4];
69
+ return [4 /*yield*/, hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap)];
70
+ case 3:
71
+ _a = !(_b.sent());
72
+ _b.label = 4;
73
+ case 4:
74
+ if (_a) {
75
+ throw Error("Token allowance is needed to estimate gas");
76
+ }
77
+ if (!!estimateGas) return [3 /*break*/, 6];
78
+ return [4 /*yield*/, curve.updateFeeData()];
79
+ case 5:
80
+ _b.sent();
81
+ _b.label = 6;
82
+ case 6: return [2 /*return*/, amounts.map(function (amount, i) { return parseUnits(amount, _this.underlyingDecimals[i]); })];
83
+ }
84
+ });
85
+ });
16
86
  }
17
- async function _withdrawImbalanceMaxBurnAmount(_amounts, slippage = 0.5) {
18
- // @ts-ignore
19
- const _expectedLpTokenAmount = await this._calcLpTokenAmount(_amounts, false);
20
- const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
21
- return fromBN(maxBurnAmountBN);
87
+ function _withdrawImbalanceMaxBurnAmount(_amounts, slippage) {
88
+ if (slippage === void 0) { slippage = 0.5; }
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ var _expectedLpTokenAmount, maxBurnAmountBN;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0: return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false)];
94
+ case 1:
95
+ _expectedLpTokenAmount = _a.sent();
96
+ maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
97
+ return [2 /*return*/, fromBN(maxBurnAmountBN)];
98
+ }
99
+ });
100
+ });
22
101
  }
23
102
  // @ts-ignore
24
- export const withdrawImbalanceMetaFactoryMixin = {
103
+ export var withdrawImbalanceMetaFactoryMixin = {
25
104
  // @ts-ignore
26
- async _withdrawImbalance(_amounts, slippage, estimateGas = false) {
27
- const _maxBurnAmount = await _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
28
- if (!estimateGas)
29
- await _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap);
30
- const contract = curve.contracts[this.zap].contract;
31
- const gas = await contract.remove_liquidity_imbalance.estimateGas(this.address, _amounts, _maxBurnAmount, curve.constantOptions);
32
- if (estimateGas)
33
- return Number(gas);
34
- const gasLimit = mulBy1_3(gas);
35
- return (await contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, { ...curve.options, gasLimit })).hash;
105
+ _withdrawImbalance: function (_amounts, slippage, estimateGas) {
106
+ if (estimateGas === void 0) { estimateGas = false; }
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var _maxBurnAmount, contract, gas, gasLimit;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
112
+ case 1:
113
+ _maxBurnAmount = _a.sent();
114
+ if (!!estimateGas) return [3 /*break*/, 3];
115
+ return [4 /*yield*/, _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap)];
116
+ case 2:
117
+ _a.sent();
118
+ _a.label = 3;
119
+ case 3:
120
+ contract = curve.contracts[this.zap].contract;
121
+ return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(this.address, _amounts, _maxBurnAmount, curve.constantOptions)];
122
+ case 4:
123
+ gas = _a.sent();
124
+ if (estimateGas)
125
+ return [2 /*return*/, Number(gas)];
126
+ gasLimit = mulBy1_3(gas);
127
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
128
+ case 5: return [2 /*return*/, (_a.sent()).hash];
129
+ }
130
+ });
131
+ });
36
132
  },
37
- async withdrawImbalanceEstimateGas(amounts) {
38
- // @ts-ignore
39
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts, true);
40
- // @ts-ignore
41
- return await this._withdrawImbalance(_amounts, 0.1, true);
133
+ withdrawImbalanceEstimateGas: function (amounts) {
134
+ return __awaiter(this, void 0, void 0, function () {
135
+ var _amounts;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
139
+ case 1:
140
+ _amounts = _a.sent();
141
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
142
+ case 2:
143
+ // @ts-ignore
144
+ return [2 /*return*/, _a.sent()];
145
+ }
146
+ });
147
+ });
42
148
  },
43
- async withdrawImbalance(amounts, slippage) {
44
- // @ts-ignore
45
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts);
46
- // @ts-ignore
47
- return await this._withdrawImbalance(_amounts, slippage);
149
+ withdrawImbalance: function (amounts, slippage) {
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var _amounts;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
155
+ case 1:
156
+ _amounts = _a.sent();
157
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
158
+ case 2:
159
+ // @ts-ignore
160
+ return [2 /*return*/, _a.sent()];
161
+ }
162
+ });
163
+ });
48
164
  },
49
165
  };
50
166
  // @ts-ignore
51
- export const withdrawImbalanceZapMixin = {
167
+ export var withdrawImbalanceZapMixin = {
52
168
  // @ts-ignore
53
- async _withdrawImbalance(_amounts, slippage, estimateGas = false) {
54
- const _maxBurnAmount = await _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
55
- if (!estimateGas)
56
- await _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap);
57
- const contract = curve.contracts[this.zap].contract;
58
- const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
59
- if (estimateGas)
60
- return Number(gas);
61
- const gasLimit = mulBy1_3(gas);
62
- return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, { ...curve.options, gasLimit })).hash;
169
+ _withdrawImbalance: function (_amounts, slippage, estimateGas) {
170
+ if (estimateGas === void 0) { estimateGas = false; }
171
+ return __awaiter(this, void 0, void 0, function () {
172
+ var _maxBurnAmount, contract, gas, gasLimit;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
176
+ case 1:
177
+ _maxBurnAmount = _a.sent();
178
+ if (!!estimateGas) return [3 /*break*/, 3];
179
+ return [4 /*yield*/, _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap)];
180
+ case 2:
181
+ _a.sent();
182
+ _a.label = 3;
183
+ case 3:
184
+ contract = curve.contracts[this.zap].contract;
185
+ return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions)];
186
+ case 4:
187
+ gas = _a.sent();
188
+ if (estimateGas)
189
+ return [2 /*return*/, Number(gas)];
190
+ gasLimit = mulBy1_3(gas);
191
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
192
+ case 5: return [2 /*return*/, (_a.sent()).hash];
193
+ }
194
+ });
195
+ });
63
196
  },
64
- async withdrawImbalanceEstimateGas(amounts) {
65
- // @ts-ignore
66
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts, true);
67
- // @ts-ignore
68
- return await this._withdrawImbalance(_amounts, 0.1, true);
197
+ withdrawImbalanceEstimateGas: function (amounts) {
198
+ return __awaiter(this, void 0, void 0, function () {
199
+ var _amounts;
200
+ return __generator(this, function (_a) {
201
+ switch (_a.label) {
202
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
203
+ case 1:
204
+ _amounts = _a.sent();
205
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
206
+ case 2:
207
+ // @ts-ignore
208
+ return [2 /*return*/, _a.sent()];
209
+ }
210
+ });
211
+ });
69
212
  },
70
- async withdrawImbalance(amounts, slippage) {
71
- // @ts-ignore
72
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts);
73
- // @ts-ignore
74
- return await this._withdrawImbalance(_amounts, slippage);
213
+ withdrawImbalance: function (amounts, slippage) {
214
+ return __awaiter(this, void 0, void 0, function () {
215
+ var _amounts;
216
+ return __generator(this, function (_a) {
217
+ switch (_a.label) {
218
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
219
+ case 1:
220
+ _amounts = _a.sent();
221
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
222
+ case 2:
223
+ // @ts-ignore
224
+ return [2 /*return*/, _a.sent()];
225
+ }
226
+ });
227
+ });
75
228
  },
76
229
  };
77
230
  // @ts-ignore
78
- export const withdrawImbalanceLendingMixin = {
231
+ export var withdrawImbalanceLendingMixin = {
79
232
  // @ts-ignore
80
- async _withdrawImbalance(_amounts, slippage, estimateGas = false) {
81
- const _maxBurnAmount = await _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
82
- const contract = curve.contracts[this.address].contract;
83
- const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, true, curve.constantOptions);
84
- if (estimateGas)
85
- return Number(gas);
86
- const gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * 140n / 100n : mulBy1_3(gas);
87
- return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, { ...curve.options, gasLimit })).hash;
233
+ _withdrawImbalance: function (_amounts, slippage, estimateGas) {
234
+ if (estimateGas === void 0) { estimateGas = false; }
235
+ return __awaiter(this, void 0, void 0, function () {
236
+ var _maxBurnAmount, contract, gas, gasLimit;
237
+ return __generator(this, function (_a) {
238
+ switch (_a.label) {
239
+ case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
240
+ case 1:
241
+ _maxBurnAmount = _a.sent();
242
+ contract = curve.contracts[this.address].contract;
243
+ return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, true, curve.constantOptions)];
244
+ case 2:
245
+ gas = _a.sent();
246
+ if (estimateGas)
247
+ return [2 /*return*/, Number(gas)];
248
+ gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
249
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
250
+ case 3: return [2 /*return*/, (_a.sent()).hash];
251
+ }
252
+ });
253
+ });
88
254
  },
89
- async withdrawImbalanceEstimateGas(amounts) {
90
- // @ts-ignore
91
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts, true);
92
- // @ts-ignore
93
- return await this._withdrawImbalance(_amounts, 0.1, true);
255
+ withdrawImbalanceEstimateGas: function (amounts) {
256
+ return __awaiter(this, void 0, void 0, function () {
257
+ var _amounts;
258
+ return __generator(this, function (_a) {
259
+ switch (_a.label) {
260
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
261
+ case 1:
262
+ _amounts = _a.sent();
263
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
264
+ case 2:
265
+ // @ts-ignore
266
+ return [2 /*return*/, _a.sent()];
267
+ }
268
+ });
269
+ });
94
270
  },
95
- async withdrawImbalance(amounts, slippage) {
96
- // @ts-ignore
97
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts);
98
- // @ts-ignore
99
- return await this._withdrawImbalance(_amounts, slippage);
271
+ withdrawImbalance: function (amounts, slippage) {
272
+ return __awaiter(this, void 0, void 0, function () {
273
+ var _amounts;
274
+ return __generator(this, function (_a) {
275
+ switch (_a.label) {
276
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
277
+ case 1:
278
+ _amounts = _a.sent();
279
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
280
+ case 2:
281
+ // @ts-ignore
282
+ return [2 /*return*/, _a.sent()];
283
+ }
284
+ });
285
+ });
100
286
  },
101
287
  };
102
288
  // @ts-ignore
103
- export const withdrawImbalancePlainMixin = {
289
+ export var withdrawImbalancePlainMixin = {
104
290
  // @ts-ignore
105
- async _withdrawImbalance(_amounts, slippage, estimateGas = false) {
106
- const _maxBurnAmount = await _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
107
- const contract = curve.contracts[this.address].contract;
108
- const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
109
- if (estimateGas)
110
- return Number(gas);
111
- const gasLimit = mulBy1_3(gas);
112
- return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, { ...curve.options, gasLimit })).hash;
291
+ _withdrawImbalance: function (_amounts, slippage, estimateGas) {
292
+ if (estimateGas === void 0) { estimateGas = false; }
293
+ return __awaiter(this, void 0, void 0, function () {
294
+ var _maxBurnAmount, contract, gas, gasLimit;
295
+ return __generator(this, function (_a) {
296
+ switch (_a.label) {
297
+ case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
298
+ case 1:
299
+ _maxBurnAmount = _a.sent();
300
+ contract = curve.contracts[this.address].contract;
301
+ return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions)];
302
+ case 2:
303
+ gas = _a.sent();
304
+ if (estimateGas)
305
+ return [2 /*return*/, Number(gas)];
306
+ gasLimit = mulBy1_3(gas);
307
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
308
+ case 3: return [2 /*return*/, (_a.sent()).hash];
309
+ }
310
+ });
311
+ });
113
312
  },
114
- async withdrawImbalanceEstimateGas(amounts) {
115
- // @ts-ignore
116
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts, true);
117
- // @ts-ignore
118
- return await this._withdrawImbalance(_amounts, 0.1, true);
313
+ withdrawImbalanceEstimateGas: function (amounts) {
314
+ return __awaiter(this, void 0, void 0, function () {
315
+ var _amounts;
316
+ return __generator(this, function (_a) {
317
+ switch (_a.label) {
318
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
319
+ case 1:
320
+ _amounts = _a.sent();
321
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
322
+ case 2:
323
+ // @ts-ignore
324
+ return [2 /*return*/, _a.sent()];
325
+ }
326
+ });
327
+ });
119
328
  },
120
- async withdrawImbalance(amounts, slippage) {
121
- // @ts-ignore
122
- const _amounts = await _withdrawImbalanceCheck.call(this, amounts);
123
- // @ts-ignore
124
- return await this._withdrawImbalance(_amounts, slippage);
329
+ withdrawImbalance: function (amounts, slippage) {
330
+ return __awaiter(this, void 0, void 0, function () {
331
+ var _amounts;
332
+ return __generator(this, function (_a) {
333
+ switch (_a.label) {
334
+ case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
335
+ case 1:
336
+ _amounts = _a.sent();
337
+ return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
338
+ case 2:
339
+ // @ts-ignore
340
+ return [2 /*return*/, _a.sent()];
341
+ }
342
+ });
343
+ });
125
344
  },
126
345
  };