@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,431 +7,216 @@ 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, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
59
12
  // @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]); })];
13
+ function _depositCheck(amounts, estimateGas = false) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ if (amounts.length !== this.underlyingCoinAddresses.length) {
16
+ throw Error(`${this.name} pool has ${this.underlyingCoinAddresses.length} coins (amounts provided for ${amounts.length})`);
17
+ }
18
+ const balances = Object.values(yield this.wallet.underlyingCoinBalances());
19
+ for (let i = 0; i < balances.length; i++) {
20
+ if (Number(balances[i]) < Number(amounts[i])) {
21
+ throw Error(`Not enough ${this.underlyingCoins[i]}. Actual: ${balances[i]}, required: ${amounts[i]}`);
96
22
  }
97
- });
23
+ }
24
+ if (estimateGas && !(yield hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, this.zap || this.address))) {
25
+ throw Error("Token allowance is needed to estimate gas");
26
+ }
27
+ if (!estimateGas)
28
+ yield curve.updateFeeData();
29
+ return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
98
30
  });
99
31
  }
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
- });
32
+ function _depositMinAmount(_amounts, slippage = 0.5) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ // @ts-ignore
35
+ const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts);
36
+ const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
37
+ return fromBN(minAmountBN);
113
38
  });
114
39
  }
115
40
  // @ts-ignore
116
- export var depositMetaFactoryMixin = {
41
+ export const depositMetaFactoryMixin = {
117
42
  // @ts-ignore
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*/, smartNumber(gas)];
141
- gasLimit = mulBy1_3(DIGas(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
- });
43
+ _deposit(_amounts, slippage, estimateGas = false) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ if (!estimateGas)
46
+ yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
47
+ // @ts-ignore
48
+ const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
49
+ const ethIndex = getEthIndex(this.underlyingCoinAddresses);
50
+ const value = _amounts[ethIndex] || curve.parseUnits("0");
51
+ const contract = curve.contracts[this.zap].contract;
52
+ const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
53
+ if (estimateGas)
54
+ return smartNumber(gas);
55
+ const gasLimit = mulBy1_3(DIGas(gas));
56
+ return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
146
57
  });
147
58
  },
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
- });
59
+ depositEstimateGas(amounts) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ // @ts-ignore
62
+ const _amounts = yield _depositCheck.call(this, amounts, true);
63
+ // @ts-ignore
64
+ return yield this._deposit(_amounts, 0.1, true);
162
65
  });
163
66
  },
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
- });
67
+ deposit(amounts, slippage) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ // @ts-ignore
70
+ const _amounts = yield _depositCheck.call(this, amounts);
71
+ // @ts-ignore
72
+ return yield this._deposit(_amounts, slippage);
178
73
  });
179
74
  },
180
75
  };
181
76
  // @ts-ignore
182
- export var depositCryptoMetaFactoryMixin = {
77
+ export const depositCryptoMetaFactoryMixin = {
183
78
  // @ts-ignore
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*/, smartNumber(gas)];
207
- gasLimit = mulBy1_3(DIGas(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
- });
79
+ _deposit(_amounts, slippage, estimateGas = false) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ if (!estimateGas)
82
+ yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
83
+ // @ts-ignore
84
+ const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
85
+ const ethIndex = getEthIndex(this.underlyingCoinAddresses);
86
+ const value = _amounts[ethIndex] || curve.parseUnits("0");
87
+ const contract = curve.contracts[this.zap].contract;
88
+ const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.constantOptions), { value }));
89
+ if (estimateGas)
90
+ return smartNumber(gas);
91
+ const gasLimit = mulBy1_3(DIGas(gas));
92
+ return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
212
93
  });
213
94
  },
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
- });
95
+ depositEstimateGas(amounts) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ // @ts-ignore
98
+ const _amounts = yield _depositCheck.call(this, amounts, true);
99
+ // @ts-ignore
100
+ return yield this._deposit(_amounts, 0.1, true);
228
101
  });
229
102
  },
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
- });
103
+ deposit(amounts, slippage) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ // @ts-ignore
106
+ const _amounts = yield _depositCheck.call(this, amounts);
107
+ // @ts-ignore
108
+ return yield this._deposit(_amounts, slippage);
244
109
  });
245
110
  },
246
111
  };
247
112
  // @ts-ignore
