@curvefi/api 2.62.0 → 2.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/boosting.js +247 -645
  2. package/lib/constants/L2Networks.js +1 -1
  3. package/lib/constants/aliases.js +31 -31
  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 +3 -3
  39. package/lib/constants/utils.js +18 -19
  40. package/lib/constants/volumeNetworks.js +1 -1
  41. package/lib/curve.d.ts +3 -1
  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 +36 -46
  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 +1 -6
  56. package/lib/pools/PoolTemplate.js +1773 -3025
  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 +5 -25
  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 +5 -4
  82. package/lib/utils.js +539 -906
  83. package/package.json +1 -1
@@ -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,328 +7,157 @@ 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
10
  import { curve } from "../../curve.js";
49
11
  import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
50
12
  // @ts-ignore
51
- function _withdrawImbalanceCheck(amounts, estimateGas) {
52
- if (estimateGas === void 0) { estimateGas = false; }
53
- return __awaiter(this, void 0, void 0, function () {
54
- var lpTokenAmount, lpTokenBalance, _a;
55
- var _this = this;
56
- return __generator(this, function (_b) {
57
- switch (_b.label) {
58
- case 0: return [4 /*yield*/, this.withdrawImbalanceExpected(amounts)];
59
- case 1:
60
- lpTokenAmount = _b.sent();
61
- return [4 /*yield*/, this.wallet.lpTokenBalances()];
62
- case 2:
63
- lpTokenBalance = (_b.sent())['lpToken'];
64
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
65
- throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
66
- }
67
- _a = estimateGas && this.zap;
68
- if (!_a) return [3 /*break*/, 4];
69
- return [4 /*yield*/, hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap)];
70
- case 3:
71
- _a = !(_b.sent());
72
- _b.label = 4;
73
- case 4:
74
- if (_a) {
75
- throw Error("Token allowance is needed to estimate gas");
76
- }
77
- if (!!estimateGas) return [3 /*break*/, 6];
78
- return [4 /*yield*/, curve.updateFeeData()];
79
- case 5:
80
- _b.sent();
81
- _b.label = 6;
82
- case 6: return [2 /*return*/, amounts.map(function (amount, i) { return parseUnits(amount, _this.underlyingDecimals[i]); })];
83
- }
84
- });
13
+ function _withdrawImbalanceCheck(amounts, estimateGas = false) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const lpTokenAmount = yield this.withdrawImbalanceExpected(amounts);
16
+ const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
17
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
18
+ throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
19
+ }
20
+ if (estimateGas && this.zap && !(yield hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
21
+ throw Error("Token allowance is needed to estimate gas");
22
+ }
23
+ if (!estimateGas)
24
+ yield curve.updateFeeData();
25
+ return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
85
26
  });
86
27
  }
87
- function _withdrawImbalanceMaxBurnAmount(_amounts, slippage) {
88
- if (slippage === void 0) { slippage = 0.5; }
89
- return __awaiter(this, void 0, void 0, function () {
90
- var _expectedLpTokenAmount, maxBurnAmountBN;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0: return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false)];
94
- case 1:
95
- _expectedLpTokenAmount = _a.sent();
96
- maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
97
- return [2 /*return*/, fromBN(maxBurnAmountBN)];
98
- }
99
- });
28
+ function _withdrawImbalanceMaxBurnAmount(_amounts, slippage = 0.5) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ // @ts-ignore
31
+ const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts, false);
32
+ const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
33
+ return fromBN(maxBurnAmountBN);
100
34
  });
101
35
  }
102
36
  // @ts-ignore
