@curvefi/api 2.32.0 → 2.33.1

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 (59) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/aliases.js +22 -11
  3. package/lib/constants/coins/arbitrum.js +5 -5
  4. package/lib/constants/coins/aurora.js +5 -5
  5. package/lib/constants/coins/avalanche.js +6 -6
  6. package/lib/constants/coins/celo.js +5 -5
  7. package/lib/constants/coins/ethereum.js +10 -9
  8. package/lib/constants/coins/fantom.js +7 -7
  9. package/lib/constants/coins/kava.js +5 -5
  10. package/lib/constants/coins/moonbeam.js +5 -5
  11. package/lib/constants/coins/optimism.js +5 -5
  12. package/lib/constants/coins/polygon.js +6 -6
  13. package/lib/constants/coins/xdai.js +5 -5
  14. package/lib/constants/pools/arbitrum.js +1 -1
  15. package/lib/constants/pools/aurora.js +1 -1
  16. package/lib/constants/pools/avalanche.js +1 -1
  17. package/lib/constants/pools/celo.js +1 -1
  18. package/lib/constants/pools/ethereum.js +1 -1
  19. package/lib/constants/pools/fantom.js +1 -1
  20. package/lib/constants/pools/kava.js +1 -1
  21. package/lib/constants/pools/moonbeam.js +1 -1
  22. package/lib/constants/pools/optimism.js +1 -1
  23. package/lib/constants/pools/polygon.js +1 -1
  24. package/lib/constants/pools/xdai.js +1 -1
  25. package/lib/constants/utils.js +19 -18
  26. package/lib/curve.js +506 -282
  27. package/lib/external-api.js +132 -45
  28. package/lib/factory/common.js +3 -3
  29. package/lib/factory/constants-crypto.js +21 -21
  30. package/lib/factory/constants.js +32 -31
  31. package/lib/factory/deploy.js +336 -176
  32. package/lib/factory/factory-api.js +256 -180
  33. package/lib/factory/factory-crypto.js +309 -163
  34. package/lib/factory/factory.d.ts +1 -1
  35. package/lib/factory/factory.js +336 -186
  36. package/lib/index.js +98 -44
  37. package/lib/interfaces.d.ts +5 -0
  38. package/lib/pools/PoolTemplate.js +2879 -1468
  39. package/lib/pools/mixins/common.js +106 -22
  40. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  41. package/lib/pools/mixins/depositMixins.js +413 -144
  42. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  43. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  44. package/lib/pools/mixins/swapMixins.js +347 -125
  45. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  46. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  47. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  48. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  49. package/lib/pools/mixins/withdrawMixins.js +385 -122
  50. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  51. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  52. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  53. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  54. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  55. package/lib/pools/poolConstructor.js +25 -5
  56. package/lib/pools/utils.js +488 -299
  57. package/lib/router.js +675 -212
  58. package/lib/utils.js +675 -354
  59. package/package.json +1 -2
@@ -1,179 +1,448 @@
1
- import { curve } from "../../curve.js";
2
- import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
3
- // @ts-ignore
4
- async function _depositCheck(amounts, estimateGas = false) {
5
- if (amounts.length !== this.underlyingCoinAddresses.length) {
6
- throw Error(`${this.name} pool has ${this.underlyingCoinAddresses.length} coins (amounts provided for ${amounts.length})`);
7
- }
8
- const balances = Object.values(await this.wallet.underlyingCoinBalances());
9
- for (let i = 0; i < balances.length; i++) {
10
- if (Number(balances[i]) < Number(amounts[i])) {
11
- throw Error(`Not enough ${this.underlyingCoins[i]}. Actual: ${balances[i]}, required: ${amounts[i]}`);
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];
12
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 };
13
46
  }
14
- if (estimateGas && !(await hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, this.zap || this.address))) {
15
- throw Error("Token allowance is needed to estimate gas");
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
+ }
16
54
  }
