Skip to content
LogoLogo

IOracleRegistry

Git Source

An aggregator of Chainlink price feeds that prices tokens in a reference currency (e.g., USD) using up to two feeds. If a direct feed between a base token and the reference currency does not exist, it combines two feeds to compute the price.

Example: To price Token A in Token B:

  • If a feed for Token A -> Reference Currency exists, the registry uses that feed.
  • If Token B lacks a direct feed to the Reference Currency, but feeds for Token B -> Intermediate Token and Intermediate Token -> Reference Currency exist, the registry combines these feeds to derive the price.
  • Finally, the price Token A -> Token B is calculated using both tokens' individual prices in the reference currency.

Functions

getFeedStaleThreshold

Feed => Staleness threshold in seconds

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

Parameters

NameTypeDescription
feedaddress

Returns

NameTypeDescription
<none>uint256

isFeedRouteRegistered

Token => Is feed route registered for the token

function isFeedRouteRegistered(address token) external view 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 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) external view 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) external view 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).

setFeedRoute

Sets the price feed route for a given token.

Both feeds, if set, must be Chainlink-interface-compliant. The combination of feed1 and feed2 must be able to price the token in the reference currency. If feed2 is set to address(0), the token price in the reference currency is assumed to be returned by feed1.

function setFeedRoute(
        address token,
        address feed1,
        uint256 stalenessThreshold1,
        address feed2,
        uint256 stalenessThreshold2
    ) external;

Parameters

NameTypeDescription
tokenaddressThe address of the token for which the price feed route is set.
feed1addressThe address of the first price feed.
stalenessThreshold1uint256The staleness threshold for the first price feed.
feed2addressThe address of the second price feed. Can be set to address(0).
stalenessThreshold2uint256The staleness threshold for the second price feed. Ignored if feed2 is address(0).

clearFeedRoute

Clears the price feed route for a given token.

Staleness thresholds for the route's feeds are preserved, as the feeds may be used by other routes.

function clearFeedRoute(address token) external;

Parameters

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

setFeedStaleThreshold

Sets the price staleness threshold for a given feed.

function setFeedStaleThreshold(address feed, uint256 newThreshold) external;

Parameters

NameTypeDescription
feedaddressThe address of the price feed.
newThresholduint256The value of staleness threshold.

Events

FeedRouteCleared

event FeedRouteCleared(address indexed token);

Parameters

NameTypeDescription
tokenaddress

FeedRouteRegistered

event FeedRouteRegistered(address indexed token, address indexed feed1, address indexed feed2);

Parameters

NameTypeDescription
tokenaddress
feed1address
feed2address

FeedStaleThresholdChanged

event FeedStaleThresholdChanged(address indexed feed, uint256 oldThreshold, uint256 newThreshold);

Parameters

NameTypeDescription
feedaddress
oldThresholduint256
newThresholduint256

Structs

FeedRoute

struct FeedRoute {
        address feed1;
        address feed2;
    }

Properties

NameTypeDescription
feed1address
feed2address