Skip to content

Constants ​

_DEX_POOL ​

solidity
address _DEX_POOL

_RESERVES_CONVERSION_ORACLE ​

solidity
contract IFluidOracle _RESERVES_CONVERSION_ORACLE

external IFluidOracle used to convert token0 into token1 or the other way around depending on _QUOTE_IN_TOKEN0.

_RESERVES_CONVERSION_INVERT ​

solidity
bool _RESERVES_CONVERSION_INVERT

_QUOTE_IN_TOKEN0 ​

solidity
bool _QUOTE_IN_TOKEN0

if true, convert all reserves token1 into token0. otherwise all token0 into token1.

_RESERVES_PEG_BUFFER_PERCENT ​

solidity
uint256 _RESERVES_PEG_BUFFER_PERCENT

if Dex is e.g. USDC / USDT a peg can be assumed instead of fetching the price at the Dex Oracle (which might not even be active in such a case). If so, this var defines the peg buffer to reduce collateral value (and increase debt value) by some defined percentage for safety handling of price ranges. in 1e4: 10000 = 1%, 1000000 = 100%

_DEX_SHARES_DECIMALS ​

solidity
uint8 _DEX_SHARES_DECIMALS

_DEX_TOKENS_DECIMALS_PRECISION ​

solidity
uint8 _DEX_TOKENS_DECIMALS_PRECISION

X128 ​

solidity
uint256 X128

_LIQUIDITY ​

solidity
contract IFluidLiquidity _LIQUIDITY

internal immutables read from DEX at time of deployment

_BORROW_TOKEN_0_SLOT ​

solidity
bytes32 _BORROW_TOKEN_0_SLOT

_BORROW_TOKEN_1_SLOT ​

solidity
bytes32 _BORROW_TOKEN_1_SLOT

_EXCHANGE_PRICE_TOKEN_0_SLOT ​

solidity
bytes32 _EXCHANGE_PRICE_TOKEN_0_SLOT

_EXCHANGE_PRICE_TOKEN_1_SLOT ​

solidity
bytes32 _EXCHANGE_PRICE_TOKEN_1_SLOT

_TOKEN_0_NUMERATOR_PRECISION ​

solidity
uint256 _TOKEN_0_NUMERATOR_PRECISION

_TOKEN_0_DENOMINATOR_PRECISION ​

solidity
uint256 _TOKEN_0_DENOMINATOR_PRECISION

_TOKEN_1_NUMERATOR_PRECISION ​

solidity
uint256 _TOKEN_1_NUMERATOR_PRECISION

_TOKEN_1_DENOMINATOR_PRECISION ​

solidity
uint256 _TOKEN_1_DENOMINATOR_PRECISION

_RESERVES_SCALER ​

solidity
uint256 _RESERVES_SCALER

DexViews ​

_getDexTotalBorrowShares ​

solidity
function _getDexTotalBorrowShares() internal view returns (uint256 totalBorrowShares_)

_getLiquidityDebt ​

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

Retrieves debt amount from liquidity layer for a given token

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)

Return Values ​

NameTypeDescription
debtAmount_uint256The calculated liquidity debt amount adjusted to 1e12 decimals

_getDexDebtReserves ​

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

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

DexSmartDebtPegOracleImpl ​

constructor ​

solidity
constructor(address dexPool_, address reservesConversionOracle_, bool quoteInToken0_, bool reservesConversionInvert_, uint256 reservesPegBufferPercent_) internal

Parameters ​

NameTypeDescription
dexPool_addressThe address of the DEX pool
reservesConversionOracle_addressThe oracle used to convert reserves. Set to address zero if not needed.
quoteInToken0_boolThe asset to quote in. If true then quote in token0. Can be skipped if no reservesConversionOracle is configured. This should be set to the pegged to asset: E.g. for token0 = WSTETH, token1 = ETH, this should be set to false! if true -> this oracle outputs how much WSTETH one Dex debt share is worth if false -> this oracle outputs how much ETH one Dex debt share is worth
reservesConversionInvert_boolWhether to invert the reserves conversion. Can be skipped if no reservesConversionOracle is configured.
reservesPegBufferPercent_uint256The percentage buffer for pegged reserves.

_getDexSmartDebtOperate ​

solidity
function _getDexSmartDebtOperate() internal view returns (uint256 rate_)

_getDexSmartDebtLiquidate ​

solidity
function _getDexSmartDebtLiquidate() internal view returns (uint256 rate_)

dexSmartDebtOracleData ​

solidity
function dexSmartDebtOracleData() public view returns (address dexPool_, uint256 reservesPegBufferPercent_, contract IFluidLiquidity liquidity_, uint256 token0NumeratorPrecision_, uint256 token0DenominatorPrecision_, uint256 token1NumeratorPrecision_, uint256 token1DenominatorPrecision_, contract IFluidOracle reservesConversionOracle_, bool reservesConversionInvert_, bool quoteInToken0_)

Returns the configuration data of the DexSmartDebtOracle.

Return Values ​

NameTypeDescription
dexPool_addressThe address of the Dex pool.
reservesPegBufferPercent_uint256The percentage of the reserves peg buffer.
liquidity_contract IFluidLiquidityThe address of the liquidity contract.
token0NumeratorPrecision_uint256The precision of the numerator for token0.
token0DenominatorPrecision_uint256The precision of the denominator for token0.
token1NumeratorPrecision_uint256The precision of the numerator for token1.
token1DenominatorPrecision_uint256The precision of the denominator for token1.
reservesConversionOracle_contract IFluidOracleThe address of the reserves conversion oracle.
reservesConversionInvert_boolA boolean indicating if reserves conversion should be inverted.
quoteInToken0_boolA boolean indicating if the quote is in token0.

dexSmartDebtSharesRates ​

solidity
function dexSmartDebtSharesRates() public view returns (uint256 operate_, uint256 liquidate_)

Returns the rates of shares (totalReserves/totalShares)