ChainlinkRelayer
Inherits: IBaseOracle, IChainlinkRelayer
This contracts transforms a Chainlink price feed into a standard IBaseOracle feed It also verifies that the reading is new enough, compared to a staleThreshold
State Variables
chainlinkFeed
Address of the Chainlink aggregator used to consult the price
IChainlinkOracle public chainlinkFeed;
symbol
Symbol of the quote: token / baseToken (e.g. 'ETH / USD')
string public symbol;
multiplier
The multiplier used to convert the quote into an 18 decimals format
uint256 public multiplier;
staleThreshold
The time threshold after which a Chainlink response is considered stale
uint256 public staleThreshold;
Functions
constructor
constructor(address _aggregator, uint256 _staleThreshold);
Parameters
Name | Type | Description |
---|---|---|
_aggregator | address | The address of the Chainlink aggregator |
_staleThreshold | uint256 | The threshold after which the price is considered stale |
getResultWithValidity
Fetch the latest oracle result and whether it is valid or not
This method should never revert
function getResultWithValidity() external view returns (uint256 _result, bool _validity);
read
Fetch the latest oracle result
Will revert if is the price feed is invalid
function read() external view returns (uint256 _result);
_parseResult
Parses the result from the aggregator into 18 decimals format
function _parseResult(int256 _chainlinkResult) internal view returns (uint256 _result);
_isValidFeed
Checks if the feed is valid, considering the staleThreshold and the feed timestamp
function _isValidFeed(uint256 _feedTimestamp) internal view returns (bool _valid);