103
- export var withdrawImbalanceMetaFactoryMixin = {
37
+ export const withdrawImbalanceMetaFactoryMixin = {
104
38
  // @ts-ignore
105
- _withdrawImbalance: function (_amounts, slippage, estimateGas) {
106
- if (estimateGas === void 0) { estimateGas = false; }
107
- return __awaiter(this, void 0, void 0, function () {
108
- var _maxBurnAmount, contract, gas, gasLimit;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
112
- case 1:
113
- _maxBurnAmount = _a.sent();
114
- if (!!estimateGas) return [3 /*break*/, 3];
115
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap)];
116
- case 2:
117
- _a.sent();
118
- _a.label = 3;
119
- case 3:
120
- contract = curve.contracts[this.zap].contract;
121
- return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(this.address, _amounts, _maxBurnAmount, curve.constantOptions)];
122
- case 4:
123
- gas = _a.sent();
124
- if (estimateGas)
125
- return [2 /*return*/, smartNumber(gas)];
126
- gasLimit = mulBy1_3(DIGas(gas));
127
- return [4 /*yield*/, contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
128
- case 5: return [2 /*return*/, (_a.sent()).hash];
129
- }
130
- });
39
+ _withdrawImbalance(_amounts, slippage, estimateGas = false) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
42
+ if (!estimateGas)
43
+ yield _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap);
44
+ const contract = curve.contracts[this.zap].contract;
45
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(this.address, _amounts, _maxBurnAmount, curve.constantOptions);
46
+ if (estimateGas)
47
+ return smartNumber(gas);
48
+ const gasLimit = mulBy1_3(DIGas(gas));
49
+ return (yield contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
131
50
  });
132
51
  },
133
- withdrawImbalanceEstimateGas: function (amounts) {
134
- return __awaiter(this, void 0, void 0, function () {
135
- var _amounts;
136
- return __generator(this, function (_a) {
137
- switch (_a.label) {
138
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
139
- case 1:
140
- _amounts = _a.sent();
141
- return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
142
- case 2:
143
- // @ts-ignore
144
- return [2 /*return*/, _a.sent()];
145
- }
146
- });
52
+ withdrawImbalanceEstimateGas(amounts) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ // @ts-ignore
55
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
56
+ // @ts-ignore
57
+ return yield this._withdrawImbalance(_amounts, 0.1, true);
147
58
  });
148
59
  },
149
- withdrawImbalance: function (amounts, slippage) {
150
- return __awaiter(this, void 0, void 0, function () {
151
- var _amounts;
152
- return __generator(this, function (_a) {
153
- switch (_a.label) {
154
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
155
- case 1:
156
- _amounts = _a.sent();
157
- return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
158
- case 2:
159
- // @ts-ignore
160
- return [2 /*return*/, _a.sent()];
161
- }
162
- });
60
+ withdrawImbalance(amounts, slippage) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ // @ts-ignore
63
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
64
+ // @ts-ignore
65
+ return yield this._withdrawImbalance(_amounts, slippage);
163
66
  });
164
67
  },
165
68
  };
166
69
  // @ts-ignore
167
- export var withdrawImbalanceZapMixin = {
70
+ export const withdrawImbalanceZapMixin = {
168
71
  // @ts-ignore
169
- _withdrawImbalance: function (_amounts, slippage, estimateGas) {
170
- if (estimateGas === void 0) { estimateGas = false; }
171
- return __awaiter(this, void 0, void 0, function () {
172
- var _maxBurnAmount, contract, gas, gasLimit;
173
- return __generator(this, function (_a) {
174
- switch (_a.label) {
175
- case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
176
- case 1:
177
- _maxBurnAmount = _a.sent();
178
- if (!!estimateGas) return [3 /*break*/, 3];
179
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap)];
180
- case 2:
181
- _a.sent();
182
- _a.label = 3;
183
- case 3:
184
- contract = curve.contracts[this.zap].contract;
185
- return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions)];
186
- case 4:
187
- gas = _a.sent();
188
- if (estimateGas)
189
- return [2 /*return*/, smartNumber(gas)];
190
- gasLimit = mulBy1_3(DIGas(gas));
191
- return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
192
- case 5: return [2 /*return*/, (_a.sent()).hash];
193
- }
194
- });
72
+ _withdrawImbalance(_amounts, slippage, estimateGas = false) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
75
+ if (!estimateGas)
76
+ yield _ensureAllowance([this.lpToken], [_maxBurnAmount], this.zap);
77
+ const contract = curve.contracts[this.zap].contract;
78
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
79
+ if (estimateGas)
80
+ return smartNumber(gas);
81
+ const gasLimit = mulBy1_3(DIGas(gas));
82
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
195
83
  });
