ChainlinkOracleFeed

Git Source

Inherits: OracleFeed

Author: luoyhang003

Oracle adapter that integrates with Chainlink price feeds.

Inherits from the abstract OracleFeed contract and implements the peek function by querying a Chainlink AggregatorV3Interface.

State Variables

priceFeed

Chainlink price feed contract (AggregatorV3Interface).

Immutable after deployment to ensure oracle integrity.

AggregatorV3Interface public immutable priceFeed;

Functions

constructor

Deploys the Chainlink oracle feed wrapper.

constructor(address _token, string memory _name, address _priceFeed) OracleFeed(_token, _name);

Parameters

NameTypeDescription
_tokenaddressThe address of the token this oracle is associated with.
_namestringA human-readable name for this oracle feed.
_priceFeedaddressThe address of the Chainlink AggregatorV3 price feed.

peek

Returns the latest price from the Chainlink feed, normalized to 18 decimals.

*Performs several safety checks:

  • Ensures the returned price is positive.
  • Ensures the round is not stale.
  • Ensures the round data is complete and not from the future.
  • Adjusts decimals from the Chainlink feed to a standard 18-decimal format.*
function peek() external view override returns (uint256 price_);

Returns

NameTypeDescription
price_uint256The latest valid price, scaled to 18 decimals.