import { AugustBase, type IAugustBase } from '../../core'; import type { IAddress, ILoanBookInfo, ISubaccountDebank, ISubaccountTransaction, IWSSubaccountListItem } from '../../types'; /** * Subaccount operation class interacting with August Subaccounts * Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform. * It functions as a cross-margin account designed for optimal capital efficiency. * * `getSubaccountSummary`, `getSubaccountHealthFactor`, `getSubaccountLoans`, * `getSubaccountCefiPositions` and `getSubaccountOtcPositions` work without an * August API key for subaccounts linked to a vault; `getSubaccountDebank` is * public. `getSubaccountTransactions` needs a key authorized for the * subaccount, and `getAllSubaccounts` and `getSubaccountLoanByAddress` need an * admin key. */ export declare class AugustSubAccounts extends AugustBase { private headers; constructor(baseConfig: IAugustBase); /** * Retrieves one page of the directory of all August subaccounts. * * Backed by the admin-only `GET /subaccount` backend endpoint, so the * August API key configured on the SDK must belong to an admin user — * non-admin keys are rejected with an auth error by the backend. Makes * exactly one HTTP request and no RPC calls. * * @param options - Pagination window over the subaccount directory * @param options.offset - Number of records to skip. Defaults to 0; must be a non-negative integer. * @param options.limit - Page size. Defaults to 100; must be an integer between 1 and 1000 (backend maximum). * @returns The page of subaccount records (address, internal/friendly names, status, type, linked chains, risk metadata). An empty array means the offset is past the end of the directory. * @throws AugustValidationError when `offset` or `limit` is out of range * @throws AugustAuthError when the API key is missing or not admin-scoped * @example * const page = await augustSdk.subAccountsModule.getAllSubaccounts({ * offset: 0, * limit: 200, * }); * console.log(page.map((s) => `${s.internal_name}: ${s.address}`)); */ getAllSubaccounts(options?: { offset?: number; limit?: number; }): Promise; /** * Retrieves the health factor for a subaccount. * @param subaccountAddress - The address of the subaccount to query * @returns The health factor data including collateral value, loan value, and health factor ratio */ getSubaccountHealthFactor(subaccountAddress: IAddress): Promise<{ id: `0x${string}`; dateTime: string; healthFactor: number; totalCollateral: number; totalLoan: number; }>; /** * Retrieves loan positions for a subaccount. * @param subaccountAddress - The address of the subaccount to query * @param side - Filter by loan side: 'BOTH' for all loans, 'LENDER' for lent positions, 'BORROWER' for borrowed positions * @param active - When true, returns only active loans; when false, returns all loans including closed ones * @returns List of loan positions matching the specified filters */ getSubaccountLoans(subaccountAddress: IAddress, side: 'BOTH' | 'LENDER' | 'BORROWER', active: boolean): Promise; /** * Retrieves CeFi (Centralized Finance) positions for a subaccount. * @param subaccountAddress - The address of the subaccount to query * @returns List of CeFi positions held by the subaccount */ getSubaccountCefiPositions(subaccountAddress: IAddress): Promise; /** * Retrieves OTC (Over-The-Counter) positions for a subaccount. * @param subaccountAddress - The address of the subaccount to query * @returns List of OTC positions held by the subaccount */ getSubaccountOtcPositions(subaccountAddress: IAddress): Promise; /** * Retrieves the summary view for a subaccount or EOA operator. * @param subaccountAddress - The address of the subaccount to query * @returns The full summary including portfolio, loanbook, tokens, and account values */ getSubaccountSummary(subaccountAddress: IAddress): Promise<{ address: `0x${string}`; name: string; type: "eoa" | "subaccount"; portfolio: { tokens: { value: number; balance: number; token: { type: string; name: string; address: string; chain: number; symbol: string; decimals: number; imgUrl: string; }; }[]; marginBalances: unknown[]; collateralBalances: unknown[]; cefiPositions: unknown[]; defiPositions: unknown[]; trsPositions: unknown[]; strategyContractPositions: unknown[]; legacyHedgerPositions: unknown[]; otcPositions: unknown[]; totalValue: number; discountedValue: number; }; loanbook: { loans: { subaccountAddress: `0x${string}`; book: { address: `0x${string}`; lender: `0x${string}`; borrower: `0x${string}`; state: string; totalRepaid: number; principalToken: { type: string; name: string; address: string; chain: number; symbol: string; decimals: number; imgUrl: string; tokenType: number; discountFactor: number; price: number; }; principalAmount: number; interestAmount: number; upcomingPayment: { amount: number; dueDate: string; }; apr: number; initialPrincipalAmount: number; deployedDate: string; paymentInterval: number; totalInterestPaymentFees: number; }; isBorrow: boolean; debtInfo: { interestOwed: number; principalDebtOwed: number; interestRepaid: number; }; creditInfo: { netInterestOwed: number; principalDebtOwed: number; netInterestRepaid: number; }; }[]; totalDebt: number; totalCredit: number; aggregatesByToken: unknown[]; }; chains: { name: string; chainId: number; }[]; tokens: { type: string; name: string; address: string; chain: number; symbol: string; decimals: number; imgUrl: string; price: number; rawBalance: number; balance: number; value: number; }[]; totalAccountValue: number; totalCollateralValue: number; totalLoanValue: number; healthFactor: number; netAccountValue: number; totalEquityValue: number; }>; /** * Retrieves a subaccount's on-chain transaction history, newest first, * optionally windowed by a time range. * * Backed by the authenticated `GET /transactions/v2` backend endpoint, * which resolves and authorizes the subaccount, so the configured August * API key must be authorized for it (an admin-scoped key always is). Makes * exactly one HTTP request and no RPC calls. * * @param subaccountAddress - The address of the subaccount to query * @param options - Optional time window * @param options.startTime - ISO-8601 datetime lower bound (inclusive); omit for no lower bound * @param options.endTime - ISO-8601 datetime upper bound (inclusive); omit for no upper bound * @returns The subaccount's transactions with decoded logs, transfers, and function names * @throws AugustValidationError When `subaccountAddress` is not a valid EVM address * @throws AugustAuthError When the API key is missing or not authorized for the subaccount * @throws AugustServerError When the API responds with a non-2xx status * @example * const txs = await augustSdk.subAccountsModule.getSubaccountTransactions( * '0xabc…', * { startTime: '2026-01-01T00:00:00Z' }, * ); */ getSubaccountTransactions(subaccountAddress: IAddress, options?: { startTime?: string; endTime?: string; }): Promise; /** * Retrieves the full loan-book detail for a single loan by its address and * chain. * * Backed by the admin-only `GET /subaccount/loans/{loan_address}` backend * endpoint (60-second server-side cache), so the configured August API key * must belong to an admin user. Makes exactly one HTTP request and no RPC * calls. * * @param loanAddress - The loan contract address * @param chainId - Numeric August chain id the loan lives on (e.g. `1` for Ethereum mainnet) * @returns The loan's {@link ILoanBookInfo} detail * @throws AugustValidationError When `chainId` is not an integer * @throws AugustAuthError When the API key is missing or not admin-scoped * @throws AugustServerError When the loan or chain is not found, or the API otherwise responds non-2xx * @example * const loan = await augustSdk.subAccountsModule.getSubaccountLoanByAddress( * '0xloan…', * 1, * ); */ getSubaccountLoanByAddress(loanAddress: string, chainId: number): Promise; /** * Retrieves cross-chain DeBank protocol positions and token balances for a * subaccount and its associated strategies. * * Backed by `GET /subaccount/{subaccount_address}/debank` (300-second * server-side cache). This is a slow endpoint — it fans out to DeBank * across every supported chain — so expect higher latency than other * subaccount reads. Makes exactly one HTTP request and no RPC calls. * * @param subaccountAddress - The address of the subaccount to query * @returns The subaccount's DeBank positions/tokens plus per-strategy breakdowns * @throws AugustValidationError When `subaccountAddress` is not a valid EVM address * @throws AugustServerError When the API responds with a non-2xx status * @example * const debank = await augustSdk.subAccountsModule.getSubaccountDebank('0xabc…'); * console.log(debank.subaccount.positions.length); */ getSubaccountDebank(subaccountAddress: IAddress): Promise; }