IBandAdapter
Title: IBandAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Band Protocol (https://github.com/bandprotocol)
Interface for the BandAdapter Diamond facet — reads Band Protocol reference data through the single global StdReference contract with per-feed staleness configuration and WAD-normalized answers.
Band uses ONE global StdReference contract per chain; feeds are keyed by an arbitrary bytes32
mapped to a (base, quote) symbol pair. rate is already 18-decimals (WAD), so normalization
only widens uint256 -> int256 (no rescaling); reads validate registration, sign, future
timestamp, and staleness on-chain. latestAnswer(bytes32)->int256 is declared with the same
selector as IPriceOracleReader, so consumers can read this adapter through that
provider-agnostic interface. (Declared directly, not by inheriting IPriceOracleReader, because
Solidity excludes inherited functions from type(I).interfaceId, which would shift the ERC-165
id.)
The adapter does NOT check an L2 sequencer-uptime feed and does NOT bound the answer to a sane range.
Integrators that need either check read through the opt-in IOracleGuard (OracleGuard facet)
instead of calling latestAnswer directly.
Functions
stdReference
Returns the StdReference contract address.
function stdReference() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
getFeed
Returns a feed's configuration.
function getFeed(bytes32 key) external view 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 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
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;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;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;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier to remove. |
Events
FeedRegistered
Emitted when a feed is registered or updated.
event FeedRegistered(bytes32 indexed key, string base, string quote, uint48 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The arbitrary feed identifier. |
| 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. |
FeedUnregistered
Emitted when a feed is removed.
event FeedUnregistered(bytes32 indexed key);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The removed feed identifier. |
ReferenceSet
Emitted when the StdReference contract address is set.
event ReferenceSet(address indexed stdReference);Parameters
| Name | Type | Description |
|---|---|---|
| stdReference | address | The StdReference contract. |
Errors
BandFeedNotRegistered
The requested feed key has not been registered.
error BandFeedNotRegistered(bytes32 key);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 |
BandStaleData
The rate is older than the feed's maxStaleness (or has a future timestamp).
error BandStaleData(bytes32 key, uint256 lastUpdated, uint256 maxStaleness);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | |
| lastUpdated | uint256 | |
| maxStaleness | uint256 |
BandInvalidAnswer
The reference returned a zero rate.
error BandInvalidAnswer(bytes32 key, uint256 rate);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | |
| rate | uint256 |
BandInvalidConfig
registerFeed was called with an empty base/quote symbol or zero maxStaleness.
error BandInvalidConfig();BandReferenceNotSet
The StdReference contract address has not been set.
error BandReferenceNotSet();BandReferenceIsZero
Setting the StdReference contract to the zero address.
error BandReferenceIsZero();