@curvefi/api 2.31.1 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/abis/stable_calc.json +151 -0
  3. package/lib/constants/abis/wbeth/swap.json +1086 -0
  4. package/lib/constants/aliases.js +33 -11
  5. package/lib/constants/coins/arbitrum.js +5 -5
  6. package/lib/constants/coins/aurora.js +5 -5
  7. package/lib/constants/coins/avalanche.js +6 -6
  8. package/lib/constants/coins/celo.js +5 -5
  9. package/lib/constants/coins/ethereum.js +10 -9
  10. package/lib/constants/coins/fantom.js +7 -7
  11. package/lib/constants/coins/kava.js +5 -5
  12. package/lib/constants/coins/moonbeam.js +5 -5
  13. package/lib/constants/coins/optimism.js +5 -5
  14. package/lib/constants/coins/polygon.js +6 -6
  15. package/lib/constants/coins/xdai.js +5 -5
  16. package/lib/constants/pools/arbitrum.js +1 -1
  17. package/lib/constants/pools/aurora.js +1 -1
  18. package/lib/constants/pools/avalanche.js +1 -1
  19. package/lib/constants/pools/celo.js +1 -1
  20. package/lib/constants/pools/ethereum.js +26 -1
  21. package/lib/constants/pools/fantom.js +1 -1
  22. package/lib/constants/pools/kava.js +1 -1
  23. package/lib/constants/pools/moonbeam.js +1 -1
  24. package/lib/constants/pools/optimism.js +1 -1
  25. package/lib/constants/pools/polygon.js +1 -1
  26. package/lib/constants/pools/xdai.js +1 -1
  27. package/lib/constants/utils.d.ts +1 -1
  28. package/lib/constants/utils.js +19 -18
  29. package/lib/curve.js +507 -281
  30. package/lib/external-api.js +132 -45
  31. package/lib/factory/common.js +3 -3
  32. package/lib/factory/constants-crypto.js +21 -21
  33. package/lib/factory/constants.js +32 -31
  34. package/lib/factory/deploy.js +336 -176
  35. package/lib/factory/factory-api.js +256 -180
  36. package/lib/factory/factory-crypto.js +309 -163
  37. package/lib/factory/factory.d.ts +1 -1
  38. package/lib/factory/factory.js +336 -186
  39. package/lib/index.js +98 -44
  40. package/lib/interfaces.d.ts +1 -1
  41. package/lib/pools/PoolTemplate.js +2882 -1511
  42. package/lib/pools/mixins/common.js +106 -22
  43. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  44. package/lib/pools/mixins/depositMixins.js +413 -144
  45. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  46. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  47. package/lib/pools/mixins/swapMixins.js +347 -125
  48. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  49. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  50. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  51. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  52. package/lib/pools/mixins/withdrawMixins.js +385 -122
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  54. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  55. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  56. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  57. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  58. package/lib/pools/poolConstructor.js +25 -5
  59. package/lib/pools/utils.js +488 -298
  60. package/lib/router.js +636 -378
  61. package/lib/utils.js +675 -354
  62. package/package.json +1 -1
@@ -1,158 +1,421 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
1
57
  import { curve } from "../../curve.js";
2
58
  import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
3
59
  // @ts-ignore
4
- async function _withdrawOneCoinCheck(lpTokenAmount, coin, estimateGas = false) {
5
- const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken'];
6
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
7
- throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
8
- }
9
- if (estimateGas && this.zap && !(await hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
10
- throw Error("Token allowance is needed to estimate gas");
11
- }
12
- if (!estimateGas)
13
- await curve.updateFeeData();
14
- // @ts-ignore
15
- const i = this._getCoinIdx(coin);
16
- const _lpTokenAmount = parseUnits(lpTokenAmount);
17
- return [_lpTokenAmount, i];
60
+ function _withdrawOneCoinCheck(lpTokenAmount, coin, estimateGas) {
61
+ if (estimateGas === void 0) { estimateGas = false; }
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var lpTokenBalance, _a, i, _lpTokenAmount;
64
+ return __generator(this, function (_b) {
65
+ switch (_b.label) {
66
+ case 0: return [4 /*yield*/, this.wallet.lpTokenBalances()];
67
+ case 1:
68
+ lpTokenBalance = (_b.sent())['lpToken'];
69
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
70
+ throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
71
+ }
72
+ _a = estimateGas && this.zap;
73
+ if (!_a) return [3 /*break*/, 3];
74
+ return [4 /*yield*/, hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap)];
75
+ case 2:
76
+ _a = !(_b.sent());
77
+ _b.label = 3;
78
+ case 3:
79
+ if (_a) {
80
+ throw Error("Token allowance is needed to estimate gas");
81
+ }
82
+ if (!!estimateGas) return [3 /*break*/, 5];
83
+ return [4 /*yield*/, curve.updateFeeData()];
84
+ case 4:
85
+ _b.sent();
86
+ _b.label = 5;
87
+ case 5:
88
+ i = this._getCoinIdx(coin);
89
+ _lpTokenAmount = parseUnits(lpTokenAmount);
90
+ return [2 /*return*/, [_lpTokenAmount, i]];
91
+ }
92
+ });
93
+ });
18
94
  }
