@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,157 +1,420 @@
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
+ };
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
+ };
1
57
  import { curve } from "../../curve.js";
2
58
  import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
3
59
  // @ts-ignore
4
- async function _withdrawCheck(lpTokenAmount, estimateGas = false) {
5
- const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken'];
6
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
7
- throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
8
- }
9
- if (estimateGas && this.zap && !(await hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
10
- throw Error("Token allowance is needed to estimate gas");
11
- }
12
- if (!estimateGas)
13
- await curve.updateFeeData();
14
- return parseUnits(lpTokenAmount);
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
+ });
90
+ });
15
91
  }
16
- async function _withdrawMinAmounts(_lpTokenAmount, slippage = 0.5) {
17
- const expectedAmounts = await this.withdrawExpected(curve.formatUnits(_lpTokenAmount));
18
- const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.underlyingDecimals[i]));
19
- const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.underlyingDecimals[i]).times(100 - slippage).div(100));
20
- return minRecvAmountsBN.map((a, i) => fromBN(a, this.underlyingDecimals[i]));
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
+ });
107
+ });
21
108
  }
22
109
  // @ts-ignore
23
- export const withdrawMetaFactoryMixin = {
110
+ export var withdrawMetaFactoryMixin = {
24
111
  // @ts-ignore
25
- async _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
26
- if (!estimateGas)
27
- await _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
28
- const _minAmounts = await _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
29
- const contract = curve.contracts[this.zap].contract;
30
- const gas = await contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, curve.constantOptions);
31
- if (estimateGas)
32
- return Number(gas);
33
- const gasLimit = mulBy1_3(gas);
34
- return (await contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, { ...curve.options, gasLimit })).hash;
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*/, Number(gas)];
133
+ gasLimit = mulBy1_3(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
+ });
138
+ });
35
139
  },
36
- async withdrawEstimateGas(lpTokenAmount) {
37
- // @ts-ignore
38
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount, true);
39
- // @ts-ignore
40
- return await this._withdraw(_lpTokenAmount, 0.1, true);
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
+ });
154
+ });
41
155
  },
42
- async withdraw(lpTokenAmount, slippage) {
43
- // @ts-ignore
44
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount);
45
- // @ts-ignore
46
- return await this._withdraw(_lpTokenAmount, slippage);
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
+ });
170
+ });
47
171
  },
48
172
  };
49
173
  // @ts-ignore
50
- export const withdrawCryptoMetaFactoryMixin = {
174
+ export var withdrawCryptoMetaFactoryMixin = {
51
175
  // @ts-ignore
52
- async _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
53
- if (!estimateGas)
54
- await _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
55
- const _minAmounts = await _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
56
- const contract = curve.contracts[this.zap].contract;
57
- const gas = await contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, curve.constantOptions);
58
- if (estimateGas)
59
- return Number(gas);
60
- const gasLimit = mulBy1_3(gas);
61
- return (await contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, { ...curve.options, gasLimit })).hash;
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*/, Number(gas)];
197
+ gasLimit = mulBy1_3(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
+ });
202
+ });
62
203
  },
63
- async withdrawEstimateGas(lpTokenAmount) {
64
- // @ts-ignore
65
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount, true);
66
- // @ts-ignore
67
- return await this._withdraw(_lpTokenAmount, 0.1, true);
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
+ });
218
+ });
68
219
  },
69
- async withdraw(lpTokenAmount, slippage) {
70
- // @ts-ignore
71
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount);
72
- // @ts-ignore
73
- return await this._withdraw(_lpTokenAmount, slippage);
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
+ });
234
+ });
74
235
  },
75
236
  };
76
237
  // @ts-ignore
77
- export const withdrawZapMixin = {
238
+ export var withdrawZapMixin = {
78
239
  // @ts-ignore
79
- async _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
80
- if (!estimateGas)
81
- await _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
82
- // @ts-ignore
83
- const _minAmounts = await _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
84
- const contract = curve.contracts[this.zap].contract;
85
- const args = [_lpTokenAmount, _minAmounts];
86
- if (`remove_liquidity(uint256,uint256[${this.underlyingCoinAddresses.length}],bool)` in contract)
87
- args.push(true);
88
- const gas = await contract.remove_liquidity.estimateGas(...args, curve.constantOptions);
89
- if (estimateGas)
90
- return Number(gas);
91
- const gasLimit = mulBy1_3(gas);
92
- return (await contract.remove_liquidity(...args, { ...curve.options, gasLimit })).hash;
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*/, Number(gas)];
265
+ gasLimit = mulBy1_3(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
+ });
270
+ });
93
271
  },
94
- async withdrawEstimateGas(lpTokenAmount) {
95
- // @ts-ignore
96
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount, true);
97
- // @ts-ignore
98
- return await this._withdraw(_lpTokenAmount, 0.1, true);
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
+ });
286
+ });
99
287
  },
100
- async withdraw(lpTokenAmount, slippage) {
101
- // @ts-ignore
102
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount);
103
- // @ts-ignore
104
- return await this._withdraw(_lpTokenAmount, slippage);
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
+ });
302
+ });
105
303
  },
106
304
  };
107
305
  // @ts-ignore
108
- export const withdrawLendingOrCryptoMixin = {
306
+ export var withdrawLendingOrCryptoMixin = {
109
307
  // @ts-ignore
110
- async _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
111
- const _minAmounts = await _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
112
- const contract = curve.contracts[this.address].contract;
113
- const gas = await contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions);
114
- if (estimateGas)
115
- return Number(gas);
116
- const gasLimit = mulBy1_3(gas);
117
- return (await contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, { ...curve.options, gasLimit })).hash;
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*/, Number(gas)];
323
+ gasLimit = mulBy1_3(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
+ });
328
+ });
118
329
  },
119
- async withdrawEstimateGas(lpTokenAmount) {
120
- // @ts-ignore
121
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount, true);
122
- // @ts-ignore
123
- return await this._withdraw(_lpTokenAmount, 0.1, true);
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
+ });
344
+ });
124
345
  },
125
- async withdraw(lpTokenAmount, slippage) {
126
- // @ts-ignore
127
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount);
128
- // @ts-ignore
129
- return await this._withdraw(_lpTokenAmount, slippage);
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
+ });
360
+ });
130
361
  },
131
362
  };
132
363
  // @ts-ignore
133
- export const withdrawPlainMixin = {
364
+ export var withdrawPlainMixin = {
134
365
  // @ts-ignore
135
- async _withdraw(_lpTokenAmount, slippage, estimateGas = false) {
136
- // @ts-ignore
137
- const _minAmounts = await _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
138
- const contract = curve.contracts[this.address].contract;
139
- const gas = await contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions);
140
- if (estimateGas)
141
- return Number(gas);
142
- const gasLimit = mulBy1_3(gas);
143
- return (await contract.remove_liquidity(_lpTokenAmount, _minAmounts, { ...curve.options, gasLimit })).hash;
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*/, Number(gas)];
381
+ gasLimit = mulBy1_3(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
+ });
386
+ });
144
387
  },
145
- async withdrawEstimateGas(lpTokenAmount) {
146
- // @ts-ignore
147
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount, true);
148
- // @ts-ignore
149
- return await this._withdraw(_lpTokenAmount, 0.1, true);
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
+ });
402
+ });
150
403
  },
151
- async withdraw(lpTokenAmount, slippage) {
152
- // @ts-ignore
153
- const _lpTokenAmount = await _withdrawCheck.call(this, lpTokenAmount);
154
- // @ts-ignore
155
- return await this._withdraw(_lpTokenAmount, slippage);
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
+ });
418
+ });
156
419
  },
157
420
  };