ChainlinkOracle.
Oracle adapter that integrates Chainlink price feeds into the resilient oracle framework. Retrieves asset prices from Chainlink's decentralized network and normalizes them for ResilientOracle consumption.
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 so only fresh price data is used.
This adapter is typically configured as the main oracle source in ResilientOracle's multi-source validation pipeline.
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 in emergencies.
function setDirectPrice(address asset, uint256 price) external;
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.