19
- async function _withdrawOneCoinMinAmount(_lpTokenAmount, i, slippage = 0.5) {
20
- // @ts-ignore
21
- const _expectedLpTokenAmount = await this._withdrawOneCoinExpected(_lpTokenAmount, i);
22
- const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
23
- return fromBN(minAmountBN);
95
+ function _withdrawOneCoinMinAmount(_lpTokenAmount, i, slippage) {
96
+ if (slippage === void 0) { slippage = 0.5; }
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var _expectedLpTokenAmount, minAmountBN;
99
+ return __generator(this, function (_a) {
100
+ switch (_a.label) {
101
+ case 0: return [4 /*yield*/, this._withdrawOneCoinExpected(_lpTokenAmount, i)];
102
+ case 1:
103
+ _expectedLpTokenAmount = _a.sent();
104
+ minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
105
+ return [2 /*return*/, fromBN(minAmountBN)];
106
+ }
107
+ });
108
+ });
24
109
  }
25
110
  // @ts-ignore
26
- export const withdrawOneCoinMetaFactoryMixin = {
111
+ export var withdrawOneCoinMetaFactoryMixin = {
27
112
  // @ts-ignore
28
- async _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
29
- if (!estimateGas)
30
- await _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
31
- const _minAmount = await _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
32
- const contract = curve.contracts[this.zap].contract;
33
- const gas = await contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, curve.constantOptions);
34
- if (estimateGas)
35
- return Number(gas);
36
- const gasLimit = mulBy1_3(gas);
37
- return (await contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, { ...curve.options, gasLimit })).hash;
113
+ _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
114
+ if (estimateGas === void 0) { estimateGas = false; }
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ var _minAmount, contract, gas, gasLimit;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ if (!!estimateGas) return [3 /*break*/, 2];
121
+ return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
122
+ case 1:
123
+ _a.sent();
124
+ _a.label = 2;
125
+ case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
126
+ case 3:
127
+ _minAmount = _a.sent();
128
+ contract = curve.contracts[this.zap].contract;
129
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, curve.constantOptions)];
130
+ case 4:
131
+ gas = _a.sent();
132
+ if (estimateGas)
133
+ return [2 /*return*/, Number(gas)];
134
+ gasLimit = mulBy1_3(gas);
135
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
136
+ case 5: return [2 /*return*/, (_a.sent()).hash];
137
+ }
138
+ });
139
+ });
38
140
  },
39
- async withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
40
- // @ts-ignore
41
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
42
- // @ts-ignore
43
- return await this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
141
+ withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
142
+ return __awaiter(this, void 0, void 0, function () {
143
+ var _a, _lpTokenAmount, i;
144
+ return __generator(this, function (_b) {
145
+ switch (_b.label) {
146
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
147
+ case 1:
148
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
149
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
150
+ case 2:
151
+ // @ts-ignore
152
+ return [2 /*return*/, _b.sent()];
153
+ }
154
+ });
155
+ });
44
156
  },
45
- async withdrawOneCoin(lpTokenAmount, coin, slippage) {
46
- // @ts-ignore
47
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
48
- // @ts-ignore
49
- return await this._withdrawOneCoin(_lpTokenAmount, i, slippage);
157
+ withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
158
+ return __awaiter(this, void 0, void 0, function () {
159
+ var _a, _lpTokenAmount, i;
160
+ return __generator(this, function (_b) {
161
+ switch (_b.label) {
162
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
163
+ case 1:
164
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
165
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
166
+ case 2:
167
+ // @ts-ignore
168
+ return [2 /*return*/, _b.sent()];
169
+ }
170
+ });
171
+ });
50
172
  },
51
173
  };
52
174
  // @ts-ignore
