MasterPriceOracle

Git Source

Inherits: Ownable, IOracle

Author: Sperax Foundation

Communicates with different price feeds to get the price

State Variables

tokenPriceFeed

Store price feed data for tokens.

mapping(address => PriceFeedData) public tokenPriceFeed;

Functions

updateTokenPriceFeed

Add/Update price feed for _token

Have to be extra cautious while updating the price feed.

function updateTokenPriceFeed(address _token, address _source, bytes memory _data) external onlyOwner;

Parameters

NameTypeDescription

_token

address

address of the desired token.

_source

address

price feed source.

_data

bytes

call data for fetching the price feed.

removeTokenPriceFeed

Remove an existing price feed for _token.

function removeTokenPriceFeed(address _token) external onlyOwner;

Parameters

NameTypeDescription

_token

address

address of the token.

getPrice

Gets the price feed for _token.

Function reverts if the price feed does not exists.

function getPrice(address _token) external view returns (PriceData memory);

Parameters

NameTypeDescription

_token

address

address of the desired token.

Returns

NameTypeDescription

PriceData

(uint256 price, uint256 precision).

priceFeedExists

Validates if price feed exists for a _token

Function reverts if price feed not set.

function priceFeedExists(address _token) external view returns (bool);

Parameters

NameTypeDescription

_token

address

address of the desired token.

Returns

NameTypeDescription

bool

bool if price feed exists.

_getPriceFeed

Gets the price feed for a _token given the feed data.

function _getPriceFeed(address _token, address _source, bytes memory _msgData)
    private
    view
    returns (PriceData memory priceData);

Parameters

NameTypeDescription

_token

address

address of the desired token.

_source

address

price feed source.

_msgData

bytes

call data for fetching feed.

Returns

NameTypeDescription

priceData

PriceData

(uint256 price, uint256 precision).

Events

PriceFeedUpdated

event PriceFeedUpdated(address indexed token, address indexed source, bytes msgData);

PriceFeedRemoved

event PriceFeedRemoved(address indexed token);

Errors

InvalidAddress

error InvalidAddress();

UnableToFetchPriceFeed

error UnableToFetchPriceFeed(address token);

InvalidPriceFeed

error InvalidPriceFeed(address token);

PriceFeedNotFound

error PriceFeedNotFound(address token);

Last updated