17
- if (!estimateGas)
18
- await curve.updateFeeData();
19
- return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
57
+ import { curve } from "../../curve.js";
58
+ import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
59
+ // @ts-ignore
60
+ function _depositCheck(amounts, estimateGas) {
61
+ if (estimateGas === void 0) { estimateGas = false; }
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var balances, _a, _b, i, _c;
64
+ var _this = this;
65
+ return __generator(this, function (_d) {
66
+ switch (_d.label) {
67
+ case 0:
68
+ if (amounts.length !== this.underlyingCoinAddresses.length) {
69
+ throw Error("".concat(this.name, " pool has ").concat(this.underlyingCoinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
70
+ }
71
+ _b = (_a = Object).values;
72
+ return [4 /*yield*/, this.wallet.underlyingCoinBalances()];
73
+ case 1:
74
+ balances = _b.apply(_a, [_d.sent()]);
75
+ for (i = 0; i < balances.length; i++) {
76
+ if (Number(balances[i]) < Number(amounts[i])) {
77
+ throw Error("Not enough ".concat(this.underlyingCoins[i], ". Actual: ").concat(balances[i], ", required: ").concat(amounts[i]));
78
+ }
79
+ }
80
+ _c = estimateGas;
81
+ if (!_c) return [3 /*break*/, 3];
82
+ return [4 /*yield*/, hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, this.zap || this.address)];
83
+ case 2:
84
+ _c = !(_d.sent());
85
+ _d.label = 3;
86
+ case 3:
87
+ if (_c) {
88
+ throw Error("Token allowance is needed to estimate gas");
89
+ }
90
+ if (!!estimateGas) return [3 /*break*/, 5];
91
+ return [4 /*yield*/, curve.updateFeeData()];
92
+ case 4:
93
+ _d.sent();
94
+ _d.label = 5;
95
+ case 5: return [2 /*return*/, amounts.map(function (amount, i) { return parseUnits(amount, _this.underlyingDecimals[i]); })];
96
+ }
97
+ });
98
+ });
20
99
  }
21
- async function _depositMinAmount(_amounts, slippage = 0.5) {
22
- // @ts-ignore
23
- const _expectedLpTokenAmount = await this._calcLpTokenAmount(_amounts);
24
- const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
25
- return fromBN(minAmountBN);
100
+ function _depositMinAmount(_amounts, slippage) {
101
+ if (slippage === void 0) { slippage = 0.5; }
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var _expectedLpTokenAmount, minAmountBN;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0: return [4 /*yield*/, this._calcLpTokenAmount(_amounts)];
107
+ case 1:
108
+ _expectedLpTokenAmount = _a.sent();
109
+ minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
110
+ return [2 /*return*/, fromBN(minAmountBN)];
111
+ }
112
+ });
113
+ });
26
114
  }
27
115
  // @ts-ignore
28
- export const depositMetaFactoryMixin = {
116
+ export var depositMetaFactoryMixin = {
29
117
  // @ts-ignore
30
- async _deposit(_amounts, slippage, estimateGas = false) {
31
- if (!estimateGas)
32
- await _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
33
- // @ts-ignore
34
- const _minMintAmount = await _depositMinAmount.call(this, _amounts, slippage);
35
- const ethIndex = getEthIndex(this.underlyingCoinAddresses);
36
- const value = _amounts[ethIndex] || 0n;
37
- const contract = curve.contracts[this.zap].contract;
38
- const gas = await contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, { ...curve.constantOptions, value });
39
- if (estimateGas)
40
- return Number(gas);
41
- const gasLimit = mulBy1_3(gas);
42
- return (await contract.add_liquidity(this.address, _amounts, _minMintAmount, { ...curve.options, gasLimit, value })).hash;
118
+ _deposit: function (_amounts, slippage, estimateGas) {
119
+ if (estimateGas === void 0) { estimateGas = false; }
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
122
+ return __generator(this, function (_a) {
123
+ switch (_a.label) {
124
+ case 0:
125
+ if (!!estimateGas) return [3 /*break*/, 2];
126
+ return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap)];
127
+ case 1:
128
+ _a.sent();
129
+ _a.label = 2;
130
+ case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
131
+ case 3:
132
+ _minMintAmount = _a.sent();
133
+ ethIndex = getEthIndex(this.underlyingCoinAddresses);
134
+ value = _amounts[ethIndex] || curve.parseUnits("0");
135
+ contract = curve.contracts[this.zap].contract;
136
+ return [4 /*yield*/, contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, __assign(__assign({}, curve.constantOptions), { value: value }))];
137
+ case 4:
138
+ gas = _a.sent();
139
+ if (estimateGas)
140
+ return [2 /*return*/, Number(gas)];
141
+ gasLimit = mulBy1_3(gas);
142
+ return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
143
+ case 5: return [2 /*return*/, (_a.sent()).hash];
144
+ }
145
+ });
146
+ });
43
147
  },
