BandAdapter
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
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| base | string | The base symbol (e.g. "ETH"). |
| quote | string | The quote symbol (e.g. "USD"). |
| maxStaleness | uint48 | Maximum 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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| answerWad | int256 | The 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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| rate | uint256 | The base/quote exchange rate (already 18 decimals). |
| lastUpdatedBase | uint256 | The unix timestamp the base symbol was last updated. |
| lastUpdatedQuote | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| reference_ | address | The 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
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The arbitrary feed identifier. |
| base | string | The base symbol (non-empty, e.g. "ETH"). |
| quote | string | The quote symbol (non-empty, e.g. "USD"). |
| 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 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
| Name | Type | Description |
|---|---|---|
| selectors | bytes |