Uniswap Substreams
Blockchain2024

UNISWAPSUBSTREAMS

Advanced price-jump detection with sqrtPriceX96 multi-hop resolution on Uniswap v3.

2+
USD hop depth (typical)
3+
Fee tiers instrumented
1
Engine shared with portfolio
SCROLL
Client
Revert Finance
Domain
Blockchain / DeFi Analytics
Platform
Rust Service
Duration
2024
Core Stack
Rust · Substreams · ClickHouse
The Brief

THE
PROBLEM

Revert’s portfolio surfaces needed to flag abnormal Uniswap v3 pool moves fast enough for traders to trust alerts — a missed spike reads as a silent bug and erodes confidence in downstream risk widgets tied to the same pricing graph.

Rust Substreams sink encodes v3-aware jump heuristics, normalizes ticks and liquidity into ClickHouse-friendly columns, and aligns rollups with the multi-hop pricing engine so portfolio and price feeds disagree only when intended.

Core Engineering Challenge

Jumps must be classified across fragmented pools with sqrtPriceX96 decoding, multi-hop USD normalization, and guardrails for low-liquidity noise so ClickHouse wasn’t flooded with false positives during sideways markets.

Multi-hop
Paths
Rust → CH
Stack
Extended stack
backend
Rust
blockchain
Substreams
database
ClickHouse
Price Analytics
Price Analytics
How we built it

THE ARCHITECTURE

01
Event normalization

Map v3 Swap/Mint/Burn topics into typed rows with pool metadata and fee tier.

SubstreamsUniswap v3
02
sqrtPriceX96 → USD

Reuse pricing graph rules so jump deltas are comparable token-denominated and USD-banded.

ClickHousePricing
03
Heuristic scoring

Liquidity-weighted thresholds, cooldown windows, and pair-specific baselines to suppress chatter.

RustAnalytics
04
ClickHouse rollups

Materialized views for minute/hour buckets feeding Revert UI and partner APIs.

ClickHouse
05
Calibration loop

Backtest alerts against known incidents; tune thresholds without redeploying the entire subgraph stack.

QADeFi
System Data Flow
Ingestion
CrawlerContent Hash10K+ pages
Processing
ChunkerDeduplicatorEmbedding API
Storage
pgvectorPostgreSQLRedis Cache
Auth
Identity ProviderJWT BridgeSessions
Query
HNSW SearchRe-rankerLLM Stream
Delivery
Web AppMobile AppUsers
What we delivered

THE RESULTS

Multi-hop

WETH/USDC anchors plus intermediate hops weighted by real liquidity depth — not naive geodesic hops through ghost pools — so jump severity reflected economic impact, not raw tick deltas alone.

Multi-hop
Paths

WETH/USDC anchors plus intermediate hops weighted by real liquidity depth — not naive geodesic hops through ghost pools — so jump severity reflected economic impact, not raw tick deltas alone.

Rust → CH
Stack

Substreams ingest into ClickHouse gives OLAP-friendly storage for rollups, anomaly scoring, and BI exports without re-querying chain RPC for every dashboard refresh.

Engineering decisions

TECH
DEEP DIVE

V3
v3-native heuristics

Tick math and concentrated liquidity semantics baked into Rust instead of generic % change on spot.

False positives dropped once liquidity concentration was part of the score, not an afterthought.

CH
ClickHouse for alert history

Cheap storage for long lookbacks enabled “was this spike real?” forensics for support.

Sharing hop logic with the pricing engine kept portfolio and jump products in sync.

Next Case Study
Blockchain
DeFiSubgraphs

Messari Protocol Suite

TypeScriptAssemblyScriptThe Graph
Start a project

LET'S
BUILD
SOMETHING.

We take on a small number of projects at a time. If the problem is hard, we're interested.

Email
hello@techmusketeers.com
Response time
Within 24 hours
Availability
Open for new projects · 2025