VaultOracleBase ​
Inherits:DexShareResolver, TokenSymbolResolver, VaultError, IFluidOracle
Title: VaultOracleBase
Abstract base for vault oracles. Inherits DexShareResolver for share pricing, TokenSymbolResolver for _tokenSymbol, and adds normal token resolution + exchange rate computation. USD Oracle reads use immutable supply/borrow eModes (per deployment). Exchange rate = debt-per-collateral in 1e27 precision adjusted for token decimals. _resolveNormalWrite serves IFluidOracleWrite vault types (T1 only; smart vaults T2–T4 stay view-only — Write there is planned for later, once actually needed).
Constants ​
SUPPLY_E_MODE ​
eMode passed to FluidUsdOracle for collateral-side price reads from this vault oracle.
uint256 internal immutable SUPPLY_E_MODEBORROW_E_MODE ​
eMode passed to FluidUsdOracle for debt-side price reads from this vault oracle.
uint256 internal immutable BORROW_E_MODEPEG_BUFFER_PPM_OPERATE ​
Reserve adjustment (ppm on PEG_BUFFER_SCALE) applied to DEX share legs on the operate path.
uint256 internal immutable PEG_BUFFER_PPM_OPERATEPEG_BUFFER_PPM_LIQUIDATE ​
Reserve adjustment (ppm on PEG_BUFFER_SCALE) applied to DEX share legs on the liquidate path.
uint256 internal immutable PEG_BUFFER_PPM_LIQUIDATENATIVE_TOKEN_ADDRESS ​
address internal constant NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEFLUID_RATE_DECIMALS ​
Fluid protocol rate / USD price fixed-point scale (1e27).
uint256 internal constant FLUID_RATE_DECIMALS = 27Functions ​
constructor ​
Bounds on both values are enforced by VaultOracleFactory at registration. Checking here as well would only surface as the deployer factory's own generic error, since the revert would happen inside deployContract.
constructor(
uint256 supplyEMode_,
uint256 borrowEMode_,
uint256 pegBufferPpmOperate_,
uint256 pegBufferPpmLiquidate_
) ;Parameters
| Name | Type | Description |
|---|---|---|
supplyEMode_ | uint256 | |
borrowEMode_ | uint256 | |
pegBufferPpmOperate_ | uint256 | Operate-path DEX share reserve adjustment. |
pegBufferPpmLiquidate_ | uint256 | Liquidate-path DEX share reserve adjustment. |
infoName ​
function infoName() public view returns (string memory);getOracleConfig ​
Returns canonical vault-oracle config fields across T1-T4.
Non-applicable fields are returned as address(0) depending on vault type.
function getOracleConfig()
external
view
returns (
address usdOracle_,
address supplyToken0_,
address supplyToken1_,
address borrowToken0_,
address borrowToken1_,
address supplyDexPool_,
address borrowDexPool_,
uint256 supplyEMode_,
uint256 borrowEMode_
);targetDecimals ​
function targetDecimals() public view returns (uint8 targetDecimals_);getExchangeRateOperate ​
Get the exchange rate for operate mode.
function getExchangeRateOperate() external view returns (uint256 exchangeRate_);getExchangeRateLiquidate ​
Get the exchange rate for liquidate mode.
function getExchangeRateLiquidate() external view returns (uint256 exchangeRate_);getExchangeRate ​
Deprecated. Same as operate.
function getExchangeRate() external view returns (uint256 exchangeRate_);getExchangeRateOperateRaw ​
Same as getExchangeRateOperate(), for resolver/UI reads only. May bypass checks that can revert on the guarded getter.
Example today: L2 sequencer uptime / grace-period. Additional bypasses may be added here over time.
function getExchangeRateOperateRaw() external view returns (uint256 exchangeRate_);getExchangeRateLiquidateRaw ​
Same as getExchangeRateLiquidate(), for resolver/UI reads only. May bypass checks that can revert on the guarded getter.
Example today: L2 sequencer uptime / grace-period. Additional bypasses may be added here over time.
function getExchangeRateLiquidateRaw() external view returns (uint256 exchangeRate_);getExchangeRateRaw ​
Same as getExchangeRate(), for resolver/UI reads only. May bypass checks that can revert on the guarded getter.
Example today: L2 sequencer uptime / grace-period. Additional bypasses may be added here over time.
function getExchangeRateRaw() external view returns (uint256 exchangeRate_);_resolveNormal ​
Resolves USD price and decimals of a normal (non-share) token.
function _resolveNormal(address usdOracle_, address token_, bool isOperate_, bool isCollateral_, bool isRaw_)
internal
view
returns (uint256 priceUsd_, uint256 decimals_);_resolveNormalWrite ​
Write variant of _resolveNormal via UsdOracle getPriceDetailed (persists source state).
function _resolveNormalWrite(address usdOracle_, address token_, bool isOperate_, bool isCollateral_)
internal
returns (uint256 priceUsd_, uint256 decimals_);_dexSharePegBufferPpm ​
Peg buffer for T2–T4 DEX share legs, set per deployment. T1 has no DEX leg and never calls this.
function _dexSharePegBufferPpm(bool isOperate_) internal view returns (uint256 pegBufferPpm_);_computeExchangeRate ​
Computes the exchange rate between collateral and debt. rate = colPriceUsd * 10^(27 + debtDecimals - colDecimals) / debtPriceUsd Example: ETH (18 dec) / USDC (6 dec) at $2000/$1: 2000e27 * 10^(27+6-18) / 1e27 = 2000e27 * 1e15 / 1e27 = 2000 * 1e15 = 2e18 targetDecimals = 15, so 2e18 represents 2000 USDC per ETH.
function _computeExchangeRate(
uint256 colPriceUsd_,
uint256 colDecimals_,
uint256 debtPriceUsd_,
uint256 debtDecimals_
) internal pure returns (uint256 exchangeRate_);_tokenDecimals ​
function _tokenDecimals(address token_) internal view returns (uint256 decimals_);_dexPairName ​
function _dexPairName(address token0_, address token1_) internal view returns (string memory);_oracleConfigAddresses ​
function _oracleConfigAddresses()
internal
view
virtual
returns (
address usdOracle_,
address supplyToken0_,
address supplyToken1_,
address borrowToken0_,
address borrowToken1_,
address supplyDexPool_,
address borrowDexPool_
);_getExchangeRate ​
Each vault oracle implements this to wire its specific collateral/debt resolution.
function _getExchangeRate(bool isOperate_, bool isRaw_) internal view virtual returns (uint256 exchangeRate_);Parameters
| Name | Type | Description |
|---|---|---|
isOperate_ | bool | |
isRaw_ | bool | When true, use raw oracle reads (getPriceDetailedViewRaw, etc.) that may bypass guarded checks (e.g. L2 sequencer uptime today). |
_collateralName ​
function _collateralName() internal view virtual returns (string memory);_debtName ​
function _debtName() internal view virtual returns (string memory);_collateralDecimals ​
function _collateralDecimals() internal view virtual returns (uint256);_debtDecimals ​
function _debtDecimals() internal view virtual returns (uint256);