@curvefi/api 2.32.0 → 2.33.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 +385 -135
- package/lib/constants/aliases.js +22 -11
- 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/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +10 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/kava.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/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/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +1 -1
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/kava.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/utils.js +19 -18
- package/lib/curve.js +506 -282
- package/lib/external-api.js +132 -45
- package/lib/factory/common.js +3 -3
- package/lib/factory/constants-crypto.js +21 -21
- package/lib/factory/constants.js +32 -31
- package/lib/factory/deploy.js +336 -176
- package/lib/factory/factory-api.js +256 -180
- package/lib/factory/factory-crypto.js +309 -163
- package/lib/factory/factory.d.ts +1 -1
- package/lib/factory/factory.js +336 -186
- package/lib/index.js +98 -44
- package/lib/interfaces.d.ts +5 -0
- package/lib/pools/PoolTemplate.js +2879 -1468
- package/lib/pools/mixins/common.js +106 -22
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
- package/lib/pools/mixins/depositMixins.js +413 -144
- package/lib/pools/mixins/depositWrappedMixins.js +223 -72
- package/lib/pools/mixins/poolBalancesMixin.js +98 -22
- package/lib/pools/mixins/swapMixins.js +347 -125
- package/lib/pools/mixins/swapWrappedMixins.js +270 -88
- package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
- package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
- package/lib/pools/mixins/withdrawMixins.js +385 -122
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
- package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
- package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
- package/lib/pools/poolConstructor.js +25 -5
- package/lib/pools/utils.js +488 -299
- package/lib/router.js +675 -212
- package/lib/utils.js +675 -354
- package/package.json +1 -2
|
@@ -1,179 +1,448 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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]}`);
|
|
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];
|
|
12
7
|
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
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 };
|
|
13
46
|
}
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
}
|
|
16
54
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
57
|
+
import { curve } from "../../curve.js";
|
|
58
|
+
import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
function _depositCheck(amounts, estimateGas) {
|
|
61
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var balances, _a, _b, i, _c;
|
|
64
|
+
var _this = this;
|
|
65
|
+
return __generator(this, function (_d) {
|
|
66
|
+
switch (_d.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
if (amounts.length !== this.underlyingCoinAddresses.length) {
|
|
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]); })];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
20
99
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
100
|
+
function _depositMinAmount(_amounts, slippage) {
|
|
101
|
+
if (slippage === void 0) { slippage = 0.5; }
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
var _expectedLpTokenAmount, minAmountBN;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
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
|
+
});
|
|
113
|
+
});
|
|
26
114
|
}
|
|
27
115
|
// @ts-ignore
|
|
28
|
-
export
|
|
116
|
+
export var depositMetaFactoryMixin = {
|
|
29
117
|
// @ts-ignore
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
118
|
+
_deposit: function (_amounts, slippage, estimateGas) {
|
|
119
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
126
|
+
return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap)];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.sent();
|
|
129
|
+
_a.label = 2;
|
|
130
|
+
case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
|
|
131
|
+
case 3:
|
|
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*/, Number(gas)];
|
|
141
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
146
|
+
});
|
|
43
147
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
148
|
+
depositEstimateGas: function (amounts) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
+
var _amounts;
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
|
|
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
|
+
});
|
|
162
|
+
});
|
|
49
163
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
164
|
+
deposit: function (amounts, slippage) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
var _amounts;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
switch (_a.label) {
|
|
169
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
|
|
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
|
+
});
|
|
178
|
+
});
|
|
55
179
|
},
|
|
56
180
|
};
|
|
57
181
|
// @ts-ignore
|
|
58
|
-
export
|
|
182
|
+
export var depositCryptoMetaFactoryMixin = {
|
|
59
183
|
// @ts-ignore
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
184
|
+
_deposit: function (_amounts, slippage, estimateGas) {
|
|
185
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
186
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
+
var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0:
|
|
191
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
192
|
+
return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap)];
|
|
193
|
+
case 1:
|
|
194
|
+
_a.sent();
|
|
195
|
+
_a.label = 2;
|
|
196
|
+
case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
|
|
197
|
+
case 3:
|
|
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*/, Number(gas)];
|
|
207
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
212
|
+
});
|
|
73
213
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
214
|
+
depositEstimateGas: function (amounts) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
+
var _amounts;
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
switch (_a.label) {
|
|
219
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
|
|
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
|
+
});
|
|
228
|
+
});
|
|
79
229
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
230
|
+
deposit: function (amounts, slippage) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
var _amounts;
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
235
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
|
|
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
|
+
});
|
|
244
|
+
});
|
|
85
245
|
},
|
|
86
246
|
};
|
|
87
247
|
// @ts-ignore
|
|
88
|
-
export
|
|
248
|
+
export var depositZapMixin = {
|
|
89
249
|
// @ts-ignore
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
250
|
+
_deposit: function (_amounts, slippage, estimateGas) {
|
|
251
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var _minMintAmount, ethIndex, value, contract, args, gas, gasLimit;
|
|
254
|
+
var _a;
|
|
255
|
+
return __generator(this, function (_b) {
|
|
256
|
+
switch (_b.label) {
|
|
257
|
+
case 0:
|
|
258
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
259
|
+
return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.zap)];
|
|
260
|
+
case 1:
|
|
261
|
+
_b.sent();
|
|
262
|
+
_b.label = 2;
|
|
263
|
+
case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
|
|
264
|
+
case 3:
|
|
265
|
+
_minMintAmount = _b.sent();
|
|
266
|
+
ethIndex = getEthIndex(this.underlyingCoinAddresses);
|
|
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*/, Number(gas)];
|
|
277
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
282
|
+
});
|
|
106
283
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
284
|
+
depositEstimateGas: function (amounts) {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
+
var _amounts;
|
|
287
|
+
return __generator(this, function (_a) {
|
|
288
|
+
switch (_a.label) {
|
|
289
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
|
|
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
|
+
});
|
|
298
|
+
});
|
|
112
299
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
300
|
+
deposit: function (amounts, slippage) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
302
|
+
var _amounts;
|
|
303
|
+
return __generator(this, function (_a) {
|
|
304
|
+
switch (_a.label) {
|
|
305
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
|
|
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
|
+
});
|
|
314
|
+
});
|
|
118
315
|
},
|
|
119
316
|
};
|
|
120
317
|
// @ts-ignore
|
|
121
|
-
export
|
|
318
|
+
export var depositLendingOrCryptoMixin = {
|
|
122
319
|
// @ts-ignore
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
320
|
+
_deposit: function (_amounts, slippage, estimateGas) {
|
|
321
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
322
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
323
|
+
var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
|
|
324
|
+
return __generator(this, function (_a) {
|
|
325
|
+
switch (_a.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
328
|
+
return [4 /*yield*/, _ensureAllowance(this.underlyingCoinAddresses, _amounts, this.address)];
|
|
329
|
+
case 1:
|
|
330
|
+
_a.sent();
|
|
331
|
+
_a.label = 2;
|
|
332
|
+
case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
|
|
333
|
+
case 3:
|
|
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*/, Number(gas)];
|
|
343
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
348
|
+
});
|
|
136
349
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
350
|
+
depositEstimateGas: function (amounts) {
|
|
351
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
+
var _amounts;
|
|
353
|
+
return __generator(this, function (_a) {
|
|
354
|
+
switch (_a.label) {
|
|
355
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
|
|
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
|
+
});
|
|
364
|
+
});
|
|
142
365
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
366
|
+
deposit: function (amounts, slippage) {
|
|
367
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
+
var _amounts;
|
|
369
|
+
return __generator(this, function (_a) {
|
|
370
|
+
switch (_a.label) {
|
|
371
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
|
|
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
|
+
});
|
|
380
|
+
});
|
|
148
381
|
},
|
|
149
382
|
};
|
|
150
383
|
// @ts-ignore
|
|
151
|
-
export
|
|
384
|
+
export var depositPlainMixin = {
|
|
152
385
|
// @ts-ignore
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
386
|
+
_deposit: function (_amounts, slippage, estimateGas) {
|
|
387
|
+
if (estimateGas === void 0) { estimateGas = false; }
|
|
388
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
389
|
+
var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
|
|
390
|
+
return __generator(this, function (_a) {
|
|
391
|
+
switch (_a.label) {
|
|
392
|
+
case 0:
|
|
393
|
+
if (!!estimateGas) return [3 /*break*/, 2];
|
|
394
|
+
return [4 /*yield*/, _ensureAllowance(this.wrappedCoinAddresses, _amounts, this.address)];
|
|
395
|
+
case 1:
|
|
396
|
+
_a.sent();
|
|
397
|
+
_a.label = 2;
|
|
398
|
+
case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
|
|
399
|
+
case 3:
|
|
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*/, Number(gas)];
|
|
409
|
+
gasLimit = mulBy1_3(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
|
+
});
|
|
414
|
+
});
|
|
166
415
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
416
|
+
depositEstimateGas: function (amounts) {
|
|
417
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
418
|
+
var _amounts;
|
|
419
|
+
return __generator(this, function (_a) {
|
|
420
|
+
switch (_a.label) {
|
|
421
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts, true)];
|
|
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
|
+
});
|
|
430
|
+
});
|
|
172
431
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
432
|
+
deposit: function (amounts, slippage) {
|
|
433
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
434
|
+
var _amounts;
|
|
435
|
+
return __generator(this, function (_a) {
|
|
436
|
+
switch (_a.label) {
|
|
437
|
+
case 0: return [4 /*yield*/, _depositCheck.call(this, amounts)];
|
|
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
|
+
});
|
|
446
|
+
});
|
|
178
447
|
},
|
|
179
448
|
};
|