44
- async depositEstimateGas(amounts) {
45
- // @ts-ignore
46
- const _amounts = await _depositCheck.call(this, amounts, true);
47
- // @ts-ignore
48
- return await this._deposit(_amounts, 0.1, true);
148
+ depositEstimateGas: function (amounts) {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ var _amounts;
151
+ return __generator(this, function (_a) {
152
+ switch (_a.label) {
153
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
154
+ case 1:
155
+ _amounts = _a.sent();
156
+ return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
157
+ case 2:
158
+ // @ts-ignore
159
+ return [2 /*return*/, _a.sent()];
160
+ }
161
+ });
162
+ });
49
163
  },
50
- async deposit(amounts, slippage) {
51
- // @ts-ignore
52
- const _amounts = await _depositCheck.call(this, amounts);
53
- // @ts-ignore
54
- return await this._deposit(_amounts, slippage);
164
+ deposit: function (amounts, slippage) {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ var _amounts;
167
+ return __generator(this, function (_a) {
168
+ switch (_a.label) {
169
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
170
+ case 1:
171
+ _amounts = _a.sent();
172
+ return [4 /*yield*/, this._deposit(_amounts, slippage)];
173
+ case 2:
174
+ // @ts-ignore
175
+ return [2 /*return*/, _a.sent()];
176
+ }
177
+ });
178
+ });
55
179
  },
56
180
  };
57
181
  // @ts-ignore
58
- export const depositCryptoMetaFactoryMixin = {
182
+ export var depositCryptoMetaFactoryMixin = {
59
183
  // @ts-ignore
60
- async _deposit(_amounts, slippage, estimateGas = false) {
61
- if (!estimateGas)
62
- await _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
63
- // @ts-ignore
64
- const _minMintAmount = await _depositMinAmount.call(this, _amounts, slippage);
65
- const ethIndex = getEthIndex(this.underlyingCoinAddresses);
66
- const value = _amounts[ethIndex] || 0n;
67
- const contract = curve.contracts[this.zap].contract;
68
- const gas = await contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, { ...curve.constantOptions, value });
69
- if (estimateGas)
70
- return Number(gas);
71
- const gasLimit = mulBy1_3(gas);
72
- return (await contract.add_liquidity(this.address, _amounts, _minMintAmount, true, { ...curve.options, gasLimit, value })).hash;
184
+ _deposit: function (_amounts, slippage, estimateGas) {
185
+ if (estimateGas === void 0) { estimateGas = false; }
186
+ return __awaiter(this, void 0, void 0, function () {
187
+ var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
188
+ return __generator(this, function (_a) {
189
+ switch (_a.label) {
190
+ case 0:
191
+ if (!!estimateGas) return [3 /*break*/, 2];
192
+ return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap)];
193
+ case 1:
194
+ _a.sent();
195
+ _a.label = 2;
196
+ case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
197
+ case 3:
198
+ _minMintAmount = _a.sent();
199
+ ethIndex = getEthIndex(this.underlyingCoinAddresses);
200
+ value = _amounts[ethIndex] || curve.parseUnits("0");
201
+ contract = curve.contracts[this.zap].contract;
202
+ return [4 /*yield*/, contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve.constantOptions), { value: value }))];
203
+ case 4:
204
+ gas = _a.sent();
205
+ if (estimateGas)
206
+ return [2 /*return*/, Number(gas)];
207
+ gasLimit = mulBy1_3(gas);
208
+ return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
209
+ case 5: return [2 /*return*/, (_a.sent()).hash];
210
+ }
211
+ });
212
+ });
73
213
  },
74
- async depositEstimateGas(amounts) {
75
- // @ts-ignore
76
- const _amounts = await _depositCheck.call(this, amounts, true);
77
- // @ts-ignore
78
- return await this._deposit(_amounts, 0.1, true);
214
+ depositEstimateGas: function (amounts) {
215
+ return __awaiter(this, void 0, void 0, function () {
216
+ var _amounts;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
220
+ case 1:
221
+ _amounts = _a.sent();
222
+ return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
223
+ case 2:
224
+ // @ts-ignore
225
+ return [2 /*return*/, _a.sent()];
226
+ }
227
+ });
228
+ });
79
229
  },
