Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS - Rust SDK #2241

Merged
merged 9 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/tutorial-icons/go_logo_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/images/tutorial-icons/rust_logo_blk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 65 additions & 47 deletions src/config/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ export const SIDEBAR: Partial<Record<Sections, SectionEntry[]>> = {
title: "Overview",
url: "data-streams",
},
{
title: "Getting Started",
url: "data-streams/getting-started",
highlightAsCurrent: ["data-streams/getting-started-hardhat"],
},
{
title: "Developer Responsibilities",
url: "data-streams/developer-responsibilities",
Expand All @@ -254,59 +249,86 @@ export const SIDEBAR: Partial<Record<Sections, SectionEntry[]>> = {
],
},
{
section: "Stream Addresses",
section: "Streams & Report Schemas",
contents: [
{
title: "Crypto streams",
title: "Cryptocurrency Streams",
url: "data-streams/crypto-streams",
children: [
{
title: "Report Schema v3",
url: "data-streams/reference/report-schema",
},
],
},
{
title: "RWA streams",
title: "Real World Asset (RWA) Streams",
url: "data-streams/rwa-streams",
children: [
{
title: "Report Schema v4",
url: "data-streams/reference/report-schema-v4",
},
],
},
{
title: "Market hours",
title: "Market Hours",
url: "data-streams/market-hours",
},
],
},
{
section: "Guides",
section: "Streams Trade",
contents: [
{
title: "Streams Trade",
url: "data-streams/tutorials/streams-trade/",
children: [
{
title: "Handle StreamsLookup errors",
url: "data-streams/tutorials/streams-trade/streams-trade-lookup-error-handler",
},
title: "Overview",
url: "data-streams/streams-trade",
},
{
title: "Getting Started",
url: "data-streams/getting-started",
highlightAsCurrent: ["data-streams/getting-started-hardhat"],
},
{
title: "Handle StreamsLookup errors",
url: "data-streams/tutorials/streams-trade/streams-trade-lookup-error-handler",
},
],
},
{
section: "Streams Direct",
contents: [
{
title: "Overview",
url: "data-streams/streams-direct",
},
{
title: "Fetch and decode reports",
url: "data-streams/tutorials/streams-direct/streams-direct-api-go",
highlightAsCurrent: [
"data-streams/tutorials/streams-direct/streams-direct-api-rust",
"data-streams/tutorials/streams-direct/streams-direct-api-rwa-go",
"data-streams/tutorials/streams-direct/streams-direct-api-rwa-rust",
],
},
{
title: "Streams Direct",
url: "data-streams/tutorials/streams-direct/",
children: [
{
title: "Fetch and decode reports",
url: "data-streams/tutorials/streams-direct/streams-direct-api",
highlightAsCurrent: ["data-streams/tutorials/streams-direct/streams-direct-api-rwa"],
},
{
title: "Stream and decode reports (WebSocket)",
url: "data-streams/tutorials/streams-direct/streams-direct-ws",
highlightAsCurrent: ["data-streams/tutorials/streams-direct/streams-direct-ws-rwa"],
},
{
title: "Verify report data",
url: "data-streams/tutorials/streams-direct/evm-onchain-report-verification",
highlightAsCurrent: [
"data-streams/tutorials/streams-direct/solana-onchain-report-verification",
"data-streams/tutorials/streams-direct/solana-offchain-report-verification",
],
},
title: "Stream and decode reports (WebSocket)",
url: "data-streams/tutorials/streams-direct/streams-direct-ws-go",
highlightAsCurrent: [
"data-streams/tutorials/streams-direct/streams-direct-ws-rust",
"data-streams/tutorials/streams-direct/streams-direct-ws-rwa-go",
"data-streams/tutorials/streams-direct/streams-direct-ws-rwa-rust",
],
},
{
title: "Verify report data (EVM)",
url: "data-streams/tutorials/streams-direct/evm-onchain-report-verification",
},
{
title: "Verify report data (Solana)",
url: "data-streams/tutorials/streams-direct/solana-onchain-report-verification",
highlightAsCurrent: ["data-streams/tutorials/streams-direct/solana-offchain-report-verification"],
},
],
},
{
Expand All @@ -326,16 +348,11 @@ export const SIDEBAR: Partial<Record<Sections, SectionEntry[]>> = {
section: "Reference",
contents: [
{
title: "Report Schemas",
url: "data-streams/reference/report-schema",
highlightAsCurrent: ["data-streams/reference/report-schema-v4"],
},
{
title: "Streams Trade Interface",
title: "Streams Trade",
url: "data-streams/reference/streams-trade-interface",
},
{
title: "Streams Direct Interface",
title: "Streams Direct",
url: "data-streams/reference/streams-direct",
children: [
{
Expand All @@ -347,11 +364,12 @@ export const SIDEBAR: Partial<Record<Sections, SectionEntry[]>> = {
url: "data-streams/reference/streams-direct/streams-direct-interface-ws",
},
{
title: "SDK Reference",
title: "SDK References",
url: "data-streams/reference/streams-direct/streams-direct-go-sdk",
highlightAsCurrent: ["data-streams/reference/streams-direct/streams-direct-rust-sdk"],
},
{
title: "Onchain report data verification (EVM chains)",
title: "Onchain report verification (EVM chains)",
url: "data-streams/reference/streams-direct/streams-direct-onchain-verification",
},
],
Expand Down
56 changes: 22 additions & 34 deletions src/content/data-streams/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ title: "Chainlink Data Streams"
isIndex: true
whatsnext:
{
"Learn the basics about how to retrieve Data Streams reports using the Streams Trade implementation": "/data-streams/getting-started",
"Learn how to fetch and decode Data Streams reports using the Streams Direct API": "/data-streams/tutorials/streams-direct/streams-direct-api",
"Learn how to retrieve Data Streams reports with the Streams Trade implementation": "/data-streams/getting-started",
"Learn how to fetch and decode Data Streams reports with the Streams Direct API": "/data-streams/tutorials/streams-direct/streams-direct-api",
"Find the list of available Stream IDs": "/data-streams/crypto-streams",
"Find the schema of data to expect from Data Streams reports": "/data-streams/reference/report-schema",
}
Expand All @@ -16,63 +16,51 @@ import DataStreams from "@features/data-streams/common/DataStreams.astro"

<DataStreams section="dsNotes" />

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, fault-tolerant, and transparent infrastructure.
Chainlink Data Streams delivers low-latency market data offchain, which you can verify onchain. This approach provides decentralized applications (dApps) with on-demand access to high-frequency market data backed by decentralized, fault-tolerant, and transparent infrastructure.

Traditional push-based oracles provide regular updates onchain when certain price thresholds or update time periods have been met. Chainlink Data Streams is built using a new pull-based oracle design that maintains trust-minimization using onchain verification.
Traditional push-based oracles update onchain data at set intervals or when certain price thresholds are met. In contrast, Chainlink Data Streams uses a pull-based design that preserves trust-minimization with onchain verification.

## Sub-Second Data and Commit-and-Reveal

Chainlink Data Streams supports sub-second data resolution for latency-sensitive use cases by retrieving data only when needed. You can combine the data with any transaction in near real time. A “commit-and-reveal” approach mitigates frontrunning by making trade data and stream data visible atomically on-chain.

## Comparison to push-based oracles

Chainlink's push-based oracles provide regular updates onchain. Chainlink Data Streams operates as a pull-based oracle where you can retrieve the data in a report and use it onchain any time. Verifying the report onchain confirms that the data was agreed upon and signed by the DON. While many applications benefit from push-based oracles and require data only after it has been verified onchain, some applications require access to data that is updated at a higher frequency and delivered with lower latency. Pull-based oracles deliver these benefits while still cryptographically signing the data to ensure its veracity.
Chainlink's push-based oracles regularly publish price data onchain. By contrast, Chainlink Data Streams relies on a pull-based design, letting you retrieve a report and verify it onchain whenever you need it. Verification confirms that the decentralized oracle network (DON) agreed on and signed the data. Some applications only need onchain data at fixed intervals, which suits push-based oracles. However, others require higher-frequency updates and lower latency. Pull-based oracles meet these needs and still provide cryptographic guarantees about data accuracy.

<ClickToZoom
src="/images/data-streams/push-based-vs-pull-based-oracles.webp"
alt="Chainlink Data Streams - Push-Based vs Pull-Based Oracles"
/>

Additionally, pull-based oracles deliver data onchain more efficiently by retrieving and verifying the data only when the application needs it. For example, a decentralized exchange might retrieve a Data Streams report and verify the data onchain when a user executes a trade. A push-based oracle repeatedly delivers data onchain even when that data is not immediately required by users.
Pull-based oracles also operate more efficiently by retrieving data only when necessary. For example, a decentralized exchange might fetch a Data Streams report and verify it onchain only when a user executes a trade, rather than continuously pushing updates that might not be immediately used.

## Comprehensive market insights

Chainlink Data Streams provides price points such as mid prices and [Liquidity-Weighted Bid and Ask](/data-streams/concepts/liquidity-weighted-prices) (LWBA) prices for Crypto Streams. LWBA prices adjust dynamically based on the current state of order books, which offers greater insights into market liquidity and depth. Liquidity-weighted prices enhance trading accuracy, improve risk management, and increase transactional efficiency as they dynamically reflect the true market conditions based on volume and liquidity.
Chainlink Data Streams offers price points such as mid prices and [Liquidity-Weighted Bid and Ask](/data-streams/concepts/liquidity-weighted-prices) (LWBA) for Crypto Streams. LWBA prices reflect current order book conditions, providing deeper insight into market liquidity and depth. With additional parameters, such as volatility and liquidity metrics, Data Streams helps protocols enhance trading accuracy, improve onchain risk management, and dynamically adjust margins or settlement conditions in response to real-time market shifts.

## High availability and resilient infrastructure

The Data Streams API services use an [active-active multi-site deployment](/data-streams/architecture#active-active-multi-site-deployment) setup as a highly available and resilient architecture across multiple distributed and fully-isolated origins. This setup ensures that the services are operational even if one origin fails, which provides robust fault tolerance and high availability.
Data Streams API services use an [active-active multi-site deployment](/data-streams/architecture#active-active-multi-site-deployment) model across multiple distributed and isolated origins. This architecture ensures continuous operations even if one origin fails, delivering robust fault tolerance and high availability.

## Use cases

Pull-based oracles allow decentralized applications to access data that is updated at a high frequency and delivered with low latency, which enables several new use cases:
Access to low-latency, high-frequency data enables a variety of onchain applications:

- **Perpetual Futures:** Low-latency data and frontrunning prevention enable onchain perpetual futures protocols that can compete on performance with centralized exchanges while still using more transparent and decentralized infrastructure.
- **Options:** Pull-based oracles allow timely and precise settlement of options contracts. Additionally, Data Streams provides more detailed market liquidity data that can support dynamic onchain risk management logic.
- **Prediction Markets:** Higher frequency data updates allow for applications where users can act quickly in response to real-time events and be confident in the accuracy of the data used in the settlement.
- **Perpetual Futures:** Sub-second data and frontrunning mitigation allow onchain perpetual futures protocols to compete with centralized exchanges on performance while retaining transparency and decentralization.
- **Options:** Pull-based oracles provide timely settlement of options contracts with the added benefit of market liquidity data to support dynamic onchain risk management.
- **Prediction Markets:** High-frequency updates let participants act on real-time data, ensuring quick reactions to events and accurate settlement.

## Data Streams implementations

### Streams Trade: Using Data Streams with Chainlink Automation

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.

<ClickToZoom
src="/images/data-streams/data-streams-trade-architecture-v3.webp"
alt="Chainlink Data Streams - Streams Trade Architecture"
/>
### Streams Trade

Read more about the [Streams Trade Architecture](/data-streams/architecture#streams-trade-architecture) and an [example trading flow](/data-streams/architecture#example-trading-flow-using-streams-trade), or learn how to [get started](/data-streams/getting-started) with Streams Trade.
Streams Trade combines Chainlink Data Streams with Chainlink Automation to deliver automated trade execution with frontrunning mitigation. This approach suits dApps that require automated, trust-minimized trade execution and high-frequency market data. Chainlink Automation ensures near-instant onchain access to data while keeping the execution of user transactions fair and reliable.

**Note**: Before implementing Streams Trade, ensure that Chainlink Automation is available on your desired network by checking the [Automation Supported Networks page](/chainlink-automation/overview/supported-networks).
[Learn more about Streams Trade](/data-streams/streams-trade)

### Streams Direct: Using Data Streams with your own bot
### Streams Direct

Streams Direct offers a direct approach to integrating low-latency and high-frequency data into your applications. You can use the [Data Streams SDK](/data-streams/reference/streams-direct/streams-direct-go-sdk) to fetch reports (REST API) or to subscribe to report updates (WebSocket connection) from the Data Streams Aggregation Network, and an onchain smart contract to [verify reports](/data-streams/reference/streams-direct/streams-direct-onchain-verification).

For instance, you can use Chainlink Data Streams with the Streams Direct implementation to display indicative pricing offchain on your front end or with your bot to settle trades onchain.

#### On-demand offchain workflows

<ClickToZoom
src="/images/data-streams/data-streams-on-demand-offchain-workflows.webp"
alt="Chainlink Data Streams - Streams Direct On-Demand Offchain Workflows"
/>
Streams Direct provides direct access to Data Streams through SDKs and APIs. This solution suits applications that need programmatic data retrieval and verification, whether for offchain display or onchain settlement. It delivers high-frequency, low-latency data for any custom use case.

Explore an example of offchain price updates through Streams Direct in the [Architecture](/data-streams/architecture#streams-direct-architecture) guide, or follow this [guide](/data-streams/tutorials/streams-direct/streams-direct-api) to learn how to fetch and decode Data Streams reports using the Data Streams SDK.
[Learn more about Streams Direct](/data-streams/streams-direct)
Loading
Loading