Skip to content
Lattice

DIAAdapter

Git Source

Inherits: IDIAAdapter

Title: DIAAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from DIA (https://github.com/diadata-org)

Diamond facet that reads DIA OracleV2 price feeds through their string-keyed getValue API with per-feed staleness configuration and WAD-normalized answers.

Stateless delegator — all logic and storage live in DIAAdapterLib. Consumers inherit this contract and add AccessControl + an initializer.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: DIA

Functions

getFeed

Returns a feed's configuration.

function getFeed(bytes32 key)
        external
        view
        virtual
        override
        returns (address oracle, string memory diaKey, uint48 maxStaleness);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
oracleaddressThe DIA OracleV2 contract address.
diaKeystringThe DIA price key string.
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 stale / future / zero value.

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

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
answerWadint256The latest price scaled to 1e18.

getValue

Returns the validated raw DIA value and its update timestamp, in DIA's native types.

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

function getValue(bytes32 key) external view virtual override returns (uint128 value, uint128 timestamp);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
valueuint128The DIA value (8 decimals).
timestampuint128The off-chain update timestamp.

registerFeed

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

function registerFeed(bytes32 key, address oracle, string calldata diaKey, uint48 maxStaleness)
        external
        virtual
        override;

Parameters

NameTypeDescription
keybytes32The arbitrary feed identifier.
oracleaddressThe DIA OracleV2 contract address (non-zero).
diaKeystringThe DIA price key string (non-empty).
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 DIAAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: getFeed(bytes32) 0x280aebcf getValue(bytes32) 0x69843940 latestAnswer(bytes32) 0x084d4783 registerFeed(bytes32,address,string,uint48) 0x8faa9164 unregisterFeed(bytes32) 0x2a589908

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

Returns

NameTypeDescription
selectorsbytes