ChainlinkDataStreamsOracle
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
Name | Type | Description |
---|---|---|
verifierAddress | address | The address of the Chainlink proxy verifier contract. |
streamId | bytes32 | The ID of the Chainlink data streams. |
getProxyVerifier
Gets the Chainlink Proxy verifier contract.
function getProxyVerifier() external view returns (IVerifierProxy proxyVerifier_);
Returns
Name | Type | Description |
---|---|---|
proxyVerifier_ | IVerifierProxy | The address of the proxy verifier contract. |
getStreamId
Gets the supported Chainlink data stream ID.
function getStreamId() external view returns (bytes32 streamId_);
Returns
Name | Type | Description |
---|---|---|
streamId_ | bytes32 | The 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
Name | Type | Description |
---|---|---|
delay_ | uint256 | The 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
Name | Type | Description |
---|---|---|
version_ | uint256 | The 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
Name | Type | Description |
---|---|---|
payload | bytes | The full report obtained from the Chainlink data streams API. |
targetTimestamp | uint128 | The target timestamp of the price. If zero, then we accept all recent prices. |
targetLimit | uint128 | The most recent timestamp a price can have. Can be zero if targetTimestamp is zero. |
Returns
Name | Type | Description |
---|---|---|
formattedPrice_ | FormattedDataStreamsPrice | The 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
Name | Type | Description |
---|---|---|
payload | bytes | The data streams payload (full report). |
Returns
Name | Type | Description |
---|---|---|
feeData_ | IFeeManager.Asset | The fee asset data including the token and the amount required to verify the report. |