80
- async deposit(amounts, slippage) {
81
- // @ts-ignore
82
- const _amounts = await _depositCheck.call(this, amounts);
83
- // @ts-ignore
84
- return await this._deposit(_amounts, slippage);
230
+ deposit: function (amounts, slippage) {
231
+ return __awaiter(this, void 0, void 0, function () {
232
+ var _amounts;
233
+ return __generator(this, function (_a) {
234
+ switch (_a.label) {
235
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
236
+ case 1:
237
+ _amounts = _a.sent();
238
+ return [4 /*yield*/, this._deposit(_amounts, slippage)];
239
+ case 2:
240
+ // @ts-ignore
241
+ return [2 /*return*/, _a.sent()];
242
+ }
243
+ });
244
+ });
85
245
  },
86
246
  };
87
247
  // @ts-ignore
88
- export const depositZapMixin = {
248
+ export var depositZapMixin = {
89
249
  // @ts-ignore
90
- async _deposit(_amounts, slippage, estimateGas = false) {
91
- if (!estimateGas)
92
- await _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
93
- // @ts-ignore
94
- const _minMintAmount = await _depositMinAmount.call(this, _amounts, slippage);
95
- const ethIndex = getEthIndex(this.underlyingCoinAddresses);
96
- const value = _amounts[ethIndex] || 0n;
97
- const contract = curve.contracts[this.zap].contract;
98
- const args = [_amounts, _minMintAmount];
99
- if (`add_liquidity(uint256[${this.underlyingCoinAddresses.length}],uint256,bool)` in contract)
100
- args.push(true);
101
- const gas = await contract.add_liquidity.estimateGas(...args, { ...curve.constantOptions, value });
102
- if (estimateGas)
103
- return Number(gas);
104
- const gasLimit = mulBy1_3(gas);
105
- return (await contract.add_liquidity(...args, { ...curve.options, gasLimit, value })).hash;
250
+ _deposit: function (_amounts, slippage, estimateGas) {
251
+ if (estimateGas === void 0) { estimateGas = false; }
252
+ return __awaiter(this, void 0, void 0, function () {
253
+ var _minMintAmount, ethIndex, value, contract, args, gas, gasLimit;
254
+ var _a;
255
+ return __generator(this, function (_b) {
256
+ switch (_b.label) {
257
+ case 0:
258
+ if (!!estimateGas) return [3 /*break*/, 2];
259
+ return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap)];
260
+ case 1:
261
+ _b.sent();
262
+ _b.label = 2;
263
+ case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
264
+ case 3:
265
+ _minMintAmount = _b.sent();
266
+ ethIndex = getEthIndex(this.underlyingCoinAddresses);
267
+ value = _amounts[ethIndex] || curve.parseUnits("0");
268
+ contract = curve.contracts[this.zap].contract;
269
+ args = [_amounts, _minMintAmount];
270
+ if ("add_liquidity(uint256[".concat(this.underlyingCoinAddresses.length, "],uint256,bool)") in contract)
271
+ args.push(true);
272
+ return [4 /*yield*/, (_a = contract.add_liquidity).estimateGas.apply(_a, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.constantOptions), { value: value })], false))];
273
+ case 4:
274
+ gas = _b.sent();
275
+ if (estimateGas)
276
+ return [2 /*return*/, Number(gas)];
277
+ gasLimit = mulBy1_3(gas);
278
+ return [4 /*yield*/, contract.add_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value })], false))];
279
+ case 5: return [2 /*return*/, (_b.sent()).hash];
280
+ }
281
+ });
282
+ });
106
283
  },
