Skip to content
LogoLogo

OracleRegistry

Git Source

Inherits: AccessManagedUpgradeable, IOracleRegistry

Constants

OracleRegistryStorageLocation

bytes32 private constant OracleRegistryStorageLocation =
        0x49c7e86ce354ebbf25fac336f41752d815bcb13797a06a09b85fd6c0c68ea000;

Functions

_getOracleRegistryStorage

function _getOracleRegistryStorage() private pure returns (OracleRegistryStorage storage $);

Returns

NameTypeDescription
$OracleRegistryStorage

constructor

constructor();

initialize

function initialize(address initialAuthority) external initializer;

Parameters

NameTypeDescription
initialAuthorityaddress

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

getPrice

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

function getPrice(address baseToken, address quoteToken) external 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).

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 override restricted;

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 override restricted;

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 override restricted;

Parameters

NameTypeDescription
feedaddressThe address of the price feed.
newThresholduint256The new staleness threshold in seconds.

_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

Structs

OracleRegistryStorage

Note:

  • storage-location: erc7201:makina.storage.OracleRegistry
struct OracleRegistryStorage {
        mapping(address token => FeedRoute feedRoute) _feedRoutes;
        mapping(address feed => uint256 stalenessThreshold) _feedStaleThresholds;
    }

Properties

NameTypeDescription
_feedRoutesmapping(address token => FeedRoute feedRoute)
_feedStaleThresholdsmapping(address feed => uint256 stalenessThreshold)