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