53
- export const withdrawOneCoinCryptoMetaFactoryMixin = {
175
+ export var withdrawOneCoinCryptoMetaFactoryMixin = {
54
176
  // @ts-ignore
55
- async _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
56
- if (!estimateGas)
57
- await _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
58
- const _minAmount = await _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
59
- const contract = curve.contracts[this.zap].contract;
60
- const gas = await contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, true, curve.constantOptions);
61
- if (estimateGas)
62
- return Number(gas);
63
- const gasLimit = mulBy1_3(gas);
64
- return (await contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, { ...curve.options, gasLimit })).hash;
177
+ _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
178
+ if (estimateGas === void 0) { estimateGas = false; }
179
+ return __awaiter(this, void 0, void 0, function () {
180
+ var _minAmount, contract, gas, gasLimit;
181
+ return __generator(this, function (_a) {
182
+ switch (_a.label) {
183
+ case 0:
184
+ if (!!estimateGas) return [3 /*break*/, 2];
185
+ return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
186
+ case 1:
187
+ _a.sent();
188
+ _a.label = 2;
189
+ case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
190
+ case 3:
191
+ _minAmount = _a.sent();
192
+ contract = curve.contracts[this.zap].contract;
193
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, true, curve.constantOptions)];
194
+ case 4:
195
+ gas = _a.sent();
196
+ if (estimateGas)
197
+ return [2 /*return*/, Number(gas)];
198
+ gasLimit = mulBy1_3(gas);
199
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
200
+ case 5: return [2 /*return*/, (_a.sent()).hash];
201
+ }
202
+ });
203
+ });
65
204
  },
66
- async withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
67
- // @ts-ignore
68
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
69
- // @ts-ignore
70
- return await this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
205
+ withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
206
+ return __awaiter(this, void 0, void 0, function () {
207
+ var _a, _lpTokenAmount, i;
208
+ return __generator(this, function (_b) {
209
+ switch (_b.label) {
210
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
211
+ case 1:
212
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
213
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
214
+ case 2:
215
+ // @ts-ignore
216
+ return [2 /*return*/, _b.sent()];
217
+ }
218
+ });
219
+ });
71
220
  },
72
- async withdrawOneCoin(lpTokenAmount, coin, slippage) {
73
- // @ts-ignore
74
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
75
- // @ts-ignore
76
- return await this._withdrawOneCoin(_lpTokenAmount, i, slippage);
221
+ withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
222
+ return __awaiter(this, void 0, void 0, function () {
223
+ var _a, _lpTokenAmount, i;
224
+ return __generator(this, function (_b) {
225
+ switch (_b.label) {
226
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
227
+ case 1:
228
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
229
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
230
+ case 2:
231
+ // @ts-ignore
232
+ return [2 /*return*/, _b.sent()];
233
+ }
234
+ });
235
+ });
77
236
  },
78
237
  };
79
238
  // @ts-ignore
80
- export const withdrawOneCoinZapMixin = {
239
+ export var withdrawOneCoinZapMixin = {
81
240
  // @ts-ignore
82
- async _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
83
- if (!estimateGas)
84
- await _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
85
- const _minAmount = await _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
86
- const contract = curve.contracts[this.zap].contract;
87
- const args = [_lpTokenAmount, i, _minAmount];
88
- if (`remove_liquidity_one_coin(uint256,uint256,uint256,bool)` in contract)
89
- args.push(true);
90
- const gas = await contract.remove_liquidity_one_coin.estimateGas(...args, curve.constantOptions);
91
- if (estimateGas)
92
- return Number(gas);
93
- const gasLimit = mulBy1_3(gas);
94
- return (await contract.remove_liquidity_one_coin(...args, { ...curve.options, gasLimit })).hash;
241
+ _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
242
+ if (estimateGas === void 0) { estimateGas = false; }
243
+ return __awaiter(this, void 0, void 0, function () {
244
+ var _minAmount, contract, args, gas, gasLimit;
245
+ var _a;
246
+ return __generator(this, function (_b) {
247
+ switch (_b.label) {
248
+ case 0:
249
+ if (!!estimateGas) return [3 /*break*/, 2];
250
+ return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
251
+ case 1:
252
+ _b.sent();
253
+ _b.label = 2;
254
+ case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
255
+ case 3:
256
+ _minAmount = _b.sent();
257
+ contract = curve.contracts[this.zap].contract;
258
+ args = [_lpTokenAmount, i, _minAmount];
259
+ if ("remove_liquidity_one_coin(uint256,uint256,uint256,bool)" in contract)
260
+ args.push(true);
261
+ return [4 /*yield*/, (_a = contract.remove_liquidity_one_coin).estimateGas.apply(_a, __spreadArray(__spreadArray([], args, false), [curve.constantOptions], false))];
262
+ case 4:
263
+ gas = _b.sent();
264
+ if (estimateGas)
265
+ return [2 /*return*/, Number(gas)];
266
+ gasLimit = mulBy1_3(gas);
267
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
268
+ case 5: return [2 /*return*/, (_b.sent()).hash];
269
+ }
270
+ });
271
+ });
95
272
  },
96
- async withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
97
- // @ts-ignore
98
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
99
- // @ts-ignore
100
- return await this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
273
+ withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
274
+ return __awaiter(this, void 0, void 0, function () {
275
+ var _a, _lpTokenAmount, i;
276
+ return __generator(this, function (_b) {
277
+ switch (_b.label) {
278
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
279
+ case 1:
280
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
281
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
282
+ case 2:
283
+ // @ts-ignore
284
+ return [2 /*return*/, _b.sent()];
285
+ }
286
+ });
287
+ });
101
288
  },
