Sperax
  • USDs (Sperax USD)
    • Minting and Redeeming
    • Auto Yield
      • Smart Contracts can opt in for the rebase feature (Auto-yield).
    • Stability Mechanism
    • Key parameters and functions
    • Technical documents
      • Sequence diagrams
      • Smart contracts
        • Vault
        • USDs
        • CollateralManager
        • SPA Buyback
        • MasterPriceOracle
        • Yield Reserve
        • Fee Calculator
        • RebaseManager
        • Dripper
        • BaseStrategy
      • Deployed contracts
  • Buyback Contract
  • Staking Protocol
    • Locking SPA
    • Withdrawing SPA
    • Staking Rewards
  • Demeter Protocol
    • How does Demeter Work?
    • Technical documents
      • Smart contracts
        • E721 Farms
          • E721Farm
          • Camelot V3
            • CamelotV3FarmDeployer
            • CamelotV3Farm
        • Base contracts
          • Farm
          • FarmStorage
          • FarmRegistry
          • FarmDeployer
        • Features
          • ClaimableFee
          • ExpirableFarm
          • OperableDeposit
        • Rewarder
          • Rewarder
          • RewarderFactory
      • Deployed contracts
  • Getting Started on Our DApp
    • Minting & Redeeming USDs
    • Stake SPA
  • Governance
  • Bug Bounty Program
  • FAQ
    • SPA Tokenomics
    • xSPA token
    • Smart Contract Addresses
    • How to Transfer SPA from Ethereum to Arbitrum
  • Quick Links
    • Audit Reports
    • Sperax Dapp
    • Demeter Dapp
    • Discord
    • Forum
    • Snapshot
Powered by GitBook
On this page
  • State Variables
  • tokenPriceFeed
  • Functions
  • updateTokenPriceFeed
  • removeTokenPriceFeed
  • getPrice
  • priceFeedExists
  • _getPriceFeed
  • Events
  • PriceFeedUpdated
  • PriceFeedRemoved
  • Errors
  • InvalidAddress
  • UnableToFetchPriceFeed
  • InvalidPriceFeed
  • PriceFeedNotFound

Was this helpful?

Export as PDF
  1. USDs (Sperax USD)
  2. Technical documents
  3. Smart contracts

MasterPriceOracle

PreviousSPA BuybackNextYield Reserve

Last updated 1 year ago

Was this helpful?

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

Name
Type
Description

_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

Name
Type
Description

_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

Name
Type
Description

_token

address

address of the desired token.

Returns

Name
Type
Description

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

Name
Type
Description

_token

address

address of the desired token.

Returns

Name
Type
Description

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

Name
Type
Description

_token

address

address of the desired token.

_source

address

price feed source.

_msgData

bytes

call data for fetching feed.

Returns

Name
Type
Description

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);
Git Source