UniV3CheckCLRSOracle

Gets the exchange rate between the underlying asset and the peg asset by using: the price from a UniV3 pool (compared against 3 TWAPs) and (optionally) comparing it against a Chainlink or Redstone price (one of Chainlink or Redstone being the main source and the other one the fallback source). Alternatively it can also use Chainlink / Redstone as main price and use UniV3 as check price.

The process for getting the aggregate oracle price is: 1. Fetch the UniV3 TWAPS, the latest interval is used as the current price 2. Verify this price is within an acceptable DELTA from the Uniswap TWAPS e.g.: a. 240 to 60s b. 60 to 15s c. 15 to 1s (last block) d. 1 to 0s (current) 3. (unless UniV3 only mode): Verify this price is within an acceptable DELTA from the Chainlink / Redstone Oracle 4. If it passes all checks, return the price. Otherwise use fallbacks, usually to Chainlink. In extreme edge-cases revert. For UniV3 with check mode, if fetching the check price fails, the UniV3 rate is used directly.

_RATE_CHECK_MAX_DELTA_PERCENT

uint256 _RATE_CHECK_MAX_DELTA_PERCENT

Rate check oracle delta percent in 1e2 percent. If current uniswap price is out of this delta, current price fetching reverts.

_RATE_SOURCE

uint8 _RATE_SOURCE

which oracle to use as final rate source: - 1 = UniV3 ONLY (no check), - 2 = UniV3 with Chainlink / Redstone check - 3 = Chainlink / Redstone with UniV3 used as check.

UniV3CheckCLRSConstructorParams

struct UniV3CheckCLRSConstructorParams {
  struct UniV3OracleImpl.UniV3ConstructorParams uniV3Params;
  struct ChainlinkStructs.ChainlinkConstructorParams chainlinkParams;
  struct RedstoneStructs.RedstoneOracleData redstoneOracle;
  uint8 rateSource;
  uint8 fallbackMainSource;
  uint256 rateCheckMaxDeltaPercent;
}

constructor

constructor(string infoName_, struct UniV3CheckCLRSOracle.UniV3CheckCLRSConstructorParams params_) public

getExchangeRateOperate

function getExchangeRateOperate() public view virtual returns (uint256 exchangeRate_)

Get the exchangeRate_ between the underlying asset and the peg asset in 1e27 for operates

getExchangeRateLiquidate

function getExchangeRateLiquidate() public view virtual returns (uint256 exchangeRate_)

Get the exchangeRate_ between the underlying asset and the peg asset in 1e27 for liquidations

getExchangeRate

function getExchangeRate() public view virtual returns (uint256 exchangeRate_)

Deprecated. Use getExchangeRateOperate() and getExchangeRateLiquidate() instead. Only implemented for backwards compatibility.

uniV3CheckOracleData

function uniV3CheckOracleData() public view returns (uint256 rateCheckMaxDelta_, uint256 rateSource_, uint256 fallbackMainSource_)

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

_getExchangeRate

function _getExchangeRate() internal view returns (uint256 exchangeRate_)