@curvefi/api 2.63.0 → 2.63.2
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 +10 -6
- 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 +46 -6
- package/lib/pools/PoolTemplate.js +1774 -3027
- 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 +11 -31
- 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 +8 -7
- package/lib/utils.js +540 -927
- package/package.json +3 -2
|
@@ -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,187 +7,87 @@ 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 { fromBN, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
50
12
|
// @ts-ignore
|
|
51
13
|
function _withdrawImbalanceWrappedCheck(amounts) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return [4 /*yield*/, this.wallet.lpTokenBalances()];
|
|
61
|
-
case 2:
|
|
62
|
-
lpTokenBalance = (_a.sent())['lpToken'];
|
|
63
|
-
if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
|
|
64
|
-
throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
|
|
65
|
-
}
|
|
66
|
-
return [4 /*yield*/, curve.updateFeeData()];
|
|
67
|
-
case 3:
|
|
68
|
-
_a.sent();
|
|
69
|
-
return [2 /*return*/, amounts.map(function (amount, i) { return parseUnits(amount, _this.wrappedDecimals[i]); })];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const lpTokenAmount = yield this.withdrawImbalanceWrappedExpected(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
|
+
yield curve.updateFeeData();
|
|
21
|
+
return amounts.map((amount, i) => parseUnits(amount, this.wrappedDecimals[i]));
|
|
72
22
|
});
|
|
73
23
|
}
|
|
74
|
-
function _withdrawImbalanceWrappedMaxBurnAmount(_amounts, slippage) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
case 0: return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false, false)];
|
|
81
|
-
case 1:
|
|
82
|
-
_expectedLpTokenAmount = _a.sent();
|
|
83
|
-
maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
|
|
84
|
-
return [2 /*return*/, fromBN(maxBurnAmountBN)];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
24
|
+
function _withdrawImbalanceWrappedMaxBurnAmount(_amounts, slippage = 0.5) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts, false, false);
|
|
28
|
+
const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
|
|
29
|
+
return fromBN(maxBurnAmountBN);
|
|
87
30
|
});
|
|
88
31
|
}
|
|
89
32
|
// @ts-ignore
|
|
90
|
-
export
|
|
33
|
+
export const withdrawImbalanceWrapped2argsMixin = {
|
|
91
34
|
// @ts-ignore
|
|
92
|
-
_withdrawImbalanceWrapped
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
contract = curve.contracts[this.address].contract;
|
|
102
|
-
return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions)];
|
|
103
|
-
case 2:
|
|
104
|
-
gas = _a.sent();
|
|
105
|
-
if (estimateGas)
|
|
106
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
107
|
-
gasLimit = mulBy1_3(DIGas(gas));
|
|
108
|
-
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
109
|
-
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
35
|
+
_withdrawImbalanceWrapped(_amounts, slippage, estimateGas = false) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const _maxBurnAmount = yield _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
|
|
38
|
+
const contract = curve.contracts[this.address].contract;
|
|
39
|
+
const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
|
|
40
|
+
if (estimateGas)
|
|
41
|
+
return smartNumber(gas);
|
|
42
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
43
|
+
return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
112
44
|
});
|
|
113
45
|
},
|
|
114
|
-
withdrawImbalanceWrappedEstimateGas
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
case 1:
|
|
121
|
-
_amounts = _a.sent();
|
|
122
|
-
return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, 0.1, true)];
|
|
123
|
-
case 2:
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
return [2 /*return*/, _a.sent()];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
46
|
+
withdrawImbalanceWrappedEstimateGas(amounts) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
return yield this._withdrawImbalanceWrapped(_amounts, 0.1, true);
|
|
128
52
|
});
|
|
129
53
|
},
|
|
130
|
-
withdrawImbalanceWrapped
|
|
131
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
case 1:
|
|
137
|
-
_amounts = _a.sent();
|
|
138
|
-
return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, slippage)];
|
|
139
|
-
case 2:
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
return [2 /*return*/, _a.sent()];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
54
|
+
withdrawImbalanceWrapped(amounts, slippage) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
return yield this._withdrawImbalanceWrapped(_amounts, slippage);
|
|
144
60
|
});
|
|
145
61
|
},
|
|
146
62
|
};
|
|
147
63
|
// @ts-ignore
|
|
148
|
-
export
|
|
64
|
+
export const withdrawImbalanceWrapped3argsMixin = {
|
|
149
65
|
// @ts-ignore
|
|
150
|
-
_withdrawImbalanceWrapped
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
contract = curve.contracts[this.address].contract;
|
|
160
|
-
return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, curve.constantOptions)];
|
|
161
|
-
case 2:
|
|
162
|
-
gas = _a.sent();
|
|
163
|
-
if (estimateGas)
|
|
164
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
165
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
166
|
-
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
167
|
-
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
168
|
-
}
|
|
169
|
-
});
|
|
66
|
+
_withdrawImbalanceWrapped(_amounts, slippage, estimateGas = false) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const _maxBurnAmount = yield _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
|
|
69
|
+
const contract = curve.contracts[this.address].contract;
|
|
70
|
+
const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, curve.constantOptions);
|
|
71
|
+
if (estimateGas)
|
|
72
|
+
return smartNumber(gas);
|
|
73
|
+
const gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
74
|
+
return (yield contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
|
|
170
75
|
});
|
|
171
76
|
},
|
|
172
|
-
withdrawImbalanceWrappedEstimateGas
|
|
173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
case 1:
|
|
179
|
-
_amounts = _a.sent();
|
|
180
|
-
return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, 0.1, true)];
|
|
181
|
-
case 2:
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
return [2 /*return*/, _a.sent()];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
77
|
+
withdrawImbalanceWrappedEstimateGas(amounts) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
return yield this._withdrawImbalanceWrapped(_amounts, 0.1, true);
|
|
186
83
|
});
|
|
187
84
|
},
|
|
188
|
-
withdrawImbalanceWrapped
|
|
189
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
case 1:
|
|
195
|
-
_amounts = _a.sent();
|
|
196
|
-
return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, slippage)];
|
|
197
|
-
case 2:
|
|
198
|
-
// @ts-ignore
|
|
199
|
-
return [2 /*return*/, _a.sent()];
|
|
200
|
-
}
|
|
201
|
-
});
|
|
85
|
+
withdrawImbalanceWrapped(amounts, slippage) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
const _amounts = yield _withdrawImbalanceWrappedCheck.call(this, amounts);
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
return yield this._withdrawImbalanceWrapped(_amounts, slippage);
|
|
202
91
|
});
|
|
203
92
|
},
|
|
204
93
|
};
|