Get Account Liquidity

Account Liquidity represents the USD value borrowable by a user, before it reaches liquidation. Users with a shortfall (negative liquidity) are subject to liquidation, and can’t withdraw or borrow assets until Account Liquidity is positive again.

For each market the user has entered into, their supplied balance is multiplied by the market’s collateral factor, and summed; borrow balances are then subtracted, to equal Account Liquidity. Borrowing an asset reduces Account Liquidity for each USD borrowed; withdrawing an asset reduces Account Liquidity by the asset’s collateral factor times each USD withdrawn.

Qore

function accountLiquidityOf(address account) external view returns (uint collateralInUSD, uint supplyInUSD, uint borrowInUSD);
  • account: The account whose liquidity shall be calculated.

  • RETURN: Tuple of values (collateral value in USD, supply value in USD, borrow value in USD). The liquidity can be calculated by subtracting borrow value from collateral value. If the borrow value exceeds the collateral value, the account is currently below his/her collateral requirement and is subject to liquidation.

Solidity

Qore qore = Qore(<qoreAddress>);
(uint collateralInUSD, uint supplyInUSD, uint borrowInUSD) = qore.accountLiquidityOf(<accountAddress>);

Ethers.js

const qore = await ethers.getContractAt(<qoreABI>, <qoreAddress>);
const { collateralInUSD, supplyInUSD, borrowInUSD } = await qore.accountLiquidityOf(<accountAddress>);

Last updated