@gearbox-protocol/sdk 15.1.0-next.4 → 15.1.0-next.6

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.
Files changed (35) hide show
  1. package/dist/cjs/dev/compareOpportunities.js +218 -0
  2. package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +2 -2
  3. package/dist/cjs/sdk/index.js +9 -5
  4. package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +1 -12
  5. package/dist/cjs/sdk/market/credit/CreditSuite.js +18 -27
  6. package/dist/cjs/sdk/market/credit/index.js +3 -0
  7. package/dist/cjs/sdk/market/credit/isStrategyCollateral.js +50 -0
  8. package/dist/cjs/sdk/market/index.js +17 -0
  9. package/dist/cjs/sdk/market/math.js +57 -44
  10. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +1 -1
  11. package/dist/cjs/sdk/opportunities/index.js +0 -13
  12. package/dist/esm/dev/compareOpportunities.js +216 -0
  13. package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +3 -3
  14. package/dist/esm/sdk/index.js +3 -2
  15. package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +2 -13
  16. package/dist/esm/sdk/market/credit/CreditSuite.js +19 -28
  17. package/dist/esm/sdk/market/credit/index.js +2 -1
  18. package/dist/esm/sdk/market/credit/isStrategyCollateral.js +48 -0
  19. package/dist/esm/sdk/market/index.js +3 -1
  20. package/dist/esm/sdk/market/math.js +52 -40
  21. package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -2
  22. package/dist/esm/sdk/opportunities/index.js +1 -2
  23. package/dist/types/dev/compareOpportunities.d.ts +153 -0
  24. package/dist/types/model/opportunities.d.ts +9 -9
  25. package/dist/types/model/positions.d.ts +3 -3
  26. package/dist/types/sdk/index.d.ts +3 -2
  27. package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +0 -4
  28. package/dist/types/sdk/market/credit/CreditSuite.d.ts +2 -16
  29. package/dist/types/sdk/market/credit/index.d.ts +2 -1
  30. package/dist/types/sdk/market/credit/isStrategyCollateral.d.ts +74 -0
  31. package/dist/types/sdk/market/credit/types.d.ts +2 -9
  32. package/dist/types/sdk/market/index.d.ts +3 -1
  33. package/dist/types/sdk/market/math.d.ts +44 -34
  34. package/dist/types/sdk/opportunities/index.d.ts +1 -2
  35. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ import { Address } from "viem";
