Skip to main content

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 exists, 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);

isFeedRouteRegistered

Token => Is feed route registered for the token

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

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).

setFeedStaleThreshold

Sets the price staleness threshold for a given feed.

function setFeedStaleThreshold(address feed, uint256 threshold) external;

Parameters

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

Events

FeedRouteRegistered

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

FeedStaleThresholdChanged

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

Structs

FeedRoute

struct FeedRoute {
address feed1;
address feed2;
}