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