Skip to main content

Crate helius_stream

Crate helius_stream 

Source
Expand description

§helius-stream

A resilient WebSocket client for Helius RPC on Solana.

Built for production: gap detection, reconnect backoff with exponential jitter, circuit-breaker-friendly state machine, and zero panic surface.

Extracted from prometheus9, an MEV engine that ran 15h on Solana mainnet against Raydium AMM v4 and Orca Whirlpool. The original engine subscribed to specific vault accounts; this crate exposes the same machinery as a general-purpose primitive.

§Quick start

use helius_stream::{HeliusStream, StreamConfig};

let config = StreamConfig::mainnet(std::env::var("HELIUS_API_KEY")?);
let mut stream = HeliusStream::connect(config)?;

// USDC mint as an example
stream.subscribe_account_b58("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")?;

while let Some(update) = stream.next_update() {
    if stream.is_safe_for_simulation() {
        println!("slot={} lamports={} bytes={}",
            update.slot, update.lamports, update.data.len());
    }
}

§Why not just use solana-client?

solana-client pulls in 200+ transitive dependencies. This crate has 8. For workloads that only need account subscriptions, that matters.

Structs§

AccountUpdate
An account update received from the stream.
HeliusStream
A resilient Helius WebSocket client.
ReconnectPolicy
Exponential backoff with cap, for reconnect attempts.
StreamConfig
Configuration for a single stream connection.
StreamHealth
Tracks slot continuity, gaps, and freshness of incoming updates.

Enums§

StreamError
StreamState
Current operational state of the stream.

Type Aliases§

Pubkey
A Solana account public key — 32 raw bytes.