Skip to content
Lattice

TellorAdapter

Git Source

Inherits: ITellorAdapter

Title: TellorAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Tellor (https://github.com/tellor-io)

Diamond facet exposing the dispute-based Tellor oracle with per-feed dispute-buffer + staleness configuration and WAD-normalized answers. Shares the IPriceOracleReader read surface with the other Lattice oracle adapters.

Stateless delegator — all logic and storage live in TellorAdapterLib. Consumers inherit this contract and add AccessControl + an initializer. Reads use Tellor's getDataBefore at a dispute buffer offset so disputed values are removed first.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Tellor

Functions

tellor

Returns the Tellor contract address.

function tellor() external view virtual override returns (address);

Returns

NameTypeDescription
<none>address

getFeed

Returns a feed's configuration.

function getFeed(bytes32 key)
        external
        view
        virtual
        override
        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 virtual override 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 virtual override 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 virtual override;

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
        virtual
        override;

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 virtual override;

Parameters

NameTypeDescription
keybytes32The feed identifier to remove.

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect TellorAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: getDataBefore(bytes32) 0xd196aaee getFeed(bytes32) 0x280aebcf latestAnswer(bytes32) 0x084d4783 registerFeed(bytes32,bytes32,uint48,uint48) 0x249fb496 setTellor(address) 0x3b88e4ad tellor() 0x1959ad5b unregisterFeed(bytes32) 0x2a589908

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes