Skip to content
Lattice

ITellorAdapter

Git Source

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

NameTypeDescription
<none>address

getFeed

Returns a feed's configuration.

function getFeed(bytes32 key) external view returns (bytes32 queryId, uint48 disputeBuffer, uint48 maxStaleness);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
queryIdbytes32The Tellor query id.
disputeBufferuint48Seconds subtracted from block.timestamp when reading (dispute window).
maxStalenessuint48Maximum 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

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
answerWadint256The 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

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
valuebytesThe reported value bytes (SpotPrice is abi.encode(uint256) at 18 decimals).
timestampuint256The timestamp the returned value was reported.

setTellor

Sets the Tellor contract. Caller must hold DEFAULT_ADMIN_ROLE.

function setTellor(address tellor_) external;

Parameters

NameTypeDescription
tellor_addressThe 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

NameTypeDescription
keybytes32The arbitrary feed identifier.
queryIdbytes32The Tellor query id (non-zero).
disputeBufferuint48Seconds subtracted from block.timestamp when reading (0 = no buffer).
maxStalenessuint48Maximum age (seconds); must be non-zero.

unregisterFeed

Removes a registered feed. Caller must hold DEFAULT_ADMIN_ROLE.

function unregisterFeed(bytes32 key) external;

Parameters

NameTypeDescription
keybytes32The 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

NameTypeDescription
keybytes32The arbitrary feed identifier.
queryIdbytes32The Tellor query id.
disputeBufferuint48Seconds subtracted from block.timestamp when reading (dispute window).
maxStalenessuint48Maximum age (seconds) before a value is stale.

FeedUnregistered

Emitted when a feed is removed.

event FeedUnregistered(bytes32 indexed key);

Parameters

NameTypeDescription
keybytes32The removed feed identifier.

TellorContractSet

Emitted when the Tellor contract address is set.

event TellorContractSet(address indexed tellor);

Parameters

NameTypeDescription
telloraddressThe Tellor contract.

Errors

TellorFeedNotRegistered

The requested feed key has not been registered.

error TellorFeedNotRegistered(bytes32 key);

Parameters

NameTypeDescription
keybytes32

TellorNoData

No data was retrieved for the feed (not found, empty, or zero value).

error TellorNoData(bytes32 key);

Parameters

NameTypeDescription
keybytes32

TellorStaleData

The value is older than the feed's maxStaleness (or has a future timestamp).

error TellorStaleData(bytes32 key, uint256 timestamp, uint256 maxStaleness);

Parameters

NameTypeDescription
keybytes32
timestampuint256
maxStalenessuint256

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();