Skip to content
AtlasOracle

Multi-Feed Contract ​

A gas-optimized, bit-packed multi-asset price registry. One contract returns the latest prices for many feeds, each identified by a 4-byte feedId, optimized for consistency and gas efficiency.

Multi-Feed contract interface:
IMultiFeed.sol

Codec library:
FeedCodec.sol

Multi-Feed exposes two price query styles:

  • Decoded view. Returns a friendly PriceSnapshot struct via fetch / fetchBatch.
  • Compact view. Returns a packed bytes32 word via staticcall from fetchCompact / fetchCompactBatch to minimize cross-contract gas overhead. We recommend using the FeedCodec library in your consumer contract to decode the packed data; see the packed word bit layout under fetchCompact.

Read-access policy

Each feed instance runs in one of two modes — whitelist (only addresses on the authorized-caller list, plus regular EOAs that have not been delegated via ERC-7702, may read) or open-read (any caller may read). Functions marked onlyReadAccess below are subject to this policy; all other functions are always callable. Use isOpenRead and isAuthorizedCaller to query the current state.

Functions

NameDescriptionView typeModifier
fetchDecoded snapshot for a single feed.Decoded viewonlyReadAccess
fetchBatchDecoded snapshots for multiple feeds.Decoded viewonlyReadAccess
fetchCompactRaw packed word for a single feed.Compact viewonlyReadAccess
fetchCompactBatchRaw packed words for multiple feeds.Compact viewonlyReadAccess
decimalsDecimal precision shared by all feeds.——
descriptionHuman-readable description of this registry.——
versionVersion number of the implementation.——
contractTypeContract type identifier (2 for Multi-Feed).——
isAuthorizedCallerChecks whether an address is whitelisted.——
isOpenReadReturns whether open-read mode is active.——

1. fetch ​

Returns a decoded snapshot for a single feed.

solidity
function fetch(bytes4 feedId) external view returns (PriceSnapshot memory priceSnapshot)

Parameters

  • feedId: 4-byte feed identifier.

Return values

  • priceSnapshot: Decoded struct with price and timestamps. A zero-initialized snapshot is returned if the feed has never been updated.

1.1 PriceSnapshot struct definition ​

Records a price snapshot at a specific point in time. Fields are bit-packed for storage efficiency:

solidity
struct PriceSnapshot {
    uint80 price;        // aggregated price
    uint48 aggregatedTs; // off-chain aggregation timestamp
    uint48 onchainTs;    // on-chain update timestamp
}

2. fetchBatch ​

Returns decoded snapshots for multiple feeds in one call.

solidity
function fetchBatch(bytes4[] calldata feedIds) external view returns (PriceSnapshot[] memory priceSnapshots)

Parameters

  • feedIds: Array of 4-byte feed identifiers.

Return values

  • priceSnapshots: Array of decoded PriceSnapshot structs, index-aligned with feedIds. Feeds that have never been updated yield zero-initialized snapshots.

3. fetchCompact ​

Returns the raw 256-bit packed word for a single feed. This is the cheapest read path; we recommend using the FeedCodec library in your consumer contract to decode it.

solidity
function fetchCompact(bytes4 feedId) external view returns (bytes32 packed)

Parameters

  • feedId: 4-byte feed identifier.

Return values

  • packed: Raw 256-bit packed word, or bytes32(0) if the feed has never been updated.

3.1 Packed word bit layout ​

The 256-bit word returned by fetchCompact / fetchCompactBatch:

Bit rangeSegmentTypeMeaning
[255:176]Reserved—Zero-filled
[175:128]OnchainTsuint48On-chain update timestamp
[127:80]AggTsuint48Off-chain aggregation timestamp
[79:0]Priceuint80Aggregated price

4. fetchCompactBatch ​

Returns raw packed words for multiple feeds in one call. Same recommendation as fetchCompact: decode locally using FeedCodec for maximum gas efficiency.

solidity
function fetchCompactBatch(bytes4[] calldata feedIds) external view returns (bytes32[] memory packedList)

Parameters

  • feedIds: Array of 4-byte feed identifiers.

Return values

  • packedList: Array of raw 256-bit packed words, index-aligned with feedIds. Feeds that have never been updated yield bytes32(0).

5. decimals ​

Returns the decimal precision shared by all feeds in this registry.

solidity
function decimals() external view returns (uint8 precision)

Parameters

(none)

Return values

  • precision: Decimal precision shared by all feeds.

6. description ​

Returns a human-readable description of this registry.

solidity
function description() external view returns (string memory desc)

Parameters

(none)

Return values

  • desc: A string identifier.

7. version ​

Returns the version number of the current implementation.

solidity
function version() external view returns (uint256 versionNumber)

Parameters

(none)

Return values

  • versionNumber: A monotonically increasing version identifier.

8. contractType ​

Returns the contract type identifier, used to distinguish feed implementations within the project.

solidity
function contractType() external view returns (uint256 typeId)

Parameters

(none)

Return values

  • typeId: Type id (2 for Multi-Feed).

9. isAuthorizedCaller ​

Checks whether an address is whitelisted as an authorized caller for price reads when open-read mode is disabled.

solidity
function isAuthorizedCaller(address account) external view returns (bool whitelisted)

Parameters

  • account: Address to query.

Return values

  • whitelisted: true if the account is on the authorized-caller whitelist.

10. isOpenRead ​

Returns whether open-read mode is currently active. When true, any caller can read prices; when false, only whitelisted callers and regular EOAs (that have not been delegated via ERC-7702) are permitted.

solidity
function isOpenRead() external view returns (bool enabled)

Parameters

(none)

Return values

  • enabled: true if open-read mode is active.