Skip to content

Ubuntu-Buddha/solana-realtime-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solana-realtime-data

Author: Trygve "Trig" Bundgaard (aka Ubuntu Buddha)

Real-time data pipelines for Solana with sub-second latency.

Design Philosophy

This library prioritizes:

  • Event-driven architecture over polling
  • Minimal latency from chain state to application
  • Automatic reconnection and health monitoring
  • Clean separation between data ingestion and business logic

Why This Exists

RPC polling is slow (5-10s). This library provides:

  1. Event-driven updates via WebSocket
  2. Shred-level detection (pre-confirmation)
  3. Instant transaction confirmation via trade/transfer events

Performance

Method Latency Notes
RPC polling 5-10+ seconds Standard getSignatureStatus loop
WebSocket (processed) 5-20ms Account change subscriptions
Shred detection Pre-confirmation Before block finalization
Event confirmation <1s Same second as on-chain, production observed

When Not to Use This

This library may not be appropriate if:

  • You only need occasional state reads
  • Your use case tolerates multi-second delays
  • You cannot maintain persistent WebSocket connections
  • Shred-level access is not available in your infrastructure

TypeScript vs Rust

This system has been implemented and validated in both TypeScript and Rust. The two implementations share the same architectural model but differ in execution characteristics, allowing direct comparison of throughput, latency, and operational tradeoffs under real production conditions.

Aspect TypeScript Rust
Latency Low Very Low
Throughput High Very High
Memory Model GC Ownership
Iteration Speed Fast Medium
Ops Overhead Lower Medium

Why Two Implementations?

The TypeScript version optimizes for:

  • Faster iteration and prototyping
  • Easier integration with JS-based tooling
  • Operational simplicity

The Rust version optimizes for:

  • Deterministic latency
  • Lower tail latency under load
  • Maximum throughput in critical paths

Architecture

┌─────────────────────────────────────────────────────────┐
│                    Application                          │
└────────────────────┬────────────────────────────────────┘
                     │
    ┌────────────────┼────────────────┐
    │                │                │
┌───▼────┐    ┌──────▼──────┐  ┌─────▼─────┐
│ Trade  │    │   Account   │  │  Instant  │
│ Feed   │    │  Subscriber │  │ Confirm   │
│ Client │    │             │  │  Service    │
└────────┘    └─────────────┘  └───────────┘
    │                │                │
    └────────────────┼────────────────┘
                     │
            ┌────────▼────────┐
            │   WebSocket     │
            │   Connection    │
            └─────────────────┘

Quick Start

TypeScript

npm install solana-realtime-data
import { TradeFeedClient } from 'solana-realtime-data';
import { Connection } from '@solana/web3.js';

const client = new TradeFeedClient({
  wsUrl: 'wss://api.example.com/trades',
  apiKey: process.env.API_KEY,
});

await client.start();
client.subscribe('TokenMintAddress...');

client.on('trade', (event) => {
  console.log(`Trade: ${event.signature}`);
});

Rust

[dependencies]
solana-realtime-data = { path = "../solana-realtime-data/rust" }
use solana_realtime_data::TradeFeedClient;

let client = TradeFeedClient::new(ws_url, Some(api_key));
client.connect().await?;
client.subscribe(mint).await?;

Components

  • Trade Feed Client: DEX trade event streaming via WebSocket
  • Account Subscriber: Account change subscriptions with auto-reconnect
  • Instant Confirmation: Event-driven transaction confirmation

License

MIT

About

Real-time data pipelines for Solana with sub-second latency

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors