Pool Discovery Service - Architectural Update
Pool Discovery Service - Architectural Update
Date: January 1, 2026 Status: π¨ Important - Service Responsibility Change Related: 25-POOL-DISCOVERY-DESIGN.md, 30.6-POOL-STATE-OWNERSHIP.md
Summary
The Pool Discovery Service has been simplified to focus ONLY on discovering new pools. Pool state management (WebSocket subscriptions, RPC updates, caching) has been moved to the Local Quote Service.
What Changed?
OLD (Dual Responsibility)
Pool Discovery Service:
ββ Discover new pools (RPC scanning)
ββ Update pool state (WebSocket subscriptions) β REMOVED
ββ RPC backup polling β REMOVED
ββ Redis persistence β REMOVED
NEW (Single Responsibility)
Pool Discovery Service:
ββ Discover new pools (RPC scanning) β
ββ Solscan enrichment (initial only) β
ββ Default reserves (1T units) β
ββ NATS event publishing β
Local Quote Service:
ββ WebSocket subscriptions (all pools) β MOVED HERE
ββ RPC backup polling β MOVED HERE
ββ In-memory cache β MOVED HERE
ββ Redis persistence (backup) β MOVED HERE
Current Responsibilities
Pool Discovery Service
ONLY Does:
- RPC Scanning: Discover new pools via
GetProgramAccountsWithOpts- Bidirectional queries (forward + reverse)
- 6 DEX protocols supported
- Deduplication by pool ID
- Solscan Enrichment: Fetch initial pool data
- TVL (liquidity USD)
- Reserve amounts (base + quote)
- Token decimals
- Best effort: If fails, use default reserves
- Default Reserves: Set large defaults to avoid premature filtering
BaseReserve: 1,000,000,000,000 (1 trillion units)QuoteReserve: 1,000,000,000,000 (1 trillion units)- Never nil, never zero
- NATS Event Publishing: Notify downstream services
pool.discovered.{dex}: New pool foundpool.enriched.{dex}: Solscan data added- Payload includes pool metadata + reserves
Does NOT Do:
- β WebSocket subscriptions
- β Pool state updates
- β RPC backup polling
- β Redis writes
Local Quote Service
New Responsibilities:
- Subscribe to NATS
pool.discovered.*events - Manage WebSocket subscriptions for all pool types
- Handle pool updates via WebSocket account notifications
- RPC backup polling (30s interval on WebSocket failure)
- In-memory cache (hot pools: <1ΞΌs access)
- Redis persistence (async, 10s interval, backup only)
Why This Change?
Problems with Dual Responsibility
- Complexity: Two services managing pool state
- Redis Bottleneck: 1-2ms access vs <1ΞΌs in-memory
- Unavoidable RPC: Quote Service needed RPC anyway for CLMM/DLMM ticks (too large for Redis)
- Debugging Difficulty: Pool updates tracked in two places
- Deployment Coordination: Changes to one service affected the other
Benefits of Single Responsibility
β 1000x faster pool access: In-memory <1ΞΌs vs Redis 1-2ms β Single source of truth: Quote Service owns all pool state β Simpler debugging: All pool updates in one service β WebSocket-first updates: Sub-second freshness vs 10s polling β Clear ownership: No coordination needed between services
Impact on Existing Documentation
25-POOL-DISCOVERY-DESIGN.md
Sections Still Accurate:
- β Problem Analysis (unidirectional matching, bidirectional solution)
- β Token pair management (LST/SOL, triangular arbitrage)
- β Protocol support (6 DEXes)
- β RPC discovery logic
- β Solscan enrichment
- β NATS event publishing
Sections Now Historical (moved to Local Quote Service):
- β οΈ WebSocket subscription management
- β οΈ RPC backup polling
- β οΈ Redis pool state writes
- β οΈ βThree-tier hybrid architectureβ
Interpretation: The document remains valuable for understanding discovery logic, but WebSocket/RPC update sections describe features now in Local Quote Service.
New Documentation
- 30.6-POOL-STATE-OWNERSHIP.md: Complete architecture of the new design
- Pool state ownership migration
- WebSocket subscription management (in Quote Service)
- In-memory cache architecture
- Redis as backup only
- Migration timeline
Migration Status
| Phase | Status | Description |
|---|---|---|
| Phase 1 | β Complete | Pool Discovery simplified (discovery only) |
| Phase 2 | π In Progress | Local Quote Service enhanced (state owner) |
| Phase 3 | β³ Pending | In-memory cache implementation |
| Phase 4 | β³ Pending | Production migration |
| Phase 5 | β³ Pending | Cleanup and documentation |
Quick Reference
Pool Discovery Service
File: go/cmd/pool-discovery-service/main.go
Key Functions:
ScanForPools(ctx, baseMint, quoteMint) error
ββ Bidirectional RPC queries
ββ Solscan enrichment (best effort)
ββ Default reserves (1T units)
ββ Publish NATS events
publishPoolDiscovered(pool) error
ββ NATS: pool.discovered.{dex}
NATS Events:
- Subject:
pool.discovered.raydium_amm - Subject:
pool.discovered.raydium_clmm - Subject:
pool.discovered.meteora_dlmm - Subject:
pool.enriched.{dex}
Local Quote Service
File: go/cmd/local-quote-service/main.go
Key Functions:
subscribeToPoolDiscovery(ctx) error
ββ NATS: pool.discovered.*
ββ Add to in-memory cache
ββ Subscribe WebSocket
ββ Queue RPC refresh
handlePoolDiscovered(event) error
ββ Validate reserves (never nil/zero)
ββ Add to cache
ββ WebSocket subscribe
ββ High-priority RPC refresh
WebSocket Manager:
- Subscription management
- Reconnection logic
- Account update handling
- Pool-specific decoders
Related Documents
- 25-POOL-DISCOVERY-DESIGN.md: Original service design (historical WebSocket/RPC sections)
- 30-QUOTE-SERVICE-ARCHITECTURE.md: Main Quote Service architecture
- 30.6-POOL-STATE-OWNERSHIP.md: Detailed migration architecture β READ THIS
Document Version: 1.0 Last Updated: January 1, 2026 Maintainer: Solution Architect Team
