FallbackOracleImpl2
Inherits: OracleError, RedstoneOracleImpl2, ChainlinkOracleImpl2
This contract is used to get the exchange rate from a main oracle feed and a fallback oracle feed.
State Variables
_FALLBACK_ORACLE2_MAIN_SOURCE
*which oracle to use as main source:
- 1 = Chainlink ONLY (no fallback)
- 2 = Chainlink with Redstone Fallback
- 3 = Redstone with Chainlink Fallback*
uint8 internal immutable _FALLBACK_ORACLE2_MAIN_SOURCE;
Functions
constructor
sets the main source, Chainlink Oracle and Redstone Oracle data.
constructor(
uint8 mainSource_,
ChainlinkConstructorParams memory chainlinkParams_,
RedstoneOracleData memory redstoneOracle_
)
ChainlinkOracleImpl2(chainlinkParams_)
RedstoneOracleImpl2(
address(redstoneOracle_.oracle) == address(0)
? RedstoneOracleData(IRedstoneOracle(_REDSTONE2_ORACLE_NOT_SET_ADDRESS), false, 1)
: redstoneOracle_
);
Parameters
Name | Type | Description |
---|---|---|
mainSource_ | uint8 | which oracle to use as main source: - 1 = Chainlink ONLY (no fallback) - 2 = Chainlink with Redstone Fallback - 3 = Redstone with Chainlink Fallback |
chainlinkParams_ | ChainlinkConstructorParams | chainlink Oracle constructor params struct. |
redstoneOracle_ | RedstoneOracleData | Redstone Oracle data. (address can be set to zero address if using Chainlink only) |
_getRateWithFallback2
returns the exchange rate for the main oracle source, or the fallback source (if configured) if the main exchange rate fails to be fetched. If returned rate is 0, fetching rate failed or something went wrong.
function _getRateWithFallback2() internal view returns (uint256 exchangeRate_, bool fallback_);
Returns
Name | Type | Description |
---|---|---|
exchangeRate_ | uint256 | exchange rate |
fallback_ | bool | whether fallback was necessary or not |
_getChainlinkOrRedstoneAsFallback2
returns the exchange rate for Chainlink, or Redstone if configured & Chainlink fails.
function _getChainlinkOrRedstoneAsFallback2() internal view returns (uint256 exchangeRate_);