107
- async depositEstimateGas(amounts) {
108
- // @ts-ignore
109
- const _amounts = await _depositCheck.call(this, amounts, true);
110
- // @ts-ignore
111
- return await this._deposit(_amounts, 0.1, true);
284
+ depositEstimateGas: function (amounts) {
285
+ return __awaiter(this, void 0, void 0, function () {
286
+ var _amounts;
287
+ return __generator(this, function (_a) {
288
+ switch (_a.label) {
289
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
290
+ case 1:
291
+ _amounts = _a.sent();
292
+ return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
293
+ case 2:
294
+ // @ts-ignore
295
+ return [2 /*return*/, _a.sent()];
296
+ }
297
+ });
298
+ });
112
299
  },
113
- async deposit(amounts, slippage) {
114
- // @ts-ignore
115
- const _amounts = await _depositCheck.call(this, amounts);
116
- // @ts-ignore
117
- return await this._deposit(_amounts, slippage);
300
+ deposit: function (amounts, slippage) {
301
+ return __awaiter(this, void 0, void 0, function () {
302
+ var _amounts;
303
+ return __generator(this, function (_a) {
304
+ switch (_a.label) {
305
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
306
+ case 1:
307
+ _amounts = _a.sent();
308
+ return [4 /*yield*/, this._deposit(_amounts, slippage)];
309
+ case 2:
310
+ // @ts-ignore
311
+ return [2 /*return*/, _a.sent()];
312
+ }
313
+ });
314
+ });
118
315
  },
119
316
  };
120
317
  // @ts-ignore
121
- export const depositLendingOrCryptoMixin = {
318
+ export var depositLendingOrCryptoMixin = {
122
319
  // @ts-ignore
123
- async _deposit(_amounts, slippage, estimateGas = false) {
124
- if (!estimateGas)
125
- await _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.address);
126
- // @ts-ignore
127
- const _minMintAmount = await _depositMinAmount.call(this, _amounts, slippage);
128
- const ethIndex = getEthIndex(this.underlyingCoinAddresses);
129
- const value = _amounts[ethIndex] || 0n;
130
- const contract = curve.contracts[this.address].contract;
131
- const gas = await contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, { ...curve.constantOptions, value });
132
- if (estimateGas)
133
- return Number(gas);
134
- const gasLimit = mulBy1_3(gas);
135
- return (await contract.add_liquidity(_amounts, _minMintAmount, true, { ...curve.options, gasLimit, value })).hash;
320
+ _deposit: function (_amounts, slippage, estimateGas) {
321
+ if (estimateGas === void 0) { estimateGas = false; }
322
+ return __awaiter(this, void 0, void 0, function () {
323
+ var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
324
+ return __generator(this, function (_a) {
325
+ switch (_a.label) {
326
+ case 0:
327
+ if (!!estimateGas) return [3 /*break*/, 2];
328
+ return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.address)];
329
+ case 1:
330
+ _a.sent();
331
+ _a.label = 2;
332
+ case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
333
+ case 3:
334
+ _minMintAmount = _a.sent();
335
+ ethIndex = getEthIndex(this.underlyingCoinAddresses);
336
+ value = _amounts[ethIndex] || curve.parseUnits("0");
337
+ contract = curve.contracts[this.address].contract;
338
+ return [4 /*yield*/, contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, __assign(__assign({}, curve.constantOptions), { value: value }))];
339
+ case 4:
340
+ gas = _a.sent();
341
+ if (estimateGas)
342
+ return [2 /*return*/, Number(gas)];
343
+ gasLimit = mulBy1_3(gas);
344
+ return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
345
+ case 5: return [2 /*return*/, (_a.sent()).hash];
346
+ }
347
+ });
348
+ });
136
349
  },
