Resilient Oracle
The ResilientOracle is the primary price feed contract for the Rheofi Protocol. It implements a multi-source price validation architecture that cross-references prices from multiple oracle sources to ensure accuracy and resistance to manipulation.
Overview
Rather than relying on a single oracle, the ResilientOracle aggregates prices from a configurable set of oracle adapters (e.g., Chainlink, TWAP, Pyth) and applies validation rules to detect anomalies. Each asset can be configured with a main oracle, a pivot oracle, and a fallback oracle. The pivot oracle is used to validate the main oracle's price against configurable bounds, and the fallback oracle provides a secondary price source if the main oracle fails validation.
This design protects the protocol from oracle manipulation attacks, stale data, and single points of failure.
Key Functions
getPrice
Returns the validated price for a given asset address.
function getPrice(address asset) external view returns (uint256);
getUnderlyingPrice
Returns the validated price for the underlying asset of an RToken market.
function getUnderlyingPrice(address rToken) external view returns (uint256);
setTokenConfig
Configures the oracle sources and validation parameters for a specific asset.
function setTokenConfig(TokenConfig memory tokenConfig) external;
The TokenConfig struct includes:
struct TokenConfig {
address asset;
address[3] oracles; // [main, pivot, fallback]
bool[3] enableFlagsForOracles;
}
setOracle
Registers or updates an oracle adapter contract for a specific oracle role.
function setOracle(
address oracle,
OracleRole role
) external;
Price Validation Flow
- The main oracle provides the price.
- The pivot oracle validates the main price against upper/lower bounds.
- If validation fails, the fallback oracle price is used.
- If all oracles fail, the transaction reverts.