@curvefi/api 2.63.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.
- package/lib/boosting.js +247 -645
- package/lib/constants/L2Networks.js +1 -1
- package/lib/constants/aliases.js +19 -19
- 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/base.js +5 -5
- package/lib/constants/coins/bsc.js +5 -5
- package/lib/constants/coins/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +9 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/fraxtal.js +5 -5
- package/lib/constants/coins/kava.js +5 -5
- package/lib/constants/coins/mantle.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/coins/xlayer.js +5 -5
- package/lib/constants/coins/zksync.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/base.js +1 -1
- package/lib/constants/pools/bsc.js +1 -1
- package/lib/constants/pools/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +2 -2
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/fraxtal.js +1 -1
- package/lib/constants/pools/kava.js +1 -1
- package/lib/constants/pools/mantle.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/pools/xlayer.js +1 -1
- package/lib/constants/pools/zksync.js +1 -1
- package/lib/constants/tricryptoDeployImplementations.js +1 -1
- package/lib/constants/utils.js +18 -19
- package/lib/constants/volumeNetworks.js +1 -1
- package/lib/curve.d.ts +3 -1
- package/lib/curve.js +534 -909
- package/lib/dao.js +351 -705
- package/lib/external-api.js +127 -256
- package/lib/factory/common.js +4 -4
- package/lib/factory/constants-crypto.js +33 -33
- package/lib/factory/constants.js +34 -34
- package/lib/factory/deploy.js +542 -907
- package/lib/factory/factory-api.js +205 -269
- package/lib/factory/factory-crypto.js +202 -342
- package/lib/factory/factory-tricrypto.js +164 -286
- package/lib/factory/factory-twocrypto.js +151 -269
- package/lib/factory/factory.js +245 -385
- package/lib/index.js +109 -198
- package/lib/interfaces.d.ts +1 -6
- package/lib/pools/PoolTemplate.js +1773 -3025
- package/lib/pools/gaugePool.js +112 -251
- package/lib/pools/mixins/common.js +22 -93
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
- package/lib/pools/mixins/depositMixins.js +160 -386
- package/lib/pools/mixins/depositWrappedMixins.js +79 -205
- package/lib/pools/mixins/poolBalancesMixin.js +24 -87
- package/lib/pools/mixins/swapMixins.js +139 -324
- package/lib/pools/mixins/swapWrappedMixins.js +111 -265
- package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
- package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
- package/lib/pools/mixins/withdrawMixins.js +139 -359
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
- package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
- package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
- package/lib/pools/poolConstructor.js +5 -25
- package/lib/pools/utils.js +301 -469
- package/lib/route-finder.worker.d.ts +9 -0
- package/lib/route-finder.worker.js +112 -0
- package/lib/route-graph.worker.d.ts +11 -0
- package/lib/route-graph.worker.js +334 -0
- package/lib/router.js +323 -912
- package/lib/utils.d.ts +5 -4
- package/lib/utils.js +539 -918
- 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,403 +7,194 @@ 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
|
-
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
|
-
};
|
|
57
10
|
import { curve } from "../../curve.js";
|
|
58
11
|
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
59
12
|
// @ts-ignore
|
|
60
|
-
function _withdrawCheck(lpTokenAmount, estimateGas) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
});
|
|
13
|
+
function _withdrawCheck(lpTokenAmount, estimateGas = false) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
|
|
16
|
+
if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
|
|
17
|
+
throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
|
|
18
|
+
}
|
|
19
|
+
if (estimateGas && this.zap && !(yield hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
|
|
20
|
+
throw Error("Token allowance is needed to estimate gas");
|
|
21
|
+
}
|
|
22
|
+
if (!estimateGas)
|
|
23
|
+
yield curve.updateFeeData();
|
|
24
|
+
return parseUnits(lpTokenAmount);
|
|
90
25
|
});
|
|
91
26
|
}
|
|
92
|
-
function _withdrawMinAmounts(_lpTokenAmount, slippage) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return
|
|
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
|
-
});
|
|
27
|
+
function _withdrawMinAmounts(_lpTokenAmount, slippage = 0.5) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const expectedAmounts = yield this.withdrawExpected(curve.formatUnits(_lpTokenAmount));
|
|
30
|
+
const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.underlyingDecimals[i]));
|
|
31
|
+
const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.underlyingDecimals[i]).times(100 - slippage).div(100));
|
|
32
|
+
return minRecvAmountsBN.map((a, i) => fromBN(a, this.underlyingDecimals[i]));
|
|
107
33
|
});
|
|
108
34
|
}
|
|
109
35
|
// @ts-ignore
|
|
110
|
-
export
|
|
36
|
+
export const withdrawMetaFactoryMixin = {
|
|
111
37
|
// @ts-ignore
|
|
112
|
-
_withdraw
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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*/, smartNumber(gas)];
|
|
133
|
-
gasLimit = mulBy1_3(DIGas(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
|
-
});
|
|
38
|
+
_withdraw(_lpTokenAmount, slippage, estimateGas = false) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!estimateGas)
|
|
41
|
+
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
42
|
+
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
43
|
+
const contract = curve.contracts[this.zap].contract;
|
|
44
|
+
const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, curve.constantOptions);
|
|
45
|
+
if (estimateGas)
|
|
46
|
+
return smartNumber(gas);
|
|
47
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
48
|
+
return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
138
49
|
});
|
|
139
50
|
},
|
|
140
|
-
withdrawEstimateGas
|
|
141
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
});
|
|
51
|
+
withdrawEstimateGas(lpTokenAmount) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return yield this._withdraw(_lpTokenAmount, 0.1, true);
|
|
154
57
|
});
|
|
155
58
|
},
|
|
156
|
-
withdraw
|
|
157
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
});
|
|
59
|
+
withdraw(lpTokenAmount, slippage) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
return yield this._withdraw(_lpTokenAmount, slippage);
|
|
170
65
|
});
|
|
171
66
|
},
|
|
172
67
|
};
|
|
173
68
|
// @ts-ignore
|
|
174
|
-
export
|
|
69
|
+
export const withdrawCryptoMetaFactoryMixin = {
|
|
175
70
|
// @ts-ignore
|
|
176
|
-
_withdraw
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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*/, smartNumber(gas)];
|
|
197
|
-
gasLimit = mulBy1_3(DIGas(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
|
-
});
|
|
71
|
+
_withdraw(_lpTokenAmount, slippage, estimateGas = false) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
if (!estimateGas)
|
|
74
|
+
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
75
|
+
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
76
|
+
const contract = curve.contracts[this.zap].contract;
|
|
77
|
+
const gas = yield contract.remove_liquidity.estimateGas(this.address, _lpTokenAmount, _minAmounts, true, curve.constantOptions);
|
|
78
|
+
if (estimateGas)
|
|
79
|
+
return smartNumber(gas);
|
|
80
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
81
|
+
return (yield contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
202
82
|
});
|
|
203
83
|
},
|
|
204
|
-
withdrawEstimateGas
|
|
205
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
});
|
|
84
|
+
withdrawEstimateGas(lpTokenAmount) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
return yield this._withdraw(_lpTokenAmount, 0.1, true);
|
|
218
90
|
});
|
|
219
91
|
},
|
|
220
|
-
withdraw
|
|
221
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
});
|
|
92
|
+
withdraw(lpTokenAmount, slippage) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
return yield this._withdraw(_lpTokenAmount, slippage);
|
|
234
98
|
});
|
|
235
99
|
},
|
|
236
100
|
};
|
|
237
101
|
// @ts-ignore
|
|
238
|
-
export
|
|
102
|
+
export const withdrawZapMixin = {
|
|
239
103
|
// @ts-ignore
|
|
240
|
-
_withdraw
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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*/, smartNumber(gas)];
|
|
265
|
-
gasLimit = mulBy1_3(DIGas(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
|
-
});
|
|
104
|
+
_withdraw(_lpTokenAmount, slippage, estimateGas = false) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
if (!estimateGas)
|
|
107
|
+
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
110
|
+
const contract = curve.contracts[this.zap].contract;
|
|
111
|
+
const args = [_lpTokenAmount, _minAmounts];
|
|
112
|
+
if (`remove_liquidity(uint256,uint256[${this.underlyingCoinAddresses.length}],bool)` in contract)
|
|
113
|
+
args.push(true);
|
|
114
|
+
const gas = yield contract.remove_liquidity.estimateGas(...args, curve.constantOptions);
|
|
115
|
+
if (estimateGas)
|
|
116
|
+
return smartNumber(gas);
|
|
117
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
118
|
+
return (yield contract.remove_liquidity(...args, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
270
119
|
});
|
|
271
120
|
},
|
|
272
|
-
withdrawEstimateGas
|
|
273
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
});
|
|
121
|
+
withdrawEstimateGas(lpTokenAmount) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
return yield this._withdraw(_lpTokenAmount, 0.1, true);
|
|
286
127
|
});
|
|
287
128
|
},
|
|
288
|
-
withdraw
|
|
289
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
});
|
|
129
|
+
withdraw(lpTokenAmount, slippage) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
return yield this._withdraw(_lpTokenAmount, slippage);
|
|
302
135
|
});
|
|
303
136
|
},
|
|
304
137
|
};
|
|
305
138
|
// @ts-ignore
|
|
306
|
-
export
|
|
139
|
+
export const withdrawLendingOrCryptoMixin = {
|
|
307
140
|
// @ts-ignore
|
|
308
|
-
_withdraw
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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*/, smartNumber(gas)];
|
|
323
|
-
gasLimit = mulBy1_3(DIGas(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
|
-
});
|
|
141
|
+
_withdraw(_lpTokenAmount, slippage, estimateGas = false) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
144
|
+
const contract = curve.contracts[this.address].contract;
|
|
145
|
+
const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions);
|
|
146
|
+
if (estimateGas)
|
|
147
|
+
return smartNumber(gas);
|
|
148
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
149
|
+
return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
328
150
|
});
|
|
329
151
|
},
|
|
330
|
-
withdrawEstimateGas
|
|
331
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|
-
});
|
|
152
|
+
withdrawEstimateGas(lpTokenAmount) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
return yield this._withdraw(_lpTokenAmount, 0.1, true);
|
|
344
158
|
});
|
|
345
159
|
},
|
|
346
|
-
withdraw
|
|
347
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
-
});
|
|
160
|
+
withdraw(lpTokenAmount, slippage) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
return yield this._withdraw(_lpTokenAmount, slippage);
|
|
360
166
|
});
|
|
361
167
|
},
|
|
362
168
|
};
|
|
363
169
|
// @ts-ignore
|
|
364
|
-
export
|
|
170
|
+
export const withdrawPlainMixin = {
|
|
365
171
|
// @ts-ignore
|
|
366
|
-
_withdraw
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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*/, smartNumber(gas)];
|
|
381
|
-
gasLimit = mulBy1_3(DIGas(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
|
-
});
|
|
172
|
+
_withdraw(_lpTokenAmount, slippage, estimateGas = false) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
176
|
+
const contract = curve.contracts[this.address].contract;
|
|
177
|
+
const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions);
|
|
178
|
+
if (estimateGas)
|
|
179
|
+
return smartNumber(gas);
|
|
180
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
181
|
+
return (yield contract.remove_liquidity(_lpTokenAmount, _minAmounts, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
386
182
|
});
|
|
387
183
|
},
|
|
388
|
-
withdrawEstimateGas
|
|
389
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
});
|
|
184
|
+
withdrawEstimateGas(lpTokenAmount) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
// @ts-ignore
|
|
187
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount, true);
|
|
188
|
+
// @ts-ignore
|
|
189
|
+
return yield this._withdraw(_lpTokenAmount, 0.1, true);
|
|
402
190
|
});
|
|
403
191
|
},
|
|
404
|
-
withdraw
|
|
405
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
-
});
|
|
192
|
+
withdraw(lpTokenAmount, slippage) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
const _lpTokenAmount = yield _withdrawCheck.call(this, lpTokenAmount);
|
|
196
|
+
// @ts-ignore
|
|
197
|
+
return yield this._withdraw(_lpTokenAmount, slippage);
|
|
418
198
|
});
|
|
419
199
|
},
|
|
420
200
|
};
|