diff --git a/public/images/data-streams/data-streams-architecture.webp b/public/images/data-streams/data-streams-architecture.webp index 258962a2a87..2919eb9a1bb 100644 Binary files a/public/images/data-streams/data-streams-architecture.webp and b/public/images/data-streams/data-streams-architecture.webp differ diff --git a/public/images/data-streams/sequence-diagram.webp b/public/images/data-streams/sequence-diagram.webp index f51e92b10e8..1300526a444 100644 Binary files a/public/images/data-streams/sequence-diagram.webp and b/public/images/data-streams/sequence-diagram.webp differ diff --git a/public/samples/DataStreams/LogEmitter.sol b/public/samples/DataStreams/LogEmitter.sol index 3ba6f011d72..138d4862e5d 100644 --- a/public/samples/DataStreams/LogEmitter.sol +++ b/public/samples/DataStreams/LogEmitter.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.8.19; +pragma solidity 0.8.19; contract LogEmitter { event Log(address indexed msgSender); diff --git a/public/samples/DataStreams/StreamsUpkeep.sol b/public/samples/DataStreams/StreamsUpkeep.sol index 0b9b698136f..ca7fde32b44 100644 --- a/public/samples/DataStreams/StreamsUpkeep.sol +++ b/public/samples/DataStreams/StreamsUpkeep.sol @@ -15,6 +15,14 @@ import {IERC20} from "@chainlink/contracts/src/v0.8/vendor/openzeppelin-solidity // Custom interfaces for IVerifierProxy and IFeeManager interface IVerifierProxy { + /** + * @notice Verifies that the data encoded has been signed. + * correctly by routing to the correct verifier, and bills the user if applicable. + * @param payload The encoded data to be verified, including the signed + * report. + * @param parameterPayload Fee metadata for billing. For the current implementation this is just the abi-encoded fee token ERC-20 address. + * @return verifierResponse The encoded report from the verifier. + */ function verify( bytes calldata payload, bytes calldata parameterPayload @@ -24,6 +32,18 @@ interface IVerifierProxy { } interface IFeeManager { + /** + * @notice Calculates the fee and reward associated with verifying a report, including discounts for subscribers. + * This function assesses the fee and reward for report verification, applying a discount for recognized subscriber addresses. + * @param subscriber The address attempting to verify the report. A discount is applied if this address + * is recognized as a subscriber. + * @param unverifiedReport The report data awaiting verification. The content of this report is used to + * determine the base fee and reward, before considering subscriber discounts. + * @param quoteAddress The payment token address used for quoting fees and rewards. + * @return fee The fee assessed for verifying the report, with subscriber discounts applied where applicable. + * @return reward The reward allocated to the caller for successfully verifying the report. + * @return totalDiscount The total discount amount deducted from the fee for subscribers. + */ function getFeeAndReward( address subscriber, bytes memory unverifiedReport, @@ -38,17 +58,7 @@ interface IFeeManager { } contract StreamsUpkeep is ILogAutomation, StreamsLookupCompatibleInterface { - struct BasicReport { - bytes32 feedId; // The feed ID the report has data for - uint32 validFromTimestamp; // Earliest timestamp for which price is applicable - uint32 observationsTimestamp; // Latest timestamp for which price is applicable - uint192 nativeFee; // Base cost to validate a transaction using the report, denominated in the chain’s native token (WETH/ETH) - uint192 linkFee; // Base cost to validate a transaction using the report, denominated in LINK - uint32 expiresAt; // Latest timestamp where the report can be verified onchain - int192 price; // DON consensus median price, carried to 8 decimal places - } - - struct PremiumReport { + struct Report { bytes32 feedId; // The feed ID the report has data for uint32 validFromTimestamp; // Earliest timestamp for which price is applicable uint32 observationsTimestamp; // Latest timestamp for which price is applicable @@ -73,10 +83,10 @@ contract StreamsUpkeep is ILogAutomation, StreamsLookupCompatibleInterface { string public constant DATASTREAMS_QUERYLABEL = "timestamp"; int192 public last_retrieved_price; - // This example reads the ID for the basic ETH/USD price report on Arbitrum Sepolia. + // This example reads the ID for the ETH/USD report on Arbitrum Sepolia. // Find a complete list of IDs at https://docs.chain.link/data-streams/stream-ids string[] public feedIds = [ - "0x00027bbaff688c906a3e20a34fe951715d1018d262a5b66e38eda027a674cd1b" + "0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782" ]; constructor(address _verifier) { @@ -162,11 +172,8 @@ contract StreamsUpkeep is ILogAutomation, StreamsLookupCompatibleInterface { abi.encode(feeTokenAddress) ); - // Decode verified report data into BasicReport struct - BasicReport memory verifiedReport = abi.decode( - verifiedReportData, - (BasicReport) - ); + // Decode verified report data into a Report struct + Report memory verifiedReport = abi.decode(verifiedReportData, (Report)); // Log price from report emit PriceUpdate(verifiedReport.price); diff --git a/public/samples/DataStreams/StreamsUpkeepRegistrar.sol b/public/samples/DataStreams/StreamsUpkeepRegistrar.sol index 8e36542a7f8..6d062e19bf0 100644 --- a/public/samples/DataStreams/StreamsUpkeepRegistrar.sol +++ b/public/samples/DataStreams/StreamsUpkeepRegistrar.sol @@ -85,17 +85,7 @@ contract StreamsUpkeepRegistrar is LinkTokenInterface public immutable i_link; AutomationRegistrarInterface public immutable i_registrar; - struct BasicReport { - bytes32 feedId; // The feed ID the report has data for - uint32 validFromTimestamp; // Earliest timestamp for which price is applicable - uint32 observationsTimestamp; // Latest timestamp for which price is applicable - uint192 nativeFee; // Base cost to validate a transaction using the report, denominated in the chain’s native token (WETH/ETH) - uint192 linkFee; // Base cost to validate a transaction using the report, denominated in LINK - uint32 expiresAt; // Latest timestamp where the report can be verified onchain - int192 price; // DON consensus median price, carried to 8 decimal places - } - - struct PremiumReport { + struct Report { bytes32 feedId; // The feed ID the report has data for uint32 validFromTimestamp; // Earliest timestamp for which price is applicable uint32 observationsTimestamp; // Latest timestamp for which price is applicable @@ -233,11 +223,8 @@ contract StreamsUpkeepRegistrar is abi.encode(feeTokenAddress) ); - // Decode verified report data into BasicReport struct - BasicReport memory verifiedReport = abi.decode( - verifiedReportData, - (BasicReport) - ); + // Decode verified report data into a Report struct + Report memory verifiedReport = abi.decode(verifiedReportData, (Report)); // Log price from report emit PriceUpdate(verifiedReport.price); diff --git a/src/content/data-streams/getting-started-hardhat.mdx b/src/content/data-streams/getting-started-hardhat.mdx index 6e4f540e22f..bb3a92386d4 100644 --- a/src/content/data-streams/getting-started-hardhat.mdx +++ b/src/content/data-streams/getting-started-hardhat.mdx @@ -15,13 +15,6 @@ whatsnext: { import { Aside } from "@components" import DataStreams from "@features/data-streams/common/DataStreams.astro" - - - + diff --git a/src/content/data-streams/getting-started.mdx b/src/content/data-streams/getting-started.mdx index 111c91c7238..cec1c1504b5 100644 --- a/src/content/data-streams/getting-started.mdx +++ b/src/content/data-streams/getting-started.mdx @@ -15,13 +15,6 @@ whatsnext: { import { Aside } from "@components" import DataStreams from "@features/data-streams/common/DataStreams.astro" - - - + diff --git a/src/content/data-streams/index.mdx b/src/content/data-streams/index.mdx index ee219272db5..8ae89de7284 100644 --- a/src/content/data-streams/index.mdx +++ b/src/content/data-streams/index.mdx @@ -12,15 +12,9 @@ whatsnext: import { Aside, ClickToZoom } from "@components" import button from "@chainlink/design-system/button.module.css" +import DataStreams from "@features/data-streams/common/DataStreams.astro" - - - + Chainlink Data Streams provides low-latency delivery of market data offchain that you can verify onchain. With Chainlink Data Streams, decentralized applications (dApps) now have on-demand access to high-frequency market data backed by decentralized and transparent infrastructure. When combined with [Chainlink Automation](/chainlink-automation/introduction), Chainlink Data Streams allows decentralized applications to automate trade execution, mitigate frontrunning, and limit bias or adverse incentives in executing non-user-triggered orders. @@ -46,8 +40,8 @@ Chainlink Data Streams supports fee payments in LINK and in alternative assets, Chainlink Data Streams has the following core components: -- **A Chainlink Decentralized Oracle Network (DON):** This DON operates similarly to the DONs that power [Chainlink Data Feeds](/data-feeds), but the key difference is that it signs and delivers reports to the Chainlink Data Engine rather than delivering answers onchain directly. This allows the Data Streams DON to deliver reports more frequently for time-sensitive applications. Nodes in the DON retrieve data from many different data providers, reach a concensus about the median price of an asset, sign a report including that data, and deliver the report to the Chainlink Data Engine. -- **The Chainlink Data Engine:** The Data Engine stores the signed reports and delivers them to Chainlink Automation when it is requested. +- **A Chainlink Decentralized Oracle Network (DON):** This DON operates similarly to the DONs that power [Chainlink Data Feeds](/data-feeds), but the key difference is that it signs and delivers reports to the Data Streams Aggregation Network rather than delivering answers onchain directly. This allows the Data Streams DON to deliver reports more frequently for time-sensitive applications. Nodes in the DON retrieve data from many different data providers, reach a concensus about the median price of an asset, sign a report including that data, and deliver the report to the Data Streams Aggregation Network. +- **The Data Streams Aggregation Network:** The Data Streams Aggregation Network stores the signed reports and delivers them to Chainlink Automation when it is requested. - **The Chainlink Verifier Contract:** This contract verifies the signature from the DON to cryptographically guarantee that the report has not been altered from the time that the DON reached concensus to the point where you use the data in your application. diff --git a/src/content/data-streams/reference/interfaces.mdx b/src/content/data-streams/reference/interfaces.mdx index 48564da8f2c..15547364324 100644 --- a/src/content/data-streams/reference/interfaces.mdx +++ b/src/content/data-streams/reference/interfaces.mdx @@ -5,15 +5,9 @@ title: "Interfaces" --- import { Aside, CodeSample } from "@components" +import DataStreams from "@features/data-streams/common/DataStreams.astro" - - - + Data Streams require several interfaces in order to retrieve and verify reports. diff --git a/src/content/data-streams/reference/report-schema.mdx b/src/content/data-streams/reference/report-schema.mdx index 01bf7e0ae35..ee1795af798 100644 --- a/src/content/data-streams/reference/report-schema.mdx +++ b/src/content/data-streams/reference/report-schema.mdx @@ -5,37 +5,22 @@ title: "Report Schema Reference" --- import { Aside } from "@components" +import DataStreams from "@features/data-streams/common/DataStreams.astro" - + - +Data Streams feeds have the following values specifically applicable to market pricing data. Current Data Streams feeds adhere to the schema outlined below: -Data Streams can deliver a broad array of information in each report. The values you can expect in each report depend on the schema for the Stream ID that you select. You can find the schema for each ID on the [Stream IDs](/data-streams/stream-ids) page. +| Value | Type | Description | +| ----------------------- | --------- | ------------------------------------------------------------------------------------- | +| `feedID` | `bytes32` | The unique identifier for the Data Streams feed | +| `validFromTimestamp` | `uint32` | The earliest timestamp during which the price is valid | +| `observationsTimestamp` | `uint32` | The latest timestamp during which the price is valid | +| `nativeFee` | `uint192` | The cost to verify this report onchain when paying with the blockchain's native token | +| `linkFee` | `uint192` | The cost to verify this report onchain when paying with LINK | +| `expiresAt` | `uint32` | The expiration date of this report | +| `price` | `int192` | The DON's consensus median price for this report carried to 18 decimal places | +| `bid` | `int192` | The simulated price impact of a buy order up to the X% depth of liquidity usage | +| `ask` | `int192` | Simulated price impact of a sell order up to the X% depth of liquidity usage | -## Basic schema - -Streams with the `Basic` schema have the following values specifically applicable to market pricing data: - -| Value | Type | Description | -| ----------------------- | --------- | ----------------------------------------------------------------------------- | -| `feedID` | `bytes32` | The unique identifier for the stream | -| `validFromTimestamp` | `uint32` | The earliest timestamp during which the price is valid | -| `observationsTimestamp` | `uint32` | The latest timestamp during which the price is valid | -| `nativeFee` | `uint192` | The cost to verify this report when paying with the blockchain's native token | -| `linkFee` | `uint192` | The cost to verify this report when paying with LINK | -| `expiresAt` | `uint32` | The expiration date of this report | -| `price` | `int192` | The DON's consensus median price for this report carried to 8 decimal places | - -## Premium schema - -The `Premium` schema includes all values from the `Basic` schema, and also includes `bid` and `ask` values: - -| Value | Type | Description | -| ----- | -------- | ------------------------------------------------------------------------------- | -| `bid` | `int192` | The simulated price impact of a buy order up to the X% depth of liquidity usage | -| `ask` | `int192` | Simulated price impact of a sell order up to the X% depth of liquidity usage | +Note: Future Data Streams feeds may use different report schemas. diff --git a/src/content/data-streams/release-notes.mdx b/src/content/data-streams/release-notes.mdx index 45695d59e20..bfe1b838c7e 100644 --- a/src/content/data-streams/release-notes.mdx +++ b/src/content/data-streams/release-notes.mdx @@ -12,10 +12,6 @@ whatsnext: import { Aside } from "@components" - -