248
- export var depositZapMixin = {
113
+ export const depositZapMixin = {
249
114
  // @ts-ignore
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*/, smartNumber(gas)];
277
- gasLimit = mulBy1_3(DIGas(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
- });
115
+ _deposit(_amounts, slippage, estimateGas = false) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ if (!estimateGas)
118
+ yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
119
+ // @ts-ignore
120
+ const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
121
+ const ethIndex = getEthIndex(this.underlyingCoinAddresses);
122
+ const value = _amounts[ethIndex] || curve.parseUnits("0");
123
+ const contract = curve.contracts[this.zap].contract;
124
+ const args = [_amounts, _minMintAmount];
125
+ if (`add_liquidity(uint256[${this.underlyingCoinAddresses.length}],uint256,bool)` in contract)
126
+ args.push(true);
127
+ const gas = yield contract.add_liquidity.estimateGas(...args, Object.assign(Object.assign({}, curve.constantOptions), { value }));
128
+ if (estimateGas)
129
+ return smartNumber(gas);
130
+ const gasLimit = mulBy1_3(DIGas(gas));
131
+ return (yield contract.add_liquidity(...args, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
282
132
  });
283
133
  },
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
- });
134
+ depositEstimateGas(amounts) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ // @ts-ignore
137
+ const _amounts = yield _depositCheck.call(this, amounts, true);
138
+ // @ts-ignore
139
+ return yield this._deposit(_amounts, 0.1, true);
298
140
  });
299
141
  },
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
- });
142
+ deposit(amounts, slippage) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ // @ts-ignore
145
+ const _amounts = yield _depositCheck.call(this, amounts);
146
+ // @ts-ignore
147
+ return yield this._deposit(_amounts, slippage);
314
148
  });
315
149
  },
316
150
  };
317
151
  // @ts-ignore
318
- export var depositLendingOrCryptoMixin = {
152
+ export const depositLendingOrCryptoMixin = {
319
153
  // @ts-ignore
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*/, smartNumber(gas)];
343
- gasLimit = mulBy1_3(DIGas(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
- });
154
+ _deposit(_amounts, slippage, estimateGas = false) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ if (!estimateGas)
157
+ yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.address);
158
+ // @ts-ignore
159
+ const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
160
+ const ethIndex = getEthIndex(this.underlyingCoinAddresses);
161
+ const value = _amounts[ethIndex] || curve.parseUnits("0");
162
+ const contract = curve.contracts[this.address].contract;
163
+ const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.constantOptions), { value }));
164
+ if (estimateGas)
165
+ return smartNumber(gas);
166
+ const gasLimit = mulBy1_3(DIGas(gas));
167
+ return (yield contract.add_liquidity(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
348
168
  });
349
169
  },
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
- });
170
+ depositEstimateGas(amounts) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ // @ts-ignore
173
+ const _amounts = yield _depositCheck.call(this, amounts, true);
174
+ // @ts-ignore
175
+ return yield this._deposit(_amounts, 0.1, true);
364
176
  });
365
177
  },
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
- });
178
+ deposit(amounts, slippage) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ // @ts-ignore
181
+ const _amounts = yield _depositCheck.call(this, amounts);
182
+ // @ts-ignore
183
+ return yield this._deposit(_amounts, slippage);
380
184
  });
381
185
  },
382
186
  };
383
187
  // @ts-ignore
384
- export var depositPlainMixin = {
188
+ export const depositPlainMixin = {
385
189
  // @ts-ignore
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*/, smartNumber(gas)];
409
- gasLimit = mulBy1_3(DIGas(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
- });
190
+ _deposit(_amounts, slippage, estimateGas = false) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ if (!estimateGas)
193
+ yield _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address);
194
+ // @ts-ignore
195
+ const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
196
+ const ethIndex = getEthIndex(this.wrappedCoinAddresses);
197
+ const value = _amounts[ethIndex] || curve.parseUnits("0");
198
+ const contract = curve.contracts[this.address].contract;
199
+ const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
200
+ if (estimateGas)
201
+ return smartNumber(gas);
202
+ const gasLimit = mulBy1_3(DIGas(gas));
203
+ return (yield contract.add_liquidity(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
414
204
  });
415
205
  },
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
- });
206
+ depositEstimateGas(amounts) {
207
+ return __awaiter(this, void 0, void 0, function* () {
208
+ // @ts-ignore
209
+ const _amounts = yield _depositCheck.call(this, amounts, true);
210
+ // @ts-ignore
211
+ return yield this._deposit(_amounts, 0.1, true);
430
212
  });
431
213
  },
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
- });
214
+ deposit(amounts, slippage) {
215
+ return __awaiter(this, void 0, void 0, function* () {
216
+ // @ts-ignore
217
+ const _amounts = yield _depositCheck.call(this, amounts);
218
+ // @ts-ignore
219
+ return yield this._deposit(_amounts, slippage);
446
220
  });
447
221
  },
448
222
  };