ChainlinkOracleImpl2

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): 1. wBTC -> BTC https://data.chain.link/ethereum/mainnet/crypto-other/wbtc-btc, rate: 0.92. 2. BTC -> USD https://data.chain.link/ethereum/mainnet/crypto-usd/btc-usd rate: 30,000. 3. 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

_CHAINLINK2_FEED1

contract IChainlinkAggregatorV3 _CHAINLINK2_FEED1

Chainlink price feed 1 to check for the exchange rate

_CHAINLINK2_FEED2

contract IChainlinkAggregatorV3 _CHAINLINK2_FEED2

Chainlink price feed 2 to check for the exchange rate

_CHAINLINK2_FEED3

contract IChainlinkAggregatorV3 _CHAINLINK2_FEED3

Chainlink price feed 3 to check for the exchange rate

_CHAINLINK2_INVERT_RATE1

bool _CHAINLINK2_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)

_CHAINLINK2_INVERT_RATE2

bool _CHAINLINK2_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)

_CHAINLINK2_INVERT_RATE3

bool _CHAINLINK2_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)

_CHAINLINK2_PRICE_SCALER_MULTIPLIER1

uint256 _CHAINLINK2_PRICE_SCALER_MULTIPLIER1

constant value for price scaling to reduce gas usage for feed 1

_CHAINLINK2_INVERT_PRICE_DIVIDEND1

uint256 _CHAINLINK2_INVERT_PRICE_DIVIDEND1

constant value for inverting price to reduce gas usage for feed 1

_CHAINLINK2_PRICE_SCALER_MULTIPLIER2

uint256 _CHAINLINK2_PRICE_SCALER_MULTIPLIER2

constant value for price scaling to reduce gas usage for feed 2

_CHAINLINK2_INVERT_PRICE_DIVIDEND2

uint256 _CHAINLINK2_INVERT_PRICE_DIVIDEND2

constant value for inverting price to reduce gas usage for feed 2

_CHAINLINK2_PRICE_SCALER_MULTIPLIER3

uint256 _CHAINLINK2_PRICE_SCALER_MULTIPLIER3

constant value for price scaling to reduce gas usage for feed 3

_CHAINLINK2_INVERT_PRICE_DIVIDEND3

uint256 _CHAINLINK2_INVERT_PRICE_DIVIDEND3

constant value for inverting price to reduce gas usage for feed 3

constructor

constructor(struct ChainlinkStructs.ChainlinkConstructorParams params_) internal

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

_getChainlinkExchangeRate2

function _getChainlinkExchangeRate2() internal view returns (uint256 rate_)

Get the exchange rate from Chainlike oracle price feed(s)

Return Values

NameTypeDescription
rate_uint256The exchange rate in OracleUtils.RATE_OUTPUT_DECIMALS

chainlinkOracleData2

function chainlinkOracleData2() public view returns (uint256 chainlinkExchangeRate_, contract IChainlinkAggregatorV3 chainlinkFeed1_, bool chainlinkInvertRate1_, uint256 chainlinkExchangeRate1_, contract IChainlinkAggregatorV3 chainlinkFeed2_, bool chainlinkInvertRate2_, uint256 chainlinkExchangeRate2_, contract IChainlinkAggregatorV3 chainlinkFeed3_, bool chainlinkInvertRate3_, uint256 chainlinkExchangeRate3_)

returns all Chainlink oracle related data as utility for easy off-chain use / block explorer in a single view method