ChainlinkDataStreamsOracle

Git Source

Inherits: IOracleMiddlewareErrors, IChainlinkDataStreamsOracle

This contract is used to get the price of the asset that corresponds to the stored Chainlink data streams ID.

Is implemented by the OracleMiddlewareWithDataStreams contract.

State Variables

PROXY_VERIFIER

The address of the Chainlink proxy verifier contract.

IVerifierProxy internal immutable PROXY_VERIFIER;

STREAM_ID

The ID of the Chainlink data streams.

Any data streams are standardized to 18 decimals.

bytes32 internal immutable STREAM_ID;

REPORT_VERSION

The report version.

uint256 internal constant REPORT_VERSION = 3;

_dataStreamsRecentPriceDelay

The maximum age of a recent price to be considered valid for Chainlink data streams.

uint256 internal _dataStreamsRecentPriceDelay = 45 seconds;

Functions

constructor

constructor(address verifierAddress, bytes32 streamId);

Parameters

NameTypeDescription
verifierAddressaddressThe address of the Chainlink proxy verifier contract.
streamIdbytes32The ID of the Chainlink data streams.

getProxyVerifier

Gets the Chainlink Proxy verifier contract.

function getProxyVerifier() external view returns (IVerifierProxy proxyVerifier_);

Returns

NameTypeDescription
proxyVerifier_IVerifierProxyThe address of the proxy verifier contract.

getStreamId

Gets the supported Chainlink data stream ID.

function getStreamId() external view returns (bytes32 streamId_);

Returns

NameTypeDescription
streamId_bytes32The unique identifier for the Chainlink data streams.

getDataStreamRecentPriceDelay

Gets the maximum age of a recent price to be considered valid.

function getDataStreamRecentPriceDelay() external view returns (uint256 delay_);

Returns

NameTypeDescription
delay_uint256The maximum acceptable age of a recent price in seconds.

getReportVersion

Gets the supported Chainlink data streams report version.

function getReportVersion() external pure returns (uint256 version_);

Returns

NameTypeDescription
version_uint256The version number of the supported Chainlink data streams report.

_getChainlinkDataStreamPrice

Gets the formatted price of the asset with Chainlink data streams.

function _getChainlinkDataStreamPrice(bytes calldata payload, uint128 targetTimestamp, uint128 targetLimit)
    internal
    returns (FormattedDataStreamsPrice memory formattedPrice_);

Parameters

NameTypeDescription
payloadbytesThe full report obtained from the Chainlink data streams API.
targetTimestampuint128The target timestamp of the price. If zero, then we accept all recent prices.
targetLimituint128The most recent timestamp a price can have. Can be zero if targetTimestamp is zero.

Returns

NameTypeDescription
formattedPrice_FormattedDataStreamsPriceThe Chainlink formatted price with 18 decimals.

_getChainlinkDataStreamFeeData

Gets the fee asset data to decode the payload.

The native token fee option will be used.

function _getChainlinkDataStreamFeeData(bytes calldata payload)
    internal
    view
    returns (IFeeManager.Asset memory feeData_);

Parameters

NameTypeDescription
payloadbytesThe data streams payload (full report).

Returns

NameTypeDescription
feeData_IFeeManager.AssetThe fee asset data including the token and the amount required to verify the report.