Source Adapters

Standardization contract to unify incoming interfaces.

This adapter wraps the Chainlink interface for ingestion into the Oval contract, allowing the Oval to handle any custom middleware or interaction patterns that a protocol uses for talking to Chainlink contracts. The common example is the standard Chainlink Source Adapter that interacts with a standard Chainlink interface in the case that there is no middleware between the protocol and a standard Chainlink feed.

  1. Access Chainlink prices via any interface.

  2. Standardize decimals across different feeds. All internal logic assumes 18 decimals.

In internal Oval calls (between source adapter, Oval contract, and destination adapters) we pass around “sourceData” which is a tuple of the latest price and latest timestamp as (int256, uint256).

The minimal interface for a source adapter looks as follows:

interface IXSourceOracleAdapter {
    // Returns the latest price data from the source and the update timestamp.
    function getLatestSourceData() view returns (int256, uint256);

    // Tries getting latest data as of requested timestamp. 
    // If this is not available returns the earliest data available past the
    // requested timestamp bounded by maxTraversal.
    function tryLatestDataAt(uint256 timestamp, uint256 maxTraversal) view returns (int256, uint256);

    // If the source requires snapshotting, this executes the snapshot.
    function snapshotData() external;
}

The directory containing all source adapters can be found here.

Last updated