@curvefi/api 2.8.1 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/pools/PoolTemplate.js +530 -496
- package/package.json +1 -1
|
@@ -75,9 +75,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
75
75
|
function PoolTemplate(id) {
|
|
76
76
|
var _this = this;
|
|
77
77
|
this.statsParameters = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
78
|
-
var multicallContract, lpMulticallContract, calls, additionalCalls,
|
|
79
|
-
return __generator(this, function (
|
|
80
|
-
switch (
|
|
78
|
+
var multicallContract, lpMulticallContract, calls, additionalCalls, _c, _lpTokenSupply, _virtualPrice, _fee, _adminFee, _A, _gamma, _d, lpTokenSupply, virtualPrice, fee, adminFee, A, gamma, A_PRECISION, _e, _future_A, _initial_A, _future_A_time, _initial_A_time, _f, future_A, initial_A, future_A_time, initial_A_time;
|
|
79
|
+
return __generator(this, function (_g) {
|
|
80
|
+
switch (_g.label) {
|
|
81
81
|
case 0:
|
|
82
82
|
multicallContract = curve_1.curve.contracts[this.address].multicallContract;
|
|
83
83
|
lpMulticallContract = curve_1.curve.contracts[this.lpToken].multicallContract;
|
|
@@ -96,25 +96,25 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
96
96
|
}
|
|
97
97
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(calls)];
|
|
98
98
|
case 1:
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
_c = _g.sent(), _lpTokenSupply = _c[0], _virtualPrice = _c[1], _fee = _c[2], _adminFee = _c[3], _A = _c[4], _gamma = _c[5];
|
|
100
|
+
_d = [
|
|
101
101
|
ethers_1.ethers.utils.formatUnits(_lpTokenSupply),
|
|
102
102
|
ethers_1.ethers.utils.formatUnits(_virtualPrice),
|
|
103
103
|
ethers_1.ethers.utils.formatUnits(_fee, 8),
|
|
104
104
|
ethers_1.ethers.utils.formatUnits(_adminFee.mul(_fee)),
|
|
105
105
|
ethers_1.ethers.utils.formatUnits(_A, 0),
|
|
106
106
|
_gamma ? ethers_1.ethers.utils.formatUnits(_gamma) : _gamma,
|
|
107
|
-
], lpTokenSupply =
|
|
107
|
+
], lpTokenSupply = _d[0], virtualPrice = _d[1], fee = _d[2], adminFee = _d[3], A = _d[4], gamma = _d[5];
|
|
108
108
|
A_PRECISION = curve_1.curve.chainId === 1 && ['compound', 'usdt', 'y', 'busd', 'susd', 'pax', 'ren', 'sbtc', 'hbtc', '3pool'].includes(this.id) ? 1 : 100;
|
|
109
109
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(additionalCalls)];
|
|
110
110
|
case 2:
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
_e = _g.sent(), _future_A = _e[0], _initial_A = _e[1], _future_A_time = _e[2], _initial_A_time = _e[3];
|
|
112
|
+
_f = [
|
|
113
113
|
_future_A ? String(Number(ethers_1.ethers.utils.formatUnits(_future_A, 0)) / A_PRECISION) : undefined,
|
|
114
114
|
_initial_A ? String(Number(ethers_1.ethers.utils.formatUnits(_initial_A, 0)) / A_PRECISION) : undefined,
|
|
115
115
|
_future_A_time ? Number(ethers_1.ethers.utils.formatUnits(_future_A_time, 0)) * 1000 : undefined,
|
|
116
116
|
_initial_A_time ? Number(ethers_1.ethers.utils.formatUnits(_initial_A_time, 0)) * 1000 : undefined,
|
|
117
|
-
], future_A =
|
|
117
|
+
], future_A = _f[0], initial_A = _f[1], future_A_time = _f[2], initial_A_time = _f[3];
|
|
118
118
|
return [2 /*return*/, { lpTokenSupply: lpTokenSupply, virtualPrice: virtualPrice, fee: fee, adminFee: adminFee, A: A, future_A: future_A, initial_A: initial_A, future_A_time: future_A_time, initial_A_time: initial_A_time, gamma: gamma }];
|
|
119
119
|
}
|
|
120
120
|
});
|
|
@@ -122,10 +122,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
122
122
|
this.statsTotalLiquidity = function (useApi) {
|
|
123
123
|
if (useApi === void 0) { useApi = true; }
|
|
124
124
|
return __awaiter(_this, void 0, void 0, function () {
|
|
125
|
-
var network, poolType, poolsData, totalLiquidity_1, balances, promises, _i,
|
|
125
|
+
var network, poolType, poolsData, totalLiquidity_1, balances, promises, _i, _c, addr, prices, totalLiquidity;
|
|
126
126
|
var _this = this;
|
|
127
|
-
return __generator(this, function (
|
|
128
|
-
switch (
|
|
127
|
+
return __generator(this, function (_d) {
|
|
128
|
+
switch (_d.label) {
|
|
129
129
|
case 0:
|
|
130
130
|
if (!useApi) return [3 /*break*/, 2];
|
|
131
131
|
network = curve_1.curve.constants.NETWORK_NAME;
|
|
@@ -135,7 +135,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
135
135
|
"factory-crypto";
|
|
136
136
|
return [4 /*yield*/, (0, external_api_1._getPoolsFromApi)(network, poolType)];
|
|
137
137
|
case 1:
|
|
138
|
-
poolsData = (
|
|
138
|
+
poolsData = (_d.sent()).poolData;
|
|
139
139
|
try {
|
|
140
140
|
totalLiquidity_1 = poolsData.filter(function (data) { return data.address.toLowerCase() === _this.address.toLowerCase(); })[0].usdTotal;
|
|
141
141
|
return [2 /*return*/, String(totalLiquidity_1)];
|
|
@@ -143,18 +143,18 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
143
143
|
catch (err) {
|
|
144
144
|
console.log(err.message);
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
_d.label = 2;
|
|
147
147
|
case 2: return [4 /*yield*/, this.statsUnderlyingBalances()];
|
|
148
148
|
case 3:
|
|
149
|
-
balances =
|
|
149
|
+
balances = _d.sent();
|
|
150
150
|
promises = [];
|
|
151
|
-
for (_i = 0,
|
|
152
|
-
addr =
|
|
151
|
+
for (_i = 0, _c = this.underlyingCoinAddresses; _i < _c.length; _i++) {
|
|
152
|
+
addr = _c[_i];
|
|
153
153
|
promises.push((0, utils_1._getUsdRate)(addr));
|
|
154
154
|
}
|
|
155
155
|
return [4 /*yield*/, Promise.all(promises)];
|
|
156
156
|
case 4:
|
|
157
|
-
prices =
|
|
157
|
+
prices = _d.sent();
|
|
158
158
|
totalLiquidity = balances.reduce(function (liquidity, b, i) { return liquidity + (Number(b) * prices[i]); }, 0);
|
|
159
159
|
return [2 /*return*/, totalLiquidity.toFixed(8)];
|
|
160
160
|
}
|
|
@@ -164,13 +164,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
164
164
|
this.statsVolume = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
165
165
|
var network, poolsData, poolData;
|
|
166
166
|
var _this = this;
|
|
167
|
-
return __generator(this, function (
|
|
168
|
-
switch (
|
|
167
|
+
return __generator(this, function (_c) {
|
|
168
|
+
switch (_c.label) {
|
|
169
169
|
case 0:
|
|
170
170
|
network = curve_1.curve.constants.NETWORK_NAME;
|
|
171
171
|
return [4 /*yield*/, (0, external_api_1._getSubgraphData)(network)];
|
|
172
172
|
case 1:
|
|
173
|
-
poolsData = (
|
|
173
|
+
poolsData = (_c.sent());
|
|
174
174
|
poolData = poolsData.find(function (d) { return d.address.toLowerCase() === _this.address; });
|
|
175
175
|
if (!poolData)
|
|
176
176
|
throw Error("Can't get base APY for ".concat(this.name, " (id: ").concat(this.id, ")"));
|
|
@@ -181,13 +181,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
181
181
|
this.statsBaseApy = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
182
182
|
var network, poolsData, poolData;
|
|
183
183
|
var _this = this;
|
|
184
|
-
return __generator(this, function (
|
|
185
|
-
switch (
|
|
184
|
+
return __generator(this, function (_c) {
|
|
185
|
+
switch (_c.label) {
|
|
186
186
|
case 0:
|
|
187
187
|
network = curve_1.curve.constants.NETWORK_NAME;
|
|
188
188
|
return [4 /*yield*/, (0, external_api_1._getSubgraphData)(network)];
|
|
189
189
|
case 1:
|
|
190
|
-
poolsData = (
|
|
190
|
+
poolsData = (_c.sent());
|
|
191
191
|
poolData = poolsData.find(function (d) { return d.address.toLowerCase() === _this.address; });
|
|
192
192
|
if (!poolData)
|
|
193
193
|
throw Error("Can't get base APY for ".concat(this.name, " (id: ").concat(this.id, ")"));
|
|
@@ -199,15 +199,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
199
199
|
});
|
|
200
200
|
}); };
|
|
201
201
|
this.statsTokenApy = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
202
|
-
var totalLiquidityUSD, gaugeContract_1, crvContract, week, currentWeek, inflationRateBN,
|
|
203
|
-
return __generator(this, function (
|
|
204
|
-
switch (
|
|
202
|
+
var totalLiquidityUSD, gaugeContract_1, crvContract, week, currentWeek, inflationRateBN, _c, _d, crvRate_1, apy, gaugeContract, lpTokenContract, gaugeControllerContract, _e, inflation, weight, workingSupply, totalSupply, rate, crvRate, baseApy, boostedApy;
|
|
203
|
+
return __generator(this, function (_f) {
|
|
204
|
+
switch (_f.label) {
|
|
205
205
|
case 0:
|
|
206
206
|
if (this.rewardsOnly())
|
|
207
207
|
throw Error("".concat(this.name, " has Rewards-Only Gauge. Use getRewardsApy instead"));
|
|
208
208
|
return [4 /*yield*/, this.statsTotalLiquidity()];
|
|
209
209
|
case 1:
|
|
210
|
-
totalLiquidityUSD =
|
|
210
|
+
totalLiquidityUSD = _f.sent();
|
|
211
211
|
if (Number(totalLiquidityUSD) === 0)
|
|
212
212
|
return [2 /*return*/, ["0", "0"]];
|
|
213
213
|
if (!(curve_1.curve.chainId !== 1)) return [3 /*break*/, 6];
|
|
@@ -215,19 +215,19 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
215
215
|
crvContract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.crv].contract;
|
|
216
216
|
week = 7 * 86400;
|
|
217
217
|
currentWeek = Math.floor(Date.now() / 1000 / week);
|
|
218
|
-
|
|
218
|
+
_c = utils_1.toBN;
|
|
219
219
|
return [4 /*yield*/, gaugeContract_1.inflation_rate(currentWeek, curve_1.curve.constantOptions)];
|
|
220
220
|
case 2:
|
|
221
|
-
inflationRateBN =
|
|
221
|
+
inflationRateBN = _c.apply(void 0, [_f.sent()]);
|
|
222
222
|
if (!inflationRateBN.eq(0)) return [3 /*break*/, 4];
|
|
223
|
-
|
|
223
|
+
_d = utils_1.toBN;
|
|
224
224
|
return [4 /*yield*/, crvContract.balanceOf(this.gauge, curve_1.curve.constantOptions)];
|
|
225
225
|
case 3:
|
|
226
|
-
inflationRateBN =
|
|
227
|
-
|
|
226
|
+
inflationRateBN = _d.apply(void 0, [_f.sent()]).div(week);
|
|
227
|
+
_f.label = 4;
|
|
228
228
|
case 4: return [4 /*yield*/, (0, utils_1._getUsdRate)(curve_1.curve.constants.ALIASES.crv)];
|
|
229
229
|
case 5:
|
|
230
|
-
crvRate_1 =
|
|
230
|
+
crvRate_1 = _f.sent();
|
|
231
231
|
apy = inflationRateBN.times(31536000).times(crvRate_1).div(Number(totalLiquidityUSD));
|
|
232
232
|
return [2 /*return*/, [apy.times(100).toFixed(4), apy.times(100).toFixed(4)]];
|
|
233
233
|
case 6:
|
|
@@ -241,13 +241,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
241
241
|
lpTokenContract.totalSupply(),
|
|
242
242
|
])];
|
|
243
243
|
case 7:
|
|
244
|
-
|
|
244
|
+
_e = (_f.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), inflation = _e[0], weight = _e[1], workingSupply = _e[2], totalSupply = _e[3];
|
|
245
245
|
if (Number(workingSupply) === 0)
|
|
246
246
|
return [2 /*return*/, ["0", "0"]];
|
|
247
247
|
rate = inflation.times(weight).times(31536000).times(0.4).div(workingSupply).times(totalSupply).div(Number(totalLiquidityUSD));
|
|
248
248
|
return [4 /*yield*/, (0, utils_1._getUsdRate)(curve_1.curve.constants.ALIASES.crv)];
|
|
249
249
|
case 8:
|
|
250
|
-
crvRate =
|
|
250
|
+
crvRate = _f.sent();
|
|
251
251
|
baseApy = rate.times(crvRate);
|
|
252
252
|
boostedApy = baseApy.times(2.5);
|
|
253
253
|
return [2 /*return*/, [baseApy.times(100).toFixed(4), boostedApy.times(100).toFixed(4)]];
|
|
@@ -255,10 +255,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
255
255
|
});
|
|
256
256
|
}); };
|
|
257
257
|
this.statsRewardsApy = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
258
|
-
var apy, rewardTokens, _i, rewardTokens_1, rewardToken, contract, totalLiquidityUSD, rewardRate, rewardData, periodFinish, inflation, baseApy, network, promises,
|
|
259
|
-
var
|
|
260
|
-
return __generator(this, function (
|
|
261
|
-
switch (
|
|
258
|
+
var apy, rewardTokens, _i, rewardTokens_1, rewardToken, contract, totalLiquidityUSD, rewardRate, rewardData, periodFinish, inflation, baseApy, network, promises, _c, mainPoolsRewards, allTypesExtendedPoolData, rewards, _d, _e, extendedPoolData, _f, _g, pool;
|
|
259
|
+
var _h;
|
|
260
|
+
return __generator(this, function (_j) {
|
|
261
|
+
switch (_j.label) {
|
|
262
262
|
case 0:
|
|
263
263
|
if (this.gauge === ethers_1.ethers.constants.AddressZero)
|
|
264
264
|
return [2 /*return*/, []];
|
|
@@ -266,22 +266,22 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
266
266
|
apy = [];
|
|
267
267
|
return [4 /*yield*/, this.rewardTokens()];
|
|
268
268
|
case 1:
|
|
269
|
-
rewardTokens =
|
|
269
|
+
rewardTokens = _j.sent();
|
|
270
270
|
_i = 0, rewardTokens_1 = rewardTokens;
|
|
271
|
-
|
|
271
|
+
_j.label = 2;
|
|
272
272
|
case 2:
|
|
273
273
|
if (!(_i < rewardTokens_1.length)) return [3 /*break*/, 7];
|
|
274
274
|
rewardToken = rewardTokens_1[_i];
|
|
275
275
|
contract = curve_1.curve.contracts[this.sRewardContract || this.gauge].contract;
|
|
276
276
|
return [4 /*yield*/, this.statsTotalLiquidity()];
|
|
277
277
|
case 3:
|
|
278
|
-
totalLiquidityUSD =
|
|
278
|
+
totalLiquidityUSD = _j.sent();
|
|
279
279
|
return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken.token)];
|
|
280
280
|
case 4:
|
|
281
|
-
rewardRate =
|
|
281
|
+
rewardRate = _j.sent();
|
|
282
282
|
return [4 /*yield*/, contract.reward_data(rewardToken.token, curve_1.curve.constantOptions)];
|
|
283
283
|
case 5:
|
|
284
|
-
rewardData =
|
|
284
|
+
rewardData = _j.sent();
|
|
285
285
|
periodFinish = Number(ethers_1.ethers.utils.formatUnits(rewardData.period_finish, 0)) * 1000;
|
|
286
286
|
inflation = (0, utils_1.toBN)(rewardData.rate, rewardToken.decimals);
|
|
287
287
|
baseApy = periodFinish > Date.now() ? inflation.times(31536000).times(rewardRate).div(Number(totalLiquidityUSD)) : (0, utils_1.BN)(0);
|
|
@@ -291,7 +291,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
291
291
|
symbol: rewardToken.symbol,
|
|
292
292
|
apy: Number(baseApy.times(100).toFixed(4)),
|
|
293
293
|
});
|
|
294
|
-
|
|
294
|
+
_j.label = 6;
|
|
295
295
|
case 6:
|
|
296
296
|
_i++;
|
|
297
297
|
return [3 /*break*/, 2];
|
|
@@ -307,18 +307,18 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
307
307
|
];
|
|
308
308
|
return [4 /*yield*/, Promise.all(promises)];
|
|
309
309
|
case 9:
|
|
310
|
-
|
|
310
|
+
_c = _j.sent(), mainPoolsRewards = _c[0], allTypesExtendedPoolData = _c.slice(1);
|
|
311
311
|
rewards = mainPoolsRewards;
|
|
312
|
-
for (
|
|
313
|
-
extendedPoolData = _d
|
|
314
|
-
for (
|
|
315
|
-
pool = _f
|
|
312
|
+
for (_d = 0, _e = allTypesExtendedPoolData; _d < _e.length; _d++) {
|
|
313
|
+
extendedPoolData = _e[_d];
|
|
314
|
+
for (_f = 0, _g = extendedPoolData.poolData; _f < _g.length; _f++) {
|
|
315
|
+
pool = _g[_f];
|
|
316
316
|
if (pool.gaugeAddress && pool.gaugeRewards) {
|
|
317
317
|
rewards[pool.gaugeAddress.toLowerCase()] = pool.gaugeRewards;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
return [2 /*return*/, (
|
|
321
|
+
return [2 /*return*/, (_h = rewards[this.gauge.toLowerCase()]) !== null && _h !== void 0 ? _h : []];
|
|
322
322
|
}
|
|
323
323
|
});
|
|
324
324
|
}); };
|
|
@@ -326,10 +326,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
326
326
|
this.crvProfit = function (address) {
|
|
327
327
|
if (address === void 0) { address = ""; }
|
|
328
328
|
return __awaiter(_this, void 0, void 0, function () {
|
|
329
|
-
var inflationRateBN, workingSupplyBN, workingBalanceBN, gaugeContract, crvContract, currentWeek,
|
|
330
|
-
var
|
|
331
|
-
return __generator(this, function (
|
|
332
|
-
switch (
|
|
329
|
+
var inflationRateBN, workingSupplyBN, workingBalanceBN, gaugeContract, crvContract, currentWeek, _c, gaugeContract, gaugeControllerContract, weightBN, crvPrice, dailyIncome, weeklyIncome, monthlyIncome, annualIncome;
|
|
330
|
+
var _d, _e;
|
|
331
|
+
return __generator(this, function (_f) {
|
|
332
|
+
switch (_f.label) {
|
|
333
333
|
case 0:
|
|
334
334
|
if (this.rewardsOnly())
|
|
335
335
|
throw Error("".concat(this.name, " has Rewards-Only Gauge. Use rewardsProfit instead"));
|
|
@@ -346,13 +346,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
346
346
|
gaugeContract.working_supply(),
|
|
347
347
|
])];
|
|
348
348
|
case 1:
|
|
349
|
-
|
|
349
|
+
_d = (_f.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), inflationRateBN = _d[0], workingBalanceBN = _d[1], workingSupplyBN = _d[2];
|
|
350
350
|
if (!inflationRateBN.eq(0)) return [3 /*break*/, 3];
|
|
351
|
-
|
|
351
|
+
_c = utils_1.toBN;
|
|
352
352
|
return [4 /*yield*/, crvContract.balanceOf(this.gauge, curve_1.curve.constantOptions)];
|
|
353
353
|
case 2:
|
|
354
|
-
inflationRateBN =
|
|
355
|
-
|
|
354
|
+
inflationRateBN = _c.apply(void 0, [_f.sent()]).div(WEEK);
|
|
355
|
+
_f.label = 3;
|
|
356
356
|
case 3: return [3 /*break*/, 6];
|
|
357
357
|
case 4:
|
|
358
358
|
gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
|
|
@@ -365,12 +365,12 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
365
365
|
gaugeContract.working_supply(),
|
|
366
366
|
])];
|
|
367
367
|
case 5:
|
|
368
|
-
|
|
368
|
+
_e = (_f.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), inflationRateBN = _e[0], weightBN = _e[1], workingBalanceBN = _e[2], workingSupplyBN = _e[3];
|
|
369
369
|
inflationRateBN = inflationRateBN.times(weightBN);
|
|
370
|
-
|
|
370
|
+
_f.label = 6;
|
|
371
371
|
case 6: return [4 /*yield*/, (0, utils_1._getUsdRate)('CRV')];
|
|
372
372
|
case 7:
|
|
373
|
-
crvPrice =
|
|
373
|
+
crvPrice = _f.sent();
|
|
374
374
|
if (workingSupplyBN.eq(0))
|
|
375
375
|
return [2 /*return*/, {
|
|
376
376
|
day: "0.0",
|
|
@@ -401,9 +401,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
401
401
|
this.boost = function (address) {
|
|
402
402
|
if (address === void 0) { address = ""; }
|
|
403
403
|
return __awaiter(_this, void 0, void 0, function () {
|
|
404
|
-
var gaugeContract,
|
|
405
|
-
return __generator(this, function (
|
|
406
|
-
switch (
|
|
404
|
+
var gaugeContract, _c, workingBalanceBN, balanceBN, boostBN;
|
|
405
|
+
return __generator(this, function (_d) {
|
|
406
|
+
switch (_d.label) {
|
|
407
407
|
case 0:
|
|
408
408
|
if (curve_1.curve.chainId !== 1)
|
|
409
409
|
throw Error("Boosting is available only on Ethereum network");
|
|
@@ -418,7 +418,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
418
418
|
gaugeContract.balanceOf(address),
|
|
419
419
|
])];
|
|
420
420
|
case 1:
|
|
421
|
-
|
|
421
|
+
_c = (_d.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), workingBalanceBN = _c[0], balanceBN = _c[1];
|
|
422
422
|
boostBN = workingBalanceBN.div(0.4).div(balanceBN);
|
|
423
423
|
return [2 /*return*/, boostBN.toFixed(4).replace(/([0-9])0+$/, '$1')];
|
|
424
424
|
}
|
|
@@ -428,21 +428,21 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
428
428
|
this.currentCrvApy = function (address) {
|
|
429
429
|
if (address === void 0) { address = ""; }
|
|
430
430
|
return __awaiter(_this, void 0, void 0, function () {
|
|
431
|
-
var
|
|
432
|
-
return __generator(this, function (
|
|
433
|
-
switch (
|
|
431
|
+
var _c, baseApy, maxApy, boost;
|
|
432
|
+
return __generator(this, function (_d) {
|
|
433
|
+
switch (_d.label) {
|
|
434
434
|
case 0:
|
|
435
435
|
address = address || curve_1.curve.signerAddress;
|
|
436
436
|
if (!address)
|
|
437
437
|
throw Error("Need to connect wallet or pass address into args");
|
|
438
438
|
return [4 /*yield*/, this.statsTokenApy()];
|
|
439
439
|
case 1:
|
|
440
|
-
|
|
440
|
+
_c = _d.sent(), baseApy = _c[0], maxApy = _c[1];
|
|
441
441
|
if (curve_1.curve.chainId !== 1)
|
|
442
442
|
return [2 /*return*/, baseApy];
|
|
443
443
|
return [4 /*yield*/, this.boost(address)];
|
|
444
444
|
case 2:
|
|
445
|
-
boost =
|
|
445
|
+
boost = _d.sent();
|
|
446
446
|
if (boost == "2.5")
|
|
447
447
|
return [2 /*return*/, maxApy];
|
|
448
448
|
if (boost === "NaN")
|
|
@@ -458,9 +458,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
458
458
|
addresses[_i] = arguments[_i];
|
|
459
459
|
}
|
|
460
460
|
return __awaiter(_this, void 0, void 0, function () {
|
|
461
|
-
var votingEscrowContract, gaugeContract, contractCalls, _response, responseBN,
|
|
462
|
-
return __generator(this, function (
|
|
463
|
-
switch (
|
|
461
|
+
var votingEscrowContract, gaugeContract, contractCalls, _response, responseBN, _c, veTotalSupplyBN, gaugeTotalSupplyBN, resultBN, result, _d, _e, entry;
|
|
462
|
+
return __generator(this, function (_f) {
|
|
463
|
+
switch (_f.label) {
|
|
464
464
|
case 0:
|
|
465
465
|
if (curve_1.curve.chainId !== 1)
|
|
466
466
|
throw Error("Boosting is available only on Ethereum network");
|
|
@@ -480,16 +480,16 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
480
480
|
});
|
|
481
481
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
|
|
482
482
|
case 1:
|
|
483
|
-
_response =
|
|
483
|
+
_response = _f.sent();
|
|
484
484
|
responseBN = _response.map(function (value) { return (0, utils_1.toBN)(value); });
|
|
485
|
-
|
|
485
|
+
_c = responseBN.splice(0, 2), veTotalSupplyBN = _c[0], gaugeTotalSupplyBN = _c[1];
|
|
486
486
|
resultBN = {};
|
|
487
487
|
addresses.forEach(function (acct, i) {
|
|
488
488
|
resultBN[acct] = responseBN[i].div(veTotalSupplyBN).times(gaugeTotalSupplyBN);
|
|
489
489
|
});
|
|
490
490
|
result = {};
|
|
491
|
-
for (
|
|
492
|
-
entry = _d
|
|
491
|
+
for (_d = 0, _e = Object.entries(resultBN); _d < _e.length; _d++) {
|
|
492
|
+
entry = _e[_d];
|
|
493
493
|
result[entry[0]] = (0, utils_1.toStringFromBN)(entry[1]);
|
|
494
494
|
}
|
|
495
495
|
return [2 /*return*/, addresses.length === 1 ? result[addresses[0]] : result];
|
|
@@ -499,9 +499,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
499
499
|
};
|
|
500
500
|
// ---------------- REWARDS PROFIT, CLAIM ----------------
|
|
501
501
|
this.rewardTokens = (0, memoizee_1.default)(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
502
|
-
var gaugeContract, gaugeMulticallContract, rewardCount,
|
|
503
|
-
return __generator(this, function (
|
|
504
|
-
switch (
|
|
502
|
+
var gaugeContract, gaugeMulticallContract, rewardCount, _c, _d, _e, tokenCalls, i, tokens, tokenInfoCalls, _i, tokens_1, token, tokenMulticallContract, tokenInfo_1, i, rewardContract, method, token, tokenMulticallContract, _f, symbol, decimals;
|
|
503
|
+
return __generator(this, function (_g) {
|
|
504
|
+
switch (_g.label) {
|
|
505
505
|
case 0:
|
|
506
506
|
if (this.gauge === ethers_1.ethers.constants.AddressZero)
|
|
507
507
|
return [2 /*return*/, []];
|
|
@@ -510,12 +510,12 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
510
510
|
if (!("reward_tokens(uint256)" in gaugeContract)) return [3 /*break*/, 5];
|
|
511
511
|
rewardCount = 8;
|
|
512
512
|
if (!("reward_count()" in gaugeContract)) return [3 /*break*/, 2];
|
|
513
|
-
|
|
514
|
-
|
|
513
|
+
_c = Number;
|
|
514
|
+
_e = (_d = ethers_1.ethers.utils).formatUnits;
|
|
515
515
|
return [4 /*yield*/, gaugeContract.reward_count(curve_1.curve.constantOptions)];
|
|
516
516
|
case 1:
|
|
517
|
-
rewardCount =
|
|
518
|
-
|
|
517
|
+
rewardCount = _c.apply(void 0, [_e.apply(_d, [_g.sent(), 0])]);
|
|
518
|
+
_g.label = 2;
|
|
519
519
|
case 2:
|
|
520
520
|
tokenCalls = [];
|
|
521
521
|
for (i = 0; i < rewardCount; i++) {
|
|
@@ -523,7 +523,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
523
523
|
}
|
|
524
524
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(tokenCalls)];
|
|
525
525
|
case 3:
|
|
526
|
-
tokens = (
|
|
526
|
+
tokens = (_g.sent())
|
|
527
527
|
.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })
|
|
528
528
|
.map(function (addr) { return addr.toLowerCase(); });
|
|
529
529
|
tokenInfoCalls = [];
|
|
@@ -535,7 +535,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
535
535
|
}
|
|
536
536
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(tokenInfoCalls)];
|
|
537
537
|
case 4:
|
|
538
|
-
tokenInfo_1 =
|
|
538
|
+
tokenInfo_1 = _g.sent();
|
|
539
539
|
for (i = 0; i < tokens.length; i++) {
|
|
540
540
|
curve_1.curve.constants.DECIMALS[tokens[i]] = tokenInfo_1[(i * 2) + 1];
|
|
541
541
|
}
|
|
@@ -547,7 +547,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
547
547
|
;
|
|
548
548
|
return [4 /*yield*/, rewardContract[method](curve_1.curve.constantOptions)];
|
|
549
549
|
case 6:
|
|
550
|
-
token = (
|
|
550
|
+
token = (_g.sent()).toLowerCase();
|
|
551
551
|
(0, utils_1._setContracts)(token, ERC20_json_1.default);
|
|
552
552
|
tokenMulticallContract = curve_1.curve.contracts[token].multicallContract;
|
|
553
553
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all([
|
|
@@ -555,7 +555,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
555
555
|
tokenMulticallContract.decimals(),
|
|
556
556
|
])];
|
|
557
557
|
case 7:
|
|
558
|
-
|
|
558
|
+
_f = _g.sent(), symbol = _f[0], decimals = _f[1];
|
|
559
559
|
return [2 /*return*/, [{ token: token, symbol: symbol, decimals: decimals }]];
|
|
560
560
|
case 8: return [2 /*return*/, []]; // gauge
|
|
561
561
|
}
|
|
@@ -567,9 +567,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
567
567
|
this.rewardsProfit = function (address) {
|
|
568
568
|
if (address === void 0) { address = ""; }
|
|
569
569
|
return __awaiter(_this, void 0, void 0, function () {
|
|
570
|
-
var rewardTokens, gaugeContract, result, calls, _i, rewardTokens_2, rewardToken, res, balanceBN, totalSupplyBN,
|
|
571
|
-
return __generator(this, function (
|
|
572
|
-
switch (
|
|
570
|
+
var rewardTokens, gaugeContract, result, calls, _i, rewardTokens_2, rewardToken, res, balanceBN, totalSupplyBN, _c, rewardTokens_3, rewardToken, _rewardData, periodFinish, inflationRateBN, tokenPrice, rewardToken, sRewardContract, _d, _inflationRate, _periodFinish, _balance, _totalSupply, periodFinish, inflationRateBN, balanceBN, totalSupplyBN, tokenPrice, _e, rewardTokens_4, rewardToken, tokenPrice;
|
|
571
|
+
return __generator(this, function (_f) {
|
|
572
|
+
switch (_f.label) {
|
|
573
573
|
case 0:
|
|
574
574
|
if (this.gauge === ethers_1.ethers.constants.AddressZero)
|
|
575
575
|
throw Error("".concat(this.name, " doesn't have gauge"));
|
|
@@ -578,7 +578,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
578
578
|
throw Error("Need to connect wallet or pass address into args");
|
|
579
579
|
return [4 /*yield*/, this.rewardTokens()];
|
|
580
580
|
case 1:
|
|
581
|
-
rewardTokens =
|
|
581
|
+
rewardTokens = _f.sent();
|
|
582
582
|
gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
|
|
583
583
|
result = [];
|
|
584
584
|
if (!('reward_data(address)' in curve_1.curve.contracts[this.gauge].contract)) return [3 /*break*/, 7];
|
|
@@ -589,20 +589,20 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
589
589
|
}
|
|
590
590
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(calls)];
|
|
591
591
|
case 2:
|
|
592
|
-
res =
|
|
592
|
+
res = _f.sent();
|
|
593
593
|
balanceBN = (0, utils_1.toBN)(res.shift());
|
|
594
594
|
totalSupplyBN = (0, utils_1.toBN)(res.shift());
|
|
595
|
-
|
|
596
|
-
|
|
595
|
+
_c = 0, rewardTokens_3 = rewardTokens;
|
|
596
|
+
_f.label = 3;
|
|
597
597
|
case 3:
|
|
598
|
-
if (!(
|
|
599
|
-
rewardToken = rewardTokens_3[
|
|
598
|
+
if (!(_c < rewardTokens_3.length)) return [3 /*break*/, 6];
|
|
599
|
+
rewardToken = rewardTokens_3[_c];
|
|
600
600
|
_rewardData = res.shift();
|
|
601
601
|
periodFinish = Number(ethers_1.ethers.utils.formatUnits(_rewardData.period_finish, 0)) * 1000;
|
|
602
602
|
inflationRateBN = periodFinish > Date.now() ? (0, utils_1.toBN)(_rewardData.rate, rewardToken.decimals) : (0, utils_1.BN)(0);
|
|
603
603
|
return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken.token)];
|
|
604
604
|
case 4:
|
|
605
|
-
tokenPrice =
|
|
605
|
+
tokenPrice = _f.sent();
|
|
606
606
|
result.push({
|
|
607
607
|
day: inflationRateBN.times(DAY).times(balanceBN).div(totalSupplyBN).toString(),
|
|
608
608
|
week: inflationRateBN.times(WEEK).times(balanceBN).div(totalSupplyBN).toString(),
|
|
@@ -612,9 +612,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
612
612
|
symbol: rewardToken.symbol,
|
|
613
613
|
price: tokenPrice,
|
|
614
614
|
});
|
|
615
|
-
|
|
615
|
+
_f.label = 5;
|
|
616
616
|
case 5:
|
|
617
|
-
|
|
617
|
+
_c++;
|
|
618
618
|
return [3 /*break*/, 3];
|
|
619
619
|
case 6: return [3 /*break*/, 14];
|
|
620
620
|
case 7:
|
|
@@ -628,14 +628,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
628
628
|
gaugeContract.totalSupply(),
|
|
629
629
|
])];
|
|
630
630
|
case 8:
|
|
631
|
-
|
|
631
|
+
_d = _f.sent(), _inflationRate = _d[0], _periodFinish = _d[1], _balance = _d[2], _totalSupply = _d[3];
|
|
632
632
|
periodFinish = Number(ethers_1.ethers.utils.formatUnits(_periodFinish, 0)) * 1000;
|
|
633
633
|
inflationRateBN = periodFinish > Date.now() ? (0, utils_1.toBN)(_inflationRate, rewardToken.decimals) : (0, utils_1.BN)(0);
|
|
634
634
|
balanceBN = (0, utils_1.toBN)(_balance);
|
|
635
635
|
totalSupplyBN = (0, utils_1.toBN)(_totalSupply);
|
|
636
636
|
return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken.token)];
|
|
637
637
|
case 9:
|
|
638
|
-
tokenPrice =
|
|
638
|
+
tokenPrice = _f.sent();
|
|
639
639
|
result.push({
|
|
640
640
|
day: inflationRateBN.times(DAY).times(balanceBN).div(totalSupplyBN).toString(),
|
|
641
641
|
week: inflationRateBN.times(WEEK).times(balanceBN).div(totalSupplyBN).toString(),
|
|
@@ -648,14 +648,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
648
648
|
return [3 /*break*/, 14];
|
|
649
649
|
case 10:
|
|
650
650
|
if (!['aave', 'saave', 'ankreth'].includes(this.id)) return [3 /*break*/, 14];
|
|
651
|
-
|
|
652
|
-
|
|
651
|
+
_e = 0, rewardTokens_4 = rewardTokens;
|
|
652
|
+
_f.label = 11;
|
|
653
653
|
case 11:
|
|
654
|
-
if (!(
|
|
655
|
-
rewardToken = rewardTokens_4[
|
|
654
|
+
if (!(_e < rewardTokens_4.length)) return [3 /*break*/, 14];
|
|
655
|
+
rewardToken = rewardTokens_4[_e];
|
|
656
656
|
return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken.token)];
|
|
657
657
|
case 12:
|
|
658
|
-
tokenPrice =
|
|
658
|
+
tokenPrice = _f.sent();
|
|
659
659
|
result.push({
|
|
660
660
|
day: "0",
|
|
661
661
|
week: "0",
|
|
@@ -665,9 +665,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
665
665
|
symbol: rewardToken.symbol,
|
|
666
666
|
price: tokenPrice,
|
|
667
667
|
});
|
|
668
|
-
|
|
668
|
+
_f.label = 13;
|
|
669
669
|
case 13:
|
|
670
|
-
|
|
670
|
+
_e++;
|
|
671
671
|
return [3 /*break*/, 11];
|
|
672
672
|
case 14: return [2 /*return*/, result];
|
|
673
673
|
}
|
|
@@ -681,9 +681,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
681
681
|
accounts[_i] = arguments[_i];
|
|
682
682
|
}
|
|
683
683
|
return __awaiter(_this, void 0, void 0, function () {
|
|
684
|
-
var votingEscrowContract, lpTokenContract, gaugeContract, contractCalls, _response, response,
|
|
685
|
-
return __generator(this, function (
|
|
686
|
-
switch (
|
|
684
|
+
var votingEscrowContract, lpTokenContract, gaugeContract, contractCalls, _response, response, _c, veTotalSupply, gaugeTotalSupply, votingPower, totalBalance, _d, accounts_1, acct, totalPower, optimalBN, _e, accounts_2, acct, amount, _f, accounts_3, acct, optimal, _g, _h, entry;
|
|
685
|
+
return __generator(this, function (_j) {
|
|
686
|
+
switch (_j.label) {
|
|
687
687
|
case 0:
|
|
688
688
|
if (this.gauge === ethers_1.ethers.constants.AddressZero)
|
|
689
689
|
throw Error("".concat(this.name, " doesn't have gauge"));
|
|
@@ -698,13 +698,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
698
698
|
});
|
|
699
699
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
|
|
700
700
|
case 1:
|
|
701
|
-
_response =
|
|
701
|
+
_response = _j.sent();
|
|
702
702
|
response = _response.map(function (value) { return (0, utils_1.toBN)(value); });
|
|
703
|
-
|
|
703
|
+
_c = response.splice(0, 2), veTotalSupply = _c[0], gaugeTotalSupply = _c[1];
|
|
704
704
|
votingPower = {};
|
|
705
705
|
totalBalance = (0, utils_1.BN)(0);
|
|
706
|
-
for (
|
|
707
|
-
acct = accounts_1[
|
|
706
|
+
for (_d = 0, accounts_1 = accounts; _d < accounts_1.length; _d++) {
|
|
707
|
+
acct = accounts_1[_d];
|
|
708
708
|
votingPower[acct] = response[0];
|
|
709
709
|
totalBalance = totalBalance.plus(response[1]).plus(response[2]);
|
|
710
710
|
response.splice(0, 3);
|
|
@@ -712,8 +712,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
712
712
|
totalPower = Object.values(votingPower).reduce(function (sum, item) { return sum.plus(item); });
|
|
713
713
|
optimalBN = Object.fromEntries(accounts.map(function (acc) { return [acc, (0, utils_1.BN)(0)]; }));
|
|
714
714
|
if (totalBalance.lt(gaugeTotalSupply.times(totalPower).div(veTotalSupply))) {
|
|
715
|
-
for (
|
|
716
|
-
acct = accounts_2[
|
|
715
|
+
for (_e = 0, accounts_2 = accounts; _e < accounts_2.length; _e++) {
|
|
716
|
+
acct = accounts_2[_e];
|
|
717
717
|
amount = gaugeTotalSupply.times(votingPower[acct]).div(veTotalSupply).lt(totalBalance) ?
|
|
718
718
|
gaugeTotalSupply.times(votingPower[acct]).div(veTotalSupply) : totalBalance;
|
|
719
719
|
optimalBN[acct] = amount;
|
|
@@ -725,16 +725,16 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
725
725
|
}
|
|
726
726
|
else {
|
|
727
727
|
if (totalPower.lt(0)) {
|
|
728
|
-
for (
|
|
729
|
-
acct = accounts_3[
|
|
728
|
+
for (_f = 0, accounts_3 = accounts; _f < accounts_3.length; _f++) {
|
|
729
|
+
acct = accounts_3[_f];
|
|
730
730
|
optimalBN[acct] = totalBalance.times(votingPower[acct]).div(totalPower);
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
optimalBN[accounts[0]] = optimalBN[accounts[0]].plus(totalBalance.minus(Object.values(optimalBN).reduce(function (sum, item) { return sum.plus(item); })));
|
|
734
734
|
}
|
|
735
735
|
optimal = {};
|
|
736
|
-
for (
|
|
737
|
-
entry = _g
|
|
736
|
+
for (_g = 0, _h = Object.entries(optimalBN); _g < _h.length; _g++) {
|
|
737
|
+
entry = _h[_g];
|
|
738
738
|
optimal[entry[0]] = (0, utils_1.toStringFromBN)(entry[1]);
|
|
739
739
|
}
|
|
740
740
|
return [2 /*return*/, optimal];
|
|
@@ -769,37 +769,37 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
769
769
|
return idx;
|
|
770
770
|
};
|
|
771
771
|
this._getRates = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
772
|
-
var _rates, i, addr,
|
|
773
|
-
return __generator(this, function (
|
|
774
|
-
switch (
|
|
772
|
+
var _rates, i, addr, _c, _d, _e, _f;
|
|
773
|
+
return __generator(this, function (_g) {
|
|
774
|
+
switch (_g.label) {
|
|
775
775
|
case 0:
|
|
776
776
|
_rates = [];
|
|
777
777
|
i = 0;
|
|
778
|
-
|
|
778
|
+
_g.label = 1;
|
|
779
779
|
case 1:
|
|
780
780
|
if (!(i < this.wrappedCoinAddresses.length)) return [3 /*break*/, 9];
|
|
781
781
|
addr = this.wrappedCoinAddresses[i];
|
|
782
782
|
if (!this.useLending[i]) return [3 /*break*/, 7];
|
|
783
783
|
if (!['compound', 'usdt', 'ib'].includes(this.id)) return [3 /*break*/, 3];
|
|
784
|
-
|
|
784
|
+
_d = (_c = _rates).push;
|
|
785
785
|
return [4 /*yield*/, curve_1.curve.contracts[addr].contract.exchangeRateStored()];
|
|
786
786
|
case 2:
|
|
787
|
-
|
|
787
|
+
_d.apply(_c, [_g.sent()]);
|
|
788
788
|
return [3 /*break*/, 6];
|
|
789
789
|
case 3:
|
|
790
790
|
if (!['y', 'busd', 'pax'].includes(this.id)) return [3 /*break*/, 5];
|
|
791
|
-
|
|
791
|
+
_f = (_e = _rates).push;
|
|
792
792
|
return [4 /*yield*/, curve_1.curve.contracts[addr].contract.getPricePerFullShare()];
|
|
793
793
|
case 4:
|
|
794
|
-
|
|
794
|
+
_f.apply(_e, [_g.sent()]);
|
|
795
795
|
return [3 /*break*/, 6];
|
|
796
796
|
case 5:
|
|
797
797
|
_rates.push(ethers_1.ethers.BigNumber.from(10).pow(18)); // Aave ratio 1:1
|
|
798
|
-
|
|
798
|
+
_g.label = 6;
|
|
799
799
|
case 6: return [3 /*break*/, 8];
|
|
800
800
|
case 7:
|
|
801
801
|
_rates.push(ethers_1.ethers.BigNumber.from(10).pow(18));
|
|
802
|
-
|
|
802
|
+
_g.label = 8;
|
|
803
803
|
case 8:
|
|
804
804
|
i++;
|
|
805
805
|
return [3 /*break*/, 1];
|
|
@@ -813,9 +813,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
813
813
|
addresses[_i - 2] = arguments[_i];
|
|
814
814
|
}
|
|
815
815
|
return __awaiter(_this, void 0, void 0, function () {
|
|
816
|
-
var coinNames, coinAddresses, i, rawBalances, balances,
|
|
817
|
-
return __generator(this, function (
|
|
818
|
-
switch (
|
|
816
|
+
var coinNames, coinAddresses, i, rawBalances, balances, _c, addresses_1, address, _d, coinNames_1, coinName;
|
|
817
|
+
return __generator(this, function (_e) {
|
|
818
|
+
switch (_e.label) {
|
|
819
819
|
case 0:
|
|
820
820
|
coinNames = [];
|
|
821
821
|
coinAddresses = [];
|
|
@@ -829,13 +829,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
829
829
|
addresses = (0, utils_1._prepareAddresses)(addresses);
|
|
830
830
|
return [4 /*yield*/, (0, utils_1._getBalances)(coinAddresses, addresses)];
|
|
831
831
|
case 1:
|
|
832
|
-
rawBalances =
|
|
832
|
+
rawBalances = _e.sent();
|
|
833
833
|
balances = {};
|
|
834
|
-
for (
|
|
835
|
-
address = addresses_1[
|
|
834
|
+
for (_c = 0, addresses_1 = addresses; _c < addresses_1.length; _c++) {
|
|
835
|
+
address = addresses_1[_c];
|
|
836
836
|
balances[address] = {};
|
|
837
|
-
for (
|
|
838
|
-
coinName = coinNames_1[
|
|
837
|
+
for (_d = 0, coinNames_1 = coinNames; _d < coinNames_1.length; _d++) {
|
|
838
|
+
coinName = coinNames_1[_d];
|
|
839
839
|
balances[address][coinName] = rawBalances[address].shift();
|
|
840
840
|
}
|
|
841
841
|
}
|
|
@@ -846,34 +846,34 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
846
846
|
};
|
|
847
847
|
// Used by mixin. Don't delete it!!!
|
|
848
848
|
this._underlyingPrices = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
849
|
-
var promises, _i,
|
|
850
|
-
return __generator(this, function (
|
|
851
|
-
switch (
|
|
849
|
+
var promises, _i, _c, addr;
|
|
850
|
+
return __generator(this, function (_d) {
|
|
851
|
+
switch (_d.label) {
|
|
852
852
|
case 0:
|
|
853
853
|
promises = [];
|
|
854
|
-
for (_i = 0,
|
|
855
|
-
addr =
|
|
854
|
+
for (_i = 0, _c = this.underlyingCoinAddresses; _i < _c.length; _i++) {
|
|
855
|
+
addr = _c[_i];
|
|
856
856
|
promises.push((0, utils_1._getUsdRate)(addr));
|
|
857
857
|
}
|
|
858
858
|
return [4 /*yield*/, Promise.all(promises)];
|
|
859
|
-
case 1: return [2 /*return*/,
|
|
859
|
+
case 1: return [2 /*return*/, _d.sent()];
|
|
860
860
|
}
|
|
861
861
|
});
|
|
862
862
|
}); };
|
|
863
863
|
// Used by mixin. Don't delete it!!!
|
|
864
864
|
// NOTE! It may crash!
|
|
865
865
|
this._wrappedPrices = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
866
|
-
var promises, _i,
|
|
867
|
-
return __generator(this, function (
|
|
868
|
-
switch (
|
|
866
|
+
var promises, _i, _c, addr;
|
|
867
|
+
return __generator(this, function (_d) {
|
|
868
|
+
switch (_d.label) {
|
|
869
869
|
case 0:
|
|
870
870
|
promises = [];
|
|
871
|
-
for (_i = 0,
|
|
872
|
-
addr =
|
|
871
|
+
for (_i = 0, _c = this.wrappedCoinAddresses; _i < _c.length; _i++) {
|
|
872
|
+
addr = _c[_i];
|
|
873
873
|
promises.push((0, utils_1._getUsdRate)(addr));
|
|
874
874
|
}
|
|
875
875
|
return [4 /*yield*/, Promise.all(promises)];
|
|
876
|
-
case 1: return [2 /*return*/,
|
|
876
|
+
case 1: return [2 /*return*/, _d.sent()];
|
|
877
877
|
}
|
|
878
878
|
});
|
|
879
879
|
}); };
|
|
@@ -960,14 +960,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
960
960
|
return __awaiter(this, void 0, void 0, function () {
|
|
961
961
|
var swapContract, contractCalls, _wrappedBalances;
|
|
962
962
|
var _this = this;
|
|
963
|
-
return __generator(this, function (
|
|
964
|
-
switch (
|
|
963
|
+
return __generator(this, function (_c) {
|
|
964
|
+
switch (_c.label) {
|
|
965
965
|
case 0:
|
|
966
966
|
swapContract = curve_1.curve.contracts[this.address].multicallContract;
|
|
967
967
|
contractCalls = this.wrappedCoins.map(function (_, i) { return swapContract.balances(i); });
|
|
968
968
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
|
|
969
969
|
case 1:
|
|
970
|
-
_wrappedBalances =
|
|
970
|
+
_wrappedBalances = _c.sent();
|
|
971
971
|
return [2 /*return*/, _wrappedBalances.map(function (_b, i) { return ethers_1.ethers.utils.formatUnits(_b, _this.wrappedDecimals[i]); })];
|
|
972
972
|
}
|
|
973
973
|
});
|
|
@@ -976,10 +976,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
976
976
|
// OVERRIDE
|
|
977
977
|
PoolTemplate.prototype.statsUnderlyingBalances = function () {
|
|
978
978
|
return __awaiter(this, void 0, void 0, function () {
|
|
979
|
-
return __generator(this, function (
|
|
980
|
-
switch (
|
|
979
|
+
return __generator(this, function (_c) {
|
|
980
|
+
switch (_c.label) {
|
|
981
981
|
case 0: return [4 /*yield*/, this.statsWrappedBalances()];
|
|
982
|
-
case 1: return [2 /*return*/,
|
|
982
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
983
983
|
}
|
|
984
984
|
});
|
|
985
985
|
});
|
|
@@ -988,30 +988,64 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
988
988
|
if (isDeposit === void 0) { isDeposit = true; }
|
|
989
989
|
if (useUnderlying === void 0) { useUnderlying = true; }
|
|
990
990
|
return __awaiter(this, void 0, void 0, function () {
|
|
991
|
-
var _rates_1,
|
|
992
|
-
return __generator(this, function (
|
|
993
|
-
switch (
|
|
991
|
+
var _rates_1, N_coins, decimals, calcContractAddress, calcContract, poolContract, lpContract, calls, res, _c, _totalSupply, _fee, _expected1, balances, _d, totalSupplyBN, feeBN, expected1BN, balancesBN, amountsBN, feesBN, i, _newAmounts, contract;
|
|
992
|
+
return __generator(this, function (_e) {
|
|
993
|
+
switch (_e.label) {
|
|
994
994
|
case 0:
|
|
995
995
|
if (!(!this.isMeta && useUnderlying)) return [3 /*break*/, 2];
|
|
996
996
|
return [4 /*yield*/, this._getRates()];
|
|
997
997
|
case 1:
|
|
998
|
-
_rates_1 =
|
|
998
|
+
_rates_1 = _e.sent();
|
|
999
999
|
_amounts = _amounts.map(function (_amount, i) {
|
|
1000
1000
|
return _amount.mul(ethers_1.ethers.BigNumber.from(10).pow(18)).div(_rates_1[i]);
|
|
1001
1001
|
});
|
|
1002
|
-
|
|
1002
|
+
_e.label = 2;
|
|
1003
1003
|
case 2:
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1004
|
+
N_coins = useUnderlying ? this.underlyingCoins.length : this.wrappedCoins.length;
|
|
1005
|
+
decimals = useUnderlying ? this.underlyingDecimals : this.wrappedDecimals;
|
|
1006
|
+
calcContractAddress = this.isMeta && useUnderlying ? this.zap : this.address;
|
|
1007
|
+
calcContract = curve_1.curve.contracts[calcContractAddress].multicallContract;
|
|
1008
|
+
poolContract = curve_1.curve.contracts[this.address].multicallContract;
|
|
1009
|
+
lpContract = curve_1.curve.contracts[this.lpToken].multicallContract;
|
|
1010
|
+
calls = [lpContract.totalSupply(), poolContract.fee()];
|
|
1011
|
+
// lpAmount before fees
|
|
1012
|
+
if (this.isMetaFactory && useUnderlying) {
|
|
1013
|
+
calls.push(calcContract.calc_token_amount(this.address, _amounts, isDeposit));
|
|
1014
|
+
}
|
|
1015
|
+
else if (calcContract["calc_token_amount(uint256[".concat(N_coins, "],bool)")]) {
|
|
1016
|
+
calls.push(calcContract.calc_token_amount(_amounts, isDeposit, curve_1.curve.constantOptions));
|
|
1017
|
+
}
|
|
1018
|
+
else {
|
|
1019
|
+
calls.push(calcContract.calc_token_amount(_amounts, curve_1.curve.constantOptions));
|
|
1020
|
+
}
|
|
1021
|
+
return [4 /*yield*/, Promise.all([
|
|
1022
|
+
curve_1.curve.multicallProvider.all(calls),
|
|
1023
|
+
useUnderlying ? this.stats.underlyingBalances() : this.stats.wrappedBalances(),
|
|
1024
|
+
])];
|
|
1025
|
+
case 3:
|
|
1026
|
+
res = _e.sent();
|
|
1027
|
+
_c = res[0], _totalSupply = _c[0], _fee = _c[1], _expected1 = _c[2];
|
|
1028
|
+
balances = res[1];
|
|
1029
|
+
_d = [(0, utils_1.toBN)(_totalSupply), (0, utils_1.toBN)(_fee, 10).times(N_coins).div(4 * (N_coins - 1)), (0, utils_1.toBN)(_expected1)], totalSupplyBN = _d[0], feeBN = _d[1], expected1BN = _d[2];
|
|
1030
|
+
balancesBN = balances.map(function (b) { return (0, utils_1.BN)(b); });
|
|
1031
|
+
amountsBN = _amounts.map(function (_a, i) { return (0, utils_1.toBN)(_a, decimals[i]); });
|
|
1032
|
+
feesBN = [];
|
|
1033
|
+
for (i = 0; i < N_coins; i++) {
|
|
1034
|
+
feesBN[i] = balancesBN[i].times(expected1BN).div(totalSupplyBN).minus(amountsBN[i]).times(feeBN);
|
|
1035
|
+
if (feesBN[i].lt(0))
|
|
1036
|
+
feesBN[i] = feesBN[i].times(-1);
|
|
1037
|
+
}
|
|
1038
|
+
_newAmounts = amountsBN.map(function (aBN, i) { return (0, utils_1.fromBN)(isDeposit ? aBN.minus(feesBN[i]) : aBN.plus(feesBN[i]), decimals[i]); });
|
|
1039
|
+
contract = curve_1.curve.contracts[calcContractAddress].contract;
|
|
1040
|
+
if (!(this.isMetaFactory && useUnderlying)) return [3 /*break*/, 5];
|
|
1041
|
+
return [4 /*yield*/, contract.calc_token_amount(this.address, _newAmounts, isDeposit, curve_1.curve.constantOptions)];
|
|
1042
|
+
case 4: return [2 /*return*/, _e.sent()];
|
|
1043
|
+
case 5:
|
|
1044
|
+
if (!contract["calc_token_amount(uint256[".concat(N_coins, "],bool)")]) return [3 /*break*/, 7];
|
|
1045
|
+
return [4 /*yield*/, contract.calc_token_amount(_newAmounts, isDeposit, curve_1.curve.constantOptions)];
|
|
1046
|
+
case 6: return [2 /*return*/, _e.sent()];
|
|
1047
|
+
case 7: return [4 /*yield*/, contract.calc_token_amount(_newAmounts, curve_1.curve.constantOptions)];
|
|
1048
|
+
case 8: return [2 /*return*/, _e.sent()];
|
|
1015
1049
|
}
|
|
1016
1050
|
});
|
|
1017
1051
|
});
|
|
@@ -1021,8 +1055,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1021
1055
|
return __awaiter(this, void 0, void 0, function () {
|
|
1022
1056
|
var _underlyingAmounts, _expected;
|
|
1023
1057
|
var _this = this;
|
|
1024
|
-
return __generator(this, function (
|
|
1025
|
-
switch (
|
|
1058
|
+
return __generator(this, function (_c) {
|
|
1059
|
+
switch (_c.label) {
|
|
1026
1060
|
case 0:
|
|
1027
1061
|
if (amounts.length !== this.underlyingCoinAddresses.length) {
|
|
1028
1062
|
throw Error("".concat(this.name, " pool has ").concat(this.underlyingCoinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
|
|
@@ -1030,7 +1064,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1030
1064
|
_underlyingAmounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, _this.underlyingDecimals[i]); });
|
|
1031
1065
|
return [4 /*yield*/, this._calcLpTokenAmount(_underlyingAmounts, isDeposit, true)];
|
|
1032
1066
|
case 1:
|
|
1033
|
-
_expected =
|
|
1067
|
+
_expected = _c.sent();
|
|
1034
1068
|
return [2 /*return*/, ethers_1.ethers.utils.formatUnits(_expected)];
|
|
1035
1069
|
}
|
|
1036
1070
|
});
|
|
@@ -1041,8 +1075,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1041
1075
|
return __awaiter(this, void 0, void 0, function () {
|
|
1042
1076
|
var _amounts, _expected;
|
|
1043
1077
|
var _this = this;
|
|
1044
|
-
return __generator(this, function (
|
|
1045
|
-
switch (
|
|
1078
|
+
return __generator(this, function (_c) {
|
|
1079
|
+
switch (_c.label) {
|
|
1046
1080
|
case 0:
|
|
1047
1081
|
if (amounts.length !== this.wrappedCoinAddresses.length) {
|
|
1048
1082
|
throw Error("".concat(this.name, " pool has ").concat(this.wrappedCoinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
|
|
@@ -1053,7 +1087,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1053
1087
|
_amounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, _this.wrappedDecimals[i]); });
|
|
1054
1088
|
return [4 /*yield*/, this._calcLpTokenAmount(_amounts, isDeposit, false)];
|
|
1055
1089
|
case 1:
|
|
1056
|
-
_expected =
|
|
1090
|
+
_expected = _c.sent();
|
|
1057
1091
|
return [2 /*return*/, ethers_1.ethers.utils.formatUnits(_expected)];
|
|
1058
1092
|
}
|
|
1059
1093
|
});
|
|
@@ -1062,17 +1096,17 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1062
1096
|
// ---------------- DEPOSIT ----------------
|
|
1063
1097
|
PoolTemplate.prototype.depositBalancedAmounts = function () {
|
|
1064
1098
|
return __awaiter(this, void 0, void 0, function () {
|
|
1065
|
-
return __generator(this, function (
|
|
1099
|
+
return __generator(this, function (_c) {
|
|
1066
1100
|
throw Error("depositBalancedAmounts method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1067
1101
|
});
|
|
1068
1102
|
});
|
|
1069
1103
|
};
|
|
1070
1104
|
PoolTemplate.prototype.depositExpected = function (amounts) {
|
|
1071
1105
|
return __awaiter(this, void 0, void 0, function () {
|
|
1072
|
-
return __generator(this, function (
|
|
1073
|
-
switch (
|
|
1106
|
+
return __generator(this, function (_c) {
|
|
1107
|
+
switch (_c.label) {
|
|
1074
1108
|
case 0: return [4 /*yield*/, this.calcLpTokenAmount(amounts)];
|
|
1075
|
-
case 1: return [2 /*return*/,
|
|
1109
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1076
1110
|
}
|
|
1077
1111
|
});
|
|
1078
1112
|
});
|
|
@@ -1080,37 +1114,37 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1080
1114
|
// OVERRIDE
|
|
1081
1115
|
PoolTemplate.prototype.depositBonus = function (amounts) {
|
|
1082
1116
|
return __awaiter(this, void 0, void 0, function () {
|
|
1083
|
-
return __generator(this, function (
|
|
1117
|
+
return __generator(this, function (_c) {
|
|
1084
1118
|
throw Error("depositBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1085
1119
|
});
|
|
1086
1120
|
});
|
|
1087
1121
|
};
|
|
1088
1122
|
PoolTemplate.prototype.depositIsApproved = function (amounts) {
|
|
1089
1123
|
return __awaiter(this, void 0, void 0, function () {
|
|
1090
|
-
return __generator(this, function (
|
|
1091
|
-
switch (
|
|
1124
|
+
return __generator(this, function (_c) {
|
|
1125
|
+
switch (_c.label) {
|
|
1092
1126
|
case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, this.zap || this.address)];
|
|
1093
|
-
case 1: return [2 /*return*/,
|
|
1127
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1094
1128
|
}
|
|
1095
1129
|
});
|
|
1096
1130
|
});
|
|
1097
1131
|
};
|
|
1098
1132
|
PoolTemplate.prototype.depositApproveEstimateGas = function (amounts) {
|
|
1099
1133
|
return __awaiter(this, void 0, void 0, function () {
|
|
1100
|
-
return __generator(this, function (
|
|
1101
|
-
switch (
|
|
1134
|
+
return __generator(this, function (_c) {
|
|
1135
|
+
switch (_c.label) {
|
|
1102
1136
|
case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, this.zap || this.address)];
|
|
1103
|
-
case 1: return [2 /*return*/,
|
|
1137
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1104
1138
|
}
|
|
1105
1139
|
});
|
|
1106
1140
|
});
|
|
1107
1141
|
};
|
|
1108
1142
|
PoolTemplate.prototype.depositApprove = function (amounts) {
|
|
1109
1143
|
return __awaiter(this, void 0, void 0, function () {
|
|
1110
|
-
return __generator(this, function (
|
|
1111
|
-
switch (
|
|
1144
|
+
return __generator(this, function (_c) {
|
|
1145
|
+
switch (_c.label) {
|
|
1112
1146
|
case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, this.zap || this.address)];
|
|
1113
|
-
case 1: return [2 /*return*/,
|
|
1147
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1114
1148
|
}
|
|
1115
1149
|
});
|
|
1116
1150
|
});
|
|
@@ -1118,7 +1152,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1118
1152
|
// OVERRIDE
|
|
1119
1153
|
PoolTemplate.prototype.depositEstimateGas = function (amounts) {
|
|
1120
1154
|
return __awaiter(this, void 0, void 0, function () {
|
|
1121
|
-
return __generator(this, function (
|
|
1155
|
+
return __generator(this, function (_c) {
|
|
1122
1156
|
throw Error("depositEstimateGas method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1123
1157
|
});
|
|
1124
1158
|
});
|
|
@@ -1127,7 +1161,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1127
1161
|
PoolTemplate.prototype.deposit = function (amounts, slippage) {
|
|
1128
1162
|
if (slippage === void 0) { slippage = 0.5; }
|
|
1129
1163
|
return __awaiter(this, void 0, void 0, function () {
|
|
1130
|
-
return __generator(this, function (
|
|
1164
|
+
return __generator(this, function (_c) {
|
|
1131
1165
|
throw Error("deposit method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1132
1166
|
});
|
|
1133
1167
|
});
|
|
@@ -1135,21 +1169,21 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1135
1169
|
// ---------------- DEPOSIT WRAPPED ----------------
|
|
1136
1170
|
PoolTemplate.prototype.depositWrappedBalancedAmounts = function () {
|
|
1137
1171
|
return __awaiter(this, void 0, void 0, function () {
|
|
1138
|
-
return __generator(this, function (
|
|
1172
|
+
return __generator(this, function (_c) {
|
|
1139
1173
|
throw Error("depositWrappedBalancedAmounts method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1140
1174
|
});
|
|
1141
1175
|
});
|
|
1142
1176
|
};
|
|
1143
1177
|
PoolTemplate.prototype.depositWrappedExpected = function (amounts) {
|
|
1144
1178
|
return __awaiter(this, void 0, void 0, function () {
|
|
1145
|
-
return __generator(this, function (
|
|
1146
|
-
switch (
|
|
1179
|
+
return __generator(this, function (_c) {
|
|
1180
|
+
switch (_c.label) {
|
|
1147
1181
|
case 0:
|
|
1148
1182
|
if (this.isFake) {
|
|
1149
1183
|
throw Error("depositWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1150
1184
|
}
|
|
1151
1185
|
return [4 /*yield*/, this.calcLpTokenAmountWrapped(amounts)];
|
|
1152
|
-
case 1: return [2 /*return*/,
|
|
1186
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1153
1187
|
}
|
|
1154
1188
|
});
|
|
1155
1189
|
});
|
|
@@ -1157,49 +1191,49 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1157
1191
|
// OVERRIDE
|
|
1158
1192
|
PoolTemplate.prototype.depositWrappedBonus = function (amounts) {
|
|
1159
1193
|
return __awaiter(this, void 0, void 0, function () {
|
|
1160
|
-
return __generator(this, function (
|
|
1194
|
+
return __generator(this, function (_c) {
|
|
1161
1195
|
throw Error("depositWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1162
1196
|
});
|
|
1163
1197
|
});
|
|
1164
1198
|
};
|
|
1165
1199
|
PoolTemplate.prototype.depositWrappedIsApproved = function (amounts) {
|
|
1166
1200
|
return __awaiter(this, void 0, void 0, function () {
|
|
1167
|
-
return __generator(this, function (
|
|
1168
|
-
switch (
|
|
1201
|
+
return __generator(this, function (_c) {
|
|
1202
|
+
switch (_c.label) {
|
|
1169
1203
|
case 0:
|
|
1170
1204
|
if (this.isFake) {
|
|
1171
1205
|
throw Error("depositWrappedIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1172
1206
|
}
|
|
1173
1207
|
return [4 /*yield*/, (0, utils_1.hasAllowance)(this.wrappedCoinAddresses, amounts, curve_1.curve.signerAddress, this.address)];
|
|
1174
|
-
case 1: return [2 /*return*/,
|
|
1208
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1175
1209
|
}
|
|
1176
1210
|
});
|
|
1177
1211
|
});
|
|
1178
1212
|
};
|
|
1179
1213
|
PoolTemplate.prototype.depositWrappedApproveEstimateGas = function (amounts) {
|
|
1180
1214
|
return __awaiter(this, void 0, void 0, function () {
|
|
1181
|
-
return __generator(this, function (
|
|
1182
|
-
switch (
|
|
1215
|
+
return __generator(this, function (_c) {
|
|
1216
|
+
switch (_c.label) {
|
|
1183
1217
|
case 0:
|
|
1184
1218
|
if (this.isFake) {
|
|
1185
1219
|
throw Error("depositWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1186
1220
|
}
|
|
1187
1221
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.wrappedCoinAddresses, amounts, this.address)];
|
|
1188
|
-
case 1: return [2 /*return*/,
|
|
1222
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1189
1223
|
}
|
|
1190
1224
|
});
|
|
1191
1225
|
});
|
|
1192
1226
|
};
|
|
1193
1227
|
PoolTemplate.prototype.depositWrappedApprove = function (amounts) {
|
|
1194
1228
|
return __awaiter(this, void 0, void 0, function () {
|
|
1195
|
-
return __generator(this, function (
|
|
1196
|
-
switch (
|
|
1229
|
+
return __generator(this, function (_c) {
|
|
1230
|
+
switch (_c.label) {
|
|
1197
1231
|
case 0:
|
|
1198
1232
|
if (this.isFake) {
|
|
1199
1233
|
throw Error("depositWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1200
1234
|
}
|
|
1201
1235
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.wrappedCoinAddresses, amounts, this.address)];
|
|
1202
|
-
case 1: return [2 /*return*/,
|
|
1236
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1203
1237
|
}
|
|
1204
1238
|
});
|
|
1205
1239
|
});
|
|
@@ -1207,7 +1241,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1207
1241
|
// OVERRIDE
|
|
1208
1242
|
PoolTemplate.prototype.depositWrappedEstimateGas = function (amounts) {
|
|
1209
1243
|
return __awaiter(this, void 0, void 0, function () {
|
|
1210
|
-
return __generator(this, function (
|
|
1244
|
+
return __generator(this, function (_c) {
|
|
1211
1245
|
throw Error("depositWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1212
1246
|
});
|
|
1213
1247
|
});
|
|
@@ -1216,7 +1250,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1216
1250
|
PoolTemplate.prototype.depositWrapped = function (amounts, slippage) {
|
|
1217
1251
|
if (slippage === void 0) { slippage = 0.5; }
|
|
1218
1252
|
return __awaiter(this, void 0, void 0, function () {
|
|
1219
|
-
return __generator(this, function (
|
|
1253
|
+
return __generator(this, function (_c) {
|
|
1220
1254
|
throw Error("depositWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1221
1255
|
});
|
|
1222
1256
|
});
|
|
@@ -1224,42 +1258,42 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1224
1258
|
// ---------------- STAKING ----------------
|
|
1225
1259
|
PoolTemplate.prototype.stakeIsApproved = function (lpTokenAmount) {
|
|
1226
1260
|
return __awaiter(this, void 0, void 0, function () {
|
|
1227
|
-
return __generator(this, function (
|
|
1228
|
-
switch (
|
|
1261
|
+
return __generator(this, function (_c) {
|
|
1262
|
+
switch (_c.label) {
|
|
1229
1263
|
case 0:
|
|
1230
1264
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1231
1265
|
throw Error("stakeIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1232
1266
|
}
|
|
1233
1267
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.gauge)];
|
|
1234
|
-
case 1: return [2 /*return*/,
|
|
1268
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1235
1269
|
}
|
|
1236
1270
|
});
|
|
1237
1271
|
});
|
|
1238
1272
|
};
|
|
1239
1273
|
PoolTemplate.prototype.stakeApproveEstimateGas = function (lpTokenAmount) {
|
|
1240
1274
|
return __awaiter(this, void 0, void 0, function () {
|
|
1241
|
-
return __generator(this, function (
|
|
1242
|
-
switch (
|
|
1275
|
+
return __generator(this, function (_c) {
|
|
1276
|
+
switch (_c.label) {
|
|
1243
1277
|
case 0:
|
|
1244
1278
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1245
1279
|
throw Error("stakeApproveEstimateGas method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1246
1280
|
}
|
|
1247
1281
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.gauge)];
|
|
1248
|
-
case 1: return [2 /*return*/,
|
|
1282
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1249
1283
|
}
|
|
1250
1284
|
});
|
|
1251
1285
|
});
|
|
1252
1286
|
};
|
|
1253
1287
|
PoolTemplate.prototype.stakeApprove = function (lpTokenAmount) {
|
|
1254
1288
|
return __awaiter(this, void 0, void 0, function () {
|
|
1255
|
-
return __generator(this, function (
|
|
1256
|
-
switch (
|
|
1289
|
+
return __generator(this, function (_c) {
|
|
1290
|
+
switch (_c.label) {
|
|
1257
1291
|
case 0:
|
|
1258
1292
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1259
1293
|
throw Error("stakeApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1260
1294
|
}
|
|
1261
1295
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.gauge)];
|
|
1262
|
-
case 1: return [2 /*return*/,
|
|
1296
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1263
1297
|
}
|
|
1264
1298
|
});
|
|
1265
1299
|
});
|
|
@@ -1267,15 +1301,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1267
1301
|
PoolTemplate.prototype.stakeEstimateGas = function (lpTokenAmount) {
|
|
1268
1302
|
return __awaiter(this, void 0, void 0, function () {
|
|
1269
1303
|
var _lpTokenAmount;
|
|
1270
|
-
return __generator(this, function (
|
|
1271
|
-
switch (
|
|
1304
|
+
return __generator(this, function (_c) {
|
|
1305
|
+
switch (_c.label) {
|
|
1272
1306
|
case 0:
|
|
1273
1307
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1274
1308
|
throw Error("stakeEstimateGas method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1275
1309
|
}
|
|
1276
1310
|
_lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
|
|
1277
1311
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
|
|
1278
|
-
case 1: return [2 /*return*/, (
|
|
1312
|
+
case 1: return [2 /*return*/, (_c.sent()).toNumber()];
|
|
1279
1313
|
}
|
|
1280
1314
|
});
|
|
1281
1315
|
});
|
|
@@ -1283,8 +1317,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1283
1317
|
PoolTemplate.prototype.stake = function (lpTokenAmount) {
|
|
1284
1318
|
return __awaiter(this, void 0, void 0, function () {
|
|
1285
1319
|
var _lpTokenAmount, gasLimit;
|
|
1286
|
-
return __generator(this, function (
|
|
1287
|
-
switch (
|
|
1320
|
+
return __generator(this, function (_c) {
|
|
1321
|
+
switch (_c.label) {
|
|
1288
1322
|
case 0:
|
|
1289
1323
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1290
1324
|
throw Error("stake method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1292,12 +1326,12 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1292
1326
|
_lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
|
|
1293
1327
|
return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.gauge)];
|
|
1294
1328
|
case 1:
|
|
1295
|
-
|
|
1329
|
+
_c.sent();
|
|
1296
1330
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
|
|
1297
1331
|
case 2:
|
|
1298
|
-
gasLimit = (
|
|
1332
|
+
gasLimit = (_c.sent()).mul(150).div(100);
|
|
1299
1333
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.deposit(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
|
|
1300
|
-
case 3: return [2 /*return*/, (
|
|
1334
|
+
case 3: return [2 /*return*/, (_c.sent()).hash];
|
|
1301
1335
|
}
|
|
1302
1336
|
});
|
|
1303
1337
|
});
|
|
@@ -1305,15 +1339,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1305
1339
|
PoolTemplate.prototype.unstakeEstimateGas = function (lpTokenAmount) {
|
|
1306
1340
|
return __awaiter(this, void 0, void 0, function () {
|
|
1307
1341
|
var _lpTokenAmount;
|
|
1308
|
-
return __generator(this, function (
|
|
1309
|
-
switch (
|
|
1342
|
+
return __generator(this, function (_c) {
|
|
1343
|
+
switch (_c.label) {
|
|
1310
1344
|
case 0:
|
|
1311
1345
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1312
1346
|
throw Error("unstakeEstimateGas method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1313
1347
|
}
|
|
1314
1348
|
_lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
|
|
1315
1349
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
|
|
1316
|
-
case 1: return [2 /*return*/, (
|
|
1350
|
+
case 1: return [2 /*return*/, (_c.sent()).toNumber()];
|
|
1317
1351
|
}
|
|
1318
1352
|
});
|
|
1319
1353
|
});
|
|
@@ -1321,8 +1355,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1321
1355
|
PoolTemplate.prototype.unstake = function (lpTokenAmount) {
|
|
1322
1356
|
return __awaiter(this, void 0, void 0, function () {
|
|
1323
1357
|
var _lpTokenAmount, gasLimit;
|
|
1324
|
-
return __generator(this, function (
|
|
1325
|
-
switch (
|
|
1358
|
+
return __generator(this, function (_c) {
|
|
1359
|
+
switch (_c.label) {
|
|
1326
1360
|
case 0:
|
|
1327
1361
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1328
1362
|
throw Error("unstake method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1330,9 +1364,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1330
1364
|
_lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
|
|
1331
1365
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
|
|
1332
1366
|
case 1:
|
|
1333
|
-
gasLimit = (
|
|
1367
|
+
gasLimit = (_c.sent()).mul(200).div(100);
|
|
1334
1368
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
|
|
1335
|
-
case 2: return [2 /*return*/, (
|
|
1369
|
+
case 2: return [2 /*return*/, (_c.sent()).hash];
|
|
1336
1370
|
}
|
|
1337
1371
|
});
|
|
1338
1372
|
});
|
|
@@ -1340,31 +1374,31 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1340
1374
|
PoolTemplate.prototype.claimableCrv = function (address) {
|
|
1341
1375
|
if (address === void 0) { address = ""; }
|
|
1342
1376
|
return __awaiter(this, void 0, void 0, function () {
|
|
1343
|
-
var
|
|
1344
|
-
return __generator(this, function (
|
|
1345
|
-
switch (
|
|
1377
|
+
var _c, _d;
|
|
1378
|
+
return __generator(this, function (_e) {
|
|
1379
|
+
switch (_e.label) {
|
|
1346
1380
|
case 0:
|
|
1347
1381
|
if (this.rewardsOnly())
|
|
1348
1382
|
throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimableRewards instead"));
|
|
1349
1383
|
address = address || curve_1.curve.signerAddress;
|
|
1350
1384
|
if (!address)
|
|
1351
1385
|
throw Error("Need to connect wallet or pass address into args");
|
|
1352
|
-
|
|
1386
|
+
_d = (_c = ethers_1.ethers.utils).formatUnits;
|
|
1353
1387
|
return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.claimable_tokens(address, curve_1.curve.constantOptions)];
|
|
1354
|
-
case 1: return [2 /*return*/,
|
|
1388
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_e.sent()])];
|
|
1355
1389
|
}
|
|
1356
1390
|
});
|
|
1357
1391
|
});
|
|
1358
1392
|
};
|
|
1359
1393
|
PoolTemplate.prototype.claimCrvEstimateGas = function () {
|
|
1360
1394
|
return __awaiter(this, void 0, void 0, function () {
|
|
1361
|
-
return __generator(this, function (
|
|
1362
|
-
switch (
|
|
1395
|
+
return __generator(this, function (_c) {
|
|
1396
|
+
switch (_c.label) {
|
|
1363
1397
|
case 0:
|
|
1364
1398
|
if (this.rewardsOnly())
|
|
1365
1399
|
throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
|
|
1366
1400
|
return [4 /*yield*/, curve_1.curve.contracts[curve_1.curve.constants.ALIASES.minter].contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
|
|
1367
|
-
case 1: return [2 /*return*/, (
|
|
1401
|
+
case 1: return [2 /*return*/, (_c.sent()).toNumber()];
|
|
1368
1402
|
}
|
|
1369
1403
|
});
|
|
1370
1404
|
});
|
|
@@ -1372,17 +1406,17 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1372
1406
|
PoolTemplate.prototype.claimCrv = function () {
|
|
1373
1407
|
return __awaiter(this, void 0, void 0, function () {
|
|
1374
1408
|
var contract, gasLimit;
|
|
1375
|
-
return __generator(this, function (
|
|
1376
|
-
switch (
|
|
1409
|
+
return __generator(this, function (_c) {
|
|
1410
|
+
switch (_c.label) {
|
|
1377
1411
|
case 0:
|
|
1378
1412
|
if (this.rewardsOnly())
|
|
1379
1413
|
throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
|
|
1380
1414
|
contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.minter].contract;
|
|
1381
1415
|
return [4 /*yield*/, contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
|
|
1382
1416
|
case 1:
|
|
1383
|
-
gasLimit = (
|
|
1417
|
+
gasLimit = (_c.sent()).mul(130).div(100);
|
|
1384
1418
|
return [4 /*yield*/, contract.mint(this.gauge, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
|
|
1385
|
-
case 2: return [2 /*return*/, (
|
|
1419
|
+
case 2: return [2 /*return*/, (_c.sent()).hash];
|
|
1386
1420
|
}
|
|
1387
1421
|
});
|
|
1388
1422
|
});
|
|
@@ -1392,8 +1426,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1392
1426
|
if (address === void 0) { address = ""; }
|
|
1393
1427
|
return __awaiter(this, void 0, void 0, function () {
|
|
1394
1428
|
var gaugeContract, rewardTokens, rewards, _i, rewardTokens_5, rewardToken, _amount, rewardToken, _totalAmount, _claimedAmount;
|
|
1395
|
-
return __generator(this, function (
|
|
1396
|
-
switch (
|
|
1429
|
+
return __generator(this, function (_c) {
|
|
1430
|
+
switch (_c.label) {
|
|
1397
1431
|
case 0:
|
|
1398
1432
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1399
1433
|
throw Error("claimableRewards method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1404,23 +1438,23 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1404
1438
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1405
1439
|
return [4 /*yield*/, this.rewardTokens()];
|
|
1406
1440
|
case 1:
|
|
1407
|
-
rewardTokens =
|
|
1441
|
+
rewardTokens = _c.sent();
|
|
1408
1442
|
rewards = [];
|
|
1409
1443
|
if (!('claimable_reward(address,address)' in gaugeContract)) return [3 /*break*/, 6];
|
|
1410
1444
|
_i = 0, rewardTokens_5 = rewardTokens;
|
|
1411
|
-
|
|
1445
|
+
_c.label = 2;
|
|
1412
1446
|
case 2:
|
|
1413
1447
|
if (!(_i < rewardTokens_5.length)) return [3 /*break*/, 5];
|
|
1414
1448
|
rewardToken = rewardTokens_5[_i];
|
|
1415
1449
|
return [4 /*yield*/, gaugeContract.claimable_reward(address, rewardToken.token, curve_1.curve.constantOptions)];
|
|
1416
1450
|
case 3:
|
|
1417
|
-
_amount =
|
|
1451
|
+
_amount = _c.sent();
|
|
1418
1452
|
rewards.push({
|
|
1419
1453
|
token: rewardToken.token,
|
|
1420
1454
|
symbol: rewardToken.symbol,
|
|
1421
1455
|
amount: ethers_1.ethers.utils.formatUnits(_amount, rewardToken.decimals),
|
|
1422
1456
|
});
|
|
1423
|
-
|
|
1457
|
+
_c.label = 4;
|
|
1424
1458
|
case 4:
|
|
1425
1459
|
_i++;
|
|
1426
1460
|
return [3 /*break*/, 2];
|
|
@@ -1430,16 +1464,16 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1430
1464
|
rewardToken = rewardTokens[0];
|
|
1431
1465
|
return [4 /*yield*/, gaugeContract.claimable_reward(address, curve_1.curve.constantOptions)];
|
|
1432
1466
|
case 7:
|
|
1433
|
-
_totalAmount =
|
|
1467
|
+
_totalAmount = _c.sent();
|
|
1434
1468
|
return [4 /*yield*/, gaugeContract.claimed_rewards_for(address, curve_1.curve.constantOptions)];
|
|
1435
1469
|
case 8:
|
|
1436
|
-
_claimedAmount =
|
|
1470
|
+
_claimedAmount = _c.sent();
|
|
1437
1471
|
rewards.push({
|
|
1438
1472
|
token: rewardToken.token,
|
|
1439
1473
|
symbol: rewardToken.symbol,
|
|
1440
1474
|
amount: ethers_1.ethers.utils.formatUnits(_totalAmount.sub(_claimedAmount), rewardToken.decimals),
|
|
1441
1475
|
});
|
|
1442
|
-
|
|
1476
|
+
_c.label = 9;
|
|
1443
1477
|
case 9: return [2 /*return*/, rewards];
|
|
1444
1478
|
}
|
|
1445
1479
|
});
|
|
@@ -1448,8 +1482,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1448
1482
|
PoolTemplate.prototype.claimRewardsEstimateGas = function () {
|
|
1449
1483
|
return __awaiter(this, void 0, void 0, function () {
|
|
1450
1484
|
var gaugeContract;
|
|
1451
|
-
return __generator(this, function (
|
|
1452
|
-
switch (
|
|
1485
|
+
return __generator(this, function (_c) {
|
|
1486
|
+
switch (_c.label) {
|
|
1453
1487
|
case 0:
|
|
1454
1488
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1455
1489
|
throw Error("claimRewards method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1458,7 +1492,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1458
1492
|
if (!("claim_rewards()" in gaugeContract))
|
|
1459
1493
|
throw Error("".concat(this.name, " pool doesn't have such method"));
|
|
1460
1494
|
return [4 /*yield*/, gaugeContract.estimateGas.claim_rewards(curve_1.curve.constantOptions)];
|
|
1461
|
-
case 1: return [2 /*return*/, (
|
|
1495
|
+
case 1: return [2 /*return*/, (_c.sent()).toNumber()];
|
|
1462
1496
|
}
|
|
1463
1497
|
});
|
|
1464
1498
|
});
|
|
@@ -1466,8 +1500,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1466
1500
|
PoolTemplate.prototype.claimRewards = function () {
|
|
1467
1501
|
return __awaiter(this, void 0, void 0, function () {
|
|
1468
1502
|
var gaugeContract, gasLimit;
|
|
1469
|
-
return __generator(this, function (
|
|
1470
|
-
switch (
|
|
1503
|
+
return __generator(this, function (_c) {
|
|
1504
|
+
switch (_c.label) {
|
|
1471
1505
|
case 0:
|
|
1472
1506
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1473
1507
|
throw Error("claimRewards method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1477,9 +1511,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1477
1511
|
throw Error("".concat(this.name, " pool doesn't have such method"));
|
|
1478
1512
|
return [4 /*yield*/, gaugeContract.estimateGas.claim_rewards(curve_1.curve.constantOptions)];
|
|
1479
1513
|
case 1:
|
|
1480
|
-
gasLimit = (
|
|
1514
|
+
gasLimit = (_c.sent()).mul(130).div(100);
|
|
1481
1515
|
return [4 /*yield*/, gaugeContract.claim_rewards(__assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
|
|
1482
|
-
case 2: return [2 /*return*/, (
|
|
1516
|
+
case 2: return [2 /*return*/, (_c.sent()).hash];
|
|
1483
1517
|
}
|
|
1484
1518
|
});
|
|
1485
1519
|
});
|
|
@@ -1487,28 +1521,28 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1487
1521
|
// ---------------- DEPOSIT & STAKE ----------------
|
|
1488
1522
|
PoolTemplate.prototype.depositAndStakeExpected = function (amounts) {
|
|
1489
1523
|
return __awaiter(this, void 0, void 0, function () {
|
|
1490
|
-
return __generator(this, function (
|
|
1491
|
-
switch (
|
|
1524
|
+
return __generator(this, function (_c) {
|
|
1525
|
+
switch (_c.label) {
|
|
1492
1526
|
case 0:
|
|
1493
1527
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1494
1528
|
throw Error("depositAndStakeExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1495
1529
|
}
|
|
1496
1530
|
return [4 /*yield*/, this.depositExpected(amounts)];
|
|
1497
|
-
case 1: return [2 /*return*/,
|
|
1531
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1498
1532
|
}
|
|
1499
1533
|
});
|
|
1500
1534
|
});
|
|
1501
1535
|
};
|
|
1502
1536
|
PoolTemplate.prototype.depositAndStakeBonus = function (amounts) {
|
|
1503
1537
|
return __awaiter(this, void 0, void 0, function () {
|
|
1504
|
-
return __generator(this, function (
|
|
1505
|
-
switch (
|
|
1538
|
+
return __generator(this, function (_c) {
|
|
1539
|
+
switch (_c.label) {
|
|
1506
1540
|
case 0:
|
|
1507
1541
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1508
1542
|
throw Error("depositAndStakeBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1509
1543
|
}
|
|
1510
1544
|
return [4 /*yield*/, this.depositBonus(amounts)];
|
|
1511
|
-
case 1: return [2 /*return*/,
|
|
1545
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1512
1546
|
}
|
|
1513
1547
|
});
|
|
1514
1548
|
});
|
|
@@ -1516,20 +1550,20 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1516
1550
|
PoolTemplate.prototype.depositAndStakeIsApproved = function (amounts) {
|
|
1517
1551
|
return __awaiter(this, void 0, void 0, function () {
|
|
1518
1552
|
var coinsAllowance, gaugeContract, gaugeAllowance;
|
|
1519
|
-
return __generator(this, function (
|
|
1520
|
-
switch (
|
|
1553
|
+
return __generator(this, function (_c) {
|
|
1554
|
+
switch (_c.label) {
|
|
1521
1555
|
case 0:
|
|
1522
1556
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1523
1557
|
throw Error("depositAndStakeIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1524
1558
|
}
|
|
1525
1559
|
return [4 /*yield*/, (0, utils_1.hasAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.curve.constants.ALIASES.deposit_and_stake)];
|
|
1526
1560
|
case 1:
|
|
1527
|
-
coinsAllowance =
|
|
1561
|
+
coinsAllowance = _c.sent();
|
|
1528
1562
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1529
1563
|
if (!Object.prototype.hasOwnProperty.call(gaugeContract, 'approved_to_deposit')) return [3 /*break*/, 3];
|
|
1530
1564
|
return [4 /*yield*/, gaugeContract.approved_to_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, curve_1.curve.signerAddress, curve_1.curve.constantOptions)];
|
|
1531
1565
|
case 2:
|
|
1532
|
-
gaugeAllowance =
|
|
1566
|
+
gaugeAllowance = _c.sent();
|
|
1533
1567
|
return [2 /*return*/, coinsAllowance && gaugeAllowance];
|
|
1534
1568
|
case 3: return [2 /*return*/, coinsAllowance];
|
|
1535
1569
|
}
|
|
@@ -1539,24 +1573,24 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1539
1573
|
PoolTemplate.prototype.depositAndStakeApproveEstimateGas = function (amounts) {
|
|
1540
1574
|
return __awaiter(this, void 0, void 0, function () {
|
|
1541
1575
|
var approveCoinsGas, gaugeContract, gaugeAllowance, approveGaugeGas;
|
|
1542
|
-
return __generator(this, function (
|
|
1543
|
-
switch (
|
|
1576
|
+
return __generator(this, function (_c) {
|
|
1577
|
+
switch (_c.label) {
|
|
1544
1578
|
case 0:
|
|
1545
1579
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1546
1580
|
throw Error("depositAndStakeApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1547
1581
|
}
|
|
1548
1582
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.underlyingCoinAddresses, amounts, curve_1.curve.constants.ALIASES.deposit_and_stake)];
|
|
1549
1583
|
case 1:
|
|
1550
|
-
approveCoinsGas =
|
|
1584
|
+
approveCoinsGas = _c.sent();
|
|
1551
1585
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1552
1586
|
if (!Object.prototype.hasOwnProperty.call(gaugeContract, 'approved_to_deposit')) return [3 /*break*/, 4];
|
|
1553
1587
|
return [4 /*yield*/, gaugeContract.approved_to_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, curve_1.curve.signerAddress, curve_1.curve.constantOptions)];
|
|
1554
1588
|
case 2:
|
|
1555
|
-
gaugeAllowance =
|
|
1589
|
+
gaugeAllowance = _c.sent();
|
|
1556
1590
|
if (!!gaugeAllowance) return [3 /*break*/, 4];
|
|
1557
1591
|
return [4 /*yield*/, gaugeContract.estimateGas.set_approve_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, true, curve_1.curve.constantOptions)];
|
|
1558
1592
|
case 3:
|
|
1559
|
-
approveGaugeGas = (
|
|
1593
|
+
approveGaugeGas = (_c.sent()).toNumber();
|
|
1560
1594
|
return [2 /*return*/, approveCoinsGas + approveGaugeGas];
|
|
1561
1595
|
case 4: return [2 /*return*/, approveCoinsGas];
|
|
1562
1596
|
}
|
|
@@ -1566,27 +1600,27 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1566
1600
|
PoolTemplate.prototype.depositAndStakeApprove = function (amounts) {
|
|
1567
1601
|
return __awaiter(this, void 0, void 0, function () {
|
|
1568
1602
|
var approveCoinsTx, gaugeContract, gaugeAllowance, gasLimit, approveGaugeTx;
|
|
1569
|
-
return __generator(this, function (
|
|
1570
|
-
switch (
|
|
1603
|
+
return __generator(this, function (_c) {
|
|
1604
|
+
switch (_c.label) {
|
|
1571
1605
|
case 0:
|
|
1572
1606
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1573
1607
|
throw Error("depositAndStakeApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1574
1608
|
}
|
|
1575
1609
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.underlyingCoinAddresses, amounts, curve_1.curve.constants.ALIASES.deposit_and_stake)];
|
|
1576
1610
|
case 1:
|
|
1577
|
-
approveCoinsTx =
|
|
1611
|
+
approveCoinsTx = _c.sent();
|
|
1578
1612
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1579
1613
|
if (!Object.prototype.hasOwnProperty.call(gaugeContract, 'approved_to_deposit')) return [3 /*break*/, 5];
|
|
1580
1614
|
return [4 /*yield*/, gaugeContract.approved_to_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, curve_1.curve.signerAddress, curve_1.curve.constantOptions)];
|
|
1581
1615
|
case 2:
|
|
1582
|
-
gaugeAllowance =
|
|
1616
|
+
gaugeAllowance = _c.sent();
|
|
1583
1617
|
if (!!gaugeAllowance) return [3 /*break*/, 5];
|
|
1584
1618
|
return [4 /*yield*/, gaugeContract.estimateGas.set_approve_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, true, curve_1.curve.constantOptions)];
|
|
1585
1619
|
case 3:
|
|
1586
|
-
gasLimit = (
|
|
1620
|
+
gasLimit = (_c.sent()).mul(130).div(100);
|
|
1587
1621
|
return [4 /*yield*/, gaugeContract.set_approve_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, true, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
|
|
1588
1622
|
case 4:
|
|
1589
|
-
approveGaugeTx = (
|
|
1623
|
+
approveGaugeTx = (_c.sent()).hash;
|
|
1590
1624
|
return [2 /*return*/, __spreadArray(__spreadArray([], approveCoinsTx, true), [approveGaugeTx], false)];
|
|
1591
1625
|
case 5: return [2 /*return*/, approveCoinsTx];
|
|
1592
1626
|
}
|
|
@@ -1595,28 +1629,28 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1595
1629
|
};
|
|
1596
1630
|
PoolTemplate.prototype.depositAndStakeEstimateGas = function (amounts) {
|
|
1597
1631
|
return __awaiter(this, void 0, void 0, function () {
|
|
1598
|
-
return __generator(this, function (
|
|
1599
|
-
switch (
|
|
1632
|
+
return __generator(this, function (_c) {
|
|
1633
|
+
switch (_c.label) {
|
|
1600
1634
|
case 0:
|
|
1601
1635
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1602
1636
|
throw Error("depositAndStake method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1603
1637
|
}
|
|
1604
1638
|
return [4 /*yield*/, this._depositAndStake(amounts, true, true)];
|
|
1605
|
-
case 1: return [2 /*return*/,
|
|
1639
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1606
1640
|
}
|
|
1607
1641
|
});
|
|
1608
1642
|
});
|
|
1609
1643
|
};
|
|
1610
1644
|
PoolTemplate.prototype.depositAndStake = function (amounts) {
|
|
1611
1645
|
return __awaiter(this, void 0, void 0, function () {
|
|
1612
|
-
return __generator(this, function (
|
|
1613
|
-
switch (
|
|
1646
|
+
return __generator(this, function (_c) {
|
|
1647
|
+
switch (_c.label) {
|
|
1614
1648
|
case 0:
|
|
1615
1649
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1616
1650
|
throw Error("depositAndStake method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1617
1651
|
}
|
|
1618
1652
|
return [4 /*yield*/, this._depositAndStake(amounts, true, false)];
|
|
1619
|
-
case 1: return [2 /*return*/,
|
|
1653
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1620
1654
|
}
|
|
1621
1655
|
});
|
|
1622
1656
|
});
|
|
@@ -1624,8 +1658,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1624
1658
|
// ---------------- DEPOSIT & STAKE WRAPPED ----------------
|
|
1625
1659
|
PoolTemplate.prototype.depositAndStakeWrappedExpected = function (amounts) {
|
|
1626
1660
|
return __awaiter(this, void 0, void 0, function () {
|
|
1627
|
-
return __generator(this, function (
|
|
1628
|
-
switch (
|
|
1661
|
+
return __generator(this, function (_c) {
|
|
1662
|
+
switch (_c.label) {
|
|
1629
1663
|
case 0:
|
|
1630
1664
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1631
1665
|
throw Error("depositAndStakeWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1633,15 +1667,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1633
1667
|
if (this.isPlain || this.isFake)
|
|
1634
1668
|
throw Error("depositAndStakeWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1635
1669
|
return [4 /*yield*/, this.depositWrappedExpected(amounts)];
|
|
1636
|
-
case 1: return [2 /*return*/,
|
|
1670
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1637
1671
|
}
|
|
1638
1672
|
});
|
|
1639
1673
|
});
|
|
1640
1674
|
};
|
|
1641
1675
|
PoolTemplate.prototype.depositAndStakeWrappedBonus = function (amounts) {
|
|
1642
1676
|
return __awaiter(this, void 0, void 0, function () {
|
|
1643
|
-
return __generator(this, function (
|
|
1644
|
-
switch (
|
|
1677
|
+
return __generator(this, function (_c) {
|
|
1678
|
+
switch (_c.label) {
|
|
1645
1679
|
case 0:
|
|
1646
1680
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1647
1681
|
throw Error("depositAndStakeWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1649,7 +1683,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1649
1683
|
if (this.isPlain || this.isFake)
|
|
1650
1684
|
throw Error("depositAndStakeWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1651
1685
|
return [4 /*yield*/, this.depositWrappedBonus(amounts)];
|
|
1652
|
-
case 1: return [2 /*return*/,
|
|
1686
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1653
1687
|
}
|
|
1654
1688
|
});
|
|
1655
1689
|
});
|
|
@@ -1657,8 +1691,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1657
1691
|
PoolTemplate.prototype.depositAndStakeWrappedIsApproved = function (amounts) {
|
|
1658
1692
|
return __awaiter(this, void 0, void 0, function () {
|
|
1659
1693
|
var coinsAllowance, gaugeContract, gaugeAllowance;
|
|
1660
|
-
return __generator(this, function (
|
|
1661
|
-
switch (
|
|
1694
|
+
return __generator(this, function (_c) {
|
|
1695
|
+
switch (_c.label) {
|
|
1662
1696
|
case 0:
|
|
1663
1697
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1664
1698
|
throw Error("depositAndStakeWrappedIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1667,12 +1701,12 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1667
1701
|
throw Error("depositAndStakeWrappedIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1668
1702
|
return [4 /*yield*/, (0, utils_1.hasAllowance)(this.wrappedCoinAddresses, amounts, curve_1.curve.signerAddress, curve_1.curve.constants.ALIASES.deposit_and_stake)];
|
|
1669
1703
|
case 1:
|
|
1670
|
-
coinsAllowance =
|
|
1704
|
+
coinsAllowance = _c.sent();
|
|
1671
1705
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1672
1706
|
if (!Object.prototype.hasOwnProperty.call(gaugeContract, 'approved_to_deposit')) return [3 /*break*/, 3];
|
|
1673
1707
|
return [4 /*yield*/, gaugeContract.approved_to_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, curve_1.curve.signerAddress, curve_1.curve.constantOptions)];
|
|
1674
1708
|
case 2:
|
|
1675
|
-
gaugeAllowance =
|
|
1709
|
+
gaugeAllowance = _c.sent();
|
|
1676
1710
|
return [2 /*return*/, coinsAllowance && gaugeAllowance];
|
|
1677
1711
|
case 3: return [2 /*return*/, coinsAllowance];
|
|
1678
1712
|
}
|
|
@@ -1682,8 +1716,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1682
1716
|
PoolTemplate.prototype.depositAndStakeWrappedApproveEstimateGas = function (amounts) {
|
|
1683
1717
|
return __awaiter(this, void 0, void 0, function () {
|
|
1684
1718
|
var approveCoinsGas, gaugeContract, gaugeAllowance, approveGaugeGas;
|
|
1685
|
-
return __generator(this, function (
|
|
1686
|
-
switch (
|
|
1719
|
+
return __generator(this, function (_c) {
|
|
1720
|
+
switch (_c.label) {
|
|
1687
1721
|
case 0:
|
|
1688
1722
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1689
1723
|
throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1692,16 +1726,16 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1692
1726
|
throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1693
1727
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)(this.wrappedCoinAddresses, amounts, curve_1.curve.constants.ALIASES.deposit_and_stake)];
|
|
1694
1728
|
case 1:
|
|
1695
|
-
approveCoinsGas =
|
|
1729
|
+
approveCoinsGas = _c.sent();
|
|
1696
1730
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1697
1731
|
if (!Object.prototype.hasOwnProperty.call(gaugeContract, 'approved_to_deposit')) return [3 /*break*/, 4];
|
|
1698
1732
|
return [4 /*yield*/, gaugeContract.approved_to_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, curve_1.curve.signerAddress, curve_1.curve.constantOptions)];
|
|
1699
1733
|
case 2:
|
|
1700
|
-
gaugeAllowance =
|
|
1734
|
+
gaugeAllowance = _c.sent();
|
|
1701
1735
|
if (!!gaugeAllowance) return [3 /*break*/, 4];
|
|
1702
1736
|
return [4 /*yield*/, gaugeContract.estimateGas.set_approve_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, true, curve_1.curve.constantOptions)];
|
|
1703
1737
|
case 3:
|
|
1704
|
-
approveGaugeGas = (
|
|
1738
|
+
approveGaugeGas = (_c.sent()).toNumber();
|
|
1705
1739
|
return [2 /*return*/, approveCoinsGas + approveGaugeGas];
|
|
1706
1740
|
case 4: return [2 /*return*/, approveCoinsGas];
|
|
1707
1741
|
}
|
|
@@ -1711,8 +1745,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1711
1745
|
PoolTemplate.prototype.depositAndStakeWrappedApprove = function (amounts) {
|
|
1712
1746
|
return __awaiter(this, void 0, void 0, function () {
|
|
1713
1747
|
var approveCoinsTx, gaugeContract, gaugeAllowance, gasLimit, approveGaugeTx;
|
|
1714
|
-
return __generator(this, function (
|
|
1715
|
-
switch (
|
|
1748
|
+
return __generator(this, function (_c) {
|
|
1749
|
+
switch (_c.label) {
|
|
1716
1750
|
case 0:
|
|
1717
1751
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1718
1752
|
throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1721,19 +1755,19 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1721
1755
|
throw Error("depositAndStakeWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1722
1756
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)(this.wrappedCoinAddresses, amounts, curve_1.curve.constants.ALIASES.deposit_and_stake)];
|
|
1723
1757
|
case 1:
|
|
1724
|
-
approveCoinsTx =
|
|
1758
|
+
approveCoinsTx = _c.sent();
|
|
1725
1759
|
gaugeContract = curve_1.curve.contracts[this.gauge].contract;
|
|
1726
1760
|
if (!Object.prototype.hasOwnProperty.call(gaugeContract, 'approved_to_deposit')) return [3 /*break*/, 5];
|
|
1727
1761
|
return [4 /*yield*/, gaugeContract.approved_to_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, curve_1.curve.signerAddress, curve_1.curve.constantOptions)];
|
|
1728
1762
|
case 2:
|
|
1729
|
-
gaugeAllowance =
|
|
1763
|
+
gaugeAllowance = _c.sent();
|
|
1730
1764
|
if (!!gaugeAllowance) return [3 /*break*/, 5];
|
|
1731
1765
|
return [4 /*yield*/, gaugeContract.estimateGas.set_approve_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, true, curve_1.curve.constantOptions)];
|
|
1732
1766
|
case 3:
|
|
1733
|
-
gasLimit = (
|
|
1767
|
+
gasLimit = (_c.sent()).mul(130).div(100);
|
|
1734
1768
|
return [4 /*yield*/, gaugeContract.set_approve_deposit(curve_1.curve.constants.ALIASES.deposit_and_stake, true, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
|
|
1735
1769
|
case 4:
|
|
1736
|
-
approveGaugeTx = (
|
|
1770
|
+
approveGaugeTx = (_c.sent()).hash;
|
|
1737
1771
|
return [2 /*return*/, __spreadArray(__spreadArray([], approveCoinsTx, true), [approveGaugeTx], false)];
|
|
1738
1772
|
case 5: return [2 /*return*/, approveCoinsTx];
|
|
1739
1773
|
}
|
|
@@ -1742,8 +1776,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1742
1776
|
};
|
|
1743
1777
|
PoolTemplate.prototype.depositAndStakeWrappedEstimateGas = function (amounts) {
|
|
1744
1778
|
return __awaiter(this, void 0, void 0, function () {
|
|
1745
|
-
return __generator(this, function (
|
|
1746
|
-
switch (
|
|
1779
|
+
return __generator(this, function (_c) {
|
|
1780
|
+
switch (_c.label) {
|
|
1747
1781
|
case 0:
|
|
1748
1782
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1749
1783
|
throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1751,15 +1785,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1751
1785
|
if (this.isPlain || this.isFake)
|
|
1752
1786
|
throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1753
1787
|
return [4 /*yield*/, this._depositAndStake(amounts, false, true)];
|
|
1754
|
-
case 1: return [2 /*return*/,
|
|
1788
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1755
1789
|
}
|
|
1756
1790
|
});
|
|
1757
1791
|
});
|
|
1758
1792
|
};
|
|
1759
1793
|
PoolTemplate.prototype.depositAndStakeWrapped = function (amounts) {
|
|
1760
1794
|
return __awaiter(this, void 0, void 0, function () {
|
|
1761
|
-
return __generator(this, function (
|
|
1762
|
-
switch (
|
|
1795
|
+
return __generator(this, function (_c) {
|
|
1796
|
+
switch (_c.label) {
|
|
1763
1797
|
case 0:
|
|
1764
1798
|
if (this.gauge === ethers_1.ethers.constants.AddressZero) {
|
|
1765
1799
|
throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1767,16 +1801,16 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1767
1801
|
if (this.isPlain || this.isFake)
|
|
1768
1802
|
throw Error("depositAndStakeWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1769
1803
|
return [4 /*yield*/, this._depositAndStake(amounts, false, false)];
|
|
1770
|
-
case 1: return [2 /*return*/,
|
|
1804
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1771
1805
|
}
|
|
1772
1806
|
});
|
|
1773
1807
|
});
|
|
1774
1808
|
};
|
|
1775
1809
|
PoolTemplate.prototype._depositAndStake = function (amounts, isUnderlying, estimateGas) {
|
|
1776
1810
|
return __awaiter(this, void 0, void 0, function () {
|
|
1777
|
-
var coinAddresses, coins, decimals, depositAddress, balances,
|
|
1778
|
-
return __generator(this, function (
|
|
1779
|
-
switch (
|
|
1811
|
+
var coinAddresses, coins, decimals, depositAddress, balances, _c, _d, _e, _f, _g, i, allowance, _h, _amounts, contract, useUnderlying, _minMintAmount, _j, _k, _l, _m, _o, ethIndex, value, i, _gas, gasLimit;
|
|
1812
|
+
return __generator(this, function (_p) {
|
|
1813
|
+
switch (_p.label) {
|
|
1780
1814
|
case 0:
|
|
1781
1815
|
coinAddresses = isUnderlying ? __spreadArray([], this.underlyingCoinAddresses, true) : __spreadArray([], this.wrappedCoinAddresses, true);
|
|
1782
1816
|
coins = isUnderlying ? this.underlyingCoins : this.wrappedCoinAddresses;
|
|
@@ -1786,19 +1820,19 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1786
1820
|
throw Error("".concat(this.name, " pool has ").concat(coinAddresses.length, " coins (amounts provided for ").concat(amounts.length, ")"));
|
|
1787
1821
|
}
|
|
1788
1822
|
if (!isUnderlying) return [3 /*break*/, 2];
|
|
1789
|
-
|
|
1823
|
+
_e = (_d = Object).values;
|
|
1790
1824
|
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
1791
1825
|
case 1:
|
|
1792
|
-
|
|
1826
|
+
_c = _e.apply(_d, [_p.sent()]);
|
|
1793
1827
|
return [3 /*break*/, 4];
|
|
1794
1828
|
case 2:
|
|
1795
|
-
|
|
1829
|
+
_g = (_f = Object).values;
|
|
1796
1830
|
return [4 /*yield*/, this.walletWrappedCoinBalances()];
|
|
1797
1831
|
case 3:
|
|
1798
|
-
|
|
1799
|
-
|
|
1832
|
+
_c = _g.apply(_f, [_p.sent()]);
|
|
1833
|
+
_p.label = 4;
|
|
1800
1834
|
case 4:
|
|
1801
|
-
balances =
|
|
1835
|
+
balances = _c;
|
|
1802
1836
|
for (i = 0; i < balances.length; i++) {
|
|
1803
1837
|
if (Number(balances[i]) < Number(amounts[i])) {
|
|
1804
1838
|
throw Error("Not enough ".concat(coins[i], ". Actual: ").concat(balances[i], ", required: ").concat(amounts[i]));
|
|
@@ -1807,14 +1841,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1807
1841
|
if (!isUnderlying) return [3 /*break*/, 6];
|
|
1808
1842
|
return [4 /*yield*/, this.depositAndStakeIsApproved(amounts)];
|
|
1809
1843
|
case 5:
|
|
1810
|
-
|
|
1844
|
+
_h = _p.sent();
|
|
1811
1845
|
return [3 /*break*/, 8];
|
|
1812
1846
|
case 6: return [4 /*yield*/, this.depositAndStakeWrappedIsApproved(amounts)];
|
|
1813
1847
|
case 7:
|
|
1814
|
-
|
|
1815
|
-
|
|
1848
|
+
_h = _p.sent();
|
|
1849
|
+
_p.label = 8;
|
|
1816
1850
|
case 8:
|
|
1817
|
-
allowance =
|
|
1851
|
+
allowance = _h;
|
|
1818
1852
|
if (estimateGas && !allowance) {
|
|
1819
1853
|
throw Error("Token allowance is needed to estimate gas");
|
|
1820
1854
|
}
|
|
@@ -1822,30 +1856,30 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1822
1856
|
if (!isUnderlying) return [3 /*break*/, 10];
|
|
1823
1857
|
return [4 /*yield*/, this.depositAndStakeApprove(amounts)];
|
|
1824
1858
|
case 9:
|
|
1825
|
-
|
|
1859
|
+
_p.sent();
|
|
1826
1860
|
return [3 /*break*/, 12];
|
|
1827
1861
|
case 10: return [4 /*yield*/, this.depositAndStakeWrappedApprove(amounts)];
|
|
1828
1862
|
case 11:
|
|
1829
|
-
|
|
1830
|
-
|
|
1863
|
+
_p.sent();
|
|
1864
|
+
_p.label = 12;
|
|
1831
1865
|
case 12:
|
|
1832
1866
|
_amounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, decimals[i]); });
|
|
1833
1867
|
contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.deposit_and_stake].contract;
|
|
1834
1868
|
useUnderlying = isUnderlying && (this.isLending || (this.isCrypto && !this.isPlain)) && !this.zap;
|
|
1835
1869
|
if (!isUnderlying) return [3 /*break*/, 14];
|
|
1836
|
-
|
|
1870
|
+
_l = (_k = ethers_1.ethers.utils).parseUnits;
|
|
1837
1871
|
return [4 /*yield*/, this.depositAndStakeExpected(amounts)];
|
|
1838
1872
|
case 13:
|
|
1839
|
-
|
|
1873
|
+
_j = _l.apply(_k, [_p.sent()]).mul(99).div(100);
|
|
1840
1874
|
return [3 /*break*/, 16];
|
|
1841
1875
|
case 14:
|
|
1842
|
-
|
|
1876
|
+
_o = (_m = ethers_1.ethers.utils).parseUnits;
|
|
1843
1877
|
return [4 /*yield*/, this.depositAndStakeWrappedExpected(amounts)];
|
|
1844
1878
|
case 15:
|
|
1845
|
-
|
|
1846
|
-
|
|
1879
|
+
_j = _o.apply(_m, [_p.sent()]).mul(99).div(100);
|
|
1880
|
+
_p.label = 16;
|
|
1847
1881
|
case 16:
|
|
1848
|
-
_minMintAmount =
|
|
1882
|
+
_minMintAmount = _j;
|
|
1849
1883
|
ethIndex = (0, utils_1.getEthIndex)(coinAddresses);
|
|
1850
1884
|
value = _amounts[ethIndex] || ethers_1.ethers.BigNumber.from(0);
|
|
1851
1885
|
for (i = 0; i < 5; i++) {
|
|
@@ -1854,15 +1888,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1854
1888
|
}
|
|
1855
1889
|
return [4 /*yield*/, contract.estimateGas.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isMetaFactory && isUnderlying ? this.address : ethers_1.ethers.constants.AddressZero, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
|
|
1856
1890
|
case 17:
|
|
1857
|
-
_gas = (
|
|
1891
|
+
_gas = (_p.sent());
|
|
1858
1892
|
if (estimateGas)
|
|
1859
1893
|
return [2 /*return*/, _gas.toNumber()];
|
|
1860
1894
|
return [4 /*yield*/, curve_1.curve.updateFeeData()];
|
|
1861
1895
|
case 18:
|
|
1862
|
-
|
|
1896
|
+
_p.sent();
|
|
1863
1897
|
gasLimit = _gas.mul(200).div(100);
|
|
1864
1898
|
return [4 /*yield*/, contract.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isMetaFactory && isUnderlying ? this.address : ethers_1.ethers.constants.AddressZero, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit, value: value }))];
|
|
1865
|
-
case 19: return [2 /*return*/, (
|
|
1899
|
+
case 19: return [2 /*return*/, (_p.sent()).hash];
|
|
1866
1900
|
}
|
|
1867
1901
|
});
|
|
1868
1902
|
});
|
|
@@ -1871,46 +1905,46 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1871
1905
|
// OVERRIDE
|
|
1872
1906
|
PoolTemplate.prototype.withdrawExpected = function (lpTokenAmount) {
|
|
1873
1907
|
return __awaiter(this, void 0, void 0, function () {
|
|
1874
|
-
return __generator(this, function (
|
|
1908
|
+
return __generator(this, function (_c) {
|
|
1875
1909
|
throw Error("withdrawExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1876
1910
|
});
|
|
1877
1911
|
});
|
|
1878
1912
|
};
|
|
1879
1913
|
PoolTemplate.prototype.withdrawIsApproved = function (lpTokenAmount) {
|
|
1880
1914
|
return __awaiter(this, void 0, void 0, function () {
|
|
1881
|
-
return __generator(this, function (
|
|
1882
|
-
switch (
|
|
1915
|
+
return __generator(this, function (_c) {
|
|
1916
|
+
switch (_c.label) {
|
|
1883
1917
|
case 0:
|
|
1884
1918
|
if (!this.zap)
|
|
1885
1919
|
return [2 /*return*/, true];
|
|
1886
1920
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.zap)];
|
|
1887
|
-
case 1: return [2 /*return*/,
|
|
1921
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1888
1922
|
}
|
|
1889
1923
|
});
|
|
1890
1924
|
});
|
|
1891
1925
|
};
|
|
1892
1926
|
PoolTemplate.prototype.withdrawApproveEstimateGas = function (lpTokenAmount) {
|
|
1893
1927
|
return __awaiter(this, void 0, void 0, function () {
|
|
1894
|
-
return __generator(this, function (
|
|
1895
|
-
switch (
|
|
1928
|
+
return __generator(this, function (_c) {
|
|
1929
|
+
switch (_c.label) {
|
|
1896
1930
|
case 0:
|
|
1897
1931
|
if (!this.zap)
|
|
1898
1932
|
return [2 /*return*/, 0];
|
|
1899
1933
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.zap)];
|
|
1900
|
-
case 1: return [2 /*return*/,
|
|
1934
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1901
1935
|
}
|
|
1902
1936
|
});
|
|
1903
1937
|
});
|
|
1904
1938
|
};
|
|
1905
1939
|
PoolTemplate.prototype.withdrawApprove = function (lpTokenAmount) {
|
|
1906
1940
|
return __awaiter(this, void 0, void 0, function () {
|
|
1907
|
-
return __generator(this, function (
|
|
1908
|
-
switch (
|
|
1941
|
+
return __generator(this, function (_c) {
|
|
1942
|
+
switch (_c.label) {
|
|
1909
1943
|
case 0:
|
|
1910
1944
|
if (!this.zap)
|
|
1911
1945
|
return [2 /*return*/, []];
|
|
1912
1946
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.zap)];
|
|
1913
|
-
case 1: return [2 /*return*/,
|
|
1947
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1914
1948
|
}
|
|
1915
1949
|
});
|
|
1916
1950
|
});
|
|
@@ -1918,7 +1952,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1918
1952
|
// OVERRIDE
|
|
1919
1953
|
PoolTemplate.prototype.withdrawEstimateGas = function (lpTokenAmount) {
|
|
1920
1954
|
return __awaiter(this, void 0, void 0, function () {
|
|
1921
|
-
return __generator(this, function (
|
|
1955
|
+
return __generator(this, function (_c) {
|
|
1922
1956
|
throw Error("withdraw method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1923
1957
|
});
|
|
1924
1958
|
});
|
|
@@ -1927,7 +1961,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1927
1961
|
PoolTemplate.prototype.withdraw = function (lpTokenAmount, slippage) {
|
|
1928
1962
|
if (slippage === void 0) { slippage = 0.5; }
|
|
1929
1963
|
return __awaiter(this, void 0, void 0, function () {
|
|
1930
|
-
return __generator(this, function (
|
|
1964
|
+
return __generator(this, function (_c) {
|
|
1931
1965
|
throw Error("withdraw method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1932
1966
|
});
|
|
1933
1967
|
});
|
|
@@ -1936,7 +1970,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1936
1970
|
// OVERRIDE
|
|
1937
1971
|
PoolTemplate.prototype.withdrawWrappedExpected = function (lpTokenAmount) {
|
|
1938
1972
|
return __awaiter(this, void 0, void 0, function () {
|
|
1939
|
-
return __generator(this, function (
|
|
1973
|
+
return __generator(this, function (_c) {
|
|
1940
1974
|
throw Error("withdrawWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1941
1975
|
});
|
|
1942
1976
|
});
|
|
@@ -1944,7 +1978,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1944
1978
|
// OVERRIDE
|
|
1945
1979
|
PoolTemplate.prototype.withdrawWrappedEstimateGas = function (lpTokenAmount) {
|
|
1946
1980
|
return __awaiter(this, void 0, void 0, function () {
|
|
1947
|
-
return __generator(this, function (
|
|
1981
|
+
return __generator(this, function (_c) {
|
|
1948
1982
|
throw Error("withdrawWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1949
1983
|
});
|
|
1950
1984
|
});
|
|
@@ -1953,7 +1987,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1953
1987
|
PoolTemplate.prototype.withdrawWrapped = function (lpTokenAmount, slippage) {
|
|
1954
1988
|
if (slippage === void 0) { slippage = 0.5; }
|
|
1955
1989
|
return __awaiter(this, void 0, void 0, function () {
|
|
1956
|
-
return __generator(this, function (
|
|
1990
|
+
return __generator(this, function (_c) {
|
|
1957
1991
|
throw Error("withdrawWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1958
1992
|
});
|
|
1959
1993
|
});
|
|
@@ -1961,13 +1995,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1961
1995
|
// ---------------- WITHDRAW IMBALANCE ----------------
|
|
1962
1996
|
PoolTemplate.prototype.withdrawImbalanceExpected = function (amounts) {
|
|
1963
1997
|
return __awaiter(this, void 0, void 0, function () {
|
|
1964
|
-
return __generator(this, function (
|
|
1965
|
-
switch (
|
|
1998
|
+
return __generator(this, function (_c) {
|
|
1999
|
+
switch (_c.label) {
|
|
1966
2000
|
case 0:
|
|
1967
2001
|
if (this.isCrypto)
|
|
1968
2002
|
throw Error("withdrawImbalanceExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1969
2003
|
return [4 /*yield*/, this.calcLpTokenAmount(amounts, false)];
|
|
1970
|
-
case 1: return [2 /*return*/,
|
|
2004
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
1971
2005
|
}
|
|
1972
2006
|
});
|
|
1973
2007
|
});
|
|
@@ -1975,7 +2009,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1975
2009
|
// OVERRIDE
|
|
1976
2010
|
PoolTemplate.prototype.withdrawImbalanceBonus = function (amounts) {
|
|
1977
2011
|
return __awaiter(this, void 0, void 0, function () {
|
|
1978
|
-
return __generator(this, function (
|
|
2012
|
+
return __generator(this, function (_c) {
|
|
1979
2013
|
throw Error("withdrawImbalanceBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
1980
2014
|
});
|
|
1981
2015
|
});
|
|
@@ -1984,8 +2018,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1984
2018
|
return __awaiter(this, void 0, void 0, function () {
|
|
1985
2019
|
var _amounts, _maxBurnAmount;
|
|
1986
2020
|
var _this = this;
|
|
1987
|
-
return __generator(this, function (
|
|
1988
|
-
switch (
|
|
2021
|
+
return __generator(this, function (_c) {
|
|
2022
|
+
switch (_c.label) {
|
|
1989
2023
|
case 0:
|
|
1990
2024
|
if (this.isCrypto)
|
|
1991
2025
|
throw Error("withdrawImbalanceIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
@@ -1993,9 +2027,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1993
2027
|
_amounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, _this.underlyingDecimals[i]); });
|
|
1994
2028
|
return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false)];
|
|
1995
2029
|
case 1:
|
|
1996
|
-
_maxBurnAmount = (
|
|
2030
|
+
_maxBurnAmount = (_c.sent()).mul(101).div(100);
|
|
1997
2031
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [ethers_1.ethers.utils.formatUnits(_maxBurnAmount, 18)], curve_1.curve.signerAddress, this.zap)];
|
|
1998
|
-
case 2: return [2 /*return*/,
|
|
2032
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
1999
2033
|
case 3: return [2 /*return*/, true];
|
|
2000
2034
|
}
|
|
2001
2035
|
});
|
|
@@ -2005,8 +2039,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2005
2039
|
return __awaiter(this, void 0, void 0, function () {
|
|
2006
2040
|
var _amounts, _maxBurnAmount;
|
|
2007
2041
|
var _this = this;
|
|
2008
|
-
return __generator(this, function (
|
|
2009
|
-
switch (
|
|
2042
|
+
return __generator(this, function (_c) {
|
|
2043
|
+
switch (_c.label) {
|
|
2010
2044
|
case 0:
|
|
2011
2045
|
if (this.isCrypto)
|
|
2012
2046
|
throw Error("withdrawImbalanceApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
@@ -2014,9 +2048,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2014
2048
|
_amounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, _this.underlyingDecimals[i]); });
|
|
2015
2049
|
return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false)];
|
|
2016
2050
|
case 1:
|
|
2017
|
-
_maxBurnAmount = (
|
|
2051
|
+
_maxBurnAmount = (_c.sent()).mul(101).div(100);
|
|
2018
2052
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [ethers_1.ethers.utils.formatUnits(_maxBurnAmount, 18)], this.zap)];
|
|
2019
|
-
case 2: return [2 /*return*/,
|
|
2053
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
2020
2054
|
case 3: return [2 /*return*/, 0];
|
|
2021
2055
|
}
|
|
2022
2056
|
});
|
|
@@ -2026,8 +2060,8 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2026
2060
|
return __awaiter(this, void 0, void 0, function () {
|
|
2027
2061
|
var _amounts, _maxBurnAmount;
|
|
2028
2062
|
var _this = this;
|
|
2029
|
-
return __generator(this, function (
|
|
2030
|
-
switch (
|
|
2063
|
+
return __generator(this, function (_c) {
|
|
2064
|
+
switch (_c.label) {
|
|
2031
2065
|
case 0:
|
|
2032
2066
|
if (this.isCrypto)
|
|
2033
2067
|
throw Error("withdrawImbalanceApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
@@ -2035,9 +2069,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2035
2069
|
_amounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, _this.underlyingDecimals[i]); });
|
|
2036
2070
|
return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false)];
|
|
2037
2071
|
case 1:
|
|
2038
|
-
_maxBurnAmount = (
|
|
2072
|
+
_maxBurnAmount = (_c.sent()).mul(101).div(100);
|
|
2039
2073
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [ethers_1.ethers.utils.formatUnits(_maxBurnAmount, 18)], this.zap)];
|
|
2040
|
-
case 2: return [2 /*return*/,
|
|
2074
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
2041
2075
|
case 3: return [2 /*return*/, []];
|
|
2042
2076
|
}
|
|
2043
2077
|
});
|
|
@@ -2046,7 +2080,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2046
2080
|
// OVERRIDE
|
|
2047
2081
|
PoolTemplate.prototype.withdrawImbalanceEstimateGas = function (amounts) {
|
|
2048
2082
|
return __awaiter(this, void 0, void 0, function () {
|
|
2049
|
-
return __generator(this, function (
|
|
2083
|
+
return __generator(this, function (_c) {
|
|
2050
2084
|
throw Error("withdrawImbalance method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2051
2085
|
});
|
|
2052
2086
|
});
|
|
@@ -2055,7 +2089,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2055
2089
|
PoolTemplate.prototype.withdrawImbalance = function (amounts, slippage) {
|
|
2056
2090
|
if (slippage === void 0) { slippage = 0.5; }
|
|
2057
2091
|
return __awaiter(this, void 0, void 0, function () {
|
|
2058
|
-
return __generator(this, function (
|
|
2092
|
+
return __generator(this, function (_c) {
|
|
2059
2093
|
throw Error("withdrawImbalance method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2060
2094
|
});
|
|
2061
2095
|
});
|
|
@@ -2063,13 +2097,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2063
2097
|
// ---------------- WITHDRAW IMBALANCE WRAPPED ----------------
|
|
2064
2098
|
PoolTemplate.prototype.withdrawImbalanceWrappedExpected = function (amounts) {
|
|
2065
2099
|
return __awaiter(this, void 0, void 0, function () {
|
|
2066
|
-
return __generator(this, function (
|
|
2067
|
-
switch (
|
|
2100
|
+
return __generator(this, function (_c) {
|
|
2101
|
+
switch (_c.label) {
|
|
2068
2102
|
case 0:
|
|
2069
2103
|
if (this.isCrypto)
|
|
2070
2104
|
throw Error("withdrawImbalanceWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2071
2105
|
return [4 /*yield*/, this.calcLpTokenAmountWrapped(amounts, false)];
|
|
2072
|
-
case 1: return [2 /*return*/,
|
|
2106
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2073
2107
|
}
|
|
2074
2108
|
});
|
|
2075
2109
|
});
|
|
@@ -2077,7 +2111,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2077
2111
|
// OVERRIDE
|
|
2078
2112
|
PoolTemplate.prototype.withdrawImbalanceWrappedBonus = function (amounts) {
|
|
2079
2113
|
return __awaiter(this, void 0, void 0, function () {
|
|
2080
|
-
return __generator(this, function (
|
|
2114
|
+
return __generator(this, function (_c) {
|
|
2081
2115
|
throw Error("withdrawImbalanceWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2082
2116
|
});
|
|
2083
2117
|
});
|
|
@@ -2085,7 +2119,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2085
2119
|
// OVERRIDE
|
|
2086
2120
|
PoolTemplate.prototype.withdrawImbalanceWrappedEstimateGas = function (amounts) {
|
|
2087
2121
|
return __awaiter(this, void 0, void 0, function () {
|
|
2088
|
-
return __generator(this, function (
|
|
2122
|
+
return __generator(this, function (_c) {
|
|
2089
2123
|
throw Error("withdrawImbalanceWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2090
2124
|
});
|
|
2091
2125
|
});
|
|
@@ -2094,7 +2128,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2094
2128
|
PoolTemplate.prototype.withdrawImbalanceWrapped = function (amounts, slippage) {
|
|
2095
2129
|
if (slippage === void 0) { slippage = 0.5; }
|
|
2096
2130
|
return __awaiter(this, void 0, void 0, function () {
|
|
2097
|
-
return __generator(this, function (
|
|
2131
|
+
return __generator(this, function (_c) {
|
|
2098
2132
|
throw Error("withdrawImbalanceWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2099
2133
|
});
|
|
2100
2134
|
});
|
|
@@ -2103,7 +2137,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2103
2137
|
// OVERRIDE
|
|
2104
2138
|
PoolTemplate.prototype._withdrawOneCoinExpected = function (_lpTokenAmount, i) {
|
|
2105
2139
|
return __awaiter(this, void 0, void 0, function () {
|
|
2106
|
-
return __generator(this, function (
|
|
2140
|
+
return __generator(this, function (_c) {
|
|
2107
2141
|
throw Error("withdrawOneCoinExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2108
2142
|
});
|
|
2109
2143
|
});
|
|
@@ -2111,14 +2145,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2111
2145
|
PoolTemplate.prototype.withdrawOneCoinExpected = function (lpTokenAmount, coin) {
|
|
2112
2146
|
return __awaiter(this, void 0, void 0, function () {
|
|
2113
2147
|
var i, _lpTokenAmount, _expected;
|
|
2114
|
-
return __generator(this, function (
|
|
2115
|
-
switch (
|
|
2148
|
+
return __generator(this, function (_c) {
|
|
2149
|
+
switch (_c.label) {
|
|
2116
2150
|
case 0:
|
|
2117
2151
|
i = this._getCoinIdx(coin);
|
|
2118
2152
|
_lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
|
|
2119
2153
|
return [4 /*yield*/, this._withdrawOneCoinExpected(_lpTokenAmount, i)];
|
|
2120
2154
|
case 1:
|
|
2121
|
-
_expected =
|
|
2155
|
+
_expected = _c.sent();
|
|
2122
2156
|
return [2 /*return*/, ethers_1.ethers.utils.formatUnits(_expected, this.underlyingDecimals[i])];
|
|
2123
2157
|
}
|
|
2124
2158
|
});
|
|
@@ -2127,46 +2161,46 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2127
2161
|
// OVERRIDE
|
|
2128
2162
|
PoolTemplate.prototype.withdrawOneCoinBonus = function (lpTokenAmount, coin) {
|
|
2129
2163
|
return __awaiter(this, void 0, void 0, function () {
|
|
2130
|
-
return __generator(this, function (
|
|
2164
|
+
return __generator(this, function (_c) {
|
|
2131
2165
|
throw Error("withdrawOneCoinBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2132
2166
|
});
|
|
2133
2167
|
});
|
|
2134
2168
|
};
|
|
2135
2169
|
PoolTemplate.prototype.withdrawOneCoinIsApproved = function (lpTokenAmount) {
|
|
2136
2170
|
return __awaiter(this, void 0, void 0, function () {
|
|
2137
|
-
return __generator(this, function (
|
|
2138
|
-
switch (
|
|
2171
|
+
return __generator(this, function (_c) {
|
|
2172
|
+
switch (_c.label) {
|
|
2139
2173
|
case 0:
|
|
2140
2174
|
if (!this.zap)
|
|
2141
2175
|
return [2 /*return*/, true];
|
|
2142
2176
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([this.lpToken], [lpTokenAmount], curve_1.curve.signerAddress, this.zap)];
|
|
2143
|
-
case 1: return [2 /*return*/,
|
|
2177
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2144
2178
|
}
|
|
2145
2179
|
});
|
|
2146
2180
|
});
|
|
2147
2181
|
};
|
|
2148
2182
|
PoolTemplate.prototype.withdrawOneCoinApproveEstimateGas = function (lpTokenAmount) {
|
|
2149
2183
|
return __awaiter(this, void 0, void 0, function () {
|
|
2150
|
-
return __generator(this, function (
|
|
2151
|
-
switch (
|
|
2184
|
+
return __generator(this, function (_c) {
|
|
2185
|
+
switch (_c.label) {
|
|
2152
2186
|
case 0:
|
|
2153
2187
|
if (!this.zap)
|
|
2154
2188
|
return [2 /*return*/, 0];
|
|
2155
2189
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.lpToken], [lpTokenAmount], this.zap)];
|
|
2156
|
-
case 1: return [2 /*return*/,
|
|
2190
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2157
2191
|
}
|
|
2158
2192
|
});
|
|
2159
2193
|
});
|
|
2160
2194
|
};
|
|
2161
2195
|
PoolTemplate.prototype.withdrawOneCoinApprove = function (lpTokenAmount) {
|
|
2162
2196
|
return __awaiter(this, void 0, void 0, function () {
|
|
2163
|
-
return __generator(this, function (
|
|
2164
|
-
switch (
|
|
2197
|
+
return __generator(this, function (_c) {
|
|
2198
|
+
switch (_c.label) {
|
|
2165
2199
|
case 0:
|
|
2166
2200
|
if (!this.zap)
|
|
2167
2201
|
return [2 /*return*/, []];
|
|
2168
2202
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.lpToken], [lpTokenAmount], this.zap)];
|
|
2169
|
-
case 1: return [2 /*return*/,
|
|
2203
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2170
2204
|
}
|
|
2171
2205
|
});
|
|
2172
2206
|
});
|
|
@@ -2174,7 +2208,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2174
2208
|
// OVERRIDE
|
|
2175
2209
|
PoolTemplate.prototype.withdrawOneCoinEstimateGas = function (lpTokenAmount, coin) {
|
|
2176
2210
|
return __awaiter(this, void 0, void 0, function () {
|
|
2177
|
-
return __generator(this, function (
|
|
2211
|
+
return __generator(this, function (_c) {
|
|
2178
2212
|
throw Error("withdrawOneCoin method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2179
2213
|
});
|
|
2180
2214
|
});
|
|
@@ -2183,7 +2217,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2183
2217
|
PoolTemplate.prototype.withdrawOneCoin = function (lpTokenAmount, coin, slippage) {
|
|
2184
2218
|
if (slippage === void 0) { slippage = 0.5; }
|
|
2185
2219
|
return __awaiter(this, void 0, void 0, function () {
|
|
2186
|
-
return __generator(this, function (
|
|
2220
|
+
return __generator(this, function (_c) {
|
|
2187
2221
|
throw Error("withdrawOneCoin method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2188
2222
|
});
|
|
2189
2223
|
});
|
|
@@ -2192,7 +2226,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2192
2226
|
// OVERRIDE
|
|
2193
2227
|
PoolTemplate.prototype._withdrawOneCoinWrappedExpected = function (_lpTokenAmount, i) {
|
|
2194
2228
|
return __awaiter(this, void 0, void 0, function () {
|
|
2195
|
-
return __generator(this, function (
|
|
2229
|
+
return __generator(this, function (_c) {
|
|
2196
2230
|
throw Error("withdrawOneCoinWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2197
2231
|
});
|
|
2198
2232
|
});
|
|
@@ -2200,14 +2234,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2200
2234
|
PoolTemplate.prototype.withdrawOneCoinWrappedExpected = function (lpTokenAmount, coin) {
|
|
2201
2235
|
return __awaiter(this, void 0, void 0, function () {
|
|
2202
2236
|
var i, _lpTokenAmount, _expected;
|
|
2203
|
-
return __generator(this, function (
|
|
2204
|
-
switch (
|
|
2237
|
+
return __generator(this, function (_c) {
|
|
2238
|
+
switch (_c.label) {
|
|
2205
2239
|
case 0:
|
|
2206
2240
|
i = this._getCoinIdx(coin, false);
|
|
2207
2241
|
_lpTokenAmount = (0, utils_1.parseUnits)(lpTokenAmount);
|
|
2208
2242
|
return [4 /*yield*/, this._withdrawOneCoinWrappedExpected(_lpTokenAmount, i)];
|
|
2209
2243
|
case 1:
|
|
2210
|
-
_expected =
|
|
2244
|
+
_expected = _c.sent();
|
|
2211
2245
|
return [2 /*return*/, ethers_1.ethers.utils.formatUnits(_expected, this.wrappedDecimals[i])];
|
|
2212
2246
|
}
|
|
2213
2247
|
});
|
|
@@ -2216,7 +2250,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2216
2250
|
// OVERRIDE
|
|
2217
2251
|
PoolTemplate.prototype.withdrawOneCoinWrappedBonus = function (lpTokenAmount, coin) {
|
|
2218
2252
|
return __awaiter(this, void 0, void 0, function () {
|
|
2219
|
-
return __generator(this, function (
|
|
2253
|
+
return __generator(this, function (_c) {
|
|
2220
2254
|
throw Error("withdrawOneCoinWrappedBonus method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2221
2255
|
});
|
|
2222
2256
|
});
|
|
@@ -2224,7 +2258,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2224
2258
|
// OVERRIDE
|
|
2225
2259
|
PoolTemplate.prototype.withdrawOneCoinWrappedEstimateGas = function (lpTokenAmount, coin) {
|
|
2226
2260
|
return __awaiter(this, void 0, void 0, function () {
|
|
2227
|
-
return __generator(this, function (
|
|
2261
|
+
return __generator(this, function (_c) {
|
|
2228
2262
|
throw Error("withdrawOneCoinWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2229
2263
|
});
|
|
2230
2264
|
});
|
|
@@ -2233,7 +2267,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2233
2267
|
PoolTemplate.prototype.withdrawOneCoinWrapped = function (lpTokenAmount, coin, slippage) {
|
|
2234
2268
|
if (slippage === void 0) { slippage = 0.5; }
|
|
2235
2269
|
return __awaiter(this, void 0, void 0, function () {
|
|
2236
|
-
return __generator(this, function (
|
|
2270
|
+
return __generator(this, function (_c) {
|
|
2237
2271
|
throw Error("withdrawOneCoinWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2238
2272
|
});
|
|
2239
2273
|
});
|
|
@@ -2245,14 +2279,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2245
2279
|
addresses[_i] = arguments[_i];
|
|
2246
2280
|
}
|
|
2247
2281
|
return __awaiter(this, void 0, void 0, function () {
|
|
2248
|
-
return __generator(this, function (
|
|
2249
|
-
switch (
|
|
2282
|
+
return __generator(this, function (_c) {
|
|
2283
|
+
switch (_c.label) {
|
|
2250
2284
|
case 0:
|
|
2251
2285
|
if (!(this.gauge === ethers_1.ethers.constants.AddressZero)) return [3 /*break*/, 2];
|
|
2252
2286
|
return [4 /*yield*/, this._balances.apply(this, __spreadArray([__spreadArray(__spreadArray(['lpToken'], this.underlyingCoinAddresses, true), this.wrappedCoinAddresses, true), __spreadArray(__spreadArray([this.lpToken], this.underlyingCoinAddresses, true), this.wrappedCoinAddresses, true)], addresses, false))];
|
|
2253
|
-
case 1: return [2 /*return*/,
|
|
2287
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2254
2288
|
case 2: return [4 /*yield*/, this._balances.apply(this, __spreadArray([__spreadArray(__spreadArray(['lpToken', 'gauge'], this.underlyingCoinAddresses, true), this.wrappedCoinAddresses, true), __spreadArray(__spreadArray([this.lpToken, this.gauge], this.underlyingCoinAddresses, true), this.wrappedCoinAddresses, true)], addresses, false))];
|
|
2255
|
-
case 3: return [2 /*return*/,
|
|
2289
|
+
case 3: return [2 /*return*/, _c.sent()];
|
|
2256
2290
|
}
|
|
2257
2291
|
});
|
|
2258
2292
|
});
|
|
@@ -2263,14 +2297,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2263
2297
|
addresses[_i] = arguments[_i];
|
|
2264
2298
|
}
|
|
2265
2299
|
return __awaiter(this, void 0, void 0, function () {
|
|
2266
|
-
return __generator(this, function (
|
|
2267
|
-
switch (
|
|
2300
|
+
return __generator(this, function (_c) {
|
|
2301
|
+
switch (_c.label) {
|
|
2268
2302
|
case 0:
|
|
2269
2303
|
if (!(this.gauge === ethers_1.ethers.constants.AddressZero)) return [3 /*break*/, 2];
|
|
2270
2304
|
return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken'], [this.lpToken]], addresses, false))];
|
|
2271
|
-
case 1: return [2 /*return*/,
|
|
2305
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2272
2306
|
case 2: return [4 /*yield*/, this._balances.apply(this, __spreadArray([['lpToken', 'gauge'], [this.lpToken, this.gauge]], addresses, false))];
|
|
2273
|
-
case 3: return [2 /*return*/,
|
|
2307
|
+
case 3: return [2 /*return*/, _c.sent()];
|
|
2274
2308
|
}
|
|
2275
2309
|
});
|
|
2276
2310
|
});
|
|
@@ -2281,10 +2315,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2281
2315
|
addresses[_i] = arguments[_i];
|
|
2282
2316
|
}
|
|
2283
2317
|
return __awaiter(this, void 0, void 0, function () {
|
|
2284
|
-
return __generator(this, function (
|
|
2285
|
-
switch (
|
|
2318
|
+
return __generator(this, function (_c) {
|
|
2319
|
+
switch (_c.label) {
|
|
2286
2320
|
case 0: return [4 /*yield*/, this._balances.apply(this, __spreadArray([this.underlyingCoinAddresses, this.underlyingCoinAddresses], addresses, false))];
|
|
2287
|
-
case 1: return [2 /*return*/,
|
|
2321
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2288
2322
|
}
|
|
2289
2323
|
});
|
|
2290
2324
|
});
|
|
@@ -2295,10 +2329,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2295
2329
|
addresses[_i] = arguments[_i];
|
|
2296
2330
|
}
|
|
2297
2331
|
return __awaiter(this, void 0, void 0, function () {
|
|
2298
|
-
return __generator(this, function (
|
|
2299
|
-
switch (
|
|
2332
|
+
return __generator(this, function (_c) {
|
|
2333
|
+
switch (_c.label) {
|
|
2300
2334
|
case 0: return [4 /*yield*/, this._balances.apply(this, __spreadArray([this.wrappedCoinAddresses, this.wrappedCoinAddresses], addresses, false))];
|
|
2301
|
-
case 1: return [2 /*return*/,
|
|
2335
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2302
2336
|
}
|
|
2303
2337
|
});
|
|
2304
2338
|
});
|
|
@@ -2309,10 +2343,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2309
2343
|
addresses[_i] = arguments[_i];
|
|
2310
2344
|
}
|
|
2311
2345
|
return __awaiter(this, void 0, void 0, function () {
|
|
2312
|
-
return __generator(this, function (
|
|
2313
|
-
switch (
|
|
2346
|
+
return __generator(this, function (_c) {
|
|
2347
|
+
switch (_c.label) {
|
|
2314
2348
|
case 0: return [4 /*yield*/, this._balances.apply(this, __spreadArray([__spreadArray(__spreadArray([], this.underlyingCoinAddresses, true), this.wrappedCoinAddresses, true), __spreadArray(__spreadArray([], this.underlyingCoinAddresses, true), this.wrappedCoinAddresses, true)], addresses, false))];
|
|
2315
|
-
case 1: return [2 /*return*/,
|
|
2349
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2316
2350
|
}
|
|
2317
2351
|
});
|
|
2318
2352
|
});
|
|
@@ -2321,11 +2355,11 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2321
2355
|
PoolTemplate.prototype._userLpTotalBalance = function (address) {
|
|
2322
2356
|
return __awaiter(this, void 0, void 0, function () {
|
|
2323
2357
|
var lpBalances, lpTotalBalanceBN;
|
|
2324
|
-
return __generator(this, function (
|
|
2325
|
-
switch (
|
|
2358
|
+
return __generator(this, function (_c) {
|
|
2359
|
+
switch (_c.label) {
|
|
2326
2360
|
case 0: return [4 /*yield*/, this.walletLpTokenBalances(address)];
|
|
2327
2361
|
case 1:
|
|
2328
|
-
lpBalances =
|
|
2362
|
+
lpBalances = _c.sent();
|
|
2329
2363
|
lpTotalBalanceBN = (0, utils_1.BN)(lpBalances.lpToken);
|
|
2330
2364
|
if ('gauge' in lpBalances)
|
|
2331
2365
|
lpTotalBalanceBN = lpTotalBalanceBN.plus((0, utils_1.BN)(lpBalances.gauge));
|
|
@@ -2338,17 +2372,17 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2338
2372
|
if (address === void 0) { address = ""; }
|
|
2339
2373
|
return __awaiter(this, void 0, void 0, function () {
|
|
2340
2374
|
var lpTotalBalanceBN;
|
|
2341
|
-
return __generator(this, function (
|
|
2342
|
-
switch (
|
|
2375
|
+
return __generator(this, function (_c) {
|
|
2376
|
+
switch (_c.label) {
|
|
2343
2377
|
case 0:
|
|
2344
2378
|
address = address || curve_1.curve.signerAddress;
|
|
2345
2379
|
if (!address)
|
|
2346
2380
|
throw Error("Need to connect wallet or pass address into args");
|
|
2347
2381
|
return [4 /*yield*/, this._userLpTotalBalance(address)];
|
|
2348
2382
|
case 1:
|
|
2349
|
-
lpTotalBalanceBN =
|
|
2383
|
+
lpTotalBalanceBN = _c.sent();
|
|
2350
2384
|
return [4 /*yield*/, this.withdrawExpected(lpTotalBalanceBN.toString())];
|
|
2351
|
-
case 2: return [2 /*return*/,
|
|
2385
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
2352
2386
|
}
|
|
2353
2387
|
});
|
|
2354
2388
|
});
|
|
@@ -2357,17 +2391,17 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2357
2391
|
if (address === void 0) { address = ""; }
|
|
2358
2392
|
return __awaiter(this, void 0, void 0, function () {
|
|
2359
2393
|
var lpTotalBalanceBN;
|
|
2360
|
-
return __generator(this, function (
|
|
2361
|
-
switch (
|
|
2394
|
+
return __generator(this, function (_c) {
|
|
2395
|
+
switch (_c.label) {
|
|
2362
2396
|
case 0:
|
|
2363
2397
|
address = address || curve_1.curve.signerAddress;
|
|
2364
2398
|
if (!address)
|
|
2365
2399
|
throw Error("Need to connect wallet or pass address into args");
|
|
2366
2400
|
return [4 /*yield*/, this._userLpTotalBalance(address)];
|
|
2367
2401
|
case 1:
|
|
2368
|
-
lpTotalBalanceBN =
|
|
2402
|
+
lpTotalBalanceBN = _c.sent();
|
|
2369
2403
|
return [4 /*yield*/, this.withdrawWrappedExpected(lpTotalBalanceBN.toString())];
|
|
2370
|
-
case 2: return [2 /*return*/,
|
|
2404
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
2371
2405
|
}
|
|
2372
2406
|
});
|
|
2373
2407
|
});
|
|
@@ -2375,20 +2409,20 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2375
2409
|
PoolTemplate.prototype.userLiquidityUSD = function (address) {
|
|
2376
2410
|
if (address === void 0) { address = ""; }
|
|
2377
2411
|
return __awaiter(this, void 0, void 0, function () {
|
|
2378
|
-
var balances, promises, _i,
|
|
2379
|
-
return __generator(this, function (
|
|
2380
|
-
switch (
|
|
2412
|
+
var balances, promises, _i, _c, addr, prices, totalLiquidity;
|
|
2413
|
+
return __generator(this, function (_d) {
|
|
2414
|
+
switch (_d.label) {
|
|
2381
2415
|
case 0: return [4 /*yield*/, this.userBalances(address)];
|
|
2382
2416
|
case 1:
|
|
2383
|
-
balances =
|
|
2417
|
+
balances = _d.sent();
|
|
2384
2418
|
promises = [];
|
|
2385
|
-
for (_i = 0,
|
|
2386
|
-
addr =
|
|
2419
|
+
for (_i = 0, _c = this.underlyingCoinAddresses; _i < _c.length; _i++) {
|
|
2420
|
+
addr = _c[_i];
|
|
2387
2421
|
promises.push((0, utils_1._getUsdRate)(addr));
|
|
2388
2422
|
}
|
|
2389
2423
|
return [4 /*yield*/, Promise.all(promises)];
|
|
2390
2424
|
case 2:
|
|
2391
|
-
prices =
|
|
2425
|
+
prices = _d.sent();
|
|
2392
2426
|
totalLiquidity = balances.reduce(function (liquidity, b, i) { return liquidity + (Number(b) * prices[i]); }, 0);
|
|
2393
2427
|
return [2 /*return*/, totalLiquidity.toFixed(8)];
|
|
2394
2428
|
}
|
|
@@ -2398,19 +2432,19 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2398
2432
|
PoolTemplate.prototype.baseProfit = function (address) {
|
|
2399
2433
|
if (address === void 0) { address = ""; }
|
|
2400
2434
|
return __awaiter(this, void 0, void 0, function () {
|
|
2401
|
-
var apyData, apyBN, totalLiquidityBN,
|
|
2402
|
-
return __generator(this, function (
|
|
2403
|
-
switch (
|
|
2435
|
+
var apyData, apyBN, totalLiquidityBN, _c, annualProfitBN, monthlyProfitBN, weeklyProfitBN, daylyProfitBN;
|
|
2436
|
+
return __generator(this, function (_d) {
|
|
2437
|
+
switch (_d.label) {
|
|
2404
2438
|
case 0: return [4 /*yield*/, this.statsBaseApy()];
|
|
2405
2439
|
case 1:
|
|
2406
|
-
apyData =
|
|
2440
|
+
apyData = _d.sent();
|
|
2407
2441
|
if (!('week' in apyData))
|
|
2408
2442
|
return [2 /*return*/, { day: "0", week: "0", month: "0", year: "0" }];
|
|
2409
2443
|
apyBN = (0, utils_1.BN)(apyData.week).div(100);
|
|
2410
|
-
|
|
2444
|
+
_c = utils_1.BN;
|
|
2411
2445
|
return [4 /*yield*/, this.userLiquidityUSD(address)];
|
|
2412
2446
|
case 2:
|
|
2413
|
-
totalLiquidityBN =
|
|
2447
|
+
totalLiquidityBN = _c.apply(void 0, [_d.sent()]);
|
|
2414
2448
|
annualProfitBN = apyBN.times(totalLiquidityBN);
|
|
2415
2449
|
monthlyProfitBN = annualProfitBN.div(12);
|
|
2416
2450
|
weeklyProfitBN = annualProfitBN.div(52);
|
|
@@ -2428,10 +2462,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2428
2462
|
PoolTemplate.prototype.userShare = function (address) {
|
|
2429
2463
|
if (address === void 0) { address = ""; }
|
|
2430
2464
|
return __awaiter(this, void 0, void 0, function () {
|
|
2431
|
-
var withGauge, userLpBalance, userLpTotalBalanceBN, totalLp, gaugeLp,
|
|
2432
|
-
var
|
|
2433
|
-
return __generator(this, function (
|
|
2434
|
-
switch (
|
|
2465
|
+
var withGauge, userLpBalance, userLpTotalBalanceBN, totalLp, gaugeLp, _c, _d;
|
|
2466
|
+
var _e;
|
|
2467
|
+
return __generator(this, function (_f) {
|
|
2468
|
+
switch (_f.label) {
|
|
2435
2469
|
case 0:
|
|
2436
2470
|
withGauge = this.gauge !== ethers_1.ethers.constants.AddressZero;
|
|
2437
2471
|
address = address || curve_1.curve.signerAddress;
|
|
@@ -2439,7 +2473,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2439
2473
|
throw Error("Need to connect wallet or pass address into args");
|
|
2440
2474
|
return [4 /*yield*/, this.walletLpTokenBalances(address)];
|
|
2441
2475
|
case 1:
|
|
2442
|
-
userLpBalance =
|
|
2476
|
+
userLpBalance = _f.sent();
|
|
2443
2477
|
userLpTotalBalanceBN = (0, utils_1.BN)(userLpBalance.lpToken);
|
|
2444
2478
|
if (withGauge)
|
|
2445
2479
|
userLpTotalBalanceBN = userLpTotalBalanceBN.plus((0, utils_1.BN)(userLpBalance.gauge));
|
|
@@ -2449,14 +2483,14 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2449
2483
|
curve_1.curve.contracts[this.gauge].multicallContract.totalSupply(),
|
|
2450
2484
|
])];
|
|
2451
2485
|
case 2:
|
|
2452
|
-
|
|
2486
|
+
_e = (_f.sent()).map(function (_supply) { return ethers_1.ethers.utils.formatUnits(_supply); }), totalLp = _e[0], gaugeLp = _e[1];
|
|
2453
2487
|
return [3 /*break*/, 5];
|
|
2454
2488
|
case 3:
|
|
2455
|
-
|
|
2489
|
+
_d = (_c = ethers_1.ethers.utils).formatUnits;
|
|
2456
2490
|
return [4 /*yield*/, curve_1.curve.contracts[this.lpToken].contract.totalSupply()];
|
|
2457
2491
|
case 4:
|
|
2458
|
-
totalLp =
|
|
2459
|
-
|
|
2492
|
+
totalLp = _d.apply(_c, [_f.sent()]);
|
|
2493
|
+
_f.label = 5;
|
|
2460
2494
|
case 5: return [2 /*return*/, {
|
|
2461
2495
|
lpUser: userLpTotalBalanceBN.toString(),
|
|
2462
2496
|
lpTotal: totalLp,
|
|
@@ -2473,16 +2507,16 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2473
2507
|
PoolTemplate.prototype._swapExpected = function (i, j, _amount) {
|
|
2474
2508
|
return __awaiter(this, void 0, void 0, function () {
|
|
2475
2509
|
var contractAddress, contract;
|
|
2476
|
-
return __generator(this, function (
|
|
2477
|
-
switch (
|
|
2510
|
+
return __generator(this, function (_c) {
|
|
2511
|
+
switch (_c.label) {
|
|
2478
2512
|
case 0:
|
|
2479
2513
|
contractAddress = this.isCrypto && this.isMeta ? this.zap : this.address;
|
|
2480
2514
|
contract = curve_1.curve.contracts[contractAddress].contract;
|
|
2481
2515
|
if (!Object.prototype.hasOwnProperty.call(contract, 'get_dy_underlying')) return [3 /*break*/, 2];
|
|
2482
2516
|
return [4 /*yield*/, contract.get_dy_underlying(i, j, _amount, curve_1.curve.constantOptions)];
|
|
2483
|
-
case 1: return [2 /*return*/,
|
|
2517
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2484
2518
|
case 2: return [4 /*yield*/, contract.get_dy(i, j, _amount, curve_1.curve.constantOptions)];
|
|
2485
|
-
case 3: return [2 /*return*/,
|
|
2519
|
+
case 3: return [2 /*return*/, _c.sent()];
|
|
2486
2520
|
}
|
|
2487
2521
|
});
|
|
2488
2522
|
});
|
|
@@ -2490,15 +2524,15 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2490
2524
|
PoolTemplate.prototype.swapExpected = function (inputCoin, outputCoin, amount) {
|
|
2491
2525
|
return __awaiter(this, void 0, void 0, function () {
|
|
2492
2526
|
var i, j, _amount, _expected;
|
|
2493
|
-
return __generator(this, function (
|
|
2494
|
-
switch (
|
|
2527
|
+
return __generator(this, function (_c) {
|
|
2528
|
+
switch (_c.label) {
|
|
2495
2529
|
case 0:
|
|
2496
2530
|
i = this._getCoinIdx(inputCoin);
|
|
2497
2531
|
j = this._getCoinIdx(outputCoin);
|
|
2498
2532
|
_amount = (0, utils_1.parseUnits)(amount, this.underlyingDecimals[i]);
|
|
2499
2533
|
return [4 /*yield*/, this._swapExpected(i, j, _amount)];
|
|
2500
2534
|
case 1:
|
|
2501
|
-
_expected =
|
|
2535
|
+
_expected = _c.sent();
|
|
2502
2536
|
return [2 /*return*/, ethers_1.ethers.utils.formatUnits(_expected, this.underlyingDecimals[j])];
|
|
2503
2537
|
}
|
|
2504
2538
|
});
|
|
@@ -2506,17 +2540,17 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2506
2540
|
};
|
|
2507
2541
|
PoolTemplate.prototype.swapPriceImpact = function (inputCoin, outputCoin, amount) {
|
|
2508
2542
|
return __awaiter(this, void 0, void 0, function () {
|
|
2509
|
-
var i, j,
|
|
2510
|
-
return __generator(this, function (
|
|
2511
|
-
switch (
|
|
2543
|
+
var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, target, amountIntBN, outputIntBN, k, smallAmountIntBN, _smallAmount, _smallOutput, amountBN, outputBN, smallAmountBN, smallOutputBN, rateBN, smallRateBN, slippageBN;
|
|
2544
|
+
return __generator(this, function (_d) {
|
|
2545
|
+
switch (_d.label) {
|
|
2512
2546
|
case 0:
|
|
2513
2547
|
i = this._getCoinIdx(inputCoin);
|
|
2514
2548
|
j = this._getCoinIdx(outputCoin);
|
|
2515
|
-
|
|
2549
|
+
_c = [this.underlyingDecimals[i], this.underlyingDecimals[j]], inputCoinDecimals = _c[0], outputCoinDecimals = _c[1];
|
|
2516
2550
|
_amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
|
|
2517
2551
|
return [4 /*yield*/, this._swapExpected(i, j, _amount)];
|
|
2518
2552
|
case 1:
|
|
2519
|
-
_output =
|
|
2553
|
+
_output = _d.sent();
|
|
2520
2554
|
target = (0, utils_1.BN)(Math.pow(10, 15));
|
|
2521
2555
|
amountIntBN = (0, utils_1.BN)(amount).times(Math.pow(10, inputCoinDecimals));
|
|
2522
2556
|
outputIntBN = (0, utils_1.toBN)(_output, 0);
|
|
@@ -2527,7 +2561,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2527
2561
|
_smallAmount = (0, utils_1.fromBN)(smallAmountIntBN.div(Math.pow(10, inputCoinDecimals)), inputCoinDecimals);
|
|
2528
2562
|
return [4 /*yield*/, this._swapExpected(i, j, _smallAmount)];
|
|
2529
2563
|
case 2:
|
|
2530
|
-
_smallOutput =
|
|
2564
|
+
_smallOutput = _d.sent();
|
|
2531
2565
|
amountBN = (0, utils_1.BN)(amount);
|
|
2532
2566
|
outputBN = (0, utils_1.toBN)(_output, outputCoinDecimals);
|
|
2533
2567
|
smallAmountBN = (0, utils_1.toBN)(_smallAmount, inputCoinDecimals);
|
|
@@ -2546,13 +2580,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2546
2580
|
PoolTemplate.prototype.swapIsApproved = function (inputCoin, amount) {
|
|
2547
2581
|
return __awaiter(this, void 0, void 0, function () {
|
|
2548
2582
|
var contractAddress, i;
|
|
2549
|
-
return __generator(this, function (
|
|
2550
|
-
switch (
|
|
2583
|
+
return __generator(this, function (_c) {
|
|
2584
|
+
switch (_c.label) {
|
|
2551
2585
|
case 0:
|
|
2552
2586
|
contractAddress = this._swapContractAddress();
|
|
2553
2587
|
i = this._getCoinIdx(inputCoin);
|
|
2554
2588
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
|
|
2555
|
-
case 1: return [2 /*return*/,
|
|
2589
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2556
2590
|
}
|
|
2557
2591
|
});
|
|
2558
2592
|
});
|
|
@@ -2560,13 +2594,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2560
2594
|
PoolTemplate.prototype.swapApproveEstimateGas = function (inputCoin, amount) {
|
|
2561
2595
|
return __awaiter(this, void 0, void 0, function () {
|
|
2562
2596
|
var contractAddress, i;
|
|
2563
|
-
return __generator(this, function (
|
|
2564
|
-
switch (
|
|
2597
|
+
return __generator(this, function (_c) {
|
|
2598
|
+
switch (_c.label) {
|
|
2565
2599
|
case 0:
|
|
2566
2600
|
contractAddress = this._swapContractAddress();
|
|
2567
2601
|
i = this._getCoinIdx(inputCoin);
|
|
2568
2602
|
return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
|
|
2569
|
-
case 1: return [2 /*return*/,
|
|
2603
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2570
2604
|
}
|
|
2571
2605
|
});
|
|
2572
2606
|
});
|
|
@@ -2574,13 +2608,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2574
2608
|
PoolTemplate.prototype.swapApprove = function (inputCoin, amount) {
|
|
2575
2609
|
return __awaiter(this, void 0, void 0, function () {
|
|
2576
2610
|
var contractAddress, i;
|
|
2577
|
-
return __generator(this, function (
|
|
2578
|
-
switch (
|
|
2611
|
+
return __generator(this, function (_c) {
|
|
2612
|
+
switch (_c.label) {
|
|
2579
2613
|
case 0:
|
|
2580
2614
|
contractAddress = this._swapContractAddress();
|
|
2581
2615
|
i = this._getCoinIdx(inputCoin);
|
|
2582
2616
|
return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
|
|
2583
|
-
case 1: return [2 /*return*/,
|
|
2617
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2584
2618
|
}
|
|
2585
2619
|
});
|
|
2586
2620
|
});
|
|
@@ -2588,7 +2622,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2588
2622
|
// OVERRIDE
|
|
2589
2623
|
PoolTemplate.prototype.swapEstimateGas = function (inputCoin, outputCoin, amount) {
|
|
2590
2624
|
return __awaiter(this, void 0, void 0, function () {
|
|
2591
|
-
return __generator(this, function (
|
|
2625
|
+
return __generator(this, function (_c) {
|
|
2592
2626
|
throw Error("swap method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2593
2627
|
});
|
|
2594
2628
|
});
|
|
@@ -2597,7 +2631,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2597
2631
|
PoolTemplate.prototype.swap = function (inputCoin, outputCoin, amount, slippage) {
|
|
2598
2632
|
if (slippage === void 0) { slippage = 0.5; }
|
|
2599
2633
|
return __awaiter(this, void 0, void 0, function () {
|
|
2600
|
-
return __generator(this, function (
|
|
2634
|
+
return __generator(this, function (_c) {
|
|
2601
2635
|
throw Error("swap method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2602
2636
|
});
|
|
2603
2637
|
});
|
|
@@ -2605,10 +2639,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2605
2639
|
// ---------------- SWAP WRAPPED ----------------
|
|
2606
2640
|
PoolTemplate.prototype._swapWrappedExpected = function (i, j, _amount) {
|
|
2607
2641
|
return __awaiter(this, void 0, void 0, function () {
|
|
2608
|
-
return __generator(this, function (
|
|
2609
|
-
switch (
|
|
2642
|
+
return __generator(this, function (_c) {
|
|
2643
|
+
switch (_c.label) {
|
|
2610
2644
|
case 0: return [4 /*yield*/, curve_1.curve.contracts[this.address].contract.get_dy(i, j, _amount, curve_1.curve.constantOptions)];
|
|
2611
|
-
case 1: return [2 /*return*/,
|
|
2645
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
2612
2646
|
}
|
|
2613
2647
|
});
|
|
2614
2648
|
});
|
|
@@ -2616,27 +2650,27 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2616
2650
|
// OVERRIDE
|
|
2617
2651
|
PoolTemplate.prototype.swapWrappedExpected = function (inputCoin, outputCoin, amount) {
|
|
2618
2652
|
return __awaiter(this, void 0, void 0, function () {
|
|
2619
|
-
return __generator(this, function (
|
|
2653
|
+
return __generator(this, function (_c) {
|
|
2620
2654
|
throw Error("swapWrappedExpected method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2621
2655
|
});
|
|
2622
2656
|
});
|
|
2623
2657
|
};
|
|
2624
2658
|
PoolTemplate.prototype.swapWrappedPriceImpact = function (inputCoin, outputCoin, amount) {
|
|
2625
2659
|
return __awaiter(this, void 0, void 0, function () {
|
|
2626
|
-
var i, j,
|
|
2627
|
-
return __generator(this, function (
|
|
2628
|
-
switch (
|
|
2660
|
+
var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, target, amountIntBN, outputIntBN, k, smallAmountIntBN, _smallAmount, _smallOutput, amountBN, outputBN, smallAmountBN, smallOutputBN, rateBN, smallRateBN, slippageBN;
|
|
2661
|
+
return __generator(this, function (_d) {
|
|
2662
|
+
switch (_d.label) {
|
|
2629
2663
|
case 0:
|
|
2630
2664
|
if (this.isPlain || this.isFake) {
|
|
2631
2665
|
throw Error("swapWrappedPriceImpact method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2632
2666
|
}
|
|
2633
2667
|
i = this._getCoinIdx(inputCoin, false);
|
|
2634
2668
|
j = this._getCoinIdx(outputCoin, false);
|
|
2635
|
-
|
|
2669
|
+
_c = [this.wrappedDecimals[i], this.wrappedDecimals[j]], inputCoinDecimals = _c[0], outputCoinDecimals = _c[1];
|
|
2636
2670
|
_amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
|
|
2637
2671
|
return [4 /*yield*/, this._swapWrappedExpected(i, j, _amount)];
|
|
2638
2672
|
case 1:
|
|
2639
|
-
_output =
|
|
2673
|
+
_output = _d.sent();
|
|
2640
2674
|
target = (0, utils_1.BN)(Math.pow(10, 15));
|
|
2641
2675
|
amountIntBN = (0, utils_1.BN)(amount).times(Math.pow(10, inputCoinDecimals));
|
|
2642
2676
|
outputIntBN = (0, utils_1.toBN)(_output, 0);
|
|
@@ -2647,7 +2681,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2647
2681
|
_smallAmount = (0, utils_1.fromBN)(smallAmountIntBN.div(Math.pow(10, inputCoinDecimals)), inputCoinDecimals);
|
|
2648
2682
|
return [4 /*yield*/, this._swapWrappedExpected(i, j, _smallAmount)];
|
|
2649
2683
|
case 2:
|
|
2650
|
-
_smallOutput =
|
|
2684
|
+
_smallOutput = _d.sent();
|
|
2651
2685
|
amountBN = (0, utils_1.BN)(amount);
|
|
2652
2686
|
outputBN = (0, utils_1.toBN)(_output, outputCoinDecimals);
|
|
2653
2687
|
smallAmountBN = (0, utils_1.toBN)(_smallAmount, inputCoinDecimals);
|
|
@@ -2663,7 +2697,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2663
2697
|
// OVERRIDE
|
|
2664
2698
|
PoolTemplate.prototype.swapWrappedIsApproved = function (inputCoin, amount) {
|
|
2665
2699
|
return __awaiter(this, void 0, void 0, function () {
|
|
2666
|
-
return __generator(this, function (
|
|
2700
|
+
return __generator(this, function (_c) {
|
|
2667
2701
|
throw Error("swapWrappedIsApproved method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2668
2702
|
});
|
|
2669
2703
|
});
|
|
@@ -2671,7 +2705,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2671
2705
|
// OVERRIDE
|
|
2672
2706
|
PoolTemplate.prototype.swapWrappedApproveEstimateGas = function (inputCoin, amount) {
|
|
2673
2707
|
return __awaiter(this, void 0, void 0, function () {
|
|
2674
|
-
return __generator(this, function (
|
|
2708
|
+
return __generator(this, function (_c) {
|
|
2675
2709
|
throw Error("swapWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2676
2710
|
});
|
|
2677
2711
|
});
|
|
@@ -2679,7 +2713,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2679
2713
|
// OVERRIDE
|
|
2680
2714
|
PoolTemplate.prototype.swapWrappedApprove = function (inputCoin, amount) {
|
|
2681
2715
|
return __awaiter(this, void 0, void 0, function () {
|
|
2682
|
-
return __generator(this, function (
|
|
2716
|
+
return __generator(this, function (_c) {
|
|
2683
2717
|
throw Error("swapWrappedApprove method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2684
2718
|
});
|
|
2685
2719
|
});
|
|
@@ -2687,7 +2721,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2687
2721
|
// OVERRIDE
|
|
2688
2722
|
PoolTemplate.prototype.swapWrappedEstimateGas = function (inputCoin, outputCoin, amount) {
|
|
2689
2723
|
return __awaiter(this, void 0, void 0, function () {
|
|
2690
|
-
return __generator(this, function (
|
|
2724
|
+
return __generator(this, function (_c) {
|
|
2691
2725
|
throw Error("swapWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2692
2726
|
});
|
|
2693
2727
|
});
|
|
@@ -2696,7 +2730,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2696
2730
|
PoolTemplate.prototype.swapWrapped = function (inputCoin, outputCoin, amount, slippage) {
|
|
2697
2731
|
if (slippage === void 0) { slippage = 0.5; }
|
|
2698
2732
|
return __awaiter(this, void 0, void 0, function () {
|
|
2699
|
-
return __generator(this, function (
|
|
2733
|
+
return __generator(this, function (_c) {
|
|
2700
2734
|
throw Error("swapWrapped method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, ")"));
|
|
2701
2735
|
});
|
|
2702
2736
|
});
|