ChainlinkOracleImpl ​
Inherits: OracleError, ChainlinkStructs
This contract is used to get the exchange rate via up to 3 hops at Chainlink price feeds. The rate is multiplied with the previous rate at each hop. E.g. to go from wBTC to USDC (assuming rates for example):
- wBTC -> BTC https://data.chain.link/ethereum/mainnet/crypto-other/wbtc-btc, rate: 0.92.
 - BTC -> USD https://data.chain.link/ethereum/mainnet/crypto-usd/btc-usd rate: 30,000.
 - USD -> USDC https://data.chain.link/ethereum/mainnet/stablecoins/usdc-usd rate: 0.98. Must invert feed: 1.02 finale rate would be: 0.92 * 30,000 * 1.02 = 28,152
 
State Variables ​
_CHAINLINK_FEED1 ​
Chainlink price feed 1 to check for the exchange rate
IChainlinkAggregatorV3 internal immutable _CHAINLINK_FEED1;_CHAINLINK_FEED2 ​
Chainlink price feed 2 to check for the exchange rate
IChainlinkAggregatorV3 internal immutable _CHAINLINK_FEED2;_CHAINLINK_FEED3 ​
Chainlink price feed 3 to check for the exchange rate
IChainlinkAggregatorV3 internal immutable _CHAINLINK_FEED3;_CHAINLINK_INVERT_RATE1 ​
Flag to invert the price or not for feed 1 (to e.g. for WETH/USDC pool return prive of USDC per 1 WETH)
bool internal immutable _CHAINLINK_INVERT_RATE1;_CHAINLINK_INVERT_RATE2 ​
Flag to invert the price or not for feed 2 (to e.g. for WETH/USDC pool return prive of USDC per 1 WETH)
bool internal immutable _CHAINLINK_INVERT_RATE2;_CHAINLINK_INVERT_RATE3 ​
Flag to invert the price or not for feed 3 (to e.g. for WETH/USDC pool return prive of USDC per 1 WETH)
bool internal immutable _CHAINLINK_INVERT_RATE3;_CHAINLINK_PRICE_SCALER_MULTIPLIER1 ​
constant value for price scaling to reduce gas usage for feed 1
uint256 internal immutable _CHAINLINK_PRICE_SCALER_MULTIPLIER1;_CHAINLINK_INVERT_PRICE_DIVIDEND1 ​
constant value for inverting price to reduce gas usage for feed 1
uint256 internal immutable _CHAINLINK_INVERT_PRICE_DIVIDEND1;_CHAINLINK_PRICE_SCALER_MULTIPLIER2 ​
constant value for price scaling to reduce gas usage for feed 2
uint256 internal immutable _CHAINLINK_PRICE_SCALER_MULTIPLIER2;_CHAINLINK_INVERT_PRICE_DIVIDEND2 ​
constant value for inverting price to reduce gas usage for feed 2
uint256 internal immutable _CHAINLINK_INVERT_PRICE_DIVIDEND2;_CHAINLINK_PRICE_SCALER_MULTIPLIER3 ​
constant value for price scaling to reduce gas usage for feed 3
uint256 internal immutable _CHAINLINK_PRICE_SCALER_MULTIPLIER3;_CHAINLINK_INVERT_PRICE_DIVIDEND3 ​
constant value for inverting price to reduce gas usage for feed 3
uint256 internal immutable _CHAINLINK_INVERT_PRICE_DIVIDEND3;Functions ​
constructor ​
constructor sets the Chainlink price feed and invertRate flag for each hop. E.g. invertRate_ should be true if for the USDC/ETH pool it's expected that the oracle returns USDC per 1 ETH
constructor(ChainlinkConstructorParams memory params_);_getChainlinkExchangeRate ​
Get the exchange rate from Chainlike oracle price feed(s)
function _getChainlinkExchangeRate() internal view returns (uint256 rate_);Returns
| Name | Type | Description | 
|---|---|---|
rate_ | uint256 | The exchange rate in OracleUtils.RATE_OUTPUT_DECIMALS | 
_readFeedRate ​
reads the exchange rate_ from a Chainlink price feed_ taking into account scaling and invertRate_
function _readFeedRate(
    IChainlinkAggregatorV3 feed_,
    bool invertRate_,
    uint256 priceMultiplier_,
    uint256 invertDividend_
) private view returns (uint256 rate_);chainlinkOracleData ​
returns all Chainlink oracle related data as utility for easy off-chain use / block explorer in a single view method
function chainlinkOracleData()
    public
    view
    returns (
        uint256 chainlinkExchangeRate_,
        IChainlinkAggregatorV3 chainlinkFeed1_,
        bool chainlinkInvertRate1_,
        uint256 chainlinkExchangeRate1_,
        IChainlinkAggregatorV3 chainlinkFeed2_,
        bool chainlinkInvertRate2_,
        uint256 chainlinkExchangeRate2_,
        IChainlinkAggregatorV3 chainlinkFeed3_,
        bool chainlinkInvertRate3_,
        uint256 chainlinkExchangeRate3_
    );
