@gearbox-protocol/sdk 8.12.3 → 8.12.4

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.
@@ -22,7 +22,6 @@ __reExport(sdk_legacy_exports, require("./core/creditSession.js"), module.export
22
22
  __reExport(sdk_legacy_exports, require("./core/endpoint.js"), module.exports);
23
23
  __reExport(sdk_legacy_exports, require("./core/eventOrTx.js"), module.exports);
24
24
  __reExport(sdk_legacy_exports, require("./core/pool.js"), module.exports);
25
- __reExport(sdk_legacy_exports, require("./core/strategy.js"), module.exports);
26
25
  __reExport(sdk_legacy_exports, require("./core/transactions.js"), module.exports);
27
26
  __reExport(sdk_legacy_exports, require("./gearboxRewards/index.js"), module.exports);
28
27
  __reExport(sdk_legacy_exports, require("./payload/creditAccount.js"), module.exports);
@@ -42,7 +41,6 @@ __reExport(sdk_legacy_exports, require("./utils/index.js"), module.exports);
42
41
  ...require("./core/endpoint.js"),
43
42
  ...require("./core/eventOrTx.js"),
44
43
  ...require("./core/pool.js"),
45
- ...require("./core/strategy.js"),
46
44
  ...require("./core/transactions.js"),
47
45
  ...require("./gearboxRewards/index.js"),
48
46
  ...require("./payload/creditAccount.js"),
@@ -5,7 +5,6 @@ export * from "./core/creditSession.js";
5
5
  export * from "./core/endpoint.js";
6
6
  export * from "./core/eventOrTx.js";
7
7
  export * from "./core/pool.js";
8
- export * from "./core/strategy.js";
9
8
  export * from "./core/transactions.js";
10
9
  export * from "./gearboxRewards/index.js";
11
10
  export * from "./payload/creditAccount.js";
@@ -5,7 +5,6 @@ export * from "./core/creditSession.js";
5
5
  export * from "./core/endpoint.js";
6
6
  export * from "./core/eventOrTx.js";
7
7
  export * from "./core/pool.js";
8
- export * from "./core/strategy.js";
9
8
  export * from "./core/transactions.js";
10
9
  export * from "./gearboxRewards/index.js";
11
10
  export * from "./payload/creditAccount.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.12.3",
3
+ "version": "8.12.4",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var strategy_exports = {};
20
- __export(strategy_exports, {
21
- PositionUtils: () => PositionUtils
22
- });
23
- module.exports = __toCommonJS(strategy_exports);
24
- var import_constants = require("../../constants/index.js");
25
- class PositionUtils {
26
- static maxLeverage(lpToken, cms) {
27
- const [maxThreshold] = PositionUtils.maxLeverageThreshold(lpToken, cms);
28
- const maxLeverage = import_constants.PERCENTAGE_FACTOR * import_constants.LEVERAGE_DECIMALS / (import_constants.PERCENTAGE_FACTOR - maxThreshold);
29
- return Number(maxLeverage - import_constants.LEVERAGE_DECIMALS);
30
- }
31
- // [apy - quotaRate * (1 + feeInterest)] +
32
- // [
33
- // apy - baseRateWithFee - quotaRate * (1 + feeInterest)
34
- // ] * (leverage - 1)
35
- static maxAPY({
36
- apy,
37
- leverage,
38
- baseRateWithFee,
39
- quotaRateWithFee
40
- }) {
41
- const collateralTerm = apy - quotaRateWithFee;
42
- const debtTerm = (apy - baseRateWithFee - quotaRateWithFee) * (leverage - Number(import_constants.LEVERAGE_DECIMALS)) / Number(import_constants.LEVERAGE_DECIMALS);
43
- return collateralTerm + Math.floor(debtTerm);
44
- }
45
- static maxLeverageThreshold(lpToken, cms) {
46
- const lpTokenLC = lpToken.toLowerCase();
47
- const ltByCM = cms.map((cm2) => {
48
- const lt2 = cm2.liquidationThresholds[lpTokenLC] || 0n;
49
- return [cm2.address, lt2];
50
- });
51
- const sorted = ltByCM.sort(([, ltA], [, ltB]) => {
52
- if (ltA > ltB) return -1;
53
- if (ltB > ltA) return 1;
54
- return 0;
55
- });
56
- const [cm = "", lt = 0n] = sorted[0] || [];
57
- return [lt, cm];
58
- }
59
- static isStrategyReleased(releaseAt, currentTimestamp, chainId) {
60
- if (releaseAt === void 0) return true;
61
- if (typeof releaseAt === "number") return currentTimestamp > releaseAt;
62
- const releaseAtNetwork = releaseAt[chainId];
63
- if (releaseAtNetwork === void 0) return true;
64
- return currentTimestamp > releaseAtNetwork;
65
- }
66
- }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- PositionUtils
70
- });
@@ -1,46 +0,0 @@
1
- import { LEVERAGE_DECIMALS, PERCENTAGE_FACTOR } from "../../constants/index.js";
2
- class PositionUtils {
3
- static maxLeverage(lpToken, cms) {
4
- const [maxThreshold] = PositionUtils.maxLeverageThreshold(lpToken, cms);
5
- const maxLeverage = PERCENTAGE_FACTOR * LEVERAGE_DECIMALS / (PERCENTAGE_FACTOR - maxThreshold);
6
- return Number(maxLeverage - LEVERAGE_DECIMALS);
7
- }
8
- // [apy - quotaRate * (1 + feeInterest)] +
9
- // [
10
- // apy - baseRateWithFee - quotaRate * (1 + feeInterest)
11
- // ] * (leverage - 1)
12
- static maxAPY({
13
- apy,
14
- leverage,
15
- baseRateWithFee,
16
- quotaRateWithFee
17
- }) {
18
- const collateralTerm = apy - quotaRateWithFee;
19
- const debtTerm = (apy - baseRateWithFee - quotaRateWithFee) * (leverage - Number(LEVERAGE_DECIMALS)) / Number(LEVERAGE_DECIMALS);
20
- return collateralTerm + Math.floor(debtTerm);
21
- }
22
- static maxLeverageThreshold(lpToken, cms) {
23
- const lpTokenLC = lpToken.toLowerCase();
24
- const ltByCM = cms.map((cm2) => {
25
- const lt2 = cm2.liquidationThresholds[lpTokenLC] || 0n;
26
- return [cm2.address, lt2];
27
- });
28
- const sorted = ltByCM.sort(([, ltA], [, ltB]) => {
29
- if (ltA > ltB) return -1;
30
- if (ltB > ltA) return 1;
31
- return 0;
32
- });
33
- const [cm = "", lt = 0n] = sorted[0] || [];
34
- return [lt, cm];
35
- }
36
- static isStrategyReleased(releaseAt, currentTimestamp, chainId) {
37
- if (releaseAt === void 0) return true;
38
- if (typeof releaseAt === "number") return currentTimestamp > releaseAt;
39
- const releaseAtNetwork = releaseAt[chainId];
40
- if (releaseAtNetwork === void 0) return true;
41
- return currentTimestamp > releaseAtNetwork;
42
- }
43
- }
44
- export {
45
- PositionUtils
46
- };
@@ -1,17 +0,0 @@
1
- import type { Address } from "viem";
2
- import type { CreditManagerData_Legacy } from "./creditManager.js";
3
- export type ReleaseAt = undefined | number | Record<number, number>;
4
- interface CalculateMaxAPYProps {
5
- apy: number;
6
- leverage: number;
7
- baseRateWithFee: number;
8
- quotaRateWithFee: number;
9
- }
10
- export declare class PositionUtils {
11
- static maxLeverage(lpToken: Address, cms: Array<PartialCM>): number;
12
- static maxAPY({ apy, leverage, baseRateWithFee, quotaRateWithFee, }: CalculateMaxAPYProps): number;
13
- protected static maxLeverageThreshold(lpToken: Address, cms: Array<PartialCM>): readonly [bigint, "" | `0x${string}`];
14
- static isStrategyReleased(releaseAt: ReleaseAt, currentTimestamp: number, chainId: number): boolean;
15
- }
16
- type PartialCM = Pick<CreditManagerData_Legacy, "liquidationThresholds" | "address">;
17
- export {};