import { type Address } from "viem"; import type { Account, AccountPopulated, AccountPosition, DaysToLiquidation, GetNextSubAccountOptions, IHasVaultAddress } from "./Account.js"; import { type GetFreeSubAccountsOptions } from "../utils/subAccounts.js"; import { type YieldApyBreakdown } from "../utils/accountComputations.js"; import type { ViewerOptions } from "../services/rewardsService/index.js"; export interface PortfolioPositionFilterContext { account: Account; } export type PortfolioPositionFilter = (position: AccountPosition, context: PortfolioPositionFilterContext) => boolean; export interface PortfolioOptions { /** Permanent predicate applied to every AccountPosition considered by the portfolio. */ positionFilter?: PortfolioPositionFilter; } export interface PortfolioSavingsPositionArgs { position: AccountPosition; vault?: TVaultEntity; subAccount: Address; shares: bigint; assets: bigint; suppliedValueUsd?: number; } /** * Savings entry produced by `Portfolio.savings`. * * The default-view getters (`apy`, `apyBreakdown`) return the no-viewer * "headline" numbers. Pass a viewer through `getApyBreakdown({ viewer })` * to apply whitelist/blacklist eligibility on the rewards bucket. */ export declare class PortfolioSavingsPosition { position: AccountPosition; vault?: TVaultEntity; subAccount: Address; shares: bigint; assets: bigint; suppliedValueUsd?: number; constructor(args: PortfolioSavingsPositionArgs); /** Default-view APY total (no viewer). */ get apy(): number | undefined; /** Default-view APY breakdown (no viewer). */ get apyBreakdown(): YieldApyBreakdown | undefined; /** * Supply APY contribution breakdown for this savings position. * `opts.viewer` filters whitelist/blacklist-gated rewards. */ getApyBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; } export interface PortfolioBorrowPositionArgs { borrow: AccountPosition; collaterals: AccountPosition[]; collateral?: AccountPosition; borrowVault?: TVaultEntity; collateralVault?: TVaultEntity; collateralVaults: Address[]; subAccount: Address; healthFactor?: bigint; userLTV?: bigint; currentLTV?: bigint; borrowed: bigint; supplied: bigint; price?: number; primaryCollateralLiquidationPrice?: number; borrowLiquidationPriceUsd?: number; collateralLiquidationPricesUsd?: Record; liquidatable: boolean; borrowLTV?: number; liquidationLTV?: number; accountLiquidationLTV?: number; liabilityValueBorrowing?: bigint; liabilityValueLiquidation?: bigint; liabilityValueUsd?: number; totalCollateralValueUsd?: number; collateralValueLiquidation?: bigint; timeToLiquidation?: DaysToLiquidation; multiplier?: number; } /** * Borrow entry produced by `Portfolio.borrows`. * * Default-view getters (`netApy`, `roe`, `apyBreakdown`, `roeBreakdown`) return * the no-viewer "headline" numbers. Pass a viewer through `getApyBreakdown({ viewer })` * or `getRoeBreakdown({ viewer })` to apply whitelist/blacklist eligibility on * the rewards bucket. */ export declare class PortfolioBorrowPosition { /** Underlying debt position. */ borrow: AccountPosition; /** Collateral positions backing the debt. */ collaterals: AccountPosition[]; /** Primary collateral position. */ collateral?: AccountPosition; borrowVault?: TVaultEntity; collateralVault?: TVaultEntity; collateralVaults: Address[]; subAccount: Address; healthFactor?: bigint; userLTV?: bigint; currentLTV?: bigint; borrowed: bigint; supplied: bigint; price?: number; primaryCollateralLiquidationPrice?: number; borrowLiquidationPriceUsd?: number; collateralLiquidationPricesUsd?: Record; liquidatable: boolean; borrowLTV?: number; liquidationLTV?: number; accountLiquidationLTV?: number; liabilityValueBorrowing?: bigint; liabilityValueLiquidation?: bigint; liabilityValueUsd?: number; totalCollateralValueUsd?: number; collateralValueLiquidation?: bigint; timeToLiquidation?: DaysToLiquidation; /** Effective collateral multiplier: supplied value / equity value. */ multiplier?: number; constructor(args: PortfolioBorrowPositionArgs); /** Default-view net APY (no viewer). */ get netApy(): number | undefined; /** Default-view ROE (no viewer). */ get roe(): number | undefined; /** Default-view APY breakdown (no viewer). */ get apyBreakdown(): YieldApyBreakdown | undefined; /** Default-view ROE breakdown (no viewer). */ get roeBreakdown(): YieldApyBreakdown | undefined; /** * Net APY contribution breakdown for this borrow position. * `opts.viewer` filters whitelist/blacklist-gated rewards. */ getApyBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; /** * ROE contribution breakdown for this borrow position. * `opts.viewer` filters whitelist/blacklist-gated rewards. */ getRoeBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; private get yieldPositions(); } export interface IPortfolio { account: Account; populated: AccountPopulated; getFreeSubAccounts(options?: GetFreeSubAccountsOptions): Address[]; getNextSubAccount(options?: GetNextSubAccountOptions): Address | undefined; getNewSubAccount(options?: GetNextSubAccountOptions): Address | undefined; /** Structural set of positions across the portfolio. Viewer-independent. */ readonly positions: AccountPosition[]; /** * Savings positions. Per-position `apyBreakdown` is the default-view (no * viewer) value; use `position.getApyBreakdown({ viewer })` for viewer-aware. */ readonly savings: PortfolioSavingsPosition[]; /** * Borrow positions. Per-position `apyBreakdown` / `roeBreakdown` are * default-view; use `position.getApyBreakdown({ viewer })` / * `position.getRoeBreakdown({ viewer })` for viewer-aware. */ readonly borrows: PortfolioBorrowPosition[]; readonly totalSuppliedValueUsd?: number; readonly totalBorrowedValueUsd?: number; readonly netAssetValueUsd?: number; /** Default-view net APY (no viewer). Equivalent to `getNetApy()`. */ readonly netApy?: number; getNetApy(opts?: ViewerOptions): number | undefined; /** Default-view ROE (no viewer). Equivalent to `getRoe()`. */ readonly roe?: number; getRoe(opts?: ViewerOptions): number | undefined; /** Default-view net APY breakdown (no viewer). Equivalent to `getNetApyBreakdown()`. */ readonly apyBreakdown?: YieldApyBreakdown; getNetApyBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; /** Default-view ROE breakdown (no viewer). Equivalent to `getRoeBreakdown()`. */ readonly roeBreakdown?: YieldApyBreakdown; getRoeBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; readonly totalRewardsValueUsd?: number; } /** * High-level account view that abstracts sub-accounts into savings and borrows. * * Portfolio is computed from an Account. It stores only the Account reference and * permanent construction options, so Account mutations and re-population are * reflected by subsequent Portfolio computed-property reads. */ export declare class Portfolio implements IPortfolio { readonly account: Account; readonly populated: AccountPopulated; private readonly options; constructor(account: Account, options?: PortfolioOptions); /** * Returns sub-account addresses with no active supplied or borrowed position * in this portfolio view. */ getFreeSubAccounts(options?: GetFreeSubAccountsOptions): Address[]; /** * Returns the first sub-account address suitable for opening a new position * in this portfolio view. */ getNextSubAccount(options?: GetNextSubAccountOptions): Address | undefined; /** Alias for callers using new-position terminology. */ getNewSubAccount(options?: GetNextSubAccountOptions): Address | undefined; /** Structural set of positions across the portfolio. Viewer-independent. */ get positions(): AccountPosition[]; /** * Savings positions visible to the portfolio. * * Each entry's default-view `apyBreakdown` reflects the headline rewards. * Use `entry.getApyBreakdown({ viewer })` for viewer-aware values. */ get savings(): PortfolioSavingsPosition[]; /** * Borrow positions visible to the portfolio. * * Each entry's default-view `apyBreakdown` / `roeBreakdown` reflect the * headline rewards. Use `entry.getApyBreakdown({ viewer })` or * `entry.getRoeBreakdown({ viewer })` for viewer-aware values. */ get borrows(): PortfolioBorrowPosition[]; /** Sum of supplied value across positions that pass the portfolio filter. */ get totalSuppliedValueUsd(): number | undefined; /** Sum of borrowed value across positions that pass the portfolio filter. */ get totalBorrowedValueUsd(): number | undefined; /** Net asset value in USD: supplied minus borrowed. */ get netAssetValueUsd(): number | undefined; /** Default-view net APY (no viewer). Equivalent to `getNetApy()`. */ get netApy(): number | undefined; /** * Net APY across positions that pass the portfolio filter. * * For include/exclude filtering (drop rewards / intrinsicApy) use * `getNetApyBreakdown(opts)` and reduce the components you want. */ getNetApy(opts?: ViewerOptions): number | undefined; /** Default-view ROE (no viewer). Equivalent to `getRoe()`. */ get roe(): number | undefined; /** * Return on equity across positions that pass the portfolio filter. * * For include/exclude filtering use `getRoeBreakdown(opts)`. */ getRoe(opts?: ViewerOptions): number | undefined; /** Default-view net APY breakdown (no viewer). Equivalent to `getNetApyBreakdown()`. */ get apyBreakdown(): YieldApyBreakdown | undefined; /** Net APY contribution breakdown across positions that pass the portfolio filter. */ getNetApyBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; /** Default-view ROE breakdown (no viewer). Equivalent to `getRoeBreakdown()`. */ get roeBreakdown(): YieldApyBreakdown | undefined; /** ROE contribution breakdown across positions that pass the portfolio filter. */ getRoeBreakdown(opts?: ViewerOptions): YieldApyBreakdown | undefined; /** Total unclaimed rewards value in USD, delegated to the wrapped Account. */ get totalRewardsValueUsd(): number | undefined; private get collateralUsageSet(); /** * Structural set of yield-bearing positions, derived without viewer. * `suppliedValueUsd` / `borrowedValueUsd` are dollar amounts which don't depend on viewer; * viewer affects the reward APR applied per-position downstream. */ private get yieldPositions(); private includePosition; private occupiedPositionSubAccounts; private borrowPositionSubAccounts; private subAccountsWithPosition; } //# sourceMappingURL=Portfolio.d.ts.map