NEW

Developer Passes are now available for Chainlink SmartCon. Get yours today.

Feed Registry API Reference

This guide outlines the functions which can be used with Chainlink's Feed Registry. You can learn more about the feed registry here.

Functions

NameDescription
decimalsThe number of decimals in the response.
descriptionThe description of the aggregator that the proxy points to.
getRoundDataGet data from a specific round.
latestRoundDataGet data from the latest round.
versionThe version representing the type of aggregator the proxy points to.
getFeedReturns the primary aggregator address of a base / quote pair.
getPhaseFeedReturns the aggregator address of a base / quote pair at a specified phase.
isFeedEnabledReturns true if an aggregator is enabled as primary on the registry.
getPhaseReturns the raw starting and ending aggregator round ids of a base / quote pair.
getRoundFeedReturns the underlying aggregator address of a base / quote pair at a specified round.
getPhaseRangeReturns the starting and ending round ids of a base / quote pair at a specified phase.
getPreviousRoundIdReturns the previous round id of a base / quote pair given a specified round.
getNextRoundIdReturns the next round id of a base / quote pair given a specified round.
getCurrentPhaseIdReturns the current phase id of a base / quote pair.

decimals

Get the number of decimals present in the response value.

function decimals(address base, address quote) external view returns (uint8)

Parameters

  • base: The base asset address.
  • quote: The quote asset address.

Return values

  • RETURN: The number of decimals.

description

Get the description of the underlying aggregator that the proxy points to.

function description(address base, address quote) external view returns (string memory)

Parameters

  • base: The base asset address.
  • quote: The quote asset address.

Return values

  • RETURN: The description of the underlying aggregator.

getRoundData

Get data about a specific round, using the roundId.

function getRoundData(address base, address quote, uint80 _roundId) external view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    )

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • roundId: The round ID.

Return values

  • roundId: The round ID.
  • answer: The price.
  • startedAt: Timestamp of when the round started.
  • updatedAt: Timestamp of when the round was updated.
  • answeredInRound: Deprecated - Previously used when answers could take multiple rounds to be computed

latestRoundData

Get the price from the latest round.

function latestRoundData(address base, address quote) external view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    )

Return values

  • roundId: The round ID.
  • answer: The price.
  • startedAt: Timestamp of when the round started.
  • updatedAt: Timestamp of when the round was updated.
  • answeredInRound: Deprecated - Previously used when answers could take multiple rounds to be computed

version

The version representing the type of aggregator the proxy points to.

function version(address base, address quote) external view returns (uint256)

Parameters

  • base: The base asset address.
  • quote: The quote asset address.

Return values

  • RETURN: The version number.

getFeed

Returns the primary aggregator address of a base / quote pair. Note that onchain contracts cannot read from aggregators directly, only through Feed Registry or Proxy contracts.

function getFeed(address base, address quote) external view returns (AggregatorV2V3Interface aggregator);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.

Return values

  • aggregator: The primary aggregator address.

getPhaseFeed

Returns the underlying aggregator address of a base / quote pair at a specified phase. Note that onchain contracts cannot read from aggregators directly, only through Feed Registry or Proxy contracts. Phase ids start at 1. You can get the current Phase by calling getCurrentPhaseId().

function getPhaseFeed(
  address base,
  address quote,
  uint16 phaseId
) external view returns (AggregatorV2V3Interface aggregator);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • phaseId: The phase id.

Return values

  • aggregator: The primary aggregator address at the specified phase.

isFeedEnabled

Returns true if an aggregator is enabled as primary on the feed registry. This is useful to check if you should index events from an aggregator contract, because you want to only index events of primary aggregators.

function isFeedEnabled(address aggregator) external view returns (bool);

Parameters

  • aggregator: The aggregator address

Return values

  • RETURN: true if the supplied aggregator is a primary aggregator for any base / quote pair.

getPhase

Returns the starting and ending aggregator round ids of a base / quote pair.

function getPhase(address base, address quote, uint16 phaseId) external view returns (Phase memory phase);

Phases hold the following information:

struct Phase {
  uint16 phaseId;
  uint80 startingAggregatorRoundId;
  uint80 endingAggregatorRoundId;
}

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • phaseId: The phase id.

Return values

  • RETURN: Phase details of a base / quote pair.

getRoundFeed

Returns the underlying aggregator address of a base / quote pair at a specified round. Note that onchain contracts cannot read from aggregators directly, only through Feed Registry or Proxy contracts.

function getRoundFeed(
  address base,
  address quote,
  uint80 roundId
) external view returns (AggregatorV2V3Interface aggregator);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • roundId: The round id.

Return values

  • aggregator: The underlying aggregator address of a base / quote pair at the specified round.

getPhaseRange

Returns the starting and ending round ids of a base / quote pair at a specified phase.

Please note that this roundId is calculated from the phase id and the underlying aggregator's round id. To get the raw aggregator round ids of a phase for indexing purposes, please use getPhase().

function getPhaseRange(
  address base,
  address quote,
  uint16 phaseId
) external view returns (uint80 startingRoundId, uint80 endingRoundId);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • phaseId: The phase id.

Return values

  • startingRoundId: The starting round id
  • endingRoundId: The ending round id

getPreviousRoundId

Returns the previous round id of a base / quote pair given a specified round. Note that rounds are non-monotonic across phases.

function getPreviousRoundId(address base, address quote, uint80 roundId) external view returns (uint80 previousRoundId);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • roundId: The round id.

Return values

  • previousRoundId: The previous round id of a base / quote pair.

getNextRoundId

Returns the next round id of a base / quote pair given a specified round. Note that rounds are non-monotonic across phases.

function getNextRoundId(address base, address quote, uint80 roundId) external view returns (uint80 nextRoundId);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.
  • roundId: The round id.

Return values

  • nextRoundId: The next round id of a base / quote pair.

getCurrentPhaseId

Returns the current phase id of a base / quote pair.

function getCurrentPhaseId(address base, address quote) external view returns (uint16 currentPhaseId);

Parameters

  • base: The base asset address.
  • quote: The quote asset address.

Return values

  • phaseId: The current phase id of a base / quote pair.

Stay updated on the latest Chainlink news