Single-Feed Contract
A high-performance oracle optimized for a single asset pair, with full wire-level compatibility with the Chainlink AggregatorV2 and AggregatorV3 interfaces.
Single-Feed contract interface:
ISingleFeed.sol
Read-access policy
Each feed instance runs in one of two modes — whitelist (only addresses on the authorized-caller list, plus regular EOAs that have not been delegated via ERC-7702, may read) or open-read (any caller may read). Functions marked onlyReadAccess below are subject to this policy; all other functions are always callable. Use isOpenRead and isAuthorizedCaller to query the current state.
Functions
| Name | Description | Compatibility | Modifier |
|---|---|---|---|
| latestAnswer | Returns the latest aggregated price. | Chainlink Aggregator V2 | onlyReadAccess |
| latestTimestamp | Block timestamp of the most recent successful update. | Chainlink Aggregator V2 | onlyReadAccess |
| latestRound | Synthetic latest round id: 1 if updated, 0 otherwise. | Chainlink Aggregator V2 | onlyReadAccess |
| getAnswer | Current price only when the round is 1. | Chainlink Aggregator V2 | onlyReadAccess |
| getTimestamp | Current on-chain timestamp only when the round is 1. | Chainlink Aggregator V2 | onlyReadAccess |
| latestRoundData | Price-related data for the latest price round. | Chainlink Aggregator V3 | onlyReadAccess |
| getRoundData | Price-related data for the specified price round. | Chainlink Aggregator V3 | onlyReadAccess |
| decimals | Returns the price precision. | Chainlink Aggregator V3 | — |
| description | Human-readable description of this feed. | Chainlink Aggregator V3 | — |
| version | Version number of the feed implementation. | Chainlink Aggregator V3 | — |
| contractType | Contract type identifier. | — | — |
| isAuthorizedCaller | Checks whether an address is whitelisted. | — | — |
| isOpenRead | Returns whether open-read mode is active. | — | — |
1. latestAnswer
Returns the latest aggregated price.
function latestAnswer() external view returns (int256 answer)Parameters
(none)
Return values
- answer: The aggregated price, cast to
int256.
2. latestTimestamp
Returns the block timestamp of the most recent successful update.
function latestTimestamp() external view returns (uint256 onchainTimestamp)Parameters
(none)
Return values
- onchainTimestamp: The timestamp when the price was written on-chain.
3. latestRound
Returns a synthetic latest round id.
function latestRound() external view returns (uint256 roundId)Parameters
(none)
Return values
- roundId:
1if the feed has been updated,0otherwise. This synthetic value ensures compliance with DeFi protocols that check for a non-zero round id before consuming a feed.
4. getAnswer
Returns the price for a given round id. Because this oracle stores only the latest state in a single storage slot, historical data is unavailable. The current price is returned only when roundId == 1, matching the synthetic value from latestRound().
function getAnswer(uint256 roundId) external view returns (int256 answer)Parameters
- roundId: Round id to query.
Return values
- answer: Price for that round; returns
0ifroundIdis not1or the feed has never been updated.
5. getTimestamp
Returns the timestamp for a given round id. Because this oracle stores only the latest state in a single storage slot, historical data is unavailable. The current on-chain timestamp is returned only when roundId == 1, matching the synthetic value from latestRound().
function getTimestamp(uint256 roundId) external view returns (uint256 onchainTimestamp)Parameters
- roundId: Round id to query.
Return values
- onchainTimestamp: On-chain timestamp for that round; returns
0ifroundIdis not1or the feed has never been updated.
6. latestRoundData
Returns the data for the latest price round. As this oracle stores only the latest state, historical rounds are unavailable; if the feed has never been updated, all zeros are returned.
function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)Parameters
(none)
Return values
- roundId: Synthetic round id (
1if updated,0otherwise). - answer: The latest aggregated price.
- startedAt: Off-chain aggregation timestamp.
- updatedAt: On-chain update timestamp.
- answeredInRound: Same as
roundId.
7. getRoundData
Returns the data for the specified price round. As this oracle stores only the latest state, historical rounds are unavailable; if _roundId is not 1 or the feed has never been updated, all zeros are returned.
function getRoundData(uint80 _roundId) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)Parameters
_roundId: Round id to fetch (in this stateless model, only1is supported).
Return values
- roundId: Synthetic round id (
1if updated,0otherwise). - answer: The latest aggregated price.
- startedAt: Off-chain aggregation timestamp.
- updatedAt: On-chain update timestamp.
- answeredInRound: Same as
roundId.
8. decimals
Returns the precision used to represent the price.
function decimals() external view returns (uint8 precision)Parameters
(none)
Return values
- precision: Decimal precision of the price feed.
9. description
Returns a human-readable description of this feed.
function description() external view returns (string memory desc)Parameters
(none)
Return values
- desc: A string identifier.
10. version
Returns the version number of the current implementation.
function version() external view returns (uint256 versionNumber)Parameters
(none)
Return values
- versionNumber: A monotonically increasing version identifier.
11. contractType
Returns the contract type identifier, used to distinguish feed implementations within the project.
function contractType() external view returns (uint256 typeId)Parameters
(none)
Return values
- typeId: Type id (
1for Single-Feed).
12. isAuthorizedCaller
Checks whether an address is whitelisted as an authorized caller for price reads when open-read mode is disabled.
function isAuthorizedCaller(address account) external view returns (bool whitelisted)Parameters
- account: Address to query.
Return values
- whitelisted:
trueif the account is on the authorized-caller whitelist.
13. isOpenRead
Returns whether open-read mode is currently active. When true, any caller can read prices; when false, only whitelisted callers and regular EOAs (that have not been delegated via ERC-7702) are permitted.
function isOpenRead() external view returns (bool enabled)Parameters
(none)
Return values
- enabled:
trueif open-read mode is active.
Stateless / latest-only model
Single-Feed stores only the latest state in a single storage slot, so historical rounds are unavailable. latestRound() returns a synthetic 1 once the feed has been updated (and 0 before that) to satisfy DeFi protocols that require a non-zero round id. getAnswer / getTimestamp / getRoundData return valid data only for roundId == 1.