@curvefi/api 2.54.1 → 2.54.3
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/curve.js +3 -12
- package/lib/pools/PoolTemplate.js +47 -25
- package/lib/utils.js +1 -1
- package/package.json +1 -1
package/lib/curve.js
CHANGED
|
@@ -1135,12 +1135,10 @@ var Curve = /** @class */ (function () {
|
|
|
1135
1135
|
};
|
|
1136
1136
|
Curve.prototype.updateFeeData = function () {
|
|
1137
1137
|
return __awaiter(this, void 0, void 0, function () {
|
|
1138
|
-
var feeData
|
|
1138
|
+
var feeData;
|
|
1139
1139
|
return __generator(this, function (_a) {
|
|
1140
1140
|
switch (_a.label) {
|
|
1141
|
-
case 0:
|
|
1142
|
-
_a.trys.push([0, 2, , 3]);
|
|
1143
|
-
return [4 /*yield*/, this.provider.getFeeData()];
|
|
1141
|
+
case 0: return [4 /*yield*/, this.provider.getFeeData()];
|
|
1144
1142
|
case 1:
|
|
1145
1143
|
feeData = _a.sent();
|
|
1146
1144
|
if (feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null) {
|
|
@@ -1159,14 +1157,7 @@ var Curve = /** @class */ (function () {
|
|
|
1159
1157
|
this.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
|
|
1160
1158
|
feeData.maxPriorityFeePerGas;
|
|
1161
1159
|
}
|
|
1162
|
-
return [
|
|
1163
|
-
case 2:
|
|
1164
|
-
e_2 = _a.sent();
|
|
1165
|
-
this.options.gasPrice = this.parseUnits('0', "gwei");
|
|
1166
|
-
this.options.maxPriorityFeePerGas = this.parseUnits('0', "gwei");
|
|
1167
|
-
this.options.maxFeePerGas = this.parseUnits('0', "gwei");
|
|
1168
|
-
return [3 /*break*/, 3];
|
|
1169
|
-
case 3: return [2 /*return*/];
|
|
1160
|
+
return [2 /*return*/];
|
|
1170
1161
|
}
|
|
1171
1162
|
});
|
|
1172
1163
|
});
|
|
@@ -2463,27 +2463,38 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2463
2463
|
};
|
|
2464
2464
|
PoolTemplate.prototype.withdrawImbalanceBonus = function (amounts) {
|
|
2465
2465
|
return __awaiter(this, void 0, void 0, function () {
|
|
2466
|
-
var prices,
|
|
2467
|
-
|
|
2468
|
-
|
|
2466
|
+
var prices, isUseStoredRates, result, value, lpTokenAmount, balancedAmounts, balancedValue;
|
|
2467
|
+
var _this = this;
|
|
2468
|
+
return __generator(this, function (_c) {
|
|
2469
|
+
switch (_c.label) {
|
|
2469
2470
|
case 0:
|
|
2471
|
+
prices = [];
|
|
2472
|
+
isUseStoredRates = isMethodExist(curve.contracts[this.address].contract, 'stored_rates') && this.isPlain;
|
|
2470
2473
|
if (!(this.isCrypto || this.id === 'wsteth')) return [3 /*break*/, 2];
|
|
2471
2474
|
return [4 /*yield*/, this._underlyingPrices()];
|
|
2472
2475
|
case 1:
|
|
2473
|
-
|
|
2474
|
-
return [3 /*break*/,
|
|
2476
|
+
prices = _c.sent();
|
|
2477
|
+
return [3 /*break*/, 5];
|
|
2475
2478
|
case 2:
|
|
2476
|
-
|
|
2477
|
-
|
|
2479
|
+
if (!isUseStoredRates) return [3 /*break*/, 4];
|
|
2480
|
+
return [4 /*yield*/, this._stored_rates()];
|
|
2478
2481
|
case 3:
|
|
2479
|
-
|
|
2482
|
+
result = _c.sent();
|
|
2483
|
+
result.forEach(function (item, index) {
|
|
2484
|
+
prices.push(Number(item) / (Math.pow(10, (36 - _this.underlyingDecimals[index]))));
|
|
2485
|
+
});
|
|
2486
|
+
return [3 /*break*/, 5];
|
|
2487
|
+
case 4:
|
|
2488
|
+
prices = this.underlyingCoins.map(function () { return 1; });
|
|
2489
|
+
_c.label = 5;
|
|
2490
|
+
case 5:
|
|
2480
2491
|
value = amounts.map(checkNumber).map(Number).reduce(function (s, a, i) { return s + (a * prices[i]); }, 0);
|
|
2481
2492
|
return [4 /*yield*/, this.withdrawImbalanceExpected(amounts)];
|
|
2482
|
-
case
|
|
2483
|
-
lpTokenAmount =
|
|
2493
|
+
case 6:
|
|
2494
|
+
lpTokenAmount = _c.sent();
|
|
2484
2495
|
return [4 /*yield*/, this.withdrawExpected(lpTokenAmount)];
|
|
2485
|
-
case
|
|
2486
|
-
balancedAmounts =
|
|
2496
|
+
case 7:
|
|
2497
|
+
balancedAmounts = _c.sent();
|
|
2487
2498
|
balancedValue = balancedAmounts.map(Number).reduce(function (s, a, i) { return s + (a * prices[i]); }, 0);
|
|
2488
2499
|
return [2 /*return*/, String((value - balancedValue) / balancedValue * 100)];
|
|
2489
2500
|
}
|
|
@@ -2650,29 +2661,40 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2650
2661
|
};
|
|
2651
2662
|
PoolTemplate.prototype.withdrawOneCoinBonus = function (lpTokenAmount, coin) {
|
|
2652
2663
|
return __awaiter(this, void 0, void 0, function () {
|
|
2653
|
-
var prices,
|
|
2654
|
-
|
|
2655
|
-
|
|
2664
|
+
var prices, isUseStoredRates, result, coinPrice, amount, _c, value, balancedAmounts, balancedValue;
|
|
2665
|
+
var _this = this;
|
|
2666
|
+
return __generator(this, function (_d) {
|
|
2667
|
+
switch (_d.label) {
|
|
2656
2668
|
case 0:
|
|
2669
|
+
prices = [];
|
|
2670
|
+
isUseStoredRates = isMethodExist(curve.contracts[this.address].contract, 'stored_rates') && this.isPlain;
|
|
2657
2671
|
if (!(this.isCrypto || this.id === 'wsteth')) return [3 /*break*/, 2];
|
|
2658
2672
|
return [4 /*yield*/, this._underlyingPrices()];
|
|
2659
2673
|
case 1:
|
|
2660
|
-
|
|
2661
|
-
return [3 /*break*/,
|
|
2674
|
+
prices = _d.sent();
|
|
2675
|
+
return [3 /*break*/, 5];
|
|
2662
2676
|
case 2:
|
|
2663
|
-
|
|
2664
|
-
|
|
2677
|
+
if (!isUseStoredRates) return [3 /*break*/, 4];
|
|
2678
|
+
return [4 /*yield*/, this._stored_rates()];
|
|
2665
2679
|
case 3:
|
|
2666
|
-
|
|
2680
|
+
result = _d.sent();
|
|
2681
|
+
result.forEach(function (item, index) {
|
|
2682
|
+
prices.push(Number(item) / (Math.pow(10, (36 - _this.underlyingDecimals[index]))));
|
|
2683
|
+
});
|
|
2684
|
+
return [3 /*break*/, 5];
|
|
2685
|
+
case 4:
|
|
2686
|
+
prices = this.underlyingCoins.map(function () { return 1; });
|
|
2687
|
+
_d.label = 5;
|
|
2688
|
+
case 5:
|
|
2667
2689
|
coinPrice = prices[this._getCoinIdx(coin)];
|
|
2668
|
-
|
|
2690
|
+
_c = Number;
|
|
2669
2691
|
return [4 /*yield*/, this.withdrawOneCoinExpected(lpTokenAmount, coin)];
|
|
2670
|
-
case
|
|
2671
|
-
amount =
|
|
2692
|
+
case 6:
|
|
2693
|
+
amount = _c.apply(void 0, [_d.sent()]);
|
|
2672
2694
|
value = amount * coinPrice;
|
|
2673
2695
|
return [4 /*yield*/, this.withdrawExpected(lpTokenAmount)];
|
|
2674
|
-
case
|
|
2675
|
-
balancedAmounts =
|
|
2696
|
+
case 7:
|
|
2697
|
+
balancedAmounts = _d.sent();
|
|
2676
2698
|
balancedValue = balancedAmounts.map(Number).reduce(function (s, a, i) { return s + (a * prices[i]); }, 0);
|
|
2677
2699
|
return [2 /*return*/, String((value - balancedValue) / balancedValue * 100)];
|
|
2678
2700
|
}
|
package/lib/utils.js
CHANGED
|
@@ -62,7 +62,7 @@ import { curve, NETWORK_CONSTANTS } from "./curve.js";
|
|
|
62
62
|
import { _getAllPoolsFromApi, _getFactoryAPYs, _getSubgraphData, _getVolumes, } from "./external-api.js";
|
|
63
63
|
import ERC20Abi from './constants/abis/ERC20.json' assert { type: 'json' };
|
|
64
64
|
import { L2Networks } from './constants/L2Networks.js';
|
|
65
|
-
import { volumeNetworks } from "./constants/volumeNetworks";
|
|
65
|
+
import { volumeNetworks } from "./constants/volumeNetworks.js";
|
|
66
66
|
export var ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
67
67
|
// export const MAX_ALLOWANCE = curve.parseUnits(new BigNumber(2).pow(256).minus(1).toFixed(), 0);
|
|
68
68
|
export var MAX_ALLOWANCE = BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"); // 2**256 - 1
|