MixedPriceOracleV4

Git Source

Inherits: IOracleOperator

State Variables

STALENESS_PERIOD

uint256 public immutable STALENESS_PERIOD;

configs

mapping(string => PriceConfig) public configs;

stalenessPerSymbol

mapping(string => uint256) public stalenessPerSymbol;

deltaPerSymbol

mapping(string => uint256) public deltaPerSymbol;

maxPriceDelta

uint256 public maxPriceDelta = 1.5e3;

PRICE_DELTA_EXP

uint256 public constant PRICE_DELTA_EXP = 1e5;

roles

IRoles public immutable roles;

Functions

constructor

constructor(string[] memory symbols_, PriceConfig[] memory configs_, address roles_, uint256 stalenessPeriod_);

setStaleness

function setStaleness(string memory symbol, uint256 val) external;

setConfig

function setConfig(string memory symbol, PriceConfig memory config) external;

setMaxPriceDelta

function setMaxPriceDelta(uint256 _delta) external;

setSymbolMaxPriceDelta

function setSymbolMaxPriceDelta(uint256 _delta, string calldata _symbol) external;

getPrice

function getPrice(address mToken) public view returns (uint256);

getUnderlyingPrice

function getUnderlyingPrice(address mToken) external view override returns (uint256);

_getPriceUSD

function _getPriceUSD(string memory symbol) internal view returns (uint256);

_getLatestPrice

function _getLatestPrice(string memory symbol, PriceConfig memory config) internal view returns (uint256, uint256);

_absDiff

function _absDiff(int256 a, int256 b) internal pure returns (uint256);

_getStaleness

function _getStaleness(string memory symbol) internal view returns (uint256);

Events

ConfigSet

event ConfigSet(string symbol, PriceConfig config);

StalenessUpdated

event StalenessUpdated(string symbol, uint256 val);

PriceDeltaUpdated

event PriceDeltaUpdated(uint256 oldVal, uint256 newVal);

PriceSymbolDeltaUpdated

event PriceSymbolDeltaUpdated(uint256 oldVal, uint256 newVal, string symbol);

Errors

MixedPriceOracle_Unauthorized

error MixedPriceOracle_Unauthorized();

MixedPriceOracle_ApiV3StalePrice

error MixedPriceOracle_ApiV3StalePrice();

MixedPriceOracle_eOracleStalePrice

error MixedPriceOracle_eOracleStalePrice();

MixedPriceOracle_InvalidPrice

error MixedPriceOracle_InvalidPrice();

MixedPriceOracle_InvalidRound

error MixedPriceOracle_InvalidRound();

MixedPriceOracle_InvalidConfig

error MixedPriceOracle_InvalidConfig();

MixedPriceOracle_InvalidConfigDecimals

error MixedPriceOracle_InvalidConfigDecimals();

MixedPriceOracle_DeltaTooHigh

error MixedPriceOracle_DeltaTooHigh();

MixedPriceOracle_MissingFeed

error MixedPriceOracle_MissingFeed();

Structs

PriceConfig

struct PriceConfig {
    address api3Feed;
    address eOracleFeed;
    string toSymbol;
    uint256 underlyingDecimals;
}