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