helius_stream/lib.rs
1//! # helius-stream
2//!
3//! A resilient WebSocket client for Helius RPC on Solana.
4//!
5//! Built for production: gap detection, reconnect backoff with exponential
6//! jitter, circuit-breaker-friendly state machine, and zero panic surface.
7//!
8//! Extracted from `prometheus9`, an MEV engine that ran 15h on Solana mainnet
9//! against Raydium AMM v4 and Orca Whirlpool. The original engine subscribed
10//! to specific vault accounts; this crate exposes the same machinery as a
11//! general-purpose primitive.
12//!
13//! ## Quick start
14//!
15//! ```no_run
16//! use helius_stream::{HeliusStream, StreamConfig};
17//!
18//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
19//! let config = StreamConfig::mainnet(std::env::var("HELIUS_API_KEY")?);
20//! let mut stream = HeliusStream::connect(config)?;
21//!
22//! // USDC mint as an example
23//! stream.subscribe_account_b58("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")?;
24//!
25//! while let Some(update) = stream.next_update() {
26//! if stream.is_safe_for_simulation() {
27//! println!("slot={} lamports={} bytes={}",
28//! update.slot, update.lamports, update.data.len());
29//! }
30//! }
31//! # Ok(()) }
32//! ```
33//!
34//! ## Why not just use `solana-client`?
35//!
36//! `solana-client` pulls in 200+ transitive dependencies. This crate has 8.
37//! For workloads that only need account subscriptions, that matters.
38
39mod error;
40mod health;
41mod stream;
42mod types;
43
44pub use error::StreamError;
45pub use health::{ReconnectPolicy, StreamHealth};
46pub use stream::HeliusStream;
47pub use types::{AccountUpdate, Pubkey, StreamConfig, StreamState};