You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/data-streams/concepts/calculated-streams.mdx
+21-20Lines changed: 21 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ Instead of aggregating only raw market data, calculated streams compute derived
46
46
47
47
## How to identify calculated streams
48
48
49
-
Calculated streams are marked with a <spanstyle="display: inline-block; font-size: 0.75rem; padding: 2px 6px; margin-left: 4px; border-radius: 4px; background: var(--blue-100); color: var(--blue-700); font-weight: 500; vertical-align: middle;">Calculated</span> badge in the documentation.
49
+
Calculated streams are marked with a <spanstyle="display: inline-block; font-size: 0.75rem; padding: 2px 6px; margin-left: 4px; border-radius: 4px; background: var(--blue-100); color: var(--blue-700); font-weight: 500; vertical-align: middle;">Calculated</span> badge in the Data Streams feed list.
50
50
51
51
## How calculated streams work
52
52
@@ -87,6 +87,20 @@ External data from specific trusted providers, such as yield rates or reference
87
87
88
88
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.
89
89
90
+
## Example: Tokenized yield product
91
+
92
+
A calculated stream for a tokenized yield-bearing vault might combine:
93
+
94
+
-**Vault balance (onchain)**: Total assets in the vault contract
95
+
-**Token supply (onchain)**: Circulating supply of vault shares
96
+
-**Accrued yield (offchain)**: Interest from an external API
**Result**: a price per share that reflects the vault's total value including pending yield.
101
+
102
+
Without this stream, protocols accepting the vault token as collateral would need to query the vault contract, fetch accrued interest from the yield provider's API, perform the calculation themselves, and keep this logic synchronized across all integrators. A calculated stream helps ensure integrators apply the same pricing logic and update together when the underlying formula or yield source changes.
103
+
90
104
---
91
105
92
106
## Risks and mitigation
@@ -101,6 +115,8 @@ Single-source inputs (such as a specific protocol API or contract) carry higher
101
115
102
116
#### Mitigation
103
117
118
+
The following strategies can help mitigate multiple dependency risks:
119
+
104
120
- Design your protocol to handle report gaps gracefully (pause operations, use last-known values with appropriate staleness checks, or implement fallbacks based on your risk tolerance)
105
121
- Implement staleness checks to detect when reports stop arriving and trigger appropriate protocol responses
106
122
- Understand your input sources and assess the reliability of each, particularly single-source APIs or contracts
@@ -115,6 +131,8 @@ If any input source experiences an outage (API errors, RPC failures, or contract
115
131
116
132
#### Mitigation
117
133
134
+
The following strategies can help mitigate timing and synchronization risks:
135
+
118
136
- Implement max deviation checks against expected ranges
119
137
- Use time-weighted averages or circuit breakers for extreme moves
120
138
- Monitor trends over time rather than reacting to individual updates
@@ -129,22 +147,10 @@ If any input source experiences an outage (API errors, RPC failures, or contract
129
147
130
148
---
131
149
132
-
## Example: Tokenized yield product
133
-
134
-
A calculated stream for a tokenized yield-bearing vault might combine:
135
-
136
-
-**Vault balance (onchain)**: Total assets in the vault contract
137
-
-**Token supply (onchain)**: Circulating supply of vault shares
138
-
-**Accrued yield (offchain)**: Interest from an external API
**Result**: a price per share that reflects the vault's total value including pending yield.
143
-
144
-
Without this stream, protocols accepting the vault token as collateral would need to query the vault contract, fetch accrued interest from the yield provider's API, perform the calculation themselves, and keep this logic synchronized across all integrators. A calculated stream helps ensure integrators apply the same pricing logic and update together when the underlying formula or yield source changes.
145
-
146
150
## Best practices
147
151
152
+
To ensure the reliability and integrity of calculated streams in your application, consider the following best practices:
153
+
148
154
### Protocol design
149
155
150
156
- Set deviation limits to cap price changes per update or time window
@@ -158,8 +164,3 @@ Without this stream, protocols accepting the vault token as collateral would nee
158
164
- Monitor key inputs independently when feasible (vault balances, token supplies, API availability) to identify which input may be causing issues
159
165
- Alert on movements outside your expected range
160
166
- For critical applications, consider independently monitoring the availability of single-source APIs or contracts used as inputs
161
-
162
-
### Handling updates
163
-
164
-
- Subscribe to Chainlink release notes for formula changes
165
-
- Test new streams or updated configurations in staging
0 commit comments