Skip to content

Commit 91b4f4e

Browse files
Artem Grigorgitbook-bot
authored andcommitted
GITBOOK-201: Add Streaming option documentation
1 parent ca1b3a0 commit 91b4f4e

File tree

4 files changed

+117
-7
lines changed

4 files changed

+117
-7
lines changed

docs/.gitbook/assets/tmp.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
3+
### Streaming Options
4+
5+
Tycho Client supports several options to customize the data stream. These are available as CLI flags, Rust builder
6+
methods, and Python parameters — refer to each client's documentation for usage details.
7+
8+
| CLI Flag | Rust Builder | Python | Description |
9+
|-------------------------|----------------------------|----------------------------|---------------------------------------------------------------------|
10+
| `--partial-blocks` | `.enable_partial_blocks()` | `partial_blocks=True` | Enable partial block updates (flash blocks) for sub-block latency |
11+
| `--no-state` | `.no_state(true)` | `include_state=False` | Only stream components and tokens; omit snapshots and state updates |
12+
| `--include-tvl` | `.include_tvl(true)` | `include_tvl=True` | Include TVL estimates in messages |
13+
| `--disable-compression` | `.disable_compression()` | `disable_compression=True` | Disable zstd compression for WebSocket messages |
14+
| `--no-tls` | `.no_tls(true)` | `use_tls=False` | Use unencrypted transports (http/ws instead of https/wss) |
15+
16+
{% hint style="info" %}
17+
**Not recommended:** `--disable-compression` and `--no-tls` are intended for debugging only. Compression (zstd)
18+
significantly reduces message sizes and improves throughput, while TLS is required to connect to the hosted endpoint.
19+
Keeping both enabled (the default) is recommended for production use.
20+
{% endhint %}
21+
22+
#### Partial Blocks
23+
24+
Some chains, such as [Base](https://docs.base.org/building-with-base/differences/flashblocks), support _flash blocks_
25+
pre-confirmation updates that contain parts of a future block before it is finalized. When `--partial-blocks` is
26+
enabled, Tycho streams these incremental updates as they arrive, giving you sub-block latency. On chains without flash block
27+
support, enabling this flag has no effect — full blocks are delivered as usual.
28+
29+
{% hint style="warning" %}
30+
Block hashes in partial block messages are **unstable** — they change between partial updates and will differ from the
31+
final block hash. Do not use them as persistent identifiers or cache keys. See
32+
the [Substreams documentation](https://docs.substreams.dev/reference-material/chain-support/flashblocks#developing-for-partial-blocks)
33+
for details.
34+
{% endhint %}
35+
36+
#### No State
37+
38+
By default, each message includes full component snapshots (on the first sync) and state deltas (reserves, balances,
39+
contract storage) on every subsequent block. If you only need to discover which components exist and which tokens they
40+
involve — for example, to build a pool registry or monitor new deployments — you can disable state with `--no-state`.
41+
This significantly reduces message sizes and processing overhead since snapshots and per-block state updates are omitted
42+
entirely.
43+
44+
#### Include TVL
45+
46+
When enabled, each message includes an approximate TVL estimate for every tracked component. This is useful for building
47+
dashboards or for ranking pools by liquidity. Note that enabling this option increases startup latency: for each
48+
snapshot request, the client makes additional RPC calls to fetch token prices and compute TVL for all tracked
49+
components. This overhead scales with the number of components you're tracking.

docs/for-dexs/protocol-integration/3.-testing.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ You need an EVM **Archive** node to fetch the state from a previous block. If yo
2929

3030
The node also needs to support the [debug\_storageRangeAt](https://www.quicknode.com/docs/ethereum/debug_storageRangeAt) method, which is required for our Token Quality Analysis.
3131

32-
As of February 2026, Erigon is the only major client supporting debug_storageRangeAt. The following API providers support archive nodes with debug\_storageRangeAt:
33-
- [Chainnodes](https://www.chainnodes.org/)
34-
- [Chainstack](https://chainstack.com/)
32+
As of February 2026, Erigon is the only major client supporting debug\_storageRangeAt. The following API providers support archive nodes with debug\_storageRangeAt:
33+
34+
* [Chainnodes](https://www.chainnodes.org/)
35+
* [Chainstack](https://chainstack.com/)
3536

3637
### Test Configuration
3738

@@ -129,18 +130,18 @@ By default this should be `false` . It should only be `true` temporarily if you
129130

130131
To be able to test execution, you need to provide the executor's runtime bytecode file.
131132

132-
1. Export it using the helper script in [tycho-execution/foundry/scripts/export-runtime-bytecode.js ](https://github.com/propeller-heads/tycho-execution/blob/main/foundry/scripts/export-runtime-bytecode.js) (see the [README](https://github.com/propeller-heads/tycho-execution/blob/main/foundry/scripts/README.md#export-runtime-bytecode) for instructions on how).
133+
1. Export it using the helper script in [tycho-execution/foundry/scripts/export-runtime-bytecode.js ](https://github.com/propeller-heads/tycho-execution/blob/main/foundry/scripts/export-runtime-bytecode.js)(see the [README](https://github.com/propeller-heads/tycho-execution/blob/main/foundry/scripts/README.md#export-runtime-bytecode) for instructions on how).
133134
2. Copy `YourExecutor.runtime.json` file to the SDK repository in [`tycho-protocol-sdk/evm/test/executors`](https://github.com/propeller-heads/tycho-protocol-sdk/tree/main/evm/test/executors) .
134135
3. Import the file in [tycho-protocol-sdk/protocol-testing/src/execution.rs](https://github.com/propeller-heads/tycho-protocol-sdk/blob/3f31f85c157b1f860fcc9604376e2c11b1e8da0c/protocol-testing/src/execution.rs#L51) and add the corresponding entry to the `EXECUTOR_MAPPING` .
135136

136137
{% hint style="danger" %}
137-
### Block Compatibility Requirements
138+
#### Block Compatibility Requirements
138139

139140
The `TychoRouter` requires post-Cancun blocks for execution. Testing must use block numbers after the Cancun upgrade.
140141
{% endhint %}
141142

142143
{% hint style="info" %}
143-
#### Testing during development
144+
**Testing during development**
144145

145146
To test your protocol integration during development, update the `tycho-simulation` and `tycho-execution` dependencies in `protocol-testing/Cargo.toml` to point to your working branch/commit or to your local repository.
146147

docs/for-solvers/indexer/tycho-client/README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ Tycho Client helps you consume data from Tycho Indexer. It's the recommended way
44

55
In this guide, you'll learn more about the Tycho Client and the streamed data models.
66

7-
{% hint style="info" %}
7+
{% hint style="success" %}
88
If you are developing in Rust and is using Tycho to simulate DeFi Protocol's behavior, we recommend checking out our [simulation.md](../../simulation.md "mention") package - this tool extends Tycho Client's data streaming functionality with powerful simulation capabilities.
99
{% endhint %}
1010

11+
{% hint style="info" %}
12+
**✨ New: Sub-Second Latency with Partial Blocks**
13+
14+
Tycho now provides early support for partial blocks on Base, enabling sub-second latency by streaming pre-confirmation updates. Enable via `--partial-blocks` (CLI), `partial_blocks=True` (Python), or `.enable_partial_blocks()` (Rust). See [Streaming Options](./#streaming-options) below for details.
15+
{% endhint %}
16+
1117
### Key Features
1218

1319
* **Real-Time Streaming**: Get low-latency updates to stay in sync with the latest protocol changes. Discover new pools as they’re created.
@@ -72,6 +78,50 @@ tycho-client --remove-tvl-threshold 95 --add-tvl-threshold 100 --exchange uniswa
7278

7379
This will stream state updates for all components whose TVL exceeds the `add-tvl-threshold`. It will continue to track already added components if they drop below the `add-tvl-threshold`, only emitting a message to remove them if they drop below `remove-tvl-threshold`.
7480

81+
#### Streaming Options
82+
83+
Tycho Client supports several options to customize the data stream. These are available as CLI flags, Rust builder methods, and Python parameters. Refer to each client's documentation for usage details.
84+
85+
| Option | Description | When to use |
86+
| ----------------------- | -------------------------------------------------- | ------------------------------- |
87+
| **Partial blocks** | Stream pre-confirmation blocks | For lower stream latency |
88+
| **No state** | Stream only component metadata and tokens | For lower stream latency |
89+
| **Include TVL** | Attach approximate TVL estimates to each component | For getting components TVL |
90+
| **No TLS** | Use unencrypted transports (http/ws) | For local self-hosted indexers |
91+
| **Disable compression** | Turn off stream message compression | _Debugging Only_ |
92+
93+
{% hint style="info" %}
94+
**Note:** `disable compression` and `no tls` are not intended to be used with the [hosted](../../hosted-endpoints.md) Tycho Indexer endpoints.
95+
{% endhint %}
96+
97+
<details>
98+
99+
<summary><strong>Details:</strong> <strong>Partial Blocks</strong></summary>
100+
101+
Some chains, such as [Base](https://docs.base.org/building-with-base/differences/flashblocks), support _flash blocks_ - pre-confirmation updates that contain parts of a future block before its construction is finished. When `partial blocks` is enabled, Tycho streams these incremental updates as they arrive, giving you sub-block latency. On chains without flash block support, enabling this flag is unsupported.
102+
103+
{% hint style="warning" %}
104+
Block hashes in partial block messages are **unstable** — they change between partial updates and will differ from the final block hash. Do not use them as persistent identifiers or cache keys. See the [Substreams documentation](https://docs.substreams.dev/reference-material/chain-support/flashblocks#developing-for-partial-blocks) for details.
105+
{% endhint %}
106+
107+
</details>
108+
109+
<details>
110+
111+
<summary><strong>Details: No State</strong></summary>
112+
113+
By default, the first sync message includes full component snapshots, and every subsequent block includes state deltas (reserves, balances, contract storage). If you only need to discover which components exist and which tokens they involve, such as to build a pool registry or monitor new deployments, you can disable state monitoring with `no state`. This significantly reduces message sizes, startup time, and processing overhead, as both snapshots and per-block state updates are omitted entirely.
114+
115+
</details>
116+
117+
<details>
118+
119+
<summary><strong>Details: Include TVL</strong></summary>
120+
121+
When enabled, each message includes an approximate TVL estimate for every tracked component. This is useful for building dashboards or for ranking pools by liquidity. Note that enabling this option increases startup latency: for each snapshot request, the client makes additional RPC calls to fetch token prices and compute TVL for all tracked components. This overhead scales with the number of components you're tracking.
122+
123+
</details>
124+
75125
***
76126

77127
## Understanding Tycho Client Messages

docs/for-solvers/simulation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Tycho Simulation is a Rust crate that provides powerful tools for **interacting
1010

1111
The repository is available [here](https://github.com/propeller-heads/tycho-simulation).
1212

13+
{% hint style="info" %}
14+
**✨ New: Sub-Second Latency with Partial Blocks**
15+
16+
Tycho now provides early support for partial blocks on Base, enabling sub-second latency by streaming pre-confirmation updates. Enable this feature with `.enable_partial_blocks()` on your `ProtocolStreamBuilder`.
17+
{% endhint %}
18+
1319
## Installation
1420

1521
The `tycho-simulation` package is available on [Github](https://github.com/propeller-heads/tycho-simulation).
@@ -210,6 +216,10 @@ The first message received will contain states for all protocol components regis
210216
211217
For a full list of supported protocols and the simulation state implementations they use, see [Supported Protocols](supported-protocols.md).
212218

219+
{% hint style="info" %}
220+
`ProtocolStreamBuilder` supports the same [streaming options](https://docs.propellerheads.xyz/tycho/for-solvers/indexer/tycho-client#streaming-options) as the Tycho Client, with one difference: TVL estimates are **always included** in the simulation package and cannot be disabled.
221+
{% endhint %}
222+
213223
<details>
214224

215225
<summary>Example: Consuming the Stream and Simulating</summary>

0 commit comments

Comments
 (0)