DIAAdapter
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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| oracle | address | The DIA OracleV2 contract address. |
| diaKey | string | The DIA price key string. |
| 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 stale / future / zero value.
function latestAnswer(bytes32 key) external view virtual override returns (int256 answerWad);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| answerWad | int256 | The 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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| value | uint128 | The DIA value (8 decimals). |
| timestamp | uint128 | The 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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The arbitrary feed identifier. |
| oracle | address | The DIA OracleV2 contract address (non-zero). |
| diaKey | string | The DIA price key string (non-empty). |
| 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 virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
| selectors | bytes |