OracleRegistry
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
| Name | Type | Description |
|---|---|---|
| feed | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
isFeedRouteRegistered
Token => Is feed route registered for the token
function isFeedRouteRegistered(address token) public view override returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
getFeedRoute
Gets the price feed route for a given token.
function getFeedRoute(address token) external view override returns (address, address);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | The address of the token for which the price feed route is requested. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address | feed1 The address of the first price feed. |
| <none> | address | feed2 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
| Name | Type | Description |
|---|---|---|
| baseToken | address | The address of the token for which the price is requested. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | price 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
| Name | Type | Description |
|---|---|---|
| baseToken | address | The address of the token for which the price is requested. |
| quoteToken | address | The address of the token in which the price is quoted. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | price 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
| Name | Type | Description |
|---|---|---|
| feed | address |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| feed | address |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| token | address | |
| feed1 | address | |
| stalenessThreshold1 | uint256 | |
| feed2 | address | |
| stalenessThreshold2 | uint256 |
_clearFeedRoute
Internal logic to clear feed route for a token.
function _clearFeedRoute(address token) internal;Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
_setFeedStaleThreshold
Internal logic to set the price staleness threshold for a given feed.
function _setFeedStaleThreshold(address feed, uint256 newThreshold) internal;Parameters
| Name | Type | Description |
|---|---|---|
| feed | address | |
| newThreshold | uint256 |