import type { IAddress } from './web3'; /** * Chain record attached to a subaccount directory entry, as serialized by the * backend `IChainRead` schema. */ export interface IWSSubaccountListChain { id: string; chain_id: number; name: string; } /** * One subaccount record (backend `ISubaccountRead` schema), as returned by the * admin-only `GET /subaccount` directory, `GET /users/{address}/subaccounts` * and `GET /org/subaccounts`. Nullable fields are optional metadata the * operations team may not have filled in. */ export interface IWSSubaccountListItem { id: string; user_id: string | null; internal_name: string; friendly_name: string | null; address: IAddress; status: string | null; subaccount_type: string | null; min_health_factor: number | null; estimated_apr: number | null; notes: string | null; proxy_salt: string | null; admin_salt: string | null; disable_discount_factor: boolean | null; turnkey_address: IAddress | null; autopay_frequency: string | null; implementation: string | null; variant: string | null; default_fee_rate_in_bips: number | null; wallet_role: string | null; /** * Cached USD account value, refreshed out of band by an hourly backend job. * A sort key and placeholder, not an authoritative NAV — read the live value * from the subaccount summary. `null` before the job's first run; absent on * backends that predate the field. */ latest_account_value?: number | null; /** Naive-UTC ISO timestamp of `latest_account_value`. */ account_value_updated_at?: string | null; chains: IWSSubaccountListChain[]; } export interface IWSSubAccountHealthFactor { id: IAddress; datetime: string; health_factor: number; total_collateral_value: number; total_loan_value: number; } export interface IWSSubaccountSummaryToken { type: string; name: string; address: string; chain: number; symbol: string; decimals: number; img_url: string; } export interface IWSSubaccountSummaryPortfolioToken { value: number; balance: number; token: IWSSubaccountSummaryToken; } export interface IWSSubaccountSummaryFullToken extends IWSSubaccountSummaryToken { price: number; raw_balance: number; balance: number; value: number; } export interface IWSSubaccountSummaryChain { name: string; chain_id: number; } export interface IWSSubaccountSummaryLoanBook { address: IAddress; lender: IAddress; borrower: IAddress; state: string; total_repaid: number; principal_token: IWSSubaccountSummaryToken & { token_type: number; discount_factor: number; price: number; }; principal_amount: number; interest_amount: number; upcoming_payment: { amount: number; due_date: string; }; apr: number; initial_principal_amount: number; deployed_date: string; payment_interval: number; total_interest_payment_fees: number; } export interface IWSSubaccountSummaryLoan { subaccount_address: IAddress; book: IWSSubaccountSummaryLoanBook; is_borrow: boolean; debt_info: { interest_owed: number; principal_debt_owed: number; interest_repaid: number; }; credit_info: { net_interest_owed: number; principal_debt_owed: number; net_interest_repaid: number; }; } export interface IWSSubaccountSummaryLoanbook { loans: IWSSubaccountSummaryLoan[]; total_debt: number; total_credit: number; aggregates_by_token: unknown[]; } export interface IWSSubaccountSummaryPortfolio { tokens: IWSSubaccountSummaryPortfolioToken[]; margin_balances: unknown[]; collateral_balances: unknown[]; cefi_positions: unknown[]; defi_positions: unknown[]; trs_positions: unknown[]; strategy_contract_positions: unknown[]; legacy_hedger_positions: unknown[]; otc_positions: unknown[]; total_value: number; discounted_value: number; } export interface IWSSubaccountSummary { address: IAddress; name: string; type: 'subaccount' | 'eoa'; portfolio: IWSSubaccountSummaryPortfolio; loanbook: IWSSubaccountSummaryLoanbook; chains: IWSSubaccountSummaryChain[]; tokens: IWSSubaccountSummaryFullToken[]; total_account_value: number; total_collateral_value: number; total_loan_value: number; health_factor: number | null; net_account_value: number; total_equity_value: number; }