Skip to content
Lattice

IChronicleAdapter

Git Source

Title: IChronicleAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Chronicle (https://github.com/chronicleprotocol)

Interface for the ChronicleAdapter Diamond facet — reads Chronicle oracle feeds through their per-feed oracle contract and exposes WAD-normalized answers.

Chronicle values are already 18-decimals (WAD), so normalization only casts uint256 -> int256 (no rescaling). Feeds are keyed by an arbitrary bytes32 mapped to a Chronicle oracle address. 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.)

OPERATIONAL PREREQUISITE — toll-gating: Chronicle oracles are Schnorr-signed and access-controlled. The adapter contract address must be whitelisted ("kissed") by the oracle operator before any read() or readWithAge() call will succeed. Without whitelisting, calls will revert at the Chronicle contract. Contact the Chronicle team or use the self-service portal to request access.

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

getFeed

Returns a feed's configuration.

function getFeed(bytes32 key) external view returns (address chronicle, uint48 maxStaleness);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
chronicleaddressThe Chronicle oracle contract address.
maxStalenessuint48Maximum 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-age / zero value.

function latestAnswer(bytes32 key) external view returns (int256 answerWad);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
answerWadint256The latest price scaled to 1e18.

readWithAge

Returns the validated raw Chronicle value and the timestamp it was last written on-chain.

Provider-native reader (mirrors IChronicle.readWithAge); keeps this adapter's ERC-165 id distinct from other adapters that share the latestAnswer selector.

function readWithAge(bytes32 key) external view returns (uint256 value, uint256 age);

Parameters

NameTypeDescription
keybytes32The feed identifier.

Returns

NameTypeDescription
valueuint256The oracle value (already 18 decimals, WAD).
ageuint256The Unix timestamp at which the value was last written on-chain.

registerFeed

Registers a Chronicle feed under key. Caller must hold DEFAULT_ADMIN_ROLE.

function registerFeed(bytes32 key, address chronicle, uint48 maxStaleness) external;

Parameters

NameTypeDescription
keybytes32The arbitrary feed identifier.
chronicleaddressThe Chronicle oracle contract address (non-zero).
maxStalenessuint48Maximum age (seconds); must be non-zero.

unregisterFeed

Removes a registered feed. Caller must hold DEFAULT_ADMIN_ROLE.

function unregisterFeed(bytes32 key) external;

Parameters

NameTypeDescription
keybytes32The feed identifier to remove.

Events

FeedRegistered

Emitted when a feed is registered or updated.

event FeedRegistered(bytes32 indexed key, address indexed chronicle, uint48 maxStaleness);

Parameters

NameTypeDescription
keybytes32The arbitrary feed identifier.
chronicleaddressThe Chronicle oracle contract address.
maxStalenessuint48Maximum age (seconds) before a value is stale.

FeedUnregistered

Emitted when a feed is removed.

event FeedUnregistered(bytes32 indexed key);

Parameters

NameTypeDescription
keybytes32The removed feed identifier.

Errors

ChronicleFeedNotRegistered

The requested feed key has not been registered.

error ChronicleFeedNotRegistered(bytes32 key);

Parameters

NameTypeDescription
keybytes32

ChronicleStaleData

The value is older than the feed's maxStaleness (or has a future age timestamp).

error ChronicleStaleData(bytes32 key, uint256 age, uint256 maxStaleness);

Parameters

NameTypeDescription
keybytes32
ageuint256
maxStalenessuint256

ChronicleInvalidAnswer

The oracle returned a zero value.

error ChronicleInvalidAnswer(bytes32 key, uint256 value);

Parameters

NameTypeDescription
keybytes32
valueuint256

ChronicleInvalidConfig

registerFeed was called with a zero chronicle address or zero maxStaleness.

error ChronicleInvalidConfig();