Skip to main content
Reference · Oracle

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.

Overview

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.

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
01

Main price

The main oracle provides the price.

02

Pivot validation

The pivot oracle validates the main price against upper/lower bounds via BoundValidator.

03

Fallback if needed

If validation fails, the fallback oracle price is used. If all oracles fail, the transaction reverts.