Solidity Interfaces
Interfaces for interaction with Chunk oracles
Overview
All chunk oracle types (Delta, Median, Proof) implement the following interfaces:
ICoreMultidataFeedsReader— the main interface for reading core data (metrics and quotes).IChainlinkCompatibleMultidataFeeds— a Chainlink-compatible wrapper interface for external integration.
These ensure that data feeds are both internally consistent (with our core system) and externally compatible (with Chainlink-based tools and infrastructure).
ICoreMultidataFeedsReader
The ICoreMultidataFeedsReader defines the core functionality of chunk feeds.
It allows external contracts or off-chain systems to:
- Discover available metrics.
- Retrieve quotes (latest values and timestamps).
- Check if a metric exists by name.
- Access detailed metric metadata (name, description, currency, tags).
- Subscribe to events when metrics are added or updated.
Note that the oracle may quote any numerical metrics, not just tokens given by an address. As a result, a metric has a string as a name. Metrics also may be queried by internal IDs to save some gas on passing strings around.
| Name | Description | Returns |
|---|---|---|
getMetricsCount | Gets a count of metrics quoted by this oracle | uint |
getMetric | Gets metric info by a numerical id. | Metric |
getMetrics | Gets a list of metrics quoted by this oracle. | Metric[] |
hasMetric(string name) | Checks if a metric is quoted by this oracle. | bool has, uint256 id |
quoteMetrics(string[] calldata names) | Gets last known quotes for specified metrics. | Quote[] |
quoteMetrics(uint256[] calldata ids) | Gets last known quotes for specified metrics by internal numerical ids. | Quote[] |
// SPDX-License-Identifier: bsl-1.1
pragma solidity ^0.8.0;
/// @title Reader of MultidataFeeds core data.
interface ICoreMultidataFeedsReader is IVersioned {
struct Metric {
string name; // unique, immutable in a contract
string description;
string currency; // USD, ETH, PCT (percent), BPS (basis points), etc
string[] tags;
}
struct Quote {
uint256 value;
uint32 updateTS;
}
event NewMetric(string name);
event MetricInfoUpdated(string name);
/// @notice updated one metric or all if metricId=type(uint256).max-1
event MetricUpdated(uint indexed epochId, uint indexed metricId);
/**
* @notice Gets a list of metrics quoted by this oracle.
* @return A list of metric info indexed by numerical metric ids.
*/
function getMetrics() external view returns (Metric[] memory);
/// @notice Gets a count of metrics quoted by this oracle.
function getMetricsCount() external view returns (uint);
/// @notice Gets metric info by a numerical id.
function getMetric(uint256 id) external view returns (Metric memory);
/**
* @notice Checks if a metric is quoted by this oracle.
* @param name Metric codename.
* @return has `true` if metric exists.
* @return id Metric numerical id, set if `has` is true.
*/
function hasMetric(string calldata name) external view returns (bool has, uint256 id);
/**
* @notice Gets last known quotes for specified metrics.
* @param names Metric codenames to query.
* @return quotes Values and update timestamps for queried metrics.
*/
function quoteMetrics(string[] calldata names) external view returns (Quote[] memory quotes);
/**
* @notice Gets last known quotes for specified metrics by internal numerical ids.
* @dev Saves one storage lookup per metric.
* @param ids Numerical metric ids to query.
* @return quotes Values and update timestamps for queried metrics.
*/
function quoteMetrics(uint256[] calldata ids) external view returns (Quote[] memory quotes);
}
/// @title Contract supporting versioning using SemVer version scheme.
interface IVersioned {
/// @notice Contract version, using SemVer version scheme.
function VERSION() external view returns (string memory);
}
Chainlink Compatibility with IChainlinkCompatibleMultidataFeeds
The IChainlinkCompatibleMultidataFeeds interface provides backward compatibility with Chainlink’s aggregator APIs.
This allows multidata feeds to act as a drop-in replacement for Chainlink feeds, so existing dashboards, protocols, or tools that expect Chainlink APIs can integrate seamlessly.
Key features:
- Exposes the metricId being quoted.
- Supports conversion (
convertTo) for normalizing values. - References the parent contract that contains the main logic.
// SPDX-License-Identifier: bsl-1.1
pragma solidity ^0.8.0;
import "./IChainlinkAggregatorV2V3Interface.sol";
/// @title Chainlink-compatible reader of a metric quoted by MultidataFeeds.
interface IChainlinkCompatibleMultidataFeeds is IChainlinkAggregatorV2V3Interface {
/// @notice quoted metric id (call ICoreMultidataFeedsReader.getMetric to see the details)
function metricId() external view returns (uint256);
/// @notice quotes are converted by multiplying by this metric id (if non-zero).
function convertTo() external view returns (uint256);
/// @notice internal contract that runs the main bulk of the logic
function parent() external view returns (address);
}
IChainlinkAggregatorV2V3Interface
The IChainlinkAggregatorV2V3Interface defines the standard Chainlink feed interface (v2 and v3).
It enables:
- Retrieving the latest and historical answers (values).
- Accessing metadata such as decimals, description, and version.
- Round-based queries (timestamps, answers, round IDs).
- Listening to Chainlink-standard events (
AnswerUpdated,NewRound).
Our compatibility layer ensures these functions operate correctly for multidata feeds.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IChainlinkAggregatorV2V3Interface is IChainlinkAggregatorInterface, IChainlinkAggregatorV3Interface
{
}
interface IChainlinkAggregatorInterface {
function latestAnswer()
external
view
returns (int256);
function latestTimestamp()
external
view
returns (uint256);
function latestRound()
external
view
returns (uint256);
function getAnswer(
uint256 roundId
)
external
view
returns (int256);
function getTimestamp(
uint256 roundId
)
external
view
returns (uint256);
event AnswerUpdated(
int256 indexed current,
uint256 indexed roundId,
uint256 updatedAt
);
event NewRound(
uint256 indexed roundId,
address indexed startedBy,
uint256 startedAt
);
}
interface IChainlinkAggregatorV3Interface {
function decimals()
external
view
returns (uint8);
function description()
external
view
returns (string memory);
function version()
external
view
returns (uint256);
// getRoundData and latestRoundData should both raise "No data present"
// if they do not have data to report, instead of returning unset values
// which could be misinterpreted as actual reported values.
function getRoundData(
uint80 _roundId
)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}