@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.
- package/lib/boosting.js +385 -135
- package/lib/constants/abis/stable_calc.json +151 -0
- package/lib/constants/abis/wbeth/swap.json +1086 -0
- package/lib/constants/aliases.js +33 -11
- package/lib/constants/coins/arbitrum.js +5 -5
- package/lib/constants/coins/aurora.js +5 -5
- package/lib/constants/coins/avalanche.js +6 -6
- package/lib/constants/coins/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +10 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/kava.js +5 -5
- package/lib/constants/coins/moonbeam.js +5 -5
- package/lib/constants/coins/optimism.js +5 -5
- package/lib/constants/coins/polygon.js +6 -6
- package/lib/constants/coins/xdai.js +5 -5
- package/lib/constants/pools/arbitrum.js +1 -1
- package/lib/constants/pools/aurora.js +1 -1
- package/lib/constants/pools/avalanche.js +1 -1
- package/lib/constants/pools/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +26 -1
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/kava.js +1 -1
- package/lib/constants/pools/moonbeam.js +1 -1
- package/lib/constants/pools/optimism.js +1 -1
- package/lib/constants/pools/polygon.js +1 -1
- package/lib/constants/pools/xdai.js +1 -1
- package/lib/constants/utils.d.ts +1 -1
- package/lib/constants/utils.js +19 -18
- package/lib/curve.js +507 -281
- package/lib/external-api.js +132 -45
- package/lib/factory/common.js +3 -3
- package/lib/factory/constants-crypto.js +21 -21
- package/lib/factory/constants.js +32 -31
- package/lib/factory/deploy.js +336 -176
- package/lib/factory/factory-api.js +256 -180
- package/lib/factory/factory-crypto.js +309 -163
- package/lib/factory/factory.d.ts +1 -1
- package/lib/factory/factory.js +336 -186
- package/lib/index.js +98 -44
- package/lib/interfaces.d.ts +1 -1
- package/lib/pools/PoolTemplate.js +2882 -1511
- package/lib/pools/mixins/common.js +106 -22
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
- package/lib/pools/mixins/depositMixins.js +413 -144
- package/lib/pools/mixins/depositWrappedMixins.js +223 -72
- package/lib/pools/mixins/poolBalancesMixin.js +98 -22
- package/lib/pools/mixins/swapMixins.js +347 -125
- package/lib/pools/mixins/swapWrappedMixins.js +270 -88
- package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
- package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
- package/lib/pools/mixins/withdrawMixins.js +385 -122
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
- package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
- package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
- package/lib/pools/poolConstructor.js +25 -5
- package/lib/pools/utils.js +488 -298
- package/lib/router.js +636 -378
- package/lib/utils.js +675 -354
- package/package.json +1 -1
|
@@ -1,126 +1,345 @@
|
|
|
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
|
+
};
|
|
1
48
|
import { curve } from "../../curve.js";
|
|
2
49
|
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
|
|
3
50
|
// @ts-ignore
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
});
|
|
85
|
+
});
|
|
16
86
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
});
|
|
100
|
+
});
|
|
22
101
|
}
|
|
23
102
|
// @ts-ignore
|
|
24
|
-
export
|
|
103
|
+
export var withdrawImbalanceMetaFactoryMixin = {
|
|
25
104
|
// @ts-ignore
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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*/, Number(gas)];
|
|
126
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
131
|
+
});
|
|
36
132
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
});
|
|
147
|
+
});
|
|
42
148
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
});
|
|
163
|
+
});
|
|
48
164
|
},
|
|
49
165
|
};
|
|
50
166
|
// @ts-ignore
|
|
51
|
-
export
|
|
167
|
+
export var withdrawImbalanceZapMixin = {
|
|
52
168
|
// @ts-ignore
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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*/, Number(gas)];
|
|
190
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
195
|
+
});
|
|
63
196
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
+
});
|
|
211
|
+
});
|
|
69
212
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
});
|
|
227
|
+
});
|
|
75
228
|
},
|
|
76
229
|
};
|
|
77
230
|
// @ts-ignore
|
|
78
|
-
export
|
|
231
|
+
export var withdrawImbalanceLendingMixin = {
|
|
79
232
|
// @ts-ignore
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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*/, Number(gas)];
|
|
248
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(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
|
+
});
|
|
253
|
+
});
|
|
88
254
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
});
|
|
269
|
+
});
|
|
94
270
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
+
});
|
|
285
|
+
});
|
|
100
286
|
},
|
|
101
287
|
};
|
|
102
288
|
// @ts-ignore
|
|
103
|
-
export
|
|
289
|
+
export var withdrawImbalancePlainMixin = {
|
|
104
290
|
// @ts-ignore
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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*/, Number(gas)];
|
|
306
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
311
|
+
});
|
|
113
312
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
+
});
|
|
327
|
+
});
|
|
119
328
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
});
|
|
343
|
+
});
|
|
125
344
|
},
|
|
126
345
|
};
|