102
- async withdrawOneCoin(lpTokenAmount, coin, slippage) {
103
- // @ts-ignore
104
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
105
- // @ts-ignore
106
- return await this._withdrawOneCoin(_lpTokenAmount, i, slippage);
289
+ withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
290
+ return __awaiter(this, void 0, void 0, function () {
291
+ var _a, _lpTokenAmount, i;
292
+ return __generator(this, function (_b) {
293
+ switch (_b.label) {
294
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
295
+ case 1:
296
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
297
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
298
+ case 2:
299
+ // @ts-ignore
300
+ return [2 /*return*/, _b.sent()];
301
+ }
302
+ });
303
+ });
107
304
  },
108
305
  };
109
306
  // @ts-ignore
110
- export const withdrawOneCoinLendingOrCryptoMixin = {
307
+ export var withdrawOneCoinLendingOrCryptoMixin = {
111
308
  // @ts-ignore
112
- async _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
113
- const _minAmount = await _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
114
- const contract = curve.contracts[this.address].contract;
115
- const gas = await contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, true, curve.constantOptions);
116
- if (estimateGas)
117
- return Number(gas);
118
- const gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * 160n / 100n : mulBy1_3(gas);
119
- return (await contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, true, { ...curve.options, gasLimit })).hash;
309
+ _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
310
+ if (estimateGas === void 0) { estimateGas = false; }
311
+ return __awaiter(this, void 0, void 0, function () {
312
+ var _minAmount, contract, gas, gasLimit;
313
+ return __generator(this, function (_a) {
314
+ switch (_a.label) {
315
+ case 0: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
316
+ case 1:
317
+ _minAmount = _a.sent();
318
+ contract = curve.contracts[this.address].contract;
319
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, true, curve.constantOptions)];
320
+ case 2:
321
+ gas = _a.sent();
322
+ if (estimateGas)
323
+ return [2 /*return*/, Number(gas)];
324
+ gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
325
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
326
+ case 3: return [2 /*return*/, (_a.sent()).hash];
327
+ }
328
+ });
329
+ });
120
330
  },
121
- async withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
122
- // @ts-ignore
123
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
124
- // @ts-ignore
125
- return await this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
331
+ withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
332
+ return __awaiter(this, void 0, void 0, function () {
333
+ var _a, _lpTokenAmount, i;
334
+ return __generator(this, function (_b) {
335
+ switch (_b.label) {
336
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
337
+ case 1:
338
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
339
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
340
+ case 2:
341
+ // @ts-ignore
342
+ return [2 /*return*/, _b.sent()];
343
+ }
344
+ });
345
+ });
126
346
  },
127
- async withdrawOneCoin(lpTokenAmount, coin, slippage) {
128
- // @ts-ignore
129
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
130
- // @ts-ignore
131
- return await this._withdrawOneCoin(_lpTokenAmount, i, slippage);
347
+ withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
348
+ return __awaiter(this, void 0, void 0, function () {
349
+ var _a, _lpTokenAmount, i;
350
+ return __generator(this, function (_b) {
351
+ switch (_b.label) {
352
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
353
+ case 1:
354
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
355
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
356
+ case 2:
357
+ // @ts-ignore
358
+ return [2 /*return*/, _b.sent()];
359
+ }
360
+ });
361
+ });
132
362
  },
