ITellorAdapter
Title: ITellorAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Tellor (https://github.com/tellor-io)
Interface for the TellorAdapter Diamond facet — reads the dispute-based Tellor oracle with per-feed dispute-buffer + staleness configuration and WAD-normalized answers.
Tellor is dispute-based and exposes a SINGLE global oracle contract per chain. Reads use
ITellor.getDataBefore(queryId, block.timestamp - disputeBuffer), so disputed values have time to
be removed before they are consumed. SpotPrice value is abi.encode(uint256) at 18 decimals
(WAD), so normalization only widens uint256 -> int256. Feeds are keyed by an arbitrary bytes32
mapped to a Tellor query id. latestAnswer(bytes32)->int256 is declared with the same selector as
IPriceOracleReader, so consumers can read this adapter through that provider-agnostic interface.
(Declared directly, not by inheriting IPriceOracleReader, because Solidity excludes inherited
functions from type(I).interfaceId, which would shift the ERC-165 id.)
The adapter does NOT check an L2 sequencer-uptime feed and does NOT bound the answer to a sane range.
Integrators that need either check read through the opt-in IOracleGuard (OracleGuard facet)
instead of calling latestAnswer directly.
Functions
tellor
Returns the Tellor contract address.
function tellor() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
getFeed
Returns a feed's configuration.
function getFeed(bytes32 key) external view returns (bytes32 queryId, uint48 disputeBuffer, uint48 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| queryId | bytes32 | The Tellor query id. |
| disputeBuffer | uint48 | Seconds subtracted from block.timestamp when reading (dispute window). |
| maxStaleness | uint48 | Maximum age (seconds) before a value is stale. |
latestAnswer
Returns the latest price for key, normalized to 18 decimals (WAD). Selector matches
IPriceOracleReader.latestAnswer. Reverts on missing / stale / future data.
function latestAnswer(bytes32 key) external view returns (int256 answerWad);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| answerWad | int256 | The latest price scaled to 1e18. |
getDataBefore
Returns the raw Tellor value bytes and report timestamp read with the feed's dispute buffer.
Provider-native reader (mirrors ITellor.getDataBefore); keeps this adapter's ERC-165 id
distinct from other read adapters that share the latestAnswer selector.
function getDataBefore(bytes32 key) external view returns (bytes memory value, uint256 timestamp);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| value | bytes | The reported value bytes (SpotPrice is abi.encode(uint256) at 18 decimals). |
| timestamp | uint256 | The timestamp the returned value was reported. |
setTellor
Sets the Tellor contract. Caller must hold DEFAULT_ADMIN_ROLE.
function setTellor(address tellor_) external;Parameters
| Name | Type | Description |
|---|---|---|
| tellor_ | address | The Tellor contract (non-zero). |
registerFeed
Registers a Tellor feed under key. Caller must hold DEFAULT_ADMIN_ROLE.
function registerFeed(bytes32 key, bytes32 queryId, uint48 disputeBuffer, uint48 maxStaleness) external;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The arbitrary feed identifier. |
| queryId | bytes32 | The Tellor query id (non-zero). |
| disputeBuffer | uint48 | Seconds subtracted from block.timestamp when reading (0 = no buffer). |
| maxStaleness | uint48 | Maximum age (seconds); must be non-zero. |
unregisterFeed
Removes a registered feed. Caller must hold DEFAULT_ADMIN_ROLE.
function unregisterFeed(bytes32 key) external;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier to remove. |
Events
FeedRegistered
Emitted when a feed is registered or updated.
event FeedRegistered(bytes32 indexed key, bytes32 indexed queryId, uint48 disputeBuffer, uint48 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The arbitrary feed identifier. |
| queryId | bytes32 | The Tellor query id. |
| disputeBuffer | uint48 | Seconds subtracted from block.timestamp when reading (dispute window). |
| maxStaleness | uint48 | Maximum age (seconds) before a value is stale. |
FeedUnregistered
Emitted when a feed is removed.
event FeedUnregistered(bytes32 indexed key);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The removed feed identifier. |
TellorContractSet
Emitted when the Tellor contract address is set.
event TellorContractSet(address indexed tellor);Parameters
| Name | Type | Description |
|---|---|---|
| tellor | address | The Tellor contract. |
Errors
TellorFeedNotRegistered
The requested feed key has not been registered.
error TellorFeedNotRegistered(bytes32 key);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 |
TellorNoData
No data was retrieved for the feed (not found, empty, or zero value).
error TellorNoData(bytes32 key);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 |
TellorStaleData
The value is older than the feed's maxStaleness (or has a future timestamp).
error TellorStaleData(bytes32 key, uint256 timestamp, uint256 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | |
| timestamp | uint256 | |
| maxStaleness | uint256 |
TellorInvalidConfig
registerFeed was called with a zero query id or zero maxStaleness.
error TellorInvalidConfig();TellorContractNotSet
The Tellor contract address has not been set.
error TellorContractNotSet();TellorContractIsZero
Setting the Tellor contract to the zero address.
error TellorContractIsZero();