import { Bps } from "../../model/primitives.js"; import { BorrowRateBreakdown, Position, StrategyPosition } from "../../model/positions.js"; import { AccountMetrics, AccountProjection } from "../../model/previews.js"; import { PositionWithdrawals } from "../../model/withdrawals.js"; import "../../model/index.js"; import { AccountSnapshot, GetCurrentWithdrawalsProps, ListPositionsProps, ListStrategyPositionsProps } from "./types.js"; import { SDKConstruct } from "../base/SDKConstruct.js"; import "../base/index.js"; //#region src/onchain/positions/PositionsService.d.ts /** * Options of the projection-aware position metrics: {@link PositionsService.borrowRate} * and {@link PositionsService.timeToLiquidation}. **/ export interface ProjectedPoolOptions { /** * Change the operation makes to the pool's available liquidity, in * underlying units: `oldDebt − newDebt`. Negative when the operation borrows * more (liquidity leaves the pool, utilization and the base rate rise), * positive when it repays. When set, the base borrow rate is re-quoted from * the interest rate model at the projected utilization instead of the pool's * current rate. **/ availableLiquidityChange?: bigint; } /** * The `positions` read model of one chain: everything a wallet holds in the * protocol — pool shares, open credit accounts, and delayed withdrawals it * took over by liquidating. **/ export declare class PositionsService extends SDKConstruct { #private; /** * Every position of a wallet on this chain, optionally narrowed by * {@link PositionFilter} (see {@link matchesPositionFilter} for what each * condition selects). Reads live chain state, so rows reflect the moment of * the call rather than the SDK's loaded snapshot. **/ list(props: ListPositionsProps): Promise; /** * Describes all credit accounts of a wallet as strategy positions. * * @param props - {@link ListStrategyPositionsProps} **/ listStrategyPositions(props: ListStrategyPositionsProps): Promise; /** * Returns delayed withdrawals of a strategy position **/ getCurrentWithdrawals(props: GetCurrentWithdrawalsProps): Promise; /** * Health factor of an account state, in basis points (`10000` = 1.0). **/ healthFactor(snapshot: AccountSnapshot, options?: { safePrices?: boolean; }): Bps; /** * Cost of an account state's debt, broken down into the pool's base rate * and per-token quota rates. A projection passes the operation's liquidity * delta via {@link ProjectedPoolOptions} to have the base rate re-quoted at * the post-operation pool utilization. **/ borrowRate(snapshot: AccountSnapshot, options?: ProjectedPoolOptions): BorrowRateBreakdown; /** * Estimated milliseconds until the account's health factor decays to * `10000` under its current borrow rate, or `null` when the debt carries * no rate (or the account is already liquidatable). Takes the same * projection options as {@link PositionsService.borrowRate}, so a projected * state decays at the projected rate. **/ timeToLiquidation(snapshot: AccountSnapshot, options?: ProjectedPoolOptions): bigint | null; /** * Price of the single non-underlying collateral at which the account * becomes liquidatable, or `null` when the account holds zero or several * non-underlying assets. **/ liquidationPrice(snapshot: AccountSnapshot): bigint | null; /** * What the collateral {@link liquidationPrice} is quoted for costs in the * market underlying right now, in the same `PRICE_DECIMALS` fixed point — * the pair a form shows beside the liquidation price. `null` under exactly * the conditions that leave the liquidation price `null`, plus an oracle * that cannot answer for either side. **/ currentPrice(snapshot: AccountSnapshot): bigint | null; /** * Every derived number of an account state at once — the whole * {@link AccountMetrics} half of a projection. * * This is what both halves of the SDK fill their answers from: `prepare`, for * a state it walked an intent into, and `preview`, for one it replayed out of * calldata. One snapshot in, one set of metrics out, so the two descriptions * of the same operation cannot disagree because one of them grew its own * formula. * * Identical to the four methods above field for field, and cheaper than * calling them one by one: the market data is collected once, and the health * factor and borrow rate the time to liquidation decays at are the very ones * reported beside it. **/ metrics(snapshot: AccountSnapshot, options?: ProjectedPoolOptions): AccountMetrics; /** * A projected account state as both halves of the SDK report it: the holdings * priced and named, and the metrics of {@link PositionsService.metrics}. * * The snapshot is taken at its word — what it lists is what comes back, so a * caller that drops dust before the walk reports an account without it, and * one that keeps wei reports them. That is the whole of the policy left to * the caller; everything downstream of the balances is decided here. * * @param options - The operation's effect on the pool, for the rate the * metrics are quoted at, see {@link ProjectedPoolOptions}. **/ projection(snapshot: AccountSnapshot, options?: ProjectedPoolOptions): AccountProjection; } //#endregion