Building On Magma
Advanced
Oracle

Oracle

Obtain accurate and reliable price data.

The Oracle is an on chain resource responsible for tracking and managing trade pairs and their associated prices. It provides information about the pairs, their prices, timestamps, and block heights.

LAVA is required to add new token pairs for the oracle to track.

Use Cases

  • Add and manage trade pairs to track
  • Fetch price (USD) of a pair
  • Use in smart contracts for on chain quotes and other DeFi apps

Usage

addTradePairs

write method to add trade pairs to be tracked by the oracle.

function addTradePairs(string[] memory pairs) external returns (bool);

getPrice

returns the price of the given trade pair

function getPrice(string memory pair) external view returns (int256, uint256, uint64);

getAllTradePairs

returns all trade pairs tracked by the oracle module.

function getAllTradePairs() external view returns (string[] memory);