ResilientOracle.
The primary price-feed contract. Implements multi-source price validation that cross-references prices from configured oracle adapters to ensure accuracy and resistance to manipulation.
Rather than relying on a single oracle, ResilientOracle aggregates prices from a configurable set of adapters (e.g., Chainlink, TWAP, Pyth) and applies validation rules to detect anomalies. Each asset can be configured with a main, pivot, and fallback oracle. The pivot validates the main price against bounds; the fallback covers the case when validation fails.
This design protects the protocol from oracle manipulation, stale data, and single points of failure.
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;
Main price
The main oracle provides the price.
Pivot validation
The pivot oracle validates the main price against upper/lower bounds via BoundValidator.
Fallback if needed
If validation fails, the fallback oracle price is used. If all oracles fail, the transaction reverts.