Skip to main content

Chainlink Oracle

The ChainlinkOracle contract is an oracle adapter that integrates Chainlink price feeds into the Rheofi Protocol's resilient oracle framework. It retrieves asset prices from Chainlink's decentralized oracle network and normalizes them for consumption by the ResilientOracle.

Overview

Chainlink provides industry-standard decentralized price feeds with broad asset coverage. The ChainlinkOracle adapter maps each supported asset to its corresponding Chainlink aggregator, handles decimal normalization, and enforces staleness checks to ensure that only fresh price data is used by the protocol.

This adapter is typically configured as the main oracle source in the ResilientOracle's multi-source validation pipeline.

Key Functions

getPrice

Returns the current price of an asset from its configured Chainlink feed.

function getPrice(address asset) external view returns (uint256);

The returned price is normalized to 18 decimals regardless of the underlying Chainlink feed's decimal precision.

setTokenConfig

Configures the Chainlink feed address and parameters for a specific asset.

function setTokenConfig(TokenConfig memory tokenConfig) external;

The TokenConfig struct:

struct TokenConfig {
address asset;
address feed;
uint256 maxStalePeriod;
}

setDirectPrice

Allows governance to set a direct price for an asset, bypassing the Chainlink feed. Used for assets without Chainlink coverage or during emergency situations.

function setDirectPrice(address asset, uint256 price) external;

Staleness Protection

Each asset's configuration includes a maxStalePeriod parameter. If the latest Chainlink round data is older than this threshold, the price request reverts, preventing the use of outdated prices.

See Also