Skip to content
LogoLogo

OracleRegistry

Git Source

Inherits: IOracleRegistry

State Variables

_feedRoutes

mapping(address token => FeedRoute feedRoute) private _feedRoutes;

_feedStaleThreshold

mapping(address feed => uint256 stalenessThreshold) private _feedStaleThreshold;

Functions

getFeedStaleThreshold

Feed => Staleness threshold in seconds

function getFeedStaleThreshold(address feed) external view override returns (uint256);

Parameters

NameTypeDescription
feedaddress

Returns

NameTypeDescription
<none>uint256

isFeedRouteRegistered

Token => Is feed route registered for the token

function isFeedRouteRegistered(address token) public view override returns (bool);

Parameters

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
<none>bool

getFeedRoute

Gets the price feed route for a given token.

function getFeedRoute(address token) external view override returns (address, address);

Parameters

NameTypeDescription
tokenaddressThe address of the token for which the price feed route is requested.

Returns

NameTypeDescription
<none>addressfeed1 The address of the first price feed.
<none>addressfeed2 The address of the optional second price feed.

getReferencePrice

Returns the price of one unit of the given token in terms of the reference currency.

function getReferencePrice(address baseToken) public view override returns (uint256);

Parameters

NameTypeDescription
baseTokenaddressThe address of the token for which the price is requested.

Returns

NameTypeDescription
<none>uint256price The price of baseToken denominated in the reference currency (expressed in 18 decimals).

getPrice

Returns the price of one unit of baseToken in terms of quoteToken.

function getPrice(address baseToken, address quoteToken) public view override returns (uint256);

Parameters

NameTypeDescription
baseTokenaddressThe address of the token for which the price is requested.
quoteTokenaddressThe address of the token in which the price is quoted.

Returns

NameTypeDescription
<none>uint256price The price of baseToken denominated in quoteToken (expressed in quoteToken decimals).

_getFeedPrice

Returns the last price of the feed.

Reverts if the feed is stale or the price is negative.

function _getFeedPrice(address feed) private view returns (uint256);

Parameters

NameTypeDescription
feedaddress

Returns

NameTypeDescription
<none>uint256

_getFeedDecimals

Returns the number of decimals of the feed.

Returns 0 if the feed is not set.

function _getFeedDecimals(address feed) private view returns (uint8);

Parameters

NameTypeDescription
feedaddress

Returns

NameTypeDescription
<none>uint8

_setFeedRoute

Internal logic to set feed route for a token.

function _setFeedRoute(
        address token,
        address feed1,
        uint256 stalenessThreshold1,
        address feed2,
        uint256 stalenessThreshold2
    ) internal;

Parameters

NameTypeDescription
tokenaddress
feed1address
stalenessThreshold1uint256
feed2address
stalenessThreshold2uint256

_clearFeedRoute

Internal logic to clear feed route for a token.

function _clearFeedRoute(address token) internal;

Parameters

NameTypeDescription
tokenaddress

_setFeedStaleThreshold

Internal logic to set the price staleness threshold for a given feed.

function _setFeedStaleThreshold(address feed, uint256 newThreshold) internal;

Parameters

NameTypeDescription
feedaddress
newThresholduint256