@curvefi/api 2.32.0 → 2.33.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.
- package/lib/boosting.js +385 -135
- package/lib/constants/aliases.js +22 -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 +1 -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.js +19 -18
- package/lib/curve.js +506 -282
- 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 +5 -0
- package/lib/pools/PoolTemplate.js +2879 -1468
- 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 -299
- package/lib/router.js +675 -212
- package/lib/utils.js +675 -354
- package/package.json +1 -2
|
@@ -1,157 +1,420 @@
|
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
60
|
+
function _withdrawCheck(lpTokenAmount, estimateGas) {
|
|
61
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var lpTokenBalance, _b;
|
|
64
|
+
return __generator(this, function (_c) {
|
|
65
|
+
switch (_c.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, this.wallet.lpTokenBalances()];
|
|
67
|
+
case 1:
|
|
68
|
+
lpTokenBalance = (_c.sent())['lpToken'];
|
|
69
|
+
if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
|
|
70
|
+
throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
|
|
71
|
+
}
|
|
72
|
+
_b = estimateGas && this.zap;
|
|
73
|
+
if (!_b) return [3 /*break*/, 3];
|
|
74
|
+
return [4 /*yield*/, hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap)];
|
|
75
|
+
case 2:
|
|
76
|
+
_b = !(_c.sent());
|
|
77
|
+
_c.label = 3;
|
|
78
|
+
case 3:
|
|
79
|
+
if (_b) {
|
|
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
|
+
_c.sent();
|
|
86
|
+
_c.label = 5;
|
|
87
|
+
case 5: return [2 /*return*/, parseUnits(lpTokenAmount)];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
15
91
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
92
|
+
function _withdrawMinAmounts(_lpTokenAmount, slippage) {
|
|
93
|
+
if (slippage === void 0) { slippage = 0.5; }
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
var expectedAmounts, _expectedAmounts, minRecvAmountsBN;
|
|
96
|
+
var _this = this;
|
|
97
|
+
return __generator(this, function (_b) {
|
|
98
|
+
switch (_b.label) {
|
|
99
|
+
case 0: return [4 /*yield*/, this.withdrawExpected(curve.formatUnits(_lpTokenAmount))];
|
|
100
|
+
case 1:
|
|
101
|
+
expectedAmounts = _b.sent();
|
|
102
|
+
_expectedAmounts = expectedAmounts.map(function (a, i) { return curve.parseUnits(a, _this.underlyingDecimals[i]); });
|
|
103
|
+
minRecvAmountsBN = _expectedAmounts.map(function (_a, i) { return toBN(_a, _this.underlyingDecimals[i]).times(100 - slippage).div(100); });
|
|
104
|
+
return [2 /*return*/, minRecvAmountsBN.map(function (a, i) { return fromBN(a, _this.underlyingDecimals[i]); })];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
21
108
|
}
|
|
22
109
|
// @ts-ignore
|
|
23
|
-
export
|
|
110
|
+
export var withdrawMetaFactoryMixin = {
|
|
24
111
|
// @ts-ignore
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
112
|
+
_withdraw: function (_lpTokenAmount, slippage, estimateGas) {
|
|
113
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
var _minAmounts, contract, gas, gasLimit;
|
|
116
|
+
return __generator(this, function (_b) {
|
|
117
|
+
switch (_b.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
120
|
+
return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
|
|
121
|
+
case 1:
|
|
122
|
+
_b.sent();
|
|
123
|
+
_b.label = 2;
|
|
124
|
+
case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
|
|
125
|
+
case 3:
|
|
126
|
+
_minAmounts = _b.sent();
|
|
127
|
+
contract = curve.contracts[this.zap].contract;
|
|
128
|
+
return [4 /*yield*/, contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, curve.constantOptions)];
|
|
129
|
+
case 4:
|
|
130
|
+
gas = _b.sent();
|
|
131
|
+
if (estimateGas)
|
|
132
|
+
return [2 /*return*/, Number(gas)];
|
|
133
|
+
gasLimit = mulBy1_3(gas);
|
|
134
|
+
return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
135
|
+
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
35
139
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
140
|
+
withdrawEstimateGas: function (lpTokenAmount) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
var _lpTokenAmount;
|
|
143
|
+
return __generator(this, function (_b) {
|
|
144
|
+
switch (_b.label) {
|
|
145
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
|
|
146
|
+
case 1:
|
|
147
|
+
_lpTokenAmount = _b.sent();
|
|
148
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
|
|
149
|
+
case 2:
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
return [2 /*return*/, _b.sent()];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
41
155
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
156
|
+
withdraw: function (lpTokenAmount, slippage) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var _lpTokenAmount;
|
|
159
|
+
return __generator(this, function (_b) {
|
|
160
|
+
switch (_b.label) {
|
|
161
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
|
|
162
|
+
case 1:
|
|
163
|
+
_lpTokenAmount = _b.sent();
|
|
164
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
|
|
165
|
+
case 2:
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
return [2 /*return*/, _b.sent()];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
47
171
|
},
|
|
48
172
|
};
|
|
49
173
|
// @ts-ignore
|
|
50
|
-
export
|
|
174
|
+
export var withdrawCryptoMetaFactoryMixin = {
|
|
51
175
|
// @ts-ignore
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
176
|
+
_withdraw: function (_lpTokenAmount, slippage, estimateGas) {
|
|
177
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
178
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
179
|
+
var _minAmounts, contract, gas, gasLimit;
|
|
180
|
+
return __generator(this, function (_b) {
|
|
181
|
+
switch (_b.label) {
|
|
182
|
+
case 0:
|
|
183
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
184
|
+
return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
|
|
185
|
+
case 1:
|
|
186
|
+
_b.sent();
|
|
187
|
+
_b.label = 2;
|
|
188
|
+
case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
|
|
189
|
+
case 3:
|
|
190
|
+
_minAmounts = _b.sent();
|
|
191
|
+
contract = curve.contracts[this.zap].contract;
|
|
192
|
+
return [4 /*yield*/, contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, curve.constantOptions)];
|
|
193
|
+
case 4:
|
|
194
|
+
gas = _b.sent();
|
|
195
|
+
if (estimateGas)
|
|
196
|
+
return [2 /*return*/, Number(gas)];
|
|
197
|
+
gasLimit = mulBy1_3(gas);
|
|
198
|
+
return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
199
|
+
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
62
203
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
204
|
+
withdrawEstimateGas: function (lpTokenAmount) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
var _lpTokenAmount;
|
|
207
|
+
return __generator(this, function (_b) {
|
|
208
|
+
switch (_b.label) {
|
|
209
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
|
|
210
|
+
case 1:
|
|
211
|
+
_lpTokenAmount = _b.sent();
|
|
212
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
|
|
213
|
+
case 2:
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
return [2 /*return*/, _b.sent()];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
68
219
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
220
|
+
withdraw: function (lpTokenAmount, slippage) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
+
var _lpTokenAmount;
|
|
223
|
+
return __generator(this, function (_b) {
|
|
224
|
+
switch (_b.label) {
|
|
225
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
|
|
226
|
+
case 1:
|
|
227
|
+
_lpTokenAmount = _b.sent();
|
|
228
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
|
|
229
|
+
case 2:
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
return [2 /*return*/, _b.sent()];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
74
235
|
},
|
|
75
236
|
};
|
|
76
237
|
// @ts-ignore
|
|
77
|
-
export
|
|
238
|
+
export var withdrawZapMixin = {
|
|
78
239
|
// @ts-ignore
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
240
|
+
_withdraw: function (_lpTokenAmount, slippage, estimateGas) {
|
|
241
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
242
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
+
var _minAmounts, contract, args, gas, gasLimit;
|
|
244
|
+
var _b;
|
|
245
|
+
return __generator(this, function (_c) {
|
|
246
|
+
switch (_c.label) {
|
|
247
|
+
case 0:
|
|
248
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
249
|
+
return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
|
|
250
|
+
case 1:
|
|
251
|
+
_c.sent();
|
|
252
|
+
_c.label = 2;
|
|
253
|
+
case 2: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
|
|
254
|
+
case 3:
|
|
255
|
+
_minAmounts = _c.sent();
|
|
256
|
+
contract = curve.contracts[this.zap].contract;
|
|
257
|
+
args = [_lpTokenAmount, _minAmounts];
|
|
258
|
+
if ("remove_liquidity(uint256,uint256[".concat(this.underlyingCoinAddresses.length, "],bool)") in contract)
|
|
259
|
+
args.push(true);
|
|
260
|
+
return [4 /*yield*/, (_b = contract.remove_liquidity).estimateGas.apply(_b, __spreadArray(__spreadArray([], args, false), [curve.constantOptions], false))];
|
|
261
|
+
case 4:
|
|
262
|
+
gas = _c.sent();
|
|
263
|
+
if (estimateGas)
|
|
264
|
+
return [2 /*return*/, Number(gas)];
|
|
265
|
+
gasLimit = mulBy1_3(gas);
|
|
266
|
+
return [4 /*yield*/, contract.remove_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
|
|
267
|
+
case 5: return [2 /*return*/, (_c.sent()).hash];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
93
271
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
272
|
+
withdrawEstimateGas: function (lpTokenAmount) {
|
|
273
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
274
|
+
var _lpTokenAmount;
|
|
275
|
+
return __generator(this, function (_b) {
|
|
276
|
+
switch (_b.label) {
|
|
277
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
|
|
278
|
+
case 1:
|
|
279
|
+
_lpTokenAmount = _b.sent();
|
|
280
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
|
|
281
|
+
case 2:
|
|
282
|
+
// @ts-ignore
|
|
283
|
+
return [2 /*return*/, _b.sent()];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
99
287
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
288
|
+
withdraw: function (lpTokenAmount, slippage) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
+
var _lpTokenAmount;
|
|
291
|
+
return __generator(this, function (_b) {
|
|
292
|
+
switch (_b.label) {
|
|
293
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
|
|
294
|
+
case 1:
|
|
295
|
+
_lpTokenAmount = _b.sent();
|
|
296
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
|
|
297
|
+
case 2:
|
|
298
|
+
// @ts-ignore
|
|
299
|
+
return [2 /*return*/, _b.sent()];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
105
303
|
},
|
|
106
304
|
};
|
|
107
305
|
// @ts-ignore
|
|
108
|
-
export
|
|
306
|
+
export var withdrawLendingOrCryptoMixin = {
|
|
109
307
|
// @ts-ignore
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
308
|
+
_withdraw: function (_lpTokenAmount, slippage, estimateGas) {
|
|
309
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
310
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
+
var _minAmounts, contract, gas, gasLimit;
|
|
312
|
+
return __generator(this, function (_b) {
|
|
313
|
+
switch (_b.label) {
|
|
314
|
+
case 0: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
|
|
315
|
+
case 1:
|
|
316
|
+
_minAmounts = _b.sent();
|
|
317
|
+
contract = curve.contracts[this.address].contract;
|
|
318
|
+
return [4 /*yield*/, contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions)];
|
|
319
|
+
case 2:
|
|
320
|
+
gas = _b.sent();
|
|
321
|
+
if (estimateGas)
|
|
322
|
+
return [2 /*return*/, Number(gas)];
|
|
323
|
+
gasLimit = mulBy1_3(gas);
|
|
324
|
+
return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
325
|
+
case 3: return [2 /*return*/, (_b.sent()).hash];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
});
|
|
118
329
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
330
|
+
withdrawEstimateGas: function (lpTokenAmount) {
|
|
331
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
332
|
+
var _lpTokenAmount;
|
|
333
|
+
return __generator(this, function (_b) {
|
|
334
|
+
switch (_b.label) {
|
|
335
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
|
|
336
|
+
case 1:
|
|
337
|
+
_lpTokenAmount = _b.sent();
|
|
338
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
|
|
339
|
+
case 2:
|
|
340
|
+
// @ts-ignore
|
|
341
|
+
return [2 /*return*/, _b.sent()];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
124
345
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
346
|
+
withdraw: function (lpTokenAmount, slippage) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
348
|
+
var _lpTokenAmount;
|
|
349
|
+
return __generator(this, function (_b) {
|
|
350
|
+
switch (_b.label) {
|
|
351
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
|
|
352
|
+
case 1:
|
|
353
|
+
_lpTokenAmount = _b.sent();
|
|
354
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
|
|
355
|
+
case 2:
|
|
356
|
+
// @ts-ignore
|
|
357
|
+
return [2 /*return*/, _b.sent()];
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
130
361
|
},
|
|
131
362
|
};
|
|
132
363
|
// @ts-ignore
|
|
133
|
-
export
|
|
364
|
+
export var withdrawPlainMixin = {
|
|
134
365
|
// @ts-ignore
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
366
|
+
_withdraw: function (_lpTokenAmount, slippage, estimateGas) {
|
|
367
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
368
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
369
|
+
var _minAmounts, contract, gas, gasLimit;
|
|
370
|
+
return __generator(this, function (_b) {
|
|
371
|
+
switch (_b.label) {
|
|
372
|
+
case 0: return [4 /*yield*/, _withdrawMinAmounts.call(this, _lpTokenAmount, slippage)];
|
|
373
|
+
case 1:
|
|
374
|
+
_minAmounts = _b.sent();
|
|
375
|
+
contract = curve.contracts[this.address].contract;
|
|
376
|
+
return [4 /*yield*/, contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions)];
|
|
377
|
+
case 2:
|
|
378
|
+
gas = _b.sent();
|
|
379
|
+
if (estimateGas)
|
|
380
|
+
return [2 /*return*/, Number(gas)];
|
|
381
|
+
gasLimit = mulBy1_3(gas);
|
|
382
|
+
return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
383
|
+
case 3: return [2 /*return*/, (_b.sent()).hash];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
});
|
|
144
387
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
388
|
+
withdrawEstimateGas: function (lpTokenAmount) {
|
|
389
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
390
|
+
var _lpTokenAmount;
|
|
391
|
+
return __generator(this, function (_b) {
|
|
392
|
+
switch (_b.label) {
|
|
393
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount, true)];
|
|
394
|
+
case 1:
|
|
395
|
+
_lpTokenAmount = _b.sent();
|
|
396
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, 0.1, true)];
|
|
397
|
+
case 2:
|
|
398
|
+
// @ts-ignore
|
|
399
|
+
return [2 /*return*/, _b.sent()];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
});
|
|
150
403
|
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
404
|
+
withdraw: function (lpTokenAmount, slippage) {
|
|
405
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
406
|
+
var _lpTokenAmount;
|
|
407
|
+
return __generator(this, function (_b) {
|
|
408
|
+
switch (_b.label) {
|
|
409
|
+
case 0: return [4 /*yield*/, _withdrawCheck.call(this, lpTokenAmount)];
|
|
410
|
+
case 1:
|
|
411
|
+
_lpTokenAmount = _b.sent();
|
|
412
|
+
return [4 /*yield*/, this._withdraw(_lpTokenAmount, slippage)];
|
|
413
|
+
case 2:
|
|
414
|
+
// @ts-ignore
|
|
415
|
+
return [2 /*return*/, _b.sent()];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
});
|
|
156
419
|
},
|
|
157
420
|
};
|