Price Oracles
Introduction
Price oracles are fundamental to Euler's lending protocol, providing the real-time price data needed to ensure borrowers remain over-collateralized and the system maintains its stability. These oracles are crucial for determining collateralization levels, triggering liquidations, and maintaining overall system health. Euler's oracle-agnostic and modular design allows seamless integration with any type of external price feed, giving vault creators and risk curators maximum flexibility in asset and risk management.
Core Components
IPriceOracle Interface
At the heart of Euler's price oracle system is the IPriceOracle
interface, which serves as the foundation for standardized price queries. This interface is the reference implementation for the "Common Quote Oracle" outlined in ERC-7726, an Ethereum Improvement Proposal that defines a standard API for data feeds providing the relative value of assets.
The interface provides three key functions:
interface IPriceOracle {
function name() external view returns (string memory);
function getQuote(
uint256 inAmount,
address base,
address quote
) external view returns (uint256 outAmount);
function getQuotes(
uint256 inAmount,
address base,
address quote
) external view returns (uint256 bidOutAmount, uint256 askOutAmount);
}
Adapters and Routers
The system uses two main types of components to interact with price feeds:
-
Adapters are immutable and ungoverned smart contracts that implement the
IPriceOracle
interface. They serve as the atomic building blocks of the system, interfacing with external oracles and converting their data into a standardized format. Currently, Euler supports adapters for various vendors including Chainlink, Chronicle, Pyth, RedStone, Lido, Uniswap V3, and Balancer Rate Provider. -
Routers are smart contracts that also implement the
IPriceOracle
interface but serve as configurable dispatchers for price queries. They can be governed to change which providers are queried, though they can be made immutable by transferring governance toaddress(0)
. This flexible design allows the system to dynamically integrate various pricing sources, adapting to different assets and market conditions.
Pricing Mechanisms
Price oracles can be categorized into different classes based on how they determine asset prices:
-
Market oracles use trading activity and liquidity from both decentralized and centralized exchanges to determine asset prices. They typically aggregate prices from multiple sources to provide real-time valuations, offering more accurate market-based pricing but potentially being more sensitive to short-term price fluctuations.
-
Fundamental oracles price assets based on intrinsic factors rather than market trading. These often use fixed prices, such as hard-coding the value of a stablecoin to 1 USD or using protocol-defined rates. While they can protect borrowers from temporary price fluctuations, they may not always reflect true market value during sustained price movements.
-
Exchange rate oracles establish prices based on built-in exchange rates between derivative assets and their underlying, using redemption values and protocol-defined calculations. These are particularly useful for assets that have a direct relationship with their underlying value.
Oracle Types and Trade-offs
Choosing an appropriate pricing mechanism for a credit vault is the responsibility of vault creators and risk curators. There is no single "best" way to price an asset in a lending protocol—each approach has trade-offs that shift risk between lenders and borrowers. For example, a fundamental price oracle that fixes an asset's price at 1 USD can protect borrowers from liquidation due to temporary price fluctuations in secondary markets, but may expose lenders to bad debt during sustained price movements. Conversely, a market-based oracle offers more accurate valuations but may be vulnerable to price manipulation or trigger unnecessary liquidations due to short-term price swings.
Vendor-Agnostic Adapter System
Euler is vendor-agnostic, supporting adapters for Chainlink, Chronicle, Pyth, RedStone, Lido, Uniswap V3, and Balancer Rate Provider. Developers can integrate additional oracle sources by implementing new adapters that conform to the IPriceOracle
interface.
Standardized Pricing Interface
Euler's IPriceOracle
is the reference implementation for the "Common Quote Oracle" outlined in ERC-7726, an Ethereum Improvement Proposal that defines a standard API for data feeds providing the relative value of assets.
Price Quoting System
Currency Pairs
The system supports various types of currency pairs for price queries:
- ERC-20 token addresses for both base and quote currencies
- Fiat currencies using ISO 4217 codes (e.g.,
address(840)
for USD) - Precious metals using similar address encoding
Quote-Based Pricing
Instead of returning simple price fractions, the system uses a quote-based approach that accepts an inAmount
parameter and returns the equivalent amount in the quote currency. This approach handles decimal precision internally and reduces precision loss in extreme cases.
Bid-Ask Spreads
The system supports bid-ask spreads to represent price uncertainty:
- Bid: The amount you would receive for selling
- Ask: The amount you would pay for buying
- Mid-point: The provider's best estimate of fair market value
- Spread: The difference between bid and ask, representing confidence interval
Implementation Details
ERC-4626 Support
The router can natively convert ERC-4626 vault shares into underlying assets using the standard convertToAssets()
method. This is particularly important for Euler's credit vault system, where collateral assets are configured as vault addresses rather than the underlying assets themselves. However, it's important to note that while the convertToAssets
function can include security mechanisms like internal balance tracking and virtual deposits to mitigate rounding-based exploits, these protections are only guaranteed in EVK vaults. For other ERC-4626 vaults, this method may be vulnerable to manipulation attacks and should be used with caution. For more information about potential vulnerabilities, see the Donation Attacks documentation.
CrossAdapter
The CrossAdapter
enables price derivation by combining two oracles that share a base or quote asset. For example, an ETH/DAI price can be derived from ETH/USDC and DAI/USDC prices. This feature enables more flexible price discovery while maintaining security through composable components.
For more detailed information about the implementation and technical specifications, please refer to the Euler Price Oracle repository.