2
+ //#region src/sdk/market/credit/isStrategyCollateral.d.ts
3
+ /**
4
+ * Withdrawal and redemption phantom tokens that can never be acquired as a
5
+ * strategy target. Other `PHANTOM_TOKEN::*` types (Convex, Infrared, staking
6
+ * rewards) can.
7
+ */
8
+ declare const NON_STRATEGY_PHANTOM_TOKEN_TYPES: readonly ["PHANTOM_TOKEN::INFINIFI_UNWIND", "PHANTOM_TOKEN::MELLOW_WITHDRAWAL", "PHANTOM_TOKEN::MIDAS_REDEMPTION", "PHANTOM_TOKEN::SECURITIZE_RD", "PHANTOM_TOKEN::UPSHIFT_WITHDRAW"];
9
+ /**
10
+ * Inputs of {@link isStrategyCollateral}, all resolved against the credit
11
+ * manager, market, and token metadata by the caller.
12
+ */
13
+ interface IsStrategyCollateralProps {
14
+ /**
15
+ * Candidate collateral token.
16
+ **/
17
+ token: Address;
18
+ /**
19
+ * Credit manager underlying (debt asset).
20
+ **/
21
+ underlying: Address;
22
+ /**
23
+ * Token the market's underlying wraps (same as `underlying` on non-RWA
24
+ * markets).
25
+ */
26
+ unwrappedUnderlying: Address;
27
+ /**
28
+ * Liquidation threshold of the token in this credit manager, in bps.
29
+ **/
30
+ liquidationThreshold: number;
31
+ /**
32
+ * Gearbox contract type of the token (e.g. `"PHANTOM_TOKEN::CONVEX"`).
33
+ * Optional — plain tokens have none.
34
+ */
35
+ contractType?: string;
36
+ /**
37
+ * Whether the token itself is expired (e.g. a matured Pendle PT). Optional
38
+ * — treated as not expired when absent.
39
+ */
40
+ isExpired?: boolean;
41
+ /**
42
+ * Latest main oracle price for the token in USD (8 decimals), `undefined`
43
+ * when there is no feed. A failed answer is `0` — PriceFeedCompressor
44
+ * guarantees `price == 0` when `success == false`.
45
+ */
46
+ mainPrice?: bigint;
47
+ /**
48
+ * Whether the market still accepts quota for the token.
49
+ **/
50
+ hasActiveQuota: boolean;
51
+ }
52
+ /**
53
+ * Whether a collateral token can be the target of a leveraged strategy.
54
+ *
55
+ * A token qualifies when it
56
+ *
57
+ * - has a liquidation threshold above `0` and below `100%`, and is not the
58
+ * suite's underlying — borrowing an asset against itself is not a position,
59
+ * and an LT of `0` or at least `100%` would mean unbounded leverage;
60
+ * - is not the token the market's underlying wraps, which for an RWA market
61
+ * is the same exposure as the underlying itself (also rejected when
62
+ * `contractType` starts with `"RWA_UNDERLYING::"`);
63
+ * - is not a withdrawal or redemption phantom token listed in
64
+ * {@link NON_STRATEGY_PHANTOM_TOKEN_TYPES} — those only ever appear as the
65
+ * intermediate step of a withdrawal and cannot be acquired;
66
+ * - is not an expired token, e.g. a matured Pendle PT;
67
+ * - has a non-zero main price in the market's oracle — a zero or missing
68
+ * answer (e.g. a failed or zero price feed) means the position cannot be
69
+ * valued;
70
+ * - the market still accepts quota for.
71
+ */
72
+ declare function isStrategyCollateral({ token, underlying, unwrappedUnderlying, liquidationThreshold, contractType, isExpired, mainPrice, hasActiveQuota }: IsStrategyCollateralProps): boolean;
73
+ //#endregion
74
+ export { IsStrategyCollateralProps, NON_STRATEGY_PHANTOM_TOKEN_TYPES, isStrategyCollateral };
@@ -127,21 +127,14 @@ interface ICreditManagerContract extends IBaseContract {
127
127
  * List of collateral tokens
128
128
  */
129
129
  collateralTokens: Address[];
130
- /**
131
- * Collateral tokens a leveraged position can be built around: the underlying
132
- * is excluded, because borrowing an asset against itself is not a position,
133
- * and so is anything whose liquidation threshold is `0` or at least `100%`,
134
- * which would mean unbounded leverage.
135
- */
136
- readonly leverageableCollaterals: Address[];
137
130
  /**
138
131
  * Percentage of liquidated account value in bps paid to the liquidator
139
132
  * (i.e. `100% - liquidationDiscount`).
140
133
  */
141
134
  readonly liquidationPremium: Bps;
142
135
  /**
143
- * Highest leverage a collateral's liquidation threshold allows,
144
- * `1 / (1 - lt)`.
136
+ * Highest total-value leverage a collateral's liquidation threshold allows:
137
+ * `(1 − 0.05) / (1 − lt)`.
145
138
  *
146
139
  * @param collateral - Collateral token address.
147
140
  * @throws If the credit manager does not value the token.
@@ -56,6 +56,7 @@ import { MarketSuite, StrategyRef } from "./MarketSuite.js";
56
56
  import { CreditSuite } from "./credit/CreditSuite.js";
57
57
  import { dominantCollateral, mustGetDominantCollateral } from "./credit/dominantCollateral.js";
58
58
  import { ExpectedBalanceDeltasProps, ExpectedOutput, expectedBalanceDeltas } from "./credit/expectedBalanceDeltas.js";
59
+ import { IsStrategyCollateralProps, NON_STRATEGY_PHANTOM_TOKEN_TYPES, isStrategyCollateral } from "./credit/isStrategyCollateral.js";
59
60
  import "./credit/index.js";
60
61
  import { CompressorZapperData, ZapperData } from "./types.js";
61
62
  import { IZapperContract, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem } from "./zapper/types.js";
@@ -66,4 +67,5 @@ import { IERC20ZapperContract } from "./zapper/IERC20ZapperContract.js";
66
67
  import { IETHZapperContract } from "./zapper/IETHZapperContract.js";
67
68
  import "./zapper/index.js";
68
69
  import { MarketRegister, MarketRegistryState, MarketRegistryStateHuman } from "./MarketRegister.js";
69
- export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalanceDelta, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, CompressorZapperData, CreditAccountTokenQuota, CreditConfiguratorV310Contract, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DStokenData, Erc4626PriceFeedContract, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, GaugeContract, GaugeParams, GetOpenAccountRequirementsProps, IAdapterContract, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, IPoolContract, IPriceFeedContract, IPriceOracleContract, IRWAFactory, IRateKeeperContract, IUpdatablePriceFeedContract, IZapperContract, InterestRateModelType, LatestUpdate, LinearInterestRateModelContract, LiquidationFees, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PlaceholderAdapterContractOptions, PoolQuotaKeeperContract, PoolSuite, PoolV310Contract, PrepareUpdateQuotasProps, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RampEvent, RateKeeperType, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyRef, type TimestampedCalldata, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZapperData, ZeroPriceFeedContract, createAdapter, createPriceOracle, createZapper, dominantCollateral, expectedBalanceDeltas, fetchRedstonePayloads, getRawPriceUpdates, isLPPriceFeed, isRWAFactory, isUpdatablePriceFeed, mustGetDominantCollateral };
70
+ import { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, calcAdditionalBorrowApy, calcBorrowApy, calcMaxLeverage, calcPositionLeverage, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./math.js";
71
+ export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalanceDelta, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, CompressorZapperData, CreditAccountTokenQuota, CreditConfiguratorV310Contract, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DStokenData, Erc4626PriceFeedContract, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, GaugeContract, GaugeParams, GetOpenAccountRequirementsProps, IAdapterContract, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, IPoolContract, IPriceFeedContract, IPriceOracleContract, IRWAFactory, IRateKeeperContract, IUpdatablePriceFeedContract, IZapperContract, InterestRateModelType, IsStrategyCollateralProps, LatestUpdate, LinearInterestRateModelContract, LiquidationFees, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, NON_STRATEGY_PHANTOM_TOKEN_TYPES, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PlaceholderAdapterContractOptions, PoolQuotaKeeperContract, PoolSuite, PoolV310Contract, PrepareUpdateQuotasProps, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RampEvent, RateKeeperType, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyRef, type TimestampedCalldata, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZapperData, ZeroPriceFeedContract, calcAdditionalBorrowApy, calcBorrowApy, calcMaxLeverage, calcPositionLeverage, calcUtilization, createAdapter, createPriceOracle, createZapper, dominantCollateral, expectedBalanceDeltas, fetchRedstonePayloads, getRawPriceUpdates, healthFactorBps, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, minSeizedAmount, mustGetDominantCollateral, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber };
@@ -7,7 +7,8 @@ import "../../model/index.js";
7
7
  *
8
8
  * @example
9
9
  * ```ts
10
- * rayToBps(50_000_000_000_000_000_000_000_000n) // 500, i.e. 5%
10
+ * // ray: 5% (0.05 × 10²⁷)
11
+ * rayToBps(50_000_000_000_000_000_000_000_000n) // 500 bps = 5%
11
12
  * ```
12
13
  **/
13
14
  declare function rayToBps(ray: bigint): Bps;
@@ -16,6 +17,7 @@ declare function rayToBps(ray: bigint): Bps;
16
17
  *
17
18
  * @example
18
19
  * ```ts
20
+ * // usd: $1500.50 in 8-decimal fixed point
19
21
  * usdToNumber(150_050_000_000n) // 1500.5
20
22
  * ```
21
23
  **/
@@ -26,78 +28,86 @@ declare function usdToNumber(usd: bigint): number;
26
28
  *
27
29
  * @example
28
30
  * ```ts
29
- * utilizationBps(750n, 1000n) // 7500, i.e. 75%
31
+ * // borrowed: 750, total: 1000
32
+ * calcUtilization(750n, 1000n) // 750 / 1000 = 7500 bps = 75%
30
33
  * ```
31
34
  **/
32
- declare function utilizationBps(borrowed: bigint, total: bigint): Bps;
35
+ declare function calcUtilization(borrowed: bigint, total: bigint): Bps;
33
36
  /**
34
- * Annual cost of debt for a credit manager, in basis points: the pool's base
35
- * rate plus the protocol's cut of the accrued interest.
37
+ * Annual cost of debt for a credit manager, in basis points:
38
+ * `baseInterestRate × (1 + feeInterest)` — the pool's base rate plus the
39
+ * protocol's cut of the accrued interest.
36
40
  *
37
41
  * @param baseInterestRate - Pool base rate in ray.
38
42
  * @param feeInterest - Credit manager interest fee in basis points.
39
43
  *
40
44
  * @example
41
45
  * ```ts
42
- * // 5% base rate, 50% interest fee
43
- * borrowApyBps(50_000_000_000_000_000_000_000_000n, 5000) // 750, i.e. 7.5%
46
+ * // baseInterestRate: 5% in ray, feeInterest: 5000 bps = 50%
47
+ * calcBorrowApy(50_000_000_000_000_000_000_000_000n, 5000) // 5% × 1.5 = 750 bps = 7.5%
44
48
  * ```
45
49
  **/
46
- declare function borrowApyBps(baseInterestRate: bigint, feeInterest: number): Bps;
50
+ declare function calcBorrowApy(baseInterestRate: bigint, feeInterest: number): Bps;
47
51
  /**
48
- * Highest leverage a liquidation threshold allows: `1 / (1 - lt)`.
49
- *
50
- * A threshold of 100% or more would allow unbounded leverage; such tokens are
51
- * not strategies and are filtered out before this is called, so the guard here
52
- * only exists to keep the function total.
52
+ * 5% safety margin subtracted from 100% in {@link calcMaxLeverage}, so a
53
+ * maxed position opens with HF slightly above 1.
54
+ **/
55
+ declare const MAX_LEVERAGE_BUFFER_BPS = 500;
56
+ /**
57
+ * Highest total-value leverage a liquidation threshold allows:
58
+ * `(100% − buffer) / (100% − liquidationThreshold)`. At HF = 1, debt is
59
+ * `liquidationThreshold × totalValue`, leaving `1 − liquidationThreshold` of
60
+ * equity per unit of exposure; the {@link MAX_LEVERAGE_BUFFER_BPS} buffer
61
+ * keeps the maxed position slightly away from that boundary.
53
62
  *
54
63
  * @example
55
64
  * ```ts
56
- * maxLeverage(9000) // 10
57
- * maxLeverage(8000) // 5
65
+ * // liquidationThreshold: 9000 bps = 90%
66
+ * calcMaxLeverage(9000) // (1 − 0.05) / (1 − 0.9) = 9.5x total exposure
58
67
  * ```
59
68
  **/
60
- declare function maxLeverage(liquidationThreshold: Bps): Leverage;
69
+ declare function calcMaxLeverage(liquidationThreshold: Bps): Leverage;
61
70
  /**
62
71
  * Converts a credit account's health factor from the 18-decimal fixed point the
63
72
  * contracts store to basis points.
64
73
  *
65
- * An account with no debt return MAX_UINT256 from contract, here we return 0
74
+ * Accounts with no debt store `MAX_UINT256` on-chain; for those this
75
+ * returns `0`.
66
76
  *
67
77
  * @example
68
78
  * ```ts
69
- * healthFactorBps(1_250_000_000_000_000_000n) // 12500, i.e. 1.25
79
+ * // healthFactor: 1.25 in 18-decimal fixed point
80
+ * healthFactorBps(1_250_000_000_000_000_000n) // 12500 bps = 1.25
70
81
  * ```
71
82
  **/
72
83
  declare function healthFactorBps(healthFactor: bigint): Bps;
73
84
  /**
74
- * Leverage of an open position: `totalDebt / equity`, where equity is what is
75
- * left of the position's value once its debt is repaid.
76
- *
77
- * Returns `0` for a position that carries no debt and for one that is
78
- * underwater, where there is no equity to lever.
85
+ * Total-value leverage of an open position:
86
+ * `totalValue / (totalValue − totalDebt)`. `1` when unleveraged, `0` when
87
+ * underwater.
79
88
  *
80
- * @param totalDebt - Debt principal plus accrued interest and fees.
81
- * @param totalValue - Total value of the position, in the same token.
89
+ * @param totalValue - Total value of the position.
90
+ * @param totalDebt - Debt principal plus accrued interest and fees, same token.
82
91
  *
83
92
  * @example
84
93
  * ```ts
85
- * positionLeverage(800n, 1000n) // 4, i.e. 4x debt per unit of equity
94
+ * // totalValue: 100k, totalDebt: 80k → equity: 100k − 80k = 20k
95
+ * calcPositionLeverage(100_000n, 80_000n) // 100k / 20k = 5x
86
96
  * ```
87
97
  **/
88
- declare function positionLeverage(totalDebt: bigint, totalValue: bigint): Leverage;
98
+ declare function calcPositionLeverage(totalValue: bigint, totalDebt: bigint): Leverage;
89
99
  /**
90
- * Annual quota cost scaled to the debt a maximally leveraged position carries,
91
- * in basis points. Every unit of own capital carries `maxLeverage - 1` units of
92
- * debt, and the quota is paid on the whole quoted position.
100
+ * Annual quota cost on equity, in basis points:
101
+ * `quotaRate × (1 + feeInterest) × leverage`. Quota accrues on the whole
102
+ * quoted position, and the DAO takes `feeInterest` of it as with base interest.
93
103
  *
94
104
  * @example
95
105
  * ```ts
96
- * // 2.5% quota rate at 5x leverage
97
- * additionalBorrowApyBps(250, 5) // 1000, i.e. 10%
106
+ * // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%, leverage: 9.5x
107
+ * calcAdditionalBorrowApy(200, 2500, 9.5) // 2% × 1.25 × 9.5 = 2375 bps = 23.75%
98
108
  * ```
99
109
  **/
100
- declare function additionalBorrowApyBps(quotaRate: Bps, leverage: Leverage): Bps;
110
+ declare function calcAdditionalBorrowApy(quotaRate: Bps, feeInterest: Bps, leverage: Leverage): Bps;
101
111
  /**
102
112
  * {@link PERCENTAGE_FACTOR} less a 0.1% safety buffer.
103
113
  *
@@ -158,4 +168,4 @@ declare function optimalRepaidAmount({ totalDebt, twvUnderlying, minDebt, optima
158
168
  **/
159
169
  declare function optimalHFForPartialLiquidation(borrowRate: bigint): bigint;
160
170
  //#endregion
161
- export { OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, additionalBorrowApyBps, borrowApyBps, healthFactorBps, maxLeverage, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, positionLeverage, rayToBps, usdToNumber, utilizationBps };
171
+ export { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, calcAdditionalBorrowApy, calcBorrowApy, calcMaxLeverage, calcPositionLeverage, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber };
@@ -1,4 +1,3 @@
1
- import { OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, additionalBorrowApyBps, borrowApyBps, healthFactorBps, maxLeverage, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, positionLeverage, rayToBps, usdToNumber, utilizationBps } from "../market/math.js";
2
1
  import { MultichainOpportunitiesService } from "./MultichainOpportunitiesService.js";
3
2
  import { OpportunitiesService } from "./OpportunitiesService.js";
4
- export { MultichainOpportunitiesService, OpportunitiesService, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, additionalBorrowApyBps, borrowApyBps, healthFactorBps, maxLeverage, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, positionLeverage, rayToBps, usdToNumber, utilizationBps };
3
+ export { MultichainOpportunitiesService, OpportunitiesService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "15.1.0-next.4",
3
+ "version": "15.1.0-next.6",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {