@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,431 +7,216 @@ 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, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
|
|
59
12
|
// @ts-ignore
|
|
60
|
-
function _depositCheck(amounts, estimateGas) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
throw Error("".concat(this.name, " pool has ").concat(this.underlyingCoinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
|
|
70
|
-
}
|
|
71
|
-
_b = (_a = Object).values;
|
|
72
|
-
return [4 /*yield*/, this.wallet.underlyingCoinBalances()];
|
|
73
|
-
case 1:
|
|
74
|
-
balances = _b.apply(_a, [_d.sent()]);
|
|
75
|
-
for (i = 0; i < balances.length; i++) {
|
|
76
|
-
if (Number(balances[i]) < Number(amounts[i])) {
|
|
77
|
-
throw Error("Not enough ".concat(this.underlyingCoins[i], ". Actual: ").concat(balances[i], ", required: ").concat(amounts[i]));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
_c = estimateGas;
|
|
81
|
-
if (!_c) return [3 /*break*/, 3];
|
|
82
|
-
return [4 /*yield*/, hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, this.zap || this.address)];
|
|
83
|
-
case 2:
|
|
84
|
-
_c = !(_d.sent());
|
|
85
|
-
_d.label = 3;
|
|
86
|
-
case 3:
|
|
87
|
-
if (_c) {
|
|
88
|
-
throw Error("Token allowance is needed to estimate gas");
|
|
89
|
-
}
|
|
90
|
-
if (!!estimateGas) return [3 /*break*/, 5];
|
|
91
|
-
return [4 /*yield*/, curve.updateFeeData()];
|
|
92
|
-
case 4:
|
|
93
|
-
_d.sent();
|
|
94
|
-
_d.label = 5;
|
|
95
|
-
case 5: return [2 /*return*/, amounts.map(function (amount, i) { return parseUnits(amount, _this.underlyingDecimals[i]); })];
|
|
13
|
+
function _depositCheck(amounts, estimateGas = false) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (amounts.length !== this.underlyingCoinAddresses.length) {
|
|
16
|
+
throw Error(`${this.name} pool has ${this.underlyingCoinAddresses.length} coins (amounts provided for ${amounts.length})`);
|
|
17
|
+
}
|
|
18
|
+
const balances = Object.values(yield this.wallet.underlyingCoinBalances());
|
|
19
|
+
for (let i = 0; i < balances.length; i++) {
|
|
20
|
+
if (Number(balances[i]) < Number(amounts[i])) {
|
|
21
|
+
throw Error(`Not enough ${this.underlyingCoins[i]}. Actual: ${balances[i]}, required: ${amounts[i]}`);
|
|
96
22
|
}
|
|
97
|
-
}
|
|
23
|
+
}
|
|
24
|
+
if (estimateGas && !(yield hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, this.zap || this.address))) {
|
|
25
|
+
throw Error("Token allowance is needed to estimate gas");
|
|
26
|
+
}
|
|
27
|
+
if (!estimateGas)
|
|
28
|
+
yield curve.updateFeeData();
|
|
29
|
+
return amounts.map((amount, i) => parseUnits(amount, this.underlyingDecimals[i]));
|
|
98
30
|
});
|
|
99
31
|
}
|
|
100
|
-
function _depositMinAmount(_amounts, slippage) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case 0: return [4 /*yield*/, this._calcLpTokenAmount(_amounts)];
|
|
107
|
-
case 1:
|
|
108
|
-
_expectedLpTokenAmount = _a.sent();
|
|
109
|
-
minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
|
|
110
|
-
return [2 /*return*/, fromBN(minAmountBN)];
|
|
111
|
-
}
|
|
112
|
-
});
|
|
32
|
+
function _depositMinAmount(_amounts, slippage = 0.5) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts);
|
|
36
|
+
const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
|
|
37
|
+
return fromBN(minAmountBN);
|
|
113
38
|
});
|
|
114
39
|
}
|
|
115
40
|
// @ts-ignore
|
|
116
|
-
export
|
|
41
|
+
export const depositMetaFactoryMixin = {
|
|
117
42
|
// @ts-ignore
|
|
118
|
-
_deposit
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
_minMintAmount = _a.sent();
|
|
133
|
-
ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
134
|
-
value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
135
|
-
contract = curve.contracts[this.zap].contract;
|
|
136
|
-
return [4 /*yield*/, contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, __assign(__assign({}, curve.constantOptions), { value: value }))];
|
|
137
|
-
case 4:
|
|
138
|
-
gas = _a.sent();
|
|
139
|
-
if (estimateGas)
|
|
140
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
141
|
-
gasLimit = mulBy1_3(DIGas(gas));
|
|
142
|
-
return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
143
|
-
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
43
|
+
_deposit(_amounts, slippage, estimateGas = false) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (!estimateGas)
|
|
46
|
+
yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
|
|
49
|
+
const ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
50
|
+
const value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
51
|
+
const contract = curve.contracts[this.zap].contract;
|
|
52
|
+
const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
|
|
53
|
+
if (estimateGas)
|
|
54
|
+
return smartNumber(gas);
|
|
55
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
56
|
+
return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
146
57
|
});
|
|
147
58
|
},
|
|
148
|
-
depositEstimateGas
|
|
149
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
case 1:
|
|
155
|
-
_amounts = _a.sent();
|
|
156
|
-
return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
|
|
157
|
-
case 2:
|
|
158
|
-
// @ts-ignore
|
|
159
|
-
return [2 /*return*/, _a.sent()];
|
|
160
|
-
}
|
|
161
|
-
});
|
|
59
|
+
depositEstimateGas(amounts) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
const _amounts = yield _depositCheck.call(this, amounts, true);
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
return yield this._deposit(_amounts, 0.1, true);
|
|
162
65
|
});
|
|
163
66
|
},
|
|
164
|
-
deposit
|
|
165
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
case 1:
|
|
171
|
-
_amounts = _a.sent();
|
|
172
|
-
return [4 /*yield*/, this._deposit(_amounts, slippage)];
|
|
173
|
-
case 2:
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
return [2 /*return*/, _a.sent()];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
67
|
+
deposit(amounts, slippage) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
const _amounts = yield _depositCheck.call(this, amounts);
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
return yield this._deposit(_amounts, slippage);
|
|
178
73
|
});
|
|
179
74
|
},
|
|
180
75
|
};
|
|
181
76
|
// @ts-ignore
|
|
182
|
-
export
|
|
77
|
+
export const depositCryptoMetaFactoryMixin = {
|
|
183
78
|
// @ts-ignore
|
|
184
|
-
_deposit
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
_minMintAmount = _a.sent();
|
|
199
|
-
ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
200
|
-
value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
201
|
-
contract = curve.contracts[this.zap].contract;
|
|
202
|
-
return [4 /*yield*/, contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve.constantOptions), { value: value }))];
|
|
203
|
-
case 4:
|
|
204
|
-
gas = _a.sent();
|
|
205
|
-
if (estimateGas)
|
|
206
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
207
|
-
gasLimit = mulBy1_3(DIGas(gas));
|
|
208
|
-
return [4 /*yield*/, contract.add_liquidity(this.address, _amounts, _minMintAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
209
|
-
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
79
|
+
_deposit(_amounts, slippage, estimateGas = false) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (!estimateGas)
|
|
82
|
+
yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
|
|
85
|
+
const ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
86
|
+
const value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
87
|
+
const contract = curve.contracts[this.zap].contract;
|
|
88
|
+
const gas = yield contract.add_liquidity.estimateGas(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.constantOptions), { value }));
|
|
89
|
+
if (estimateGas)
|
|
90
|
+
return smartNumber(gas);
|
|
91
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
92
|
+
return (yield contract.add_liquidity(this.address, _amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
212
93
|
});
|
|
213
94
|
},
|
|
214
|
-
depositEstimateGas
|
|
215
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
case 1:
|
|
221
|
-
_amounts = _a.sent();
|
|
222
|
-
return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
|
|
223
|
-
case 2:
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
return [2 /*return*/, _a.sent()];
|
|
226
|
-
}
|
|
227
|
-
});
|
|
95
|
+
depositEstimateGas(amounts) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
const _amounts = yield _depositCheck.call(this, amounts, true);
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
return yield this._deposit(_amounts, 0.1, true);
|
|
228
101
|
});
|
|
229
102
|
},
|
|
230
|
-
deposit
|
|
231
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
case 1:
|
|
237
|
-
_amounts = _a.sent();
|
|
238
|
-
return [4 /*yield*/, this._deposit(_amounts, slippage)];
|
|
239
|
-
case 2:
|
|
240
|
-
// @ts-ignore
|
|
241
|
-
return [2 /*return*/, _a.sent()];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
103
|
+
deposit(amounts, slippage) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
const _amounts = yield _depositCheck.call(this, amounts);
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
return yield this._deposit(_amounts, slippage);
|
|
244
109
|
});
|
|
245
110
|
},
|
|
246
111
|
};
|
|
247
112
|
// @ts-ignore
|
|
248
|
-
export
|
|
113
|
+
export const depositZapMixin = {
|
|
249
114
|
// @ts-ignore
|
|
250
|
-
_deposit
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
268
|
-
contract = curve.contracts[this.zap].contract;
|
|
269
|
-
args = [_amounts, _minMintAmount];
|
|
270
|
-
if ("add_liquidity(uint256[".concat(this.underlyingCoinAddresses.length, "],uint256,bool)") in contract)
|
|
271
|
-
args.push(true);
|
|
272
|
-
return [4 /*yield*/, (_a = contract.add_liquidity).estimateGas.apply(_a, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.constantOptions), { value: value })], false))];
|
|
273
|
-
case 4:
|
|
274
|
-
gas = _b.sent();
|
|
275
|
-
if (estimateGas)
|
|
276
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
277
|
-
gasLimit = mulBy1_3(DIGas(gas));
|
|
278
|
-
return [4 /*yield*/, contract.add_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value })], false))];
|
|
279
|
-
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
115
|
+
_deposit(_amounts, slippage, estimateGas = false) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
if (!estimateGas)
|
|
118
|
+
yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap);
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
|
|
121
|
+
const ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
122
|
+
const value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
123
|
+
const contract = curve.contracts[this.zap].contract;
|
|
124
|
+
const args = [_amounts, _minMintAmount];
|
|
125
|
+
if (`add_liquidity(uint256[${this.underlyingCoinAddresses.length}],uint256,bool)` in contract)
|
|
126
|
+
args.push(true);
|
|
127
|
+
const gas = yield contract.add_liquidity.estimateGas(...args, Object.assign(Object.assign({}, curve.constantOptions), { value }));
|
|
128
|
+
if (estimateGas)
|
|
129
|
+
return smartNumber(gas);
|
|
130
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
131
|
+
return (yield contract.add_liquidity(...args, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
282
132
|
});
|
|
283
133
|
},
|
|
284
|
-
depositEstimateGas
|
|
285
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
case 1:
|
|
291
|
-
_amounts = _a.sent();
|
|
292
|
-
return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
|
|
293
|
-
case 2:
|
|
294
|
-
// @ts-ignore
|
|
295
|
-
return [2 /*return*/, _a.sent()];
|
|
296
|
-
}
|
|
297
|
-
});
|
|
134
|
+
depositEstimateGas(amounts) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
const _amounts = yield _depositCheck.call(this, amounts, true);
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
return yield this._deposit(_amounts, 0.1, true);
|
|
298
140
|
});
|
|
299
141
|
},
|
|
300
|
-
deposit
|
|
301
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
case 1:
|
|
307
|
-
_amounts = _a.sent();
|
|
308
|
-
return [4 /*yield*/, this._deposit(_amounts, slippage)];
|
|
309
|
-
case 2:
|
|
310
|
-
// @ts-ignore
|
|
311
|
-
return [2 /*return*/, _a.sent()];
|
|
312
|
-
}
|
|
313
|
-
});
|
|
142
|
+
deposit(amounts, slippage) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
const _amounts = yield _depositCheck.call(this, amounts);
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
return yield this._deposit(_amounts, slippage);
|
|
314
148
|
});
|
|
315
149
|
},
|
|
316
150
|
};
|
|
317
151
|
// @ts-ignore
|
|
318
|
-
export
|
|
152
|
+
export const depositLendingOrCryptoMixin = {
|
|
319
153
|
// @ts-ignore
|
|
320
|
-
_deposit
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
_minMintAmount = _a.sent();
|
|
335
|
-
ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
336
|
-
value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
337
|
-
contract = curve.contracts[this.address].contract;
|
|
338
|
-
return [4 /*yield*/, contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, __assign(__assign({}, curve.constantOptions), { value: value }))];
|
|
339
|
-
case 4:
|
|
340
|
-
gas = _a.sent();
|
|
341
|
-
if (estimateGas)
|
|
342
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
343
|
-
gasLimit = mulBy1_3(DIGas(gas));
|
|
344
|
-
return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
345
|
-
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
346
|
-
}
|
|
347
|
-
});
|
|
154
|
+
_deposit(_amounts, slippage, estimateGas = false) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
if (!estimateGas)
|
|
157
|
+
yield _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.address);
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
|
|
160
|
+
const ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
161
|
+
const value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
162
|
+
const contract = curve.contracts[this.address].contract;
|
|
163
|
+
const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.constantOptions), { value }));
|
|
164
|
+
if (estimateGas)
|
|
165
|
+
return smartNumber(gas);
|
|
166
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
167
|
+
return (yield contract.add_liquidity(_amounts, _minMintAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
348
168
|
});
|
|
349
169
|
},
|
|
350
|
-
depositEstimateGas
|
|
351
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
case 1:
|
|
357
|
-
_amounts = _a.sent();
|
|
358
|
-
return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
|
|
359
|
-
case 2:
|
|
360
|
-
// @ts-ignore
|
|
361
|
-
return [2 /*return*/, _a.sent()];
|
|
362
|
-
}
|
|
363
|
-
});
|
|
170
|
+
depositEstimateGas(amounts) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
const _amounts = yield _depositCheck.call(this, amounts, true);
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
return yield this._deposit(_amounts, 0.1, true);
|
|
364
176
|
});
|
|
365
177
|
},
|
|
366
|
-
deposit
|
|
367
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
case 1:
|
|
373
|
-
_amounts = _a.sent();
|
|
374
|
-
return [4 /*yield*/, this._deposit(_amounts, slippage)];
|
|
375
|
-
case 2:
|
|
376
|
-
// @ts-ignore
|
|
377
|
-
return [2 /*return*/, _a.sent()];
|
|
378
|
-
}
|
|
379
|
-
});
|
|
178
|
+
deposit(amounts, slippage) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
const _amounts = yield _depositCheck.call(this, amounts);
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
return yield this._deposit(_amounts, slippage);
|
|
380
184
|
});
|
|
381
185
|
},
|
|
382
186
|
};
|
|
383
187
|
// @ts-ignore
|
|
384
|
-
export
|
|
188
|
+
export const depositPlainMixin = {
|
|
385
189
|
// @ts-ignore
|
|
386
|
-
_deposit
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
_minMintAmount = _a.sent();
|
|
401
|
-
ethIndex = getEthIndex(this.wrappedCoinAddresses);
|
|
402
|
-
value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
403
|
-
contract = curve.contracts[this.address].contract;
|
|
404
|
-
return [4 /*yield*/, contract.add_liquidity.estimateGas(_amounts, _minMintAmount, __assign(__assign({}, curve.constantOptions), { value: value }))];
|
|
405
|
-
case 4:
|
|
406
|
-
gas = _a.sent();
|
|
407
|
-
if (estimateGas)
|
|
408
|
-
return [2 /*return*/, smartNumber(gas)];
|
|
409
|
-
gasLimit = mulBy1_3(DIGas(gas));
|
|
410
|
-
return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
411
|
-
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
412
|
-
}
|
|
413
|
-
});
|
|
190
|
+
_deposit(_amounts, slippage, estimateGas = false) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
if (!estimateGas)
|
|
193
|
+
yield _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address);
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
const _minMintAmount = yield _depositMinAmount.call(this, _amounts, slippage);
|
|
196
|
+
const ethIndex = getEthIndex(this.wrappedCoinAddresses);
|
|
197
|
+
const value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
198
|
+
const contract = curve.contracts[this.address].contract;
|
|
199
|
+
const gas = yield contract.add_liquidity.estimateGas(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.constantOptions), { value }));
|
|
200
|
+
if (estimateGas)
|
|
201
|
+
return smartNumber(gas);
|
|
202
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
203
|
+
return (yield contract.add_liquidity(_amounts, _minMintAmount, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
414
204
|
});
|
|
415
205
|
},
|
|
416
|
-
depositEstimateGas
|
|
417
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
case 1:
|
|
423
|
-
_amounts = _a.sent();
|
|
424
|
-
return [4 /*yield*/, this._deposit(_amounts, 0.1, true)];
|
|
425
|
-
case 2:
|
|
426
|
-
// @ts-ignore
|
|
427
|
-
return [2 /*return*/, _a.sent()];
|
|
428
|
-
}
|
|
429
|
-
});
|
|
206
|
+
depositEstimateGas(amounts) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
const _amounts = yield _depositCheck.call(this, amounts, true);
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
return yield this._deposit(_amounts, 0.1, true);
|
|
430
212
|
});
|
|
431
213
|
},
|
|
432
|
-
deposit
|
|
433
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
case 1:
|
|
439
|
-
_amounts = _a.sent();
|
|
440
|
-
return [4 /*yield*/, this._deposit(_amounts, slippage)];
|
|
441
|
-
case 2:
|
|
442
|
-
// @ts-ignore
|
|
443
|
-
return [2 /*return*/, _a.sent()];
|
|
444
|
-
}
|
|
445
|
-
});
|
|
214
|
+
deposit(amounts, slippage) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
const _amounts = yield _depositCheck.call(this, amounts);
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
return yield this._deposit(_amounts, slippage);
|
|
446
220
|
});
|
|
447
221
|
},
|
|
448
222
|
};
|