Skip to content

DexReservesFromLiquidity ​

Git Source

Inherits:DexOracleBase

reads the dex reserves directly from Liquidity (user supply / user debt)

Functions ​

constructor ​

solidity
constructor(address dexPool_, bool quoteInToken0_) DexOracleBase(dexPool_, quoteInToken0_);

_getLiquidityCollateral ​

Retrieves collateral amount from liquidity layer for a given token

solidity
function _getLiquidityCollateral(bytes32 supplyTokenSlot_, bytes32 exchangePriceSlot_, bool isToken0_)
    private
    view
    returns (uint256 tokenSupply_);

Parameters

NameTypeDescription
supplyTokenSlot_bytes32The storage slot for the supply token data
exchangePriceSlot_bytes32The storage slot for the exchange price of the token
isToken0_boolBoolean indicating if the token is token0 (true) or token1 (false)

Returns

NameTypeDescription
tokenSupply_uint256The calculated liquidity collateral amount

_getLiquidityDebt ​

Retrieves debt amount from liquidity layer for a given token

solidity
function _getLiquidityDebt(bytes32 borrowTokenSlot_, bytes32 exchangePriceSlot_, bool isToken0_)
    private
    view
    returns (uint256 debtAmount_);

Parameters

NameTypeDescription
borrowTokenSlot_bytes32The storage slot for the borrow token data
exchangePriceSlot_bytes32The storage slot for the exchange price of the token
isToken0_boolBoolean indicating if the token is token0 (true) or token1 (false)

Returns

NameTypeDescription
debtAmount_uint256The calculated liquidity debt amount adjusted to 1e12 decimals

_getDexCollateralReserves ​

Get the col reserves at the Dex adjusted to 1e12 decimals

solidity
function _getDexCollateralReserves() internal view virtual returns (uint256 token0Reserves_, uint256 token1Reserves_);

_getDexDebtReserves ​

Get the debt reserves at the Dex adjusted to 1e12 decimals

solidity
function _getDexDebtReserves() internal view virtual returns (uint256 token0Reserves_, uint256 token1Reserves_);