@gearbox-protocol/sdk 1.20.18 → 1.20.19
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.
|
@@ -33,7 +33,7 @@ export declare class CreditAccountData {
|
|
|
33
33
|
balancesSorted(prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): Array<Asset>;
|
|
34
34
|
calcBorrowAmountPlusInterestRate(currentCumulativeIndex: BigNumber): BigNumber;
|
|
35
35
|
updateHealthFactor(creditManager: CreditManagerData, currentCumulativeIndex: BigNumber, priceOracle: PriceOracleData): void;
|
|
36
|
-
static calcMaxIncreaseBorrow(healthFactor: number, borrowAmountPlusInterest: BigNumber, maxLeverageFactor: number, underlyingLT: number): BigNumber;
|
|
36
|
+
static calcMaxIncreaseBorrow(healthFactor: number, borrowAmountPlusInterest: BigNumber, maxLeverageFactor: number, underlyingLT: number, minHf?: number): BigNumber;
|
|
37
37
|
get id(): string;
|
|
38
38
|
hash(): string;
|
|
39
39
|
static hash(creditManager: string, borrower: string): string;
|
|
@@ -78,11 +78,12 @@ var CreditAccountData = /** @class */ (function () {
|
|
|
78
78
|
.div(this.calcBorrowAmountPlusInterestRate(currentCumulativeIndex))
|
|
79
79
|
.toNumber();
|
|
80
80
|
};
|
|
81
|
-
CreditAccountData.calcMaxIncreaseBorrow = function (healthFactor, borrowAmountPlusInterest, maxLeverageFactor, underlyingLT) {
|
|
81
|
+
CreditAccountData.calcMaxIncreaseBorrow = function (healthFactor, borrowAmountPlusInterest, maxLeverageFactor, underlyingLT, minHf) {
|
|
82
|
+
if (minHf === void 0) { minHf = constants_1.PERCENTAGE_FACTOR; }
|
|
82
83
|
var minHealthFactor = maxLeverageFactor > 0
|
|
83
84
|
? Math.floor((underlyingLT * (maxLeverageFactor + constants_1.LEVERAGE_DECIMALS)) /
|
|
84
85
|
maxLeverageFactor)
|
|
85
|
-
:
|
|
86
|
+
: minHf;
|
|
86
87
|
var result = borrowAmountPlusInterest
|
|
87
88
|
.mul(healthFactor - minHealthFactor)
|
|
88
89
|
.div(minHealthFactor - underlyingLT);
|
package/lib/core/strategy.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class Strategy {
|
|
|
29
29
|
static maxLeverage(lpToken: string, cms: Array<PartialCM>): number;
|
|
30
30
|
maxAPY(baseAPY: number, maxLeverage: number, borrowAPY: number): number;
|
|
31
31
|
overallAPY(apy: number, leverage: number, depositCollateral: string, borrowAPY: number): number;
|
|
32
|
-
liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, lpAmount, lpToken, }: LiquidationPriceProps): BigNumber;
|
|
32
|
+
static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, lpAmount, lpToken, }: LiquidationPriceProps): BigNumber;
|
|
33
33
|
protected farmLev(leverage: number, depositCollateral: string): number;
|
|
34
34
|
protected inBaseAssets(depositCollateral: string): boolean;
|
|
35
35
|
protected inLeveragableAssets(depositCollateral: string): boolean;
|
package/lib/core/strategy.js
CHANGED
|
@@ -35,8 +35,7 @@ var Strategy = /** @class */ (function () {
|
|
|
35
35
|
var farmLev = this.farmLev(leverage, depositCollateral);
|
|
36
36
|
return roi(apy, farmLev, leverage - constants_1.LEVERAGE_DECIMALS, borrowAPY);
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
Strategy.prototype.liquidationPrice = function (_a) {
|
|
38
|
+
Strategy.liquidationPrice = function (_a) {
|
|
40
39
|
var prices = _a.prices, liquidationThresholds = _a.liquidationThresholds, borrowed = _a.borrowed, underlyingToken = _a.underlyingToken, lpAmount = _a.lpAmount, lpToken = _a.lpToken;
|
|
41
40
|
var underlyingTokenAddressLC = underlyingToken.toLowerCase();
|
|
42
41
|
var underlyingTokenSymbol = token_1.tokenSymbolByAddress[underlyingTokenAddressLC];
|
|
@@ -50,7 +50,7 @@ describe("Strategy test", function () {
|
|
|
50
50
|
(0, chai_1.expect)(result).to.be.eq(332716);
|
|
51
51
|
});
|
|
52
52
|
it("liquidationPrice calculation is correct", function () {
|
|
53
|
-
var result =
|
|
53
|
+
var result = strategy_1.Strategy.liquidationPrice({
|
|
54
54
|
liquidationThresholds: liquidationThresholds,
|
|
55
55
|
prices: prices,
|
|
56
56
|
borrowed: (0, formatter_1.toBN)("350", decimals_1.decimals.WETH),
|