Skip to main content

tycho_simulation/price_level_stream/
mod.rs

1//! Titan pAMM price level stream integration.
2//!
3//! Titan Builder exposes a WebSocket stream of complete per-pair quote snapshots (simulated and
4//! interpolated price levels) for a subset of its supported pAMMs (see
5//! <https://docs.titanbuilder.xyz/propamms/takers#pamm-price-level>). This module turns those
6//! snapshots directly into [`Update`](crate::protocol::models::Update)s ready for consumption.
7//!
8//! Quotes target the block currently being built, so every emitted update is marked as partial
9//! and supersedes the previous one for the pairs it contains.
10//!
11//! Components produced here are identified as `pricelevelstream:{pamm}`, where `{pamm}` is the
12//! configured venue name (e.g. `pricelevelstream:fermiswap`) or, for auto-detected venues, the
13//! venue address (e.g. `pricelevelstream:0x5979…`). The prefix keeps these components distinct
14//! from those any other integration path may produce for the same venue (e.g. `vm:fermiswap`).
15//!
16//! Venues on Titan's PropAMMRouter whitelist are emitted under `propammfallback:{pamm}` instead:
17//! tycho-execution routes their swaps through the router, which falls back to a single-hop
18//! Uniswap V3 pool when the venue reverts. The builder reads the whitelist once, at
19//! [`build`](stream::PriceLevelStreamBuilder::build), via the node at `RPC_URL`; without the
20//! variable, or when the read fails, it warns and keeps every venue on the direct path.
21//! [`without_fallback_router`](stream::PriceLevelStreamBuilder::without_fallback_router) skips
22//! the read and keeps every venue on the direct path unconditionally.
23//!
24//! Distinct identifiers do not imply distinct liquidity, though: a venue served here may also be
25//! integrated through another path (FermiSwap, for example, also exists as `vm:fermiswap`), in
26//! which case the components of both paths price the same underlying inventory. Consumers
27//! subscribing to multiple paths must expect such overlaps and deduplicate by venue — e.g. via
28//! the [`PAMM_ADDRESS_ATTRIBUTE`](stream::PAMM_ADDRESS_ATTRIBUTE) — wherever double-counting
29//! matters, such as routing over the combined liquidity.
30//!
31//! Entry point: [`PriceLevelStreamBuilder`](stream::PriceLevelStreamBuilder). Register the pAMMs
32//! to serve — the known venues via
33//! [`with_known_pamms`](stream::PriceLevelStreamBuilder::with_known_pamms), individual
34//! [`PriceLevelStreamConfig`](config::PriceLevelStreamConfig)s via
35//! [`add_pamm`](stream::PriceLevelStreamBuilder::add_pamm), or any streamed venue via
36//! auto-detection — provide token metadata, and consume the resulting stream of
37//! [`Update`](crate::protocol::models::Update)s.
38
39pub mod config;
40pub mod fallback_router;
41pub mod state;
42pub mod stream;
43mod titan;