@gearbox-protocol/sdk 3.0.0-next.226 → 3.0.0-next.228

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.
@@ -148,6 +148,6 @@ export declare class CreditAccountData {
148
148
  * Calculates the time remaining until liquidation for a credit account.
149
149
  * @returns The time remaining until liquidation in milliseconds.
150
150
  */
151
- static getTimeToLiquidation({ healthFactor, totalBorrowRate_debt, }: TimeToLiquidationProps): bigint;
151
+ static getTimeToLiquidation({ healthFactor, totalBorrowRate_debt, }: TimeToLiquidationProps): bigint | null;
152
152
  }
153
153
  export {};
@@ -405,7 +405,7 @@ class CreditAccountData {
405
405
  */
406
406
  static getTimeToLiquidation({ healthFactor, totalBorrowRate_debt, }) {
407
407
  if (healthFactor <= sdk_gov_1.PERCENTAGE_FACTOR || totalBorrowRate_debt === 0n)
408
- return 0n;
408
+ return null;
409
409
  // (HF - 1) / (br_D / year) or (HF - 1) * (year / br_D)
410
410
  const HF_1 = BigInt(healthFactor) - sdk_gov_1.PERCENTAGE_FACTOR;
411
411
  const brPerYear = (BigInt(sdk_gov_1.SECONDS_PER_YEAR) * sdk_gov_1.PERCENTAGE_FACTOR * sdk_gov_1.PERCENTAGE_DECIMALS) /
@@ -1,13 +1,15 @@
1
- import { SupportedToken } from "@gearbox-protocol/sdk-gov";
1
+ import { NetworkType, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address } from "viem";
3
3
  import { AllLPTokens } from "../apy";
4
4
  import { CreditManagerData } from "./creditManager";
5
+ type ReleaseAt = undefined | number | PartialRecord<NetworkType, number>;
5
6
  export interface StrategyPayload {
6
7
  name: string;
7
8
  lpTokenSymbol: AllLPTokens;
8
9
  protocolSymbol: string;
9
10
  collateralTokens: Array<SupportedToken>;
10
11
  liquidationTokens: Array<SupportedToken>;
12
+ releaseAt?: ReleaseAt;
11
13
  }
12
14
  interface CalculateMaxAPYProps {
13
15
  apy: number;
@@ -19,12 +21,14 @@ export declare class Strategy {
19
21
  readonly name: string;
20
22
  readonly lpTokenSymbol: AllLPTokens;
21
23
  readonly protocolSymbol: string;
24
+ readonly releaseAt: ReleaseAt;
22
25
  readonly collateralTokens: Array<SupportedToken>;
23
26
  readonly liquidationTokens: Array<SupportedToken>;
24
27
  constructor(payload: StrategyPayload);
25
28
  static maxLeverage(lpToken: Address, cms: Array<PartialCM>): number;
26
29
  static maxAPY({ apy, leverage, baseRateWithFee, quotaRateWithFee, }: CalculateMaxAPYProps): number;
27
30
  protected static maxLeverageThreshold(lpToken: Address, cms: Array<PartialCM>): readonly [bigint, "" | `0x${string}`];
31
+ static isStrategyReleased(releaseAt: ReleaseAt, currentTimestamp: number, network: NetworkType): boolean;
28
32
  }
29
33
  type PartialCM = Pick<CreditManagerData, "liquidationThresholds" | "address">;
30
34
  export {};
@@ -6,6 +6,7 @@ class Strategy {
6
6
  name;
7
7
  lpTokenSymbol;
8
8
  protocolSymbol;
9
+ releaseAt;
9
10
  collateralTokens;
10
11
  liquidationTokens;
11
12
  constructor(payload) {
@@ -14,6 +15,7 @@ class Strategy {
14
15
  this.protocolSymbol = payload.protocolSymbol;
15
16
  this.collateralTokens = payload.collateralTokens;
16
17
  this.liquidationTokens = payload.liquidationTokens;
18
+ this.releaseAt = payload.releaseAt;
17
19
  }
18
20
  static maxLeverage(lpToken, cms) {
19
21
  const [maxThreshold] = Strategy.maxLeverageThreshold(lpToken, cms);
@@ -44,5 +46,15 @@ class Strategy {
44
46
  const [cm = "", lt = 0n] = sorted[0] || [];
45
47
  return [lt, cm];
46
48
  }
49
+ static isStrategyReleased(releaseAt, currentTimestamp, network) {
50
+ if (releaseAt === undefined)
51
+ return true;
52
+ if (typeof releaseAt === "number")
53
+ return currentTimestamp > releaseAt;
54
+ const releaseAtNetwork = releaseAt[network];
55
+ if (releaseAtNetwork === undefined)
56
+ return true;
57
+ return currentTimestamp > releaseAtNetwork;
58
+ }
47
59
  }
48
60
  exports.Strategy = Strategy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.226",
3
+ "version": "3.0.0-next.228",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",