ChainlinkAdapter
Inherits: IChainlinkAdapter
Title: ChainlinkAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Chainlink (https://github.com/smartcontractkit/chainlink-evm/blob/develop/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol)
Diamond facet that exposes Chainlink AggregatorV3 price feeds with per-feed staleness configuration and WAD-normalised answers.
Stateless delegator — all logic and storage live in ChainlinkAdapterLib. Consumers inherit this contract and add AccessControl + an initializer.
Notes:
- lattice-version: 0.1.0
- lattice-source: Chainlink
Functions
getFeed
Returns the registered feed address and staleness threshold for a key.
function getFeed(bytes32 key) external view virtual override returns (address feed, uint48 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| feed | address | Address of the AggregatorV3 feed. |
| maxStaleness | uint48 | Maximum age in seconds before data is considered stale. |
latestAnswer
Returns the latest price normalised to 18 decimal places.
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. |
latestAnswerRaw
Returns the raw latest price, its update timestamp, and the feed's decimals.
function latestAnswerRaw(bytes32 key)
external
view
virtual
override
returns (int256 answer, uint256 updatedAt, uint8 decimals_);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| answer | int256 | The raw answer from the feed. |
| updatedAt | uint256 | The timestamp of the last update. |
| decimals_ | uint8 | The number of decimals used by the feed. |
registerFeed
Registers a Chainlink price feed under the given key.
Caller must hold DEFAULT_ADMIN_ROLE. The feed's decimals() is
read and cached at registration time.
function registerFeed(bytes32 key, address feed, uint48 maxStaleness) external virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | Arbitrary identifier for this feed. |
| feed | address | Address of the AggregatorV3 contract. |
| maxStaleness | uint48 | Maximum age (seconds) an answer may be before it is considered stale. Must be non-zero. |
unregisterFeed
Removes a registered price 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 ChainlinkAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
getFeed(bytes32) 0x280aebcf
latestAnswer(bytes32) 0x084d4783
latestAnswerRaw(bytes32) 0xad0ddbee
registerFeed(bytes32,address,uint48) 0x915d3063
unregisterFeed(bytes32) 0x2a589908
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |