Oracles
Accurate asset pricing is fundamental to the safety and efficiency of lending and borrowing operations. To address this, lending protocols use Oracle contracts to aggregate and process price feeds. Dahlia’s approach to oracles is designed to provide flexibility, scalability, and robust data integrity — critical for long-tail assets that often face liquidity challenges.
Oracle-Agnostic Design
Dahlia markets are oracle agnostic, meaning any oracle can be used as long as it implements the IDahliaOracle interface. This allows for seamless integration with existing price feeds while supporting custom oracle implementations.
Dahlia’s Oracle Factory enhances this flexibility, enabling market deployers to choose from pre-built oracle types or deploy their own custom oracles.
Pre-Built Oracles
Chainlink Oracle
Relies on Chainlink’s decentralized oracle network for accurate and reliable price feeds.
Dahlia uses a maximum delay check to ensure the data remains fresh and hasn’t been delayed beyond an acceptable threshold.
Uniswap V3 TWAP Oracle
Uses the Time-Weighted Average Price (TWAP) from Uniswap V3 to calculate decentralized pricing.
Particularly effective for newer or long-tail assets that lack dedicated Chainlink feeds or suffer from liquidity constraints.
Dual Oracle (Chainlink with Uniswap Fallback)
The Chainlink Oracle serves as the primary price feed.
If the Chainlink Oracle returns
badData
— indicating stale or invalid pricing — the system falls back to the Uniswap V3 TWAP Oracle as a secondary source.This fallback mechanism ensures continued price reliability and system safety while minimizing exposure to oracle failures.
The Oracle Factory allows anyone to deploy a new oracle using one of the pre-built oracle types. For further customization, developers can implement their own oracles, provided they:
Adhere to the IDahliaOracle interface.
Include a properly defined
getPrice()
function.
Oracle Malfunction
If an oracle that implements the delay sanity check fails (e.g., returns badData
), Dahlia activates safeguards to protect users.
When an oracle malfunction occurs:
Actions requiring fresh price data, such as liquidations, borrowing, or withdrawing collateral, are halted.
The Oracle Stalled Mode, detailed on the Market Modes page, outlines the resolution process. This includes a
REPAY_PERIOD
during which borrowers can repay debts and reclaim collateral, ensuring fair liquidity distribution even without a functioning price feed.
Last updated