Constants ​
_DEX_POOL ​
address _DEX_POOL
_RESERVES_CONVERSION_ORACLE ​
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 ​
bool _RESERVES_CONVERSION_INVERT
_QUOTE_IN_TOKEN0 ​
bool _QUOTE_IN_TOKEN0
if true, convert all reserves token1 into token0. otherwise all token0 into token1.
_RESERVES_PEG_BUFFER_PERCENT ​
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 ​
uint8 _DEX_SHARES_DECIMALS
_DEX_TOKENS_DECIMALS_PRECISION ​
uint8 _DEX_TOKENS_DECIMALS_PRECISION
X128 ​
uint256 X128
_LIQUIDITY ​
contract IFluidLiquidity _LIQUIDITY
internal immutables read from DEX at time of deployment
_BORROW_TOKEN_0_SLOT ​
bytes32 _BORROW_TOKEN_0_SLOT
_BORROW_TOKEN_1_SLOT ​
bytes32 _BORROW_TOKEN_1_SLOT
_EXCHANGE_PRICE_TOKEN_0_SLOT ​
bytes32 _EXCHANGE_PRICE_TOKEN_0_SLOT
_EXCHANGE_PRICE_TOKEN_1_SLOT ​
bytes32 _EXCHANGE_PRICE_TOKEN_1_SLOT
_TOKEN_0_NUMERATOR_PRECISION ​
uint256 _TOKEN_0_NUMERATOR_PRECISION
_TOKEN_0_DENOMINATOR_PRECISION ​
uint256 _TOKEN_0_DENOMINATOR_PRECISION
_TOKEN_1_NUMERATOR_PRECISION ​
uint256 _TOKEN_1_NUMERATOR_PRECISION
_TOKEN_1_DENOMINATOR_PRECISION ​
uint256 _TOKEN_1_DENOMINATOR_PRECISION
_RESERVES_SCALER ​
uint256 _RESERVES_SCALER
DexViews ​
_getDexTotalBorrowShares ​
function _getDexTotalBorrowShares() internal view returns (uint256 totalBorrowShares_)
_getLiquidityDebt ​
function _getLiquidityDebt(bytes32 borrowTokenSlot_, bytes32 exchangePriceSlot_, bool isToken0_) internal view returns (uint256 debtAmount_)
Retrieves debt amount from liquidity layer for a given token
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) |
Return Values ​
Name | Type | Description |
---|---|---|
debtAmount_ | uint256 | The calculated liquidity debt amount adjusted to 1e12 decimals |
_getDexDebtReserves ​
function _getDexDebtReserves() internal view returns (uint256 token0Reserves_, uint256 token1Reserves_)
Get the debt reserves at the Dex adjusted to 1e12 decimals
DexSmartDebtPegOracleImpl ​
constructor ​
constructor(address dexPool_, address reservesConversionOracle_, bool quoteInToken0_, bool reservesConversionInvert_, uint256 reservesPegBufferPercent_) internal
Parameters ​
Name | Type | Description |
---|---|---|
dexPool_ | address | The address of the DEX pool |
reservesConversionOracle_ | address | The oracle used to convert reserves. Set to address zero if not needed. |
quoteInToken0_ | bool | The 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_ | bool | Whether to invert the reserves conversion. Can be skipped if no reservesConversionOracle is configured. |
reservesPegBufferPercent_ | uint256 | The percentage buffer for pegged reserves. |
_getDexSmartDebtOperate ​
function _getDexSmartDebtOperate() internal view returns (uint256 rate_)
_getDexSmartDebtLiquidate ​
function _getDexSmartDebtLiquidate() internal view returns (uint256 rate_)
dexSmartDebtOracleData ​
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 ​
Name | Type | Description |
---|---|---|
dexPool_ | address | The address of the Dex pool. |
reservesPegBufferPercent_ | uint256 | The percentage of the reserves peg buffer. |
liquidity_ | contract IFluidLiquidity | The address of the liquidity contract. |
token0NumeratorPrecision_ | uint256 | The precision of the numerator for token0. |
token0DenominatorPrecision_ | uint256 | The precision of the denominator for token0. |
token1NumeratorPrecision_ | uint256 | The precision of the numerator for token1. |
token1DenominatorPrecision_ | uint256 | The precision of the denominator for token1. |
reservesConversionOracle_ | contract IFluidOracle | The address of the reserves conversion oracle. |
reservesConversionInvert_ | bool | A boolean indicating if reserves conversion should be inverted. |
quoteInToken0_ | bool | A boolean indicating if the quote is in token0. |
dexSmartDebtSharesRates ​
function dexSmartDebtSharesRates() public view returns (uint256 operate_, uint256 liquidate_)
Returns the rates of shares (totalReserves/totalShares)