Skip to content

Commit 21c4d5b

Browse files
committed
calculated streams draft
1 parent 34d00ee commit 21c4d5b

File tree

3 files changed

+164
-0
lines changed

3 files changed

+164
-0
lines changed
423 KB
Loading

src/config/sidebar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,10 @@ export const SIDEBAR: Partial<Record<Sections, SectionEntry[]>> = {
944944
title: "Best Practices",
945945
url: "data-streams/concepts/best-practices",
946946
},
947+
{
948+
title: "Calculated Streams",
949+
url: "data-streams/concepts/calculated-streams",
950+
},
947951
{
948952
title: "Liquidity-Weighted Bid and Ask prices",
949953
url: "data-streams/concepts/liquidity-weighted-prices",
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
section: dataStreams
3+
date: "Last Modified"
4+
title: "Calculated Streams"
5+
metadata:
6+
title: "Chainlink Calculated Streams | Derived Data Stream Values"
7+
description: "Learn about Calculated Streams in Chainlink Data Streams - streams whose values are derived from multiple underlying inputs using predefined expressions."
8+
keywords:
9+
[
10+
"Calculated Streams",
11+
"Data Streams",
12+
"Derived Values",
13+
"Index Pricing",
14+
"Collateral Values",
15+
"Tokenized Assets",
16+
"Stream Calculations",
17+
]
18+
whatsnext:
19+
{
20+
"Find the list of available Crypto streams": "/data-streams/crypto-streams",
21+
"Find the list of available RWA streams": "/data-streams/rwa-streams",
22+
"Learn about Data Streams architecture": "/data-streams/architecture",
23+
"Data Streams Best Practices": "/data-streams/concepts/best-practices",
24+
}
25+
---
26+
27+
import { Aside, ClickToZoom } from "@components"
28+
29+
Calculated streams are Chainlink data streams whose values are derived by applying arithmetic expressions to multiple underlying inputs.
30+
31+
All Data Streams use a [Decentralized Oracle Network (DON)](/data-streams/architecture) where nodes reach consensus and publish signed reports.
32+
33+
Traditional Data Streams aggregate market data from multiple independent providers, ensuring no single data source can compromise the stream's integrity.
34+
35+
Instead of aggregating raw market data, Calculated Streams compute derived values using predefined formulas applied to various inputs—including existing data streams, onchain state, and offchain APIs. This enables protocols to consume complex, computed data points without implementing their own calculation logic.
36+
37+
<Aside type="caution" title="Important Considerations">
38+
Calculated streams introduce additional dependencies and timing considerations compared to standard streams. Before
39+
integrating a calculated stream, review the <a href="#unique-risks-and-mitigation">risks and mitigation</a> section to
40+
understand how multiple inputs and update cadences may affect your application.
41+
</Aside>
42+
43+
## Why use calculated streams?
44+
45+
- **Simpler integrations**: Consume one stream instead of implementing calculation logic in your contracts or backend
46+
- **Canonical formulas**: All integrators use the same formula and inputs, ensuring consistency across protocols
47+
- **Managed infrastructure**: Chainlink handles RPC calls, API integrations, and the calculation pipeline
48+
49+
## How to identify calculated streams
50+
51+
Calculated streams are marked with a **Calculated** badge in the documentation.
52+
53+
## How calculated streams work
54+
55+
Calculated streams leverage existing Data Streams infrastructure. Data providers feed market data into the DON, which produces base streams. The DON then uses these base streams—along with onchain state and offchain APIs—as inputs to calculate derived values.
56+
57+
<ClickToZoom
58+
src="/images/data-streams/calculated-streams-diagram.png"
59+
alt="Calculated Streams architecture diagram showing data providers feeding into LLO DON nodes, which perform index price calculations and output to channels containing multiple streams."
60+
/>
61+
62+
### Architecture flow
63+
64+
1. **Data collection**: The DON retrieves inputs specific to each calculated stream, which may include:
65+
- Existing Data Streams (market prices from multiple independent data providers)
66+
- Onchain state via RPC calls (vault balances, token supplies, contract data)
67+
- Offchain data via APIs (yield rates, interest components, external reference data)
68+
2. **Calculation**: The DON applies the predefined formula to combine the inputs
69+
3. **Consensus and signing**: Nodes reach consensus on the calculated value and sign the report
70+
4. **Publication**: Calculated streams are published through the Data Streams Aggregation Network
71+
72+
### Input sources
73+
74+
The inputs for a calculated stream depend on what it's computing. A stream might use:
75+
76+
#### Existing Data Streams
77+
78+
Market prices already aggregated from multiple independent sources (3+ providers). Example: using individual crypto asset prices as inputs for an index calculation.
79+
80+
#### Onchain state
81+
82+
Protocol-specific data read via RPC, such as vault balances, token supplies, or smart contract state. May come from a single protocol's contracts.
83+
84+
#### Offchain APIs
85+
86+
External data from specific trusted providers, such as yield rates or reference values. May come from a single API endpoint.
87+
88+
### Calculation and output
89+
90+
The DON executes the predefined formula (weighted averages, ratios, sums, etc.) using the latest available inputs. The calculated value is packaged into a signed report with standard metadata (timestamps, fees) and published through the Data Streams Aggregation Network. You consume these reports using the same REST APIs, WebSocket connections, and onchain verification as traditional streams.
91+
92+
---
93+
94+
## Risks and mitigation
95+
96+
Calculated streams inherit risks from their underlying inputs and introduce additional considerations due to combining multiple data sources.
97+
98+
### Multiple dependencies
99+
100+
Each input—RPC providers, external APIs, smart contracts—represents a potential point of failure. If any required input becomes unavailable, the calculated stream cannot produce a value.
101+
102+
#### Mitigation
103+
104+
- Chainlink operators use redundant RPC and API providers
105+
- Design your protocol to handle missing data gracefully (pause operations, use last-known values, or implement fallbacks based on your risk tolerance)
106+
107+
### Timing and synchronization
108+
109+
Inputs update at different frequencies and are read via separate calls, so they may reflect slightly different block heights or timestamps. The calculated value is an approximation based on the latest available data, not a single-block atomic snapshot.
110+
111+
Users should expect small, transient differences between the calculated stream value and values you see on dashboards or compute independently. This is normal during rapid changes (large deposits, withdrawals, market volatility).
112+
113+
#### Mitigation
114+
115+
- Implement max deviation checks against expected ranges
116+
- Use time-weighted averages or circuit breakers for extreme moves
117+
- Monitor trends over time rather than reacting to individual updates
118+
119+
<Aside type="note" title="Developer Responsibilities">
120+
When using calculated streams, you inherit all responsibilities associated with the underlying inputs plus additional
121+
responsibilities for monitoring calculation health and managing time-sensitivity requirements. Review the{" "}
122+
<a href="/data-streams/developer-responsibilities">Developer Responsibilities</a> page for comprehensive guidance on
123+
risk assessment and mitigation techniques.
124+
</Aside>
125+
126+
---
127+
128+
## Example: Tokenized yield product
129+
130+
A calculated stream for a tokenized yield-bearing vault might combine:
131+
132+
- **Vault balance (onchain)**: Total assets in the vault contract
133+
- **Token supply (onchain)**: Circulating supply of vault shares
134+
- **Accrued yield (offchain)**: Interest from an external API
135+
136+
**Formula:** `(vault balance + accrued yield) / token supply`
137+
138+
**Result:** A price per share that accounts for both principal and yield
139+
140+
**Why this matters:** Protocols can price positions, determine collateral values, or calculate redemption rates without implementing vault-specific logic or managing multiple data sources. The calculated stream handles RPC calls, API queries, and the arithmetic.
141+
142+
## Best practices
143+
144+
### Protocol design
145+
146+
- Set deviation limits to cap price changes per update or time window
147+
- Compare calculated values against market references when available (e.g., spot prices for index tokens)
148+
- Define fallback behavior if the stream stops updating or jumps beyond thresholds
149+
150+
### Monitoring
151+
152+
- Track the calculated stream value over time to establish normal behavior
153+
- Monitor key inputs independently when feasible (vault balances, token supplies) to cross-check outputs
154+
- Alert on update gaps or movements outside your safe range
155+
156+
### Handling updates
157+
158+
- Subscribe to Chainlink release notes for formula changes
159+
- Test new streams or updated configurations in staging
160+
- Build flexibility to support stream ID updates when formulas evolve

0 commit comments

Comments
 (0)