133
363
  };
134
364
  // @ts-ignore
135
- export const withdrawOneCoinPlainMixin = {
365
+ export var withdrawOneCoinPlainMixin = {
136
366
  // @ts-ignore
137
- async _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
138
- const _minAmount = await _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
139
- const contract = curve.contracts[this.address].contract;
140
- const gas = await contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions);
141
- if (estimateGas)
142
- return Number(gas);
143
- const gasLimit = mulBy1_3(gas);
144
- return (await contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, { ...curve.options, gasLimit })).hash;
367
+ _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
368
+ if (estimateGas === void 0) { estimateGas = false; }
369
+ return __awaiter(this, void 0, void 0, function () {
370
+ var _minAmount, contract, gas, gasLimit;
371
+ return __generator(this, function (_a) {
372
+ switch (_a.label) {
373
+ case 0: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
374
+ case 1:
375
+ _minAmount = _a.sent();
376
+ contract = curve.contracts[this.address].contract;
377
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions)];
378
+ case 2:
379
+ gas = _a.sent();
380
+ if (estimateGas)
381
+ return [2 /*return*/, Number(gas)];
382
+ gasLimit = mulBy1_3(gas);
383
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
384
+ case 3: return [2 /*return*/, (_a.sent()).hash];
385
+ }
386
+ });
387
+ });
145
388
  },
146
- async withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
147
- // @ts-ignore
148
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
149
- // @ts-ignore
150
- return await this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
389
+ withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
390
+ return __awaiter(this, void 0, void 0, function () {
391
+ var _a, _lpTokenAmount, i;
392
+ return __generator(this, function (_b) {
393
+ switch (_b.label) {
394
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
395
+ case 1:
396
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
397
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
398
+ case 2:
399
+ // @ts-ignore
400
+ return [2 /*return*/, _b.sent()];
401
+ }
402
+ });
403
+ });
151
404
  },
152
- async withdrawOneCoin(lpTokenAmount, coin, slippage) {
153
- // @ts-ignore
154
- const [_lpTokenAmount, i] = await _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
155
- // @ts-ignore
156
- return await this._withdrawOneCoin(_lpTokenAmount, i, slippage);
405
+ withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
406
+ return __awaiter(this, void 0, void 0, function () {
407
+ var _a, _lpTokenAmount, i;
408
+ return __generator(this, function (_b) {
409
+ switch (_b.label) {
410
+ case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
411
+ case 1:
412
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
413
+ return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
414
+ case 2:
415
+ // @ts-ignore
416
+ return [2 /*return*/, _b.sent()];
417
+ }
418
+ });
419
+ });
157
420
  },
158
421
  };
@@ -1,15 +1,69 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import { curve } from "../../curve.js";
2
38
  // @ts-ignore
3
- export const withdrawOneCoinWrappedExpected2argsMixin = {
4
- async _withdrawOneCoinWrappedExpected(_lpTokenAmount, i) {
5
- const contract = curve.contracts[this.address].contract;
6
- return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, curve.constantOptions);
39
+ export var withdrawOneCoinWrappedExpected2argsMixin = {
40
+ _withdrawOneCoinWrappedExpected: function (_lpTokenAmount, i) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var contract;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0:
46
+ contract = curve.contracts[this.address].contract;
47
+ return [4 /*yield*/, contract.calc_withdraw_one_coin(_lpTokenAmount, i, curve.constantOptions)];
48
+ case 1: return [2 /*return*/, _a.sent()];
49
+ }
50
+ });
51
+ });
7
52
  },
8
53
  };
9
54
  // @ts-ignore
10
- export const withdrawOneCoinWrappedExpected3argsMixin = {
11
- async _withdrawOneCoinWrappedExpected(_lpTokenAmount, i) {
12
- const contract = curve.contracts[this.address].contract;
13
- return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, false, curve.constantOptions);
55
+ export var withdrawOneCoinWrappedExpected3argsMixin = {
56
+ _withdrawOneCoinWrappedExpected: function (_lpTokenAmount, i) {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ var contract;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0:
62
+ contract = curve.contracts[this.address].contract;
63
+ return [4 /*yield*/, contract.calc_withdraw_one_coin(_lpTokenAmount, i, false, curve.constantOptions)];
64
+ case 1: return [2 /*return*/, _a.sent()];
65
+ }
66
+ });
67
+ });
14
68
  },
15
69
  };