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