For the complete documentation index, see llms.txt. This page is also available as Markdown.

Reading prices

Find a PriceFeed contract address, connect using the Chainlink interface, and read the current price with proper validation.

Step 1: Find the Oracle Address

Three ways to find a PriceFeed contract address for a given pair:

  • Price Oracle Tracker (easiest during development): price-oracle-tracker.vercel.app, which shows all deployed pairs, live prices, decimals, heartbeat, and addresses.

  • On-chain via OracleFactory: call pairToOracle(string pair). Pair symbols must be passed in uppercase (e.g. "PSG/USDT"); the factory does not normalise input on reads.

  • Bulk on-chain via OracleFactoryReader: call getActiveOracles() to retrieve all active pairs and their addresses in one call.

interface IOracleFactory {
    function pairToOracle(string memory pair) external view returns (address);
    function getOracleCount() external view returns (uint256);
}

function resolveFeed(address factory, string memory pair)
    external view returns (address)
{
    // Pair symbol must be passed in uppercase (e.g. "PSG/USDT").
    return IOracleFactory(factory).pairToOracle(pair);
}

Step 2: Connect Using the Interface

The PriceFeed contract implements the standard Chainlink IAggregatorV3Interface, plus Chiliz-specific extensions for health and pause status.

Step 3: Read the Price

The primary function is latestRoundData(), which returns the current price alongside round and timestamp metadata.

If your protocol uses the feed's native decimals rather than normalising to 18:

Historical Data

The oracle stores all historical round data on-chain. Each price update creates a new round with an incrementing roundId.

Additional helper views exposed by the Chiliz feed:

Function
Returns

latestAnswer()

Latest price, or 0 if none

latestTimestamp()

Latest updatedAt, or 0 if none

latestRound()

Current round ID

getAnswer(uint80 roundId)

Price for a specific round, or 0

getTimestamp(uint80 roundId)

Timestamp for a specific round, or 0

getRoundsData(uint80[] roundIds)

Bulk RoundData array

roundExists(uint80 roundId)

true if updatedAt > 0

Events

Each PriceFeed contract emits:

  • AnswerUpdated(int256 indexed current, uint80 indexed roundId, uint256 updatedAt): emitted on every price update. Filter by price or round.

  • NewRound(uint80 indexed roundId, address indexed startedBy, uint256 startedAt): emitted when a new round begins. Filter by round or by the address that started it.

Discovery Functions (OracleFactoryReader)

Function
Description

getActiveOracles()

Returns all active pairs with their oracle addresses

getAllOracles()

Returns all oracles, including inactive ones

getOraclesByPairs(string[] pairs)

Resolve multiple pair names to oracle addresses in one call

getOracleHealthStatus(address oracle)

Health status for a single oracle

getAllOracleHealthStatus()

Health status for every oracle in the system

Last updated

Was this helpful?