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