â Support This Project
This SDK is completely free and open source. However, maintaining and continuously updating it requires significant AI computing resources and token consumption. If this SDK helps with your development, consider making a monthly SOL donation â any amount is appreciated and helps keep this project alive!
Donation Wallet:
6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8
ðĶ SDK Versions
This SDK is available in multiple languages:
| Language | Repository | Description |
|---|---|---|
| Rust | sol-parser-sdk | Ultra-low latency with SIMD optimization |
| Node.js | sol-parser-sdk-nodejs | TypeScript/JavaScript for Node.js |
| Python | sol-parser-sdk-python | Async/await native support |
| Go | sol-parser-sdk-golang | Concurrent-safe with goroutine support |
ð Performance Highlights
⥠Ultra-Low Latency
- 10-20Ξs parsing latency in release mode
- Zero-copy parsing with stack-allocated buffers
- SIMD-accelerated pattern matching (memchr)
- Lock-free ArrayQueue for event delivery
ðïļ Flexible Order Modes
| Mode | Latency | Description |
|---|---|---|
| Unordered | 10-20Ξs | Immediate output, ultra-low latency |
| MicroBatch | 50-200Ξs | Micro-batch ordering with time window |
| StreamingOrdered | 0.1-5ms | Stream ordering with continuous sequence release |
| Ordered | 1-50ms | Full slot ordering, wait for complete slot |
ð Optimization Highlights
- â Zero heap allocation for hot paths
- â SIMD pattern matching for all protocol detection
- â Static pre-compiled finders for string search
- â Inline functions with aggressive optimization
- â Event type filtering for targeted parsing
- â Conditional Create detection (only when needed)
- â Multiple order modes for latency vs ordering trade-off
ðĨ Quick Start
Installation
Clone the repository:
Add to your Cargo.toml:
[]
# Default: Borsh parser
= { = "../sol-parser-sdk" }
# Or: Zero-copy parser (maximum performance)
= { = "../sol-parser-sdk", = false, = ["parse-zero-copy"] }
Use crates.io
# Add to your Cargo.toml
= "0.4.3"
Or with the zero-copy parser (maximum performance):
= { = "0.4.3", = false, = ["parse-zero-copy"] }
Performance Testing
Test parsing latency with the optimized examples:
# PumpFun with detailed metrics (per-event + 10s stats)
# PumpSwap with detailed metrics (per-event + 10s stats)
# PumpSwap ultra-low latency test
# PumpSwap with MicroBatch ordering
# Expected output:
# gRPC receive time: 1234567890 Ξs
# Event receive time: 1234567900 Ξs
# Latency: 10 Ξs <-- Ultra-low latency!
Examples
| Description | Run Command | Source Code |
|---|---|---|
| PumpFun | ||
| PumpFun event parsing with metrics | cargo run --example pumpfun_with_metrics --release |
examples/pumpfun_with_metrics.rs |
| PumpFun trade type filtering | cargo run --example pumpfun_trade_filter --release |
examples/pumpfun_trade_filter.rs |
| PumpFun trade with ordered mode | cargo run --example pumpfun_trade_filter_ordered --release |
examples/pumpfun_trade_filter_ordered.rs |
| Quick PumpFun connection test | cargo run --example pumpfun_quick_test --release |
examples/pumpfun_quick_test.rs |
| Parse PumpFun tx by signature | TX_SIGNATURE=<sig> cargo run --example parse_pump_tx --release |
examples/parse_pump_tx.rs |
| Debug PumpFun transaction | cargo run --example debug_pump_tx --release |
examples/debug_pump_tx.rs |
| PumpSwap | ||
| PumpSwap events with metrics | cargo run --example pumpswap_with_metrics --release |
examples/pumpswap_with_metrics.rs |
| PumpSwap ultra-low latency | cargo run --example pumpswap_low_latency --release |
examples/pumpswap_low_latency.rs |
| PumpSwap with MicroBatch ordering | cargo run --example pumpswap_ordered --release |
examples/pumpswap_ordered.rs |
| Parse PumpSwap tx by signature | TX_SIGNATURE=<sig> cargo run --example parse_pumpswap_tx --release |
examples/parse_pumpswap_tx.rs |
| Debug PumpSwap transaction | cargo run --example debug_pumpswap_tx --release |
examples/debug_pumpswap_tx.rs |
| Meteora DAMM | ||
| Meteora DAMM V2 events | cargo run --example meteora_damm_grpc --release |
examples/meteora_damm_grpc.rs |
| Parse Meteora DAMM tx by signature | TX_SIGNATURE=<sig> cargo run --example parse_meteora_damm_tx --release |
examples/parse_meteora_damm_tx.rs |
| Account subscription | ||
| Token account balance updates | TOKEN_ACCOUNT=<pubkey> cargo run --example token_balance_listen --release |
examples/token_balance_listen.rs |
| Nonce account state changes | NONCE_ACCOUNT=<pubkey> cargo run --example nonce_listen --release |
examples/nonce_listen.rs |
| Mint account info | MINT_ACCOUNT=<pubkey> cargo run --example token_decimals_listen --release |
examples/token_decimals_listen.rs |
| PumpSwap pool accounts via memcmp | cargo run --example pumpswap_pool_account_listen --release |
examples/pumpswap_pool_account_listen.rs |
| All ATAs for mints | cargo run --example mint_all_ata_account_listen --release |
examples/mint_all_ata_account_listen.rs |
| ShredStream | ||
| Jito ShredStream subscription | cargo run --example shredstream_example --release |
examples/shredstream_example.rs |
| Utility | ||
| Dynamic subscription filters | cargo run --example dynamic_subscription --release |
examples/dynamic_subscription.rs |
| Debug PumpSwap account filling | cargo run --example test_account_filling --release |
examples/test_account_filling.rs |
Basic Usage
use ;
async
ShredStream Usage (Jito)
ShredStream provides ultra-low latency (~50-100ms faster than gRPC) by directly subscribing to Jito's ShredStream service:
use ;
use DexEvent;
use Arc;
async
ShredStream Limitations:
- Only
static_account_keys()- transactions using ALT may have incorrect accounts - No Inner Instructions - cannot parse CPI calls
- No block_time - always 0
- tx_index is entry-level, not slot-level
ðïļ Supported Protocols
DEX Protocols
- â PumpFun - Meme coin trading (ultra-fast zero-copy path, incl. v2 instructions)
- â PumpSwap - PumpFun swap protocol
- â Raydium AMM V4 - Automated Market Maker
- â Raydium CLMM - Concentrated Liquidity
- â Raydium CPMM - Concentrated Pool
- â Orca Whirlpool - Concentrated liquidity AMM
- â Meteora AMM - Dynamic AMM
- â Meteora DAMM - Dynamic AMM V2
- â Meteora DLMM - Dynamic Liquidity Market Maker
- â Bonk Launchpad - Token launch platform
Event Types
Each protocol supports:
- ð Trade/Swap Events - Buy/sell transactions
- ð§ Liquidity Events - Deposits/withdrawals
- ð Pool Events - Pool creation/initialization
- ðŊ Position Events - Open/close positions (CLMM)
⥠Performance Features
Zero-Copy Parsing
// Stack-allocated 512-byte buffer for PumpFun Trade
const MAX_DECODE_SIZE: usize = 512;
let mut decode_buf: = ;
// Decode directly to stack, no heap allocation
STANDARD
.decode_slice
.ok?;
SIMD Pattern Matching
// Pre-compiled SIMD finders (initialized once)
static PUMPFUN_FINDER: =
new;
// 3-10x faster than .contains()
if PUMPFUN_FINDER.find.is_some
Event Type Filtering
// Ultra-fast path for single event type
if include_only.len == 1 && include_only == PumpFunTrade
Lock-Free Queue
// ArrayQueue with 100,000 capacity
let queue = new;
// Non-blocking push/pop (no mutex overhead)
let _ = queue.push;
if let Some = queue.pop
ðŊ Event Filtering
Reduce processing overhead by filtering specific events:
Example: Trading Bot
let event_filter = include_only;
Example: Pool Monitor
let event_filter = include_only;
Performance Impact:
- 60-80% reduction in processing
- Lower memory usage
- Reduced network bandwidth
ð§ Advanced Features
Create+Buy Detection
Automatically detects when a token is created and immediately bought in the same transaction:
// Detects "Program data: GB7IKAUcB3c..." pattern
let has_create = detect_pumpfun_create;
// Sets is_created_buy flag on Trade events
if has_create
Pump.fun Bonding Curve v2 (buy_v2 / sell_v2 / buy_exact_quote_in_v2)
The SDK recognizes Pump.fun's new v2 trading instructions introduced in the Bonding Curve upgrade. Event logs from buy_v2, sell_v2, and buy_exact_quote_in_v2 are parsed with the same zero-copy path and mapped to the existing event types:
| ix_name in TradeEvent | DexEvent Variant |
|---|---|
"buy" / "buy_v2" |
DexEvent::PumpFunBuy |
"sell" / "sell_v2" |
DexEvent::PumpFunSell |
"buy_exact_sol_in" / "buy_exact_quote_in_v2" |
DexEvent::PumpFunBuyExactSolIn |
No changes are required in your event handling code â v2 events arrive through the same PumpFunTradeEvent struct with the correct ix_name field populated. Instruction discriminators for buy_v2 ([184, 23, 238, 97, 103, 197, 211, 61]), sell_v2 ([93, 246, 130, 60, 231, 233, 64, 178]), and buy_exact_quote_in_v2 ([194, 171, 28, 70, 104, 77, 91, 47]) are recognized at the instruction parser level.
Dynamic Subscription
Update filters without reconnecting:
grpc.update_subscription.await?;
Order Modes
Choose the right balance between latency and ordering:
use ;
// Ultra-low latency (no ordering guarantee)
let config = ClientConfig ;
// Low latency with micro-batch ordering (50-200Ξs)
let config = ClientConfig ;
// Stream ordering with continuous sequence release (0.1-5ms)
let config = ClientConfig ;
// Full slot ordering (1-50ms, wait for complete slot)
let config = ClientConfig ;
Performance Metrics
let config = ClientConfig ;
let grpc = new_with_config?;
ð Project Structure
src/
âââ core/
â âââ events.rs # Event definitions
âââ grpc/
â âââ client.rs # Yellowstone gRPC client
â âââ buffers.rs # SlotBuffer & MicroBatchBuffer
â âââ types.rs # OrderMode, ClientConfig, filters
âââ shredstream/
â âââ client.rs # Jito ShredStream client
â âââ config.rs # ShredStreamConfig
â âââ proto/ # Protobuf definitions
âââ logs/
â âââ optimized_matcher.rs # SIMD log detection
â âââ zero_copy_parser.rs # Zero-copy parsing
â âââ pumpfun.rs # PumpFun parser
â âââ raydium_*.rs # Raydium parsers
â âââ orca_*.rs # Orca parsers
â âââ meteora_*.rs # Meteora parsers
âââ instr/
â âââ *.rs # Instruction parsers
âââ warmup/
â âââ mod.rs # Parser warmup (auto-called)
âââ lib.rs
ð Optimization Techniques
1. SIMD String Matching
- Replaced all
.contains()withmemmem::Finder - 3-10x performance improvement
- Pre-compiled static finders
2. Zero-Copy Parsing
- Stack-allocated buffers (512 bytes)
- No heap allocation in hot path
- Inline helper functions
3. Event Type Filtering
- Early filtering at protocol level
- Conditional Create detection
- Single-type ultra-fast path
4. Lock-Free Queue
- ArrayQueue (100K capacity)
- Spin-wait hybrid strategy
- No mutex overhead
5. Aggressive Inlining
ð Benchmarks
Parsing Latency (Release Mode)
| Protocol | Avg Latency | Min | Max |
|---|---|---|---|
| PumpFun Trade (zero-copy) | 10-15Ξs | 8Ξs | 20Ξs |
| Raydium AMM V4 Swap | 15-20Ξs | 12Ξs | 25Ξs |
| Orca Whirlpool Swap | 15-20Ξs | 12Ξs | 25Ξs |
SIMD Pattern Matching
| Operation | Before (contains) | After (SIMD) | Speedup |
|---|---|---|---|
| Protocol detection | 50-100ns | 10-20ns | 3-10x |
| Create event detection | 150ns | 30ns | 5x |
ð License
MIT License
ð Contact
- Repository: https://github.com/0xfnzero/solana-streamer
- Telegram: https://t.me/fnzero_group
- Discord: https://discord.gg/vuazbGkqQE
â ïļ Performance Tips
- Use Event Filtering - Filter at the source for 60-80% performance gain
- Run in Release Mode -
cargo build --releasefor full optimization - Test with sudo -
sudo cargo run --example basic --releasefor accurate timing - Monitor Latency - Check
grpc_recv_usand queue latency in production - Tune Queue Size - Adjust ArrayQueue capacity based on your throughput
- Spin-Wait Strategy - Tune spin count (default: 1000) for your use case
ðŽ Development
# Run tests
# Build release binary
# Generate docs