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
priceFeed
Address of the Chainlink price feed used to consult the price
IChainlinkOracle public priceFeed;
_sequencerUptimeFeed
Internal storage variable to allow overrides in child implementation contract
IChainlinkOracle internal _sequencerUptimeFeed;
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 _priceFeed, address __sequencerUptimeFeed, uint256 _staleThreshold);
Parameters
Name | Type | Description |
---|---|---|
_priceFeed | address | The address of the Chainlink price feed |
__sequencerUptimeFeed | address | The address of the Chainlink sequencer uptime feed |
_staleThreshold | uint256 | The threshold after which the price is considered stale |
sequencerUptimeFeed
Address of the Chainlink sequencer uptime feed used to consult the sequencer status
function sequencerUptimeFeed() public view virtual returns (IChainlinkOracle __sequencerUptimeFeed);
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 price feed into 18 decimals format
function _parseResult(int256 _feedResult) internal view returns (uint256 _result);
_isValidFeed
Checks if the feed is valid, considering the sequencer status, the staleThreshold and the feed timestamp
function _isValidFeed(uint256 _feedTimestamp) internal view returns (bool _valid);
_setSequencerUptimeFeed
Sets the Chainlink sequencer uptime feed contract address
function _setSequencerUptimeFeed(address __sequencerUptimeFeed) internal virtual;