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