196
84
  },
197
- withdrawImbalanceEstimateGas: function (amounts) {
198
- return __awaiter(this, void 0, void 0, function () {
199
- var _amounts;
200
- return __generator(this, function (_a) {
201
- switch (_a.label) {
202
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
203
- case 1:
204
- _amounts = _a.sent();
205
- return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
206
- case 2:
207
- // @ts-ignore
208
- return [2 /*return*/, _a.sent()];
209
- }
210
- });
85
+ withdrawImbalanceEstimateGas(amounts) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ // @ts-ignore
88
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
89
+ // @ts-ignore
90
+ return yield this._withdrawImbalance(_amounts, 0.1, true);
211
91
  });
212
92
  },
213
- withdrawImbalance: function (amounts, slippage) {
214
- return __awaiter(this, void 0, void 0, function () {
215
- var _amounts;
216
- return __generator(this, function (_a) {
217
- switch (_a.label) {
218
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
219
- case 1:
220
- _amounts = _a.sent();
221
- return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
222
- case 2:
223
- // @ts-ignore
224
- return [2 /*return*/, _a.sent()];
225
- }
226
- });
93
+ withdrawImbalance(amounts, slippage) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ // @ts-ignore
96
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
97
+ // @ts-ignore
98
+ return yield this._withdrawImbalance(_amounts, slippage);
227
99
  });
228
100
  },
229
101
  };
230
102
  // @ts-ignore
231
- export var withdrawImbalanceLendingMixin = {
103
+ export const withdrawImbalanceLendingMixin = {
232
104
  // @ts-ignore
233
- _withdrawImbalance: function (_amounts, slippage, estimateGas) {
234
- if (estimateGas === void 0) { estimateGas = false; }
235
- return __awaiter(this, void 0, void 0, function () {
236
- var _maxBurnAmount, contract, gas, gasLimit;
237
- return __generator(this, function (_a) {
238
- switch (_a.label) {
239
- case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
240
- case 1:
241
- _maxBurnAmount = _a.sent();
242
- contract = curve.contracts[this.address].contract;
243
- return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, true, curve.constantOptions)];
244
- case 2:
245
- gas = _a.sent();
246
- if (estimateGas)
247
- return [2 /*return*/, smartNumber(gas)];
248
- gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
249
- return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
250
- case 3: return [2 /*return*/, (_a.sent()).hash];
251
- }
252
- });
105
+ _withdrawImbalance(_amounts, slippage, estimateGas = false) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
108
+ const contract = curve.contracts[this.address].contract;
109
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, true, curve.constantOptions);
110
+ if (estimateGas)
111
+ return smartNumber(gas);
112
+ const gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
113
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
253
114
  });
254
115
  },
255
- withdrawImbalanceEstimateGas: function (amounts) {
256
- return __awaiter(this, void 0, void 0, function () {
257
- var _amounts;
258
- return __generator(this, function (_a) {
259
- switch (_a.label) {
260
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
261
- case 1:
262
- _amounts = _a.sent();
263
- return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
264
- case 2:
265
- // @ts-ignore
266
- return [2 /*return*/, _a.sent()];
267
- }
268
- });
116
+ withdrawImbalanceEstimateGas(amounts) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ // @ts-ignore
119
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
120
+ // @ts-ignore
121
+ return yield this._withdrawImbalance(_amounts, 0.1, true);
269
122
  });
270
123
  },
