DexReservesFromLiquidity ​
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
Name | Type | Description |
---|---|---|
supplyTokenSlot_ | bytes32 | The storage slot for the supply token data |
exchangePriceSlot_ | bytes32 | The storage slot for the exchange price of the token |
isToken0_ | bool | Boolean indicating if the token is token0 (true) or token1 (false) |
Returns
Name | Type | Description |
---|---|---|
tokenSupply_ | uint256 | The 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
Name | Type | Description |
---|---|---|
borrowTokenSlot_ | bytes32 | The storage slot for the borrow token data |
exchangePriceSlot_ | bytes32 | The storage slot for the exchange price of the token |
isToken0_ | bool | Boolean indicating if the token is token0 (true) or token1 (false) |
Returns
Name | Type | Description |
---|---|---|
debtAmount_ | uint256 | The 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_);