Resilient Helius WebSocket client for Solana. Gap detection, reconnect backoff, circuit-breaker state. Extracted from a battle-tested MEV engine that ran 15h on Solana mainnet.
solana-client pulls 200+ transitive dependencies. For workloads that only need
account subscriptions, that's a heavy tax. helius-stream does one thing:
subscribe to accounts via Helius WebSocket and surface updates as a typed stream,
with built-in health tracking so you can wire a circuit breaker in 3 lines.
Dependency count: 8 direct, ~25 transitive.
use helius_stream::{HeliusStream, StreamConfig};
let config = StreamConfig::mainnet(std::env::var("HELIUS_API_KEY")?);
let mut stream = HeliusStream::connect(config)?;
// USDC mint
stream.subscribe_account_b58("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")?;
while let Some(update) = stream.next_update() {
if stream.is_safe_for_simulation() {
println!("slot={} lamports={}", update.slot, update.lamports);
}
}Run the included example:
HELIUS_API_KEY=your_key cargo run --example basic_streamHeliusStream— synchronous WebSocket client. Subscribe to accounts, receiveAccountUpdateevents.StreamHealth— slot-gap detection, staleness tracking, gap rate.ReconnectPolicy— exponential backoff with cap (default: 100ms → 10s).StreamState— typed state machine (Connected,Degraded,Stale,Failed) for circuit-breaker logic.- No panics in normal operation — all errors via
StreamError.
- Async API. v0.1 is sync; wrap in
spawn_blockingif you need tokio. Async feature flag planned for v0.2. - Multi-stream orchestration. Open multiple
HeliusStreaminstances yourself. - Program subscriptions, log subscriptions, signature subscriptions. v0.1
covers only
accountSubscribe. PRs welcome. - A Solana SDK. This is an RPC client, not a transaction builder.
Extracted from prometheus9, a Rust MEV engine that ran 15 hours on Solana mainnet monitoring cross-DEX SOL/USDC arbitrage. The engine captured zero opportunities — the market was efficient to within 29 bps. The infrastructure code, however, proved itself: gap detection, auto-reconnect, and zero crashes across 15 hours. That infrastructure is this crate.
Single connection, single thread, residential fiber (Vodafone PT, Porto):
- ~1,500 updates/hour sustained
- ~50ms p50 from server send to
next_update()return - ~1,200 slot gaps observed over 15 hours (network variance, not crate bug)
Apache-2.0. Includes patent grant — contributors automatically grant patent rights for their contributions, and the grant terminates if a user initiates patent litigation. See LICENSE.
Issues and PRs at github.com/ginugokz/helius-stream-rs. For paid work (custom protocols, async port, audit support), see the author's contact.