271
- withdrawImbalance: function (amounts, slippage) {
272
- return __awaiter(this, void 0, void 0, function () {
273
- var _amounts;
274
- return __generator(this, function (_a) {
275
- switch (_a.label) {
276
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
277
- case 1:
278
- _amounts = _a.sent();
279
- return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
280
- case 2:
281
- // @ts-ignore
282
- return [2 /*return*/, _a.sent()];
283
- }
284
- });
124
+ withdrawImbalance(amounts, slippage) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ // @ts-ignore
127
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
128
+ // @ts-ignore
129
+ return yield this._withdrawImbalance(_amounts, slippage);
285
130
  });
286
131
  },
287
132
  };
288
133
  // @ts-ignore
289
- export var withdrawImbalancePlainMixin = {
134
+ export const withdrawImbalancePlainMixin = {
290
135
  // @ts-ignore
291
- _withdrawImbalance: function (_amounts, slippage, estimateGas) {
292
- if (estimateGas === void 0) { estimateGas = false; }
293
- return __awaiter(this, void 0, void 0, function () {
294
- var _maxBurnAmount, contract, gas, gasLimit;
295
- return __generator(this, function (_a) {
296
- switch (_a.label) {
297
- case 0: return [4 /*yield*/, _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage)];
298
- case 1:
299
- _maxBurnAmount = _a.sent();
300
- contract = curve.contracts[this.address].contract;
301
- return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions)];
302
- case 2:
303
- gas = _a.sent();
304
- if (estimateGas)
305
- return [2 /*return*/, smartNumber(gas)];
306
- gasLimit = mulBy1_3(DIGas(gas));
307
- return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
308
- case 3: return [2 /*return*/, (_a.sent()).hash];
309
- }
310
- });
136
+ _withdrawImbalance(_amounts, slippage, estimateGas = false) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ const _maxBurnAmount = yield _withdrawImbalanceMaxBurnAmount.call(this, _amounts, slippage);
139
+ const contract = curve.contracts[this.address].contract;
140
+ const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
141
+ if (estimateGas)
142
+ return smartNumber(gas);
143
+ const gasLimit = mulBy1_3(DIGas(gas));
144
+ return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
311
145
  });
312
146
  },
313
- withdrawImbalanceEstimateGas: function (amounts) {
314
- return __awaiter(this, void 0, void 0, function () {
315
- var _amounts;
316
- return __generator(this, function (_a) {
317
- switch (_a.label) {
318
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts, true)];
319
- case 1:
320
- _amounts = _a.sent();
321
- return [4 /*yield*/, this._withdrawImbalance(_amounts, 0.1, true)];
322
- case 2:
323
- // @ts-ignore
324
- return [2 /*return*/, _a.sent()];
325
- }
326
- });
147
+ withdrawImbalanceEstimateGas(amounts) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ // @ts-ignore
150
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts, true);
151
+ // @ts-ignore
152
+ return yield this._withdrawImbalance(_amounts, 0.1, true);
327
153
  });
328
154
  },
329
- withdrawImbalance: function (amounts, slippage) {
330
- return __awaiter(this, void 0, void 0, function () {
331
- var _amounts;
332
- return __generator(this, function (_a) {
333
- switch (_a.label) {
334
- case 0: return [4 /*yield*/, _withdrawImbalanceCheck.call(this, amounts)];
335
- case 1:
336
- _amounts = _a.sent();
337
- return [4 /*yield*/, this._withdrawImbalance(_amounts, slippage)];
338
- case 2:
339
- // @ts-ignore
340
- return [2 /*return*/, _a.sent()];
341
- }
342
- });
155
+ withdrawImbalance(amounts, slippage) {
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ // @ts-ignore
158
+ const _amounts = yield _withdrawImbalanceCheck.call(this, amounts);
159
+ // @ts-ignore
160
+ return yield this._withdrawImbalance(_amounts, slippage);
343
161
  });
344
162
  },
345
163
  };