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