@curvefi/api 2.61.8 → 2.61.9
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.d.ts +1 -1
- package/lib/pools/PoolTemplate.js +3 -2
- package/lib/utils.js +30 -22
- package/package.json +1 -1
|
@@ -120,7 +120,7 @@ export declare class PoolTemplate {
|
|
|
120
120
|
depositBonus(amounts: (number | string)[]): Promise<string>;
|
|
121
121
|
depositIsApproved(amounts: (number | string)[]): Promise<boolean>;
|
|
122
122
|
private depositApproveEstimateGas;
|
|
123
|
-
depositApprove(amounts: (number | string)[]): Promise<string[]>;
|
|
123
|
+
depositApprove(amounts: (number | string)[], isMax?: boolean): Promise<string[]>;
|
|
124
124
|
private depositEstimateGas;
|
|
125
125
|
deposit(amounts: (number | string)[], slippage?: number): Promise<string>;
|
|
126
126
|
depositWrappedBalancedAmounts(): Promise<string[]>;
|
|
@@ -1534,11 +1534,12 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1534
1534
|
});
|
|
1535
1535
|
});
|
|
1536
1536
|
};
|
|
1537
|
-
PoolTemplate.prototype.depositApprove = function (amounts) {
|
|
1537
|
+
PoolTemplate.prototype.depositApprove = function (amounts, isMax) {
|
|
1538
|
+
if (isMax === void 0) { isMax = true; }
|
|
1538
1539
|
return __awaiter(this, void 0, void 0, function () {
|
|
1539
1540
|
return __generator(this, function (_c) {
|
|
1540
1541
|
switch (_c.label) {
|
|
1541
|
-
case 0: return [4 /*yield*/, ensureAllowance(this.underlyingCoinAddresses, amounts, this.zap || this.address)];
|
|
1542
|
+
case 0: return [4 /*yield*/, ensureAllowance(this.underlyingCoinAddresses, amounts, this.zap || this.address, isMax)];
|
|
1542
1543
|
case 1: return [2 /*return*/, _c.sent()];
|
|
1543
1544
|
}
|
|
1544
1545
|
});
|
package/lib/utils.js
CHANGED
|
@@ -324,51 +324,59 @@ export var hasAllowance = function (coins, amounts, address, spender) { return _
|
|
|
324
324
|
export var _ensureAllowance = function (coins, amounts, spender, isMax) {
|
|
325
325
|
if (isMax === void 0) { isMax = true; }
|
|
326
326
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
327
|
-
var address, allowance, txHashes, i, contract, _approveAmount, gasLimit_1, _a, _b,
|
|
328
|
-
return __generator(this, function (
|
|
329
|
-
switch (
|
|
327
|
+
var address, allowance, txHashes, i, contract, _approveAmount, gasLimit_1, _a, _b, resetTx, gasLimit, _c, _d, approveTx;
|
|
328
|
+
return __generator(this, function (_e) {
|
|
329
|
+
switch (_e.label) {
|
|
330
330
|
case 0:
|
|
331
331
|
address = curve.signerAddress;
|
|
332
332
|
return [4 /*yield*/, _getAllowance(coins, address, spender)];
|
|
333
333
|
case 1:
|
|
334
|
-
allowance =
|
|
334
|
+
allowance = _e.sent();
|
|
335
335
|
txHashes = [];
|
|
336
336
|
i = 0;
|
|
337
|
-
|
|
337
|
+
_e.label = 2;
|
|
338
338
|
case 2:
|
|
339
|
-
if (!(i < allowance.length)) return [3 /*break*/,
|
|
340
|
-
if (!(allowance[i] < amounts[i])) return [3 /*break*/,
|
|
339
|
+
if (!(i < allowance.length)) return [3 /*break*/, 12];
|
|
340
|
+
if (!(allowance[i] < amounts[i])) return [3 /*break*/, 11];
|
|
341
341
|
contract = curve.contracts[coins[i]].contract;
|
|
342
342
|
_approveAmount = isMax ? MAX_ALLOWANCE : amounts[i];
|
|
343
343
|
return [4 /*yield*/, curve.updateFeeData()];
|
|
344
344
|
case 3:
|
|
345
|
-
|
|
346
|
-
if (!(allowance[i] > curve.parseUnits("0"))) return [3 /*break*/,
|
|
345
|
+
_e.sent();
|
|
346
|
+
if (!(allowance[i] > curve.parseUnits("0"))) return [3 /*break*/, 7];
|
|
347
347
|
_a = mulBy1_3;
|
|
348
348
|
_b = DIGas;
|
|
349
349
|
return [4 /*yield*/, contract.approve.estimateGas(spender, curve.parseUnits("0"), curve.constantOptions)];
|
|
350
350
|
case 4:
|
|
351
|
-
gasLimit_1 = _a.apply(void 0, [_b.apply(void 0, [
|
|
352
|
-
_d = (_c = txHashes).push;
|
|
351
|
+
gasLimit_1 = _a.apply(void 0, [_b.apply(void 0, [_e.sent()])]);
|
|
353
352
|
return [4 /*yield*/, contract.approve(spender, curve.parseUnits("0"), __assign(__assign({}, curve.options), { gasLimit: gasLimit_1 }))];
|
|
354
353
|
case 5:
|
|
355
|
-
|
|
356
|
-
|
|
354
|
+
resetTx = _e.sent();
|
|
355
|
+
console.log("Reset approval tx hash: ".concat(resetTx.hash));
|
|
356
|
+
txHashes.push(resetTx.hash);
|
|
357
|
+
return [4 /*yield*/, resetTx.wait()];
|
|
357
358
|
case 6:
|
|
358
|
-
_e
|
|
359
|
-
|
|
360
|
-
return [4 /*yield*/, contract.approve.estimateGas(spender, _approveAmount, curve.constantOptions)];
|
|
359
|
+
_e.sent();
|
|
360
|
+
_e.label = 7;
|
|
361
361
|
case 7:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return [4 /*yield*/, contract.approve(spender, _approveAmount,
|
|
362
|
+
_c = mulBy1_3;
|
|
363
|
+
_d = DIGas;
|
|
364
|
+
return [4 /*yield*/, contract.approve.estimateGas(spender, _approveAmount, curve.constantOptions)];
|
|
365
365
|
case 8:
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
gasLimit = _c.apply(void 0, [_d.apply(void 0, [_e.sent()])]);
|
|
367
|
+
return [4 /*yield*/, contract.approve(spender, _approveAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
368
368
|
case 9:
|
|
369
|
+
approveTx = _e.sent();
|
|
370
|
+
console.log("Set approval tx hash: ".concat(approveTx.hash));
|
|
371
|
+
txHashes.push(approveTx.hash);
|
|
372
|
+
return [4 /*yield*/, approveTx.wait()];
|
|
373
|
+
case 10:
|
|
374
|
+
_e.sent();
|
|
375
|
+
_e.label = 11;
|
|
376
|
+
case 11:
|
|
369
377
|
i++;
|
|
370
378
|
return [3 /*break*/, 2];
|
|
371
|
-
case
|
|
379
|
+
case 12: return [2 /*return*/, txHashes];
|
|
372
380
|
}
|
|
373
381
|
});
|
|
374
382
|
});
|