RedStoneAdapter
Inherits: IRedStoneAdapter
Title: RedStoneAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from RedStone (https://github.com/redstone-finance/redstone-oracles-monorepo)
Diamond facet that reads RedStone Push price feeds from their on-chain PriceFeedsAdapter with per-feed staleness configuration and WAD-normalized answers.
Stateless delegator — all logic and storage live in RedStoneAdapterLib. Consumers inherit this contract and add AccessControl + an initializer.
Notes:
- lattice-version: 0.1.0
- lattice-source: RedStone
Functions
getFeed
Returns a feed's configuration.
function getFeed(bytes32 key)
external
view
virtual
override
returns (address adapter, bytes32 dataFeedId, uint48 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| adapter | address | The RedStone PriceFeedsAdapter contract. |
| dataFeedId | bytes32 | The RedStone data-feed id. |
| 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 / overflowing 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. |
getValueForDataFeed
Returns the validated raw RedStone value (8 decimals) and the batch update timestamp.
Provider-native reader; keeps this adapter's ERC-165 id distinct from other read adapters that share the latestAnswer selector.
function getValueForDataFeed(bytes32 key)
external
view
virtual
override
returns (uint256 value, uint256 timestamp);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| value | uint256 | The RedStone value (8 decimals). |
| timestamp | uint256 | The on-chain batch update timestamp (seconds). |
registerFeed
Registers a RedStone feed under key. Caller must hold DEFAULT_ADMIN_ROLE.
function registerFeed(bytes32 key, address adapter, bytes32 dataFeedId, uint48 maxStaleness)
external
virtual
override;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The arbitrary feed identifier. |
| adapter | address | The RedStone PriceFeedsAdapter contract (non-zero). |
| dataFeedId | bytes32 | The RedStone data-feed id. |
| 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 RedStoneAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
getFeed(bytes32) 0x280aebcf
getValueForDataFeed(bytes32) 0x44e02982
latestAnswer(bytes32) 0x084d4783
registerFeed(bytes32,address,bytes32,uint48) 0x9b50b20b
unregisterFeed(bytes32) 0x2a589908
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |