Skip to content
Lattice

BandAdapter

Git Source

Inherits: IBandAdapter

Title: BandAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Band Protocol (https://github.com/bandprotocol)

Diamond facet that reads Band Protocol reference data through the single global StdReference contract with per-feed 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 BandAdapterLib. Consumers inherit this contract and add AccessControl + an initializer.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Band

Functions

stdReference

Returns the StdReference contract address.

function stdReference() 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 (string memory base, string memory quote, uint48 maxStaleness);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
basestringThe base symbol (e.g. "ETH").
quotestringThe quote symbol (e.g. "USD").
maxStalenessuint48Maximum age (seconds) before a value is stale.

latestAnswer

Returns the latest rate for key, normalized to 18 decimals (WAD). Selector matches IPriceOracleReader.latestAnswer. Reverts on stale / future / zero rate.

function latestAnswer(bytes32 key) external view virtual override returns (int256 answerWad);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
answerWadint256The latest rate scaled to 1e18.

getReferenceData

Returns the validated raw Band reference data for key, in Band's native types.

Provider-native reader (mirrors IStdReference.getReferenceData); keeps this adapter's ERC-165 id distinct from other read adapters that share the latestAnswer selector.

function getReferenceData(bytes32 key)
        external
        view
        virtual
        override
        returns (uint256 rate, uint256 lastUpdatedBase, uint256 lastUpdatedQuote);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
rateuint256The base/quote exchange rate (already 18 decimals).
lastUpdatedBaseuint256The unix timestamp the base symbol was last updated.
lastUpdatedQuoteuint256The unix timestamp the quote symbol was last updated.

setReference

Sets the StdReference contract. Caller must hold DEFAULT_ADMIN_ROLE.

function setReference(address reference_) external virtual override;

Parameters

NameTypeDescription
reference_addressThe StdReference contract (non-zero).

registerFeed

Registers a Band feed under key. Caller must hold DEFAULT_ADMIN_ROLE.

function registerFeed(bytes32 key, string calldata base, string calldata quote, uint48 maxStaleness)
        external
        virtual
        override;

Parameters

NameTypeDescription
keybytes32The arbitrary feed identifier.
basestringThe base symbol (non-empty, e.g. "ETH").
quotestringThe quote symbol (non-empty, e.g. "USD").
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 BandAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: getFeed(bytes32) 0x280aebcf getReferenceData(bytes32) 0x182400b9 latestAnswer(bytes32) 0x084d4783 registerFeed(bytes32,string,string,uint48) 0xcf3f0bd3 setReference(address) 0x34bdf2c4 stdReference() 0x02664b2f unregisterFeed(bytes32) 0x2a589908

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

Returns

NameTypeDescription
selectorsbytes