Feed Registry API Reference
This guide outlines the functions which can be used with the Feed Registry. You can find the interface contract here.
Peripheral functions
Name | Description |
---|---|
totalPairsAvailable | The total number of pairs available |
getAllPairs | Fetch all the pairs available on the registry as an array |
getTradingPairDetails | Get the token addresses and feed adapter address for a pair |
exists | Check if a pair exists in the registry |
Core Functions
Name | Description |
---|---|
decimals | The number of decimals in the response. |
decimalsByName | The number of decimals in the response and also resolves the decimals for synthetic pairs |
description | The description of the underlying aggregator |
descriptionByName | The description of the underlying aggregator |
version | The version of the underlying aggregator |
versionByName | The version of the underlying aggregator |
latestRoundData | Get the data of the latest round |
latestRoundDataByName | The latest round data for a pair |
latestRound | Get the latest round ID for a base/quote pair (V2 interface) |
latestAnswer | The latest answer of a base/quote pair (V2 interface) |
latestAnswerByName | The latest answer of a base/quote pair and also resolves the answer for synthetic pairs |
latestTimestamp | Returns the last timestamp when the pair was updated on-chain (V2 interface) |
getRoundData | Get the round data details on a given round |
getAnswer | Get the answer for a specific round (V2 interface) |
getTimestamp | Get the updated time timestamp for a specific round (V2 interface) |
getFeed | Get the current aggregator for this pair |
getPhaseFeed | The aggregator address given a phaseId |
isFeedEnabled | Checks if a given aggregator is currently being used |
getPhase | Get the raw starting and the ending round IDs of the given Phase Id |
getRoundFeed | The aggregator which executed the given roundId |
getPhaseRange | Get the starting and the ending round IDs of the given Phase Id |
getPreviousRoundId | Returns the previous round ID of a base/quote pair given a specified round |
getNextRoundId | Returns the next round ID of a base/quote pair given a specified round |
getCurrentPhaseId | Returns the current phase id of a base/quote pair |
totalPairsAvailable
Returns the total number of pairs available in the registry.
function totalPairsAvailable() external view returns (uint256);
Return values
- RETURN: The number of pairs offered
getAllPairs
Returns all the pairs available on the registry.
function getAllPairs() external view returns (EnumerableTradingPairMap.Pair[] memory);
Return values
- RETURN: Array of pairs. Each pair is a struct of two strings, the base and quote tokens.
getTradingPairDetails
Returns the token address and feed adapter details for a pair.
function getTradingPairDetails(string calldata base, string calldata quote)
external
view
returns (
address,
address,
address
);
Parameters
- base: The base token represented as a string
- quote: The quote token represented as a string
Return values
- base address: The address of the base token
- quote address: The address of the quote token
- feed adapter address: The address of the feed adapter for this pair
exists
Check if a given pair exists in the registry.
function exists(string calldata base, string calldata quote) external view returns (bool);
Parameters
- base: The base token represented as a string
- quote: The quote token represented as a string
Return values
- RETURN: true if exists, false otherwise
decimals
Get the number of decimals of the response in fixed point system.
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
decimalsByName
Get the number of decimals of the response in fixed point system using string params
function decimalsByName(string memory base, string memory quote) external view returns (uint8);
Parameters
- base: The base asset string
- quote The quote asset string
Return values
- RETURN: The number of decimals
description
Get the description of the underlying aggregator
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
descriptionByName
Get the description of the underlying aggregator using string params
function descriptionByName(string memory base, string memory quote) external view returns (string memory);
Parameters
- base: The base asset string
- quote The quote asset string
Return values
- RETURN: The description of the underlying aggregator
version
Get the version of the underlying aggregator
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 of the underlying aggregator
versionByName
Get the version of the underlying aggregator using string params
function versionByName(string memory base, string memory quote) external view returns (uint256);
Parameters
- base: The base asset string
- quote The quote asset string
Return values
- RETURN: The version of the underlying aggregator
latestRoundData
Get the latest round data details for the pair
function latestRoundData(address base, address quote)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
Parameters
- base: The base asset address
- quote The quote asset address
Return values
- roundId: The round ID
- answer: The answer on the round
- startedAt: The timestamp at which the price was submitted
- updatedAt: The timestamp at which the price was updated on the chain
- answeredInRound: The round at which this data was computed
latestRoundDataByName
Get the latest round data details for the pair using string params
function latestRoundDataByName(string memory base, string memory quote)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
Parameters
- base: The base asset string
- quote The quote asset string
Return values
- roundId: The round ID
- answer: The answer on the round
- startedAt: The timestamp at which the price was submitted
- updatedAt: The timestamp at which the price was updated on the chain
- answeredInRound: The round at which this data was computed
latestRound
Get the latest round ID for the pair using AggregatorV2 interface
function latestRound(address base, address quote) external view returns (uint256 roundId);
Parameters
- base: The base asset address
- quote The quote asset address
Return values
- roundId: The latest round ID
latestAnswer
Get the latest answer for the pair
function latestAnswer(address base, address quote) external view returns (int256);
Parameters
- base: The base asset address
- quote The quote asset address
Return values
- RETURN: The latest answer from the underlying aggregator
latestAnswerByName
Get the latest answer from the underlying aggregator using string params
function latestAnswerByName(string memory base, string memory quote) external view returns (int256);
Parameters
- base: The base asset string
- quote The quote asset string
Return values
- RETURN: The latest answer from the underlying aggregator
latestTimestamp
Get the timestamp at which the pair has been last updated on the chain
function latestTimestamp(address base, address quote) external view returns (uint256);
Parameters
- base: The base asset address
- quote The quote asset address
Return values
- RETURN: The latest timestamp
getMultipleLatestRoundData
Get the latest round data details for multiple pairs in a single call
function getMultipleLatestRoundData(string[] memory bases, string[] memory quotes)
external
view
returns (RoundData[] memory);
Parameters
- bases: The base asset strings
- quotes The quote asset strings. The length of this array must be equal to the length of the bases array
Return values
- RETURN: The latest round data details for the pairs
getRoundData
Get the round data details for the pair for a given round ID
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 for which the data is required
Return values
- roundId: The round ID
- answer: The answer on the round
- startedAt: The timestamp at which the price was submitted
- updatedAt: The timestamp at which the price was updated on the chain
- answeredInRound: The round at which this data was computed
getAnswer
Get the answer for the pair for a given round ID over AggregatorV2 Interface
function getAnswer(
address base,
address quote,
uint256 roundId
) external view returns (int256 answer);
Parameters
- base: The base asset address
- quote The quote asset address
- roundId: The round ID for which the data is required
Return values
- answer: The answer on the round
getTimestamp
Get the timestamp for the pair for a given round ID over AggregatorV2 Interface
function getTimestamp(
address base,
address quote,
uint256 roundId
) external view returns (uint256 timestamp);
Parameters
- base: The base asset address
- quote The quote asset address
- roundId: The round ID for which the timestamp is required
Return values
- timestamp: The timestamp at which this round was updated
getFeed
Retrieve the aggregator of an base / quote pair in the current phase
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 aggregator currently being used
getPhaseFeed
Retrieve the aggregator of an base / quote pair in a given phase
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 phaseId
Return values
- aggregator: The aggregator in the given phase
isFeedEnabled
Check if the aggregator of an base / quote pair is enabled
function isFeedEnabled(address aggregator) external view returns (bool);
Parameters
- aggregator: The aggregator address
Return values
- RETURN: True if the aggregator is currently in use
getPhase
Get the phase details (starting and ending round IDs) for the given phase ID
function getPhase(
address base,
address quote,
uint16 phaseId
) external view returns (Phase memory phase);
Parameters
- base: The base asset address
- quote The quote asset address
- phaseId: The phaseId
Return values
- phase: Phase representing the starting and ending round IDs of this phase/ aggregator
getRoundFeed
Get the aggregator which computed the given roundId
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 roundId
Return values
- aggregator: The aggregator which computed the given roundId
getPhaseRange
Get the phase range(starting, ending rounds) for the given phase
function getPhaseRange(
address base,
address quote,
uint16 phaseId
) external view returns (uint80 startingRound, uint80 endingRound);
Parameters
- base: The base asset address
- quote The quote asset address
- phaseId: The phaseId
Return values
- startingRound: The starting round of the phase
- endingRound: The ending round of the phase
getPreviousRoundId
Get the previous roundId for the given roundId. The roundIds may not be contiguous
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 roundId
Return values
- previousRoundId: The previous roundId for the given roundId
getNextRoundId
Get the next roundId for the given roundId. The roundIds may not be contiguous
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 roundId
Return values
- nextRoundId: The next roundId for the given roundId
getCurrentPhaseId
Get the current phaseId for the given 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
- currentPhaseId: The current phaseId for the given pair