import { type IMarket, Market, type MaxBorrowOptions, type MaxPositionCapacities, type MaxWithdrawCollateralOptions } from "../market/index.js"; import type { Address, BigIntish, MarketId } from "../types.js"; export interface IPosition { user: Address; marketId: MarketId; supplyShares: bigint; borrowShares: bigint; collateral: bigint; } export declare class Position implements IPosition { /** * The user holding this position. */ readonly user: Address; /** * The id of the market on which this position is held. */ readonly marketId: MarketId; /** * The amount of supply shares held with this position. */ supplyShares: bigint; /** * The amount of borrow shares held with this position. */ borrowShares: bigint; /** * The amount of collateral assets held with this position. */ collateral: bigint; constructor({ user, marketId, supplyShares, borrowShares, collateral, }: IPosition); } export interface IAccrualPosition extends Omit { } export declare class AccrualPosition extends Position implements IAccrualPosition { protected readonly _market: Market; constructor(position: IAccrualPosition, market: IMarket); /** * The market on which this position is held. */ get market(): Market; get supplyAssets(): bigint; get borrowAssets(): bigint; /** * The value of this position's collateral quoted in loan assets. * `undefined` if the market's oracle is undefined or reverts. */ get collateralValue(): bigint | undefined; /** * The maximum amount of loan assets that can be borrowed against this position's collateral. * `undefined` if the market's oracle is undefined or reverts. */ get maxBorrowAssets(): bigint | undefined; /** * The maximum additional amount of assets that can be borrowed against this position's collateral. * `undefined` if the market's oracle is undefined or reverts. */ get maxBorrowableAssets(): bigint | undefined; /** * The maximum amount of collateral that can be seized in exchange for the outstanding debt. * `undefined` if the market's oracle is undefined or reverts. */ get seizableCollateral(): bigint | undefined; /** * The maximum amount of collateral that can be withdrawn. * `undefined` if the market's oracle is undefined or reverts. */ get withdrawableCollateral(): bigint | undefined; /** * Whether this position is healthy. * `undefined` if the market's oracle is undefined or reverts. */ get isHealthy(): boolean | undefined; /** * Whether this position can be liquidated. * `undefined` if the market's oracle is undefined or reverts. */ get isLiquidatable(): boolean | undefined; /** * The price of the collateral quoted in loan assets that would allow this position to be liquidated. * `null` if the position has no borrow. */ get liquidationPrice(): bigint | null; /** * The price variation required for the position to reach its liquidation threshold (scaled by WAD). * Negative when healthy (the price needs to drop x%), positive when unhealthy (the price needs to soar x%). * `undefined` if the market's oracle is undefined or reverts. * `null` if the position is not a borrow. */ get priceVariationToLiquidationPrice(): bigint | null | undefined; /** * This position's Loan-To-Value (debt over collateral power, scaled by WAD). * If the collateral price is 0, LTV is `MaxUint256`. * `undefined` if the market's oracle is undefined or reverts. */ get ltv(): bigint | null | undefined; /** * This position's health factor (collateral power over debt, scaled by WAD). * If the debt is 0, health factor is `MaxUint256`. * `undefined` if the market's oracle is undefined or reverts. */ get healthFactor(): bigint | undefined; /** * The percentage of this position's borrow power currently used (scaled by WAD). * If the collateral price is 0, usage is `MaxUint256`. */ get borrowCapacityUsage(): bigint | undefined; /** * Returns the maximum amount of loan assets that can be withdrawn given a certain supply position * and a balance of loan assets, and the reason for the limit. */ get withdrawCapacityLimit(): import("../utils.js").CapacityLimit; /** * Returns a new position derived from this position, whose interest has been accrued up to the given timestamp. * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the market's `lastUpdate`. */ accrueInterest(timestamp?: BigIntish): AccrualPosition; supply(assets: bigint, shares: bigint, timestamp?: BigIntish): { position: AccrualPosition; assets: bigint; shares: bigint; }; withdraw(assets: bigint, shares: bigint, timestamp?: BigIntish): { position: AccrualPosition; assets: bigint; shares: bigint; }; supplyCollateral(assets: bigint): AccrualPosition; withdrawCollateral(assets: bigint, timestamp?: BigIntish): AccrualPosition; borrow(assets: bigint, shares: bigint, timestamp?: BigIntish): { position: AccrualPosition; assets: bigint; shares: bigint; }; repay(assets: bigint, shares: bigint, timestamp?: BigIntish): { position: AccrualPosition; assets: bigint; shares: bigint; }; getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../utils.js").CapacityLimit | undefined; getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../utils.js").CapacityLimit | undefined; getRepayCapacityLimit(loanTokenBalance: bigint): import("../utils.js").CapacityLimit; getMaxCapacities(loanTokenBalance: bigint, collateralTokenBalance: bigint, options?: { borrow?: MaxBorrowOptions; withdrawCollateral?: MaxWithdrawCollateralOptions; }): MaxPositionCapacities; }