137
- async depositEstimateGas(amounts) {
138
- // @ts-ignore
139
- const _amounts = await _depositCheck.call(this, amounts, true);
140
- // @ts-ignore
141
- return await this._deposit(_amounts, 0.1, true);
350
+ depositEstimateGas: function (amounts) {
351
+ return __awaiter(this, void 0, void 0, function () {
352
+ var _amounts;
353
+ return __generator(this, function (_a) {
354
+ switch (_a.label) {
355
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
356
+ case 1:
357
+ _amounts = _a.sent();
358
+ return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
359
+ case 2:
360
+ // @ts-ignore
361
+ return [2 /*return*/, _a.sent()];
362
+ }
363
+ });
364
+ });
142
365
  },
143
- async deposit(amounts, slippage) {
144
- // @ts-ignore
145
- const _amounts = await _depositCheck.call(this, amounts);
146
- // @ts-ignore
147
- return await this._deposit(_amounts, slippage);
366
+ deposit: function (amounts, slippage) {
367
+ return __awaiter(this, void 0, void 0, function () {
368
+ var _amounts;
369
+ return __generator(this, function (_a) {
370
+ switch (_a.label) {
371
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
372
+ case 1:
373
+ _amounts = _a.sent();
374
+ return [4 /*yield*/, this._deposit(_amounts, slippage)];
375
+ case 2:
376
+ // @ts-ignore
377
+ return [2 /*return*/, _a.sent()];
378
+ }
379
+ });
380
+ });
148
381
  },
149
382
  };
150
383
  // @ts-ignore
151
- export const depositPlainMixin = {
384
+ export var depositPlainMixin = {
152
385
  // @ts-ignore
153
- async _deposit(_amounts, slippage, estimateGas = false) {
154
- if (!estimateGas)
155
- await _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address);
156
- // @ts-ignore
157
- const _minMintAmount = await _depositMinAmount.call(this, _amounts, slippage);
158
- const ethIndex = getEthIndex(this.wrappedCoinAddresses);
159
- const value = _amounts[ethIndex] || 0n;
160
- const contract = curve.contracts[this.address].contract;
161
- const gas = await contract.add_liquidity.estimateGas(_amounts, _minMintAmount, { ...curve.constantOptions, value });
162
- if (estimateGas)
163
- return Number(gas);
164
- const gasLimit = mulBy1_3(gas);
165
- return (await contract.add_liquidity(_amounts, _minMintAmount, { ...curve.options, gasLimit, value })).hash;
386
+ _deposit: function (_amounts, slippage, estimateGas) {
387
+ if (estimateGas === void 0) { estimateGas = false; }
388
+ return __awaiter(this, void 0, void 0, function () {
389
+ var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
390
+ return __generator(this, function (_a) {
391
+ switch (_a.label) {
392
+ case 0:
393
+ if (!!estimateGas) return [3 /*break*/, 2];
394
+ return [4 /*yield*/, _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address)];
395
+ case 1:
396
+ _a.sent();
397
+ _a.label = 2;
398
+ case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
399
+ case 3:
400
+ _minMintAmount = _a.sent();
401
+ ethIndex = getEthIndex(this.wrappedCoinAddresses);
402
+ value = _amounts[ethIndex] || curve.parseUnits("0");
403
+ contract = curve.contracts[this.address].contract;
404
+ return [4 /*yield*/, contract.add_liquidity.estimateGas(_amounts, _minMintAmount, __assign(__assign({}, curve.constantOptions), { value: value }))];
405
+ case 4:
406
+ gas = _a.sent();
407
+ if (estimateGas)
408
+ return [2 /*return*/, Number(gas)];
409
+ gasLimit = mulBy1_3(gas);
410
+ return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
411
+ case 5: return [2 /*return*/, (_a.sent()).hash];
412
+ }
413
+ });
414
+ });
166
415
  },
167
- async depositEstimateGas(amounts) {
168
- // @ts-ignore
169
- const _amounts = await _depositCheck.call(this, amounts, true);
170
- // @ts-ignore
171
- return await this._deposit(_amounts, 0.1, true);
416
+ depositEstimateGas: function (amounts) {
417
+ return __awaiter(this, void 0, void 0, function () {
418
+ var _amounts;
419
+ return __generator(this, function (_a) {
420
+ switch (_a.label) {
421
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
422
+ case 1:
423
+ _amounts = _a.sent();
424
+ return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
425
+ case 2:
426
+ // @ts-ignore
427
+ return [2 /*return*/, _a.sent()];
428
+ }
429
+ });
430
+ });
172
431
  },
173
- async deposit(amounts, slippage) {
174
- // @ts-ignore
175
- const _amounts = await _depositCheck.call(this, amounts);
176
- // @ts-ignore
177
- return await this._deposit(_amounts, slippage);
432
+ deposit: function (amounts, slippage) {
433
+ return __awaiter(this, void 0, void 0, function () {
434
+ var _amounts;
435
+ return __generator(this, function (_a) {
436
+ switch (_a.label) {
437
+ case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
438
+ case 1:
439
+ _amounts = _a.sent();
440
+ return [4 /*yield*/, this._deposit(_amounts, slippage)];
441
+ case 2:
442
+ // @ts-ignore
443
+ return [2 /*return*/, _a.sent()];
444
+ }
445
+ });
446
+ });
178
447
  },
179
448
  };