🚀 FnZero Solana Examples
Practical examples and tools for Solana DEX trading and development
A collection of Rust examples, SDKs, and tools for building high-performance Solana trading bots. Includes trading examples, SDKs for DEX integration, transaction parsing, key management, and real-time streaming.
中文 |
English |
Website |
Telegram |
Discord
☕ 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
📋 Table of Contents
What This Repository Is For
fnzero-examples is a hands-on example collection for building Solana trading bots with the FnZero SDK ecosystem. It focuses on runnable Rust examples for PumpFun bonding-curve trading, PumpSwap AMM trading, encrypted keystore flows, Yellowstone gRPC monitoring, ShredStream monitoring, SWQoS submit lanes, and durable nonce setup.
| Area |
Coverage |
| Trading examples |
PumpFun buy/sell loops, PumpSwap buy/sell loops, encrypted-keystore variants |
| Sniper examples |
PumpFun creator-first-buy monitoring through Yellowstone gRPC or Jito ShredStream |
| SDKs used |
sol-trade-sdk, sol-parser-sdk, and sol-safekey |
| Target users |
Solana bot developers, copy-trading builders, DEX integrators, and operators testing FnZero SDK workflows |
✨ Features
- Trading Examples: Ready-to-use bots for PumpSwap (outer pool) and PumpFun (bonding curve) with automated buy/sell
- Multiple SWQoS Support: Concurrent transaction submission via multiple MEV protection services
- Comprehensive SDKs: Modular SDKs for trading, parsing, key management, and streaming
- Real-time Streaming: gRPC-based transaction streaming and parsing with low-latency event processing
- Secure Key Management: Encrypted keystore support with password protection
- Production Oriented: Optimized builds and core workflows; examples still require application-specific risk controls, state management, and monitoring
📁 Project Structure
fnzero-examples/
├── pumpswap_trade/ # PumpSwap (outer pool) trading example (direct private key)
├── pumpswap_trade_with_safekey/ # PumpSwap (outer pool) trading example (encrypted keystore)
├── pumpfun_trade/ # PumpFun (bonding curve) trading example (direct private key)
├── pumpfun_trade_with_safekey/ # PumpFun (bonding curve) trading example (encrypted keystore)
├── pumpfun_grpc_sniper/ # PumpFun gRPC sniper example (direct private key)
└── pumpfun_shredstream_sniper/ # PumpFun ShredStream sniper example (direct private key)
sol-safekey is resolved from crates.io by the encrypted-keystore examples; no sibling checkout is required. Local SDK checkouts remain ignored by .gitignore for optional development work.
🛠️ Examples
Trading Examples
| Example |
Description |
Run Command |
Source Code |
| PumpSwap Trading |
Automated buy→wait→sell loop on PumpSwap (outer AMM); configurable rounds and rest |
./run.sh |
pumpswap_trade |
| PumpSwap Trading (Encrypted) |
Same as above with encrypted keystore |
./run.sh |
pumpswap_trade_with_safekey |
| PumpFun Trading |
Buy→wait→sell on PumpFun bonding curve; token must not have graduated to PumpSwap |
./run.sh |
pumpfun_trade |
| PumpFun Trading (Encrypted) |
Same as above; keystore / KEYPAIR_BASE58 |
./run.sh |
pumpfun_trade_with_safekey |
| PumpFun gRPC Sniper |
Monitor creator first buys through sol-parser-sdk gRPC, buy once, auto-sell after 3s |
./run.sh |
pumpfun_grpc_sniper |
| PumpFun ShredStream Sniper |
Monitor creator first buys through sol-parser-sdk ShredStream, buy once, auto-sell after 3s |
./run.sh |
pumpfun_shredstream_sniper |
Safekey compatibility: both *_with_safekey crates use sol-safekey 0.1.8, sol-trade-sdk 4.0.22, and the same high-level Simple*Params trade API as the direct-key examples. Cargo downloads the library automatically.
Which example should I use?
| Scenario |
Directory |
| Token still on PumpFun bonding curve (not graduated to PumpSwap) |
pumpfun_trade or pumpfun_trade_with_safekey |
| Token on PumpSwap outer AMM |
pumpswap_trade or pumpswap_trade_with_safekey |
Private key via PRIVATE_KEY or private_key in YAML |
pumpfun_trade / pumpswap_trade |
Encrypted keystore + password (or fallback KEYPAIR_BASE58) |
pumpfun_trade_with_safekey / pumpswap_trade_with_safekey |
| Snipe new PumpFun tokens from a gRPC trade stream |
pumpfun_grpc_sniper |
| Snipe new PumpFun tokens from ShredStream outer instructions |
pumpfun_shredstream_sniper |
See the low-latency bot development guide for architecture, trade intents, state freshness, SWQoS, and bounded requoting.
Shared behavior (four loop trading examples)
- ✅ Flow: Buy → wait ~30s → sell; 1 round by default (change
ROUNDS / REST_SECS in each crate’s src/run.rs)
- ✅ Multi-SWQoS: Concurrent submission to several MEV channels
- ✅ YAML +
.env: config/dev|prod/solana.yaml, trading.yaml, and env overrides
- ✅ Durable nonce: Required when 2+ SWQoS providers are enabled—set
nonce_config or NONCE_ACCOUNT; empty "" placeholders in YAML are skipped so NONCE_ACCOUNT still works
- ✅ Gas / slippage: Configurable in
trading.yaml
- ✅ Default:
wait_tx_confirmed: false; the bot waits a fixed interval after buy before reading balance—tune for production if needed
- ⚠️ Sell size: Each round sells the wallet’s full token balance for that mint (including any balance you held before the buy)
Example README index
Configuration
- The repo only ships
*.yaml.example and .env.example. Your local solana.yaml, trading.yaml, and .env are created from those templates and are git-ignored (see “Before you run & privacy”).
- Environment variables can override YAML. With multiple SWQoS providers, configure durable nonce or
NONCE_ACCOUNT.
Supported SWQoS Services
| Service |
Transport Protocols |
| Astralane |
HTTP, QUIC ⚡ |
| BlockRazor |
HTTP, gRPC |
| Bloxroute |
HTTP |
| FlashBlock |
HTTP |
| Jito |
HTTP |
| NextBlock |
HTTP |
| Soyas |
QUIC ⚡ |
| Speedlanding |
QUIC ⚡ |
| Stellium |
HTTP |
| Temporal |
HTTP |
| ZeroSlot |
HTTP |
| Default |
RPC |
API Key Application: Apply for API keys through the official website: https://fnzero.dev/swqos
Note: ⚡ = QUIC (Quick UDP Internet Connections) provides lower latency compared to HTTP/gRPC. Services using QUIC (Astralane, Soyas, Speedlanding) typically offer the best transaction submission performance.
📦 SDKs & Tools
sol-trade-sdk
Comprehensive Rust SDK for Solana DEX trading with unified interface for multiple protocols.
Features:
- Support for PumpFun, PumpSwap, Bonk, Raydium CPMM, Raydium AMM V4, Meteora DAMM V2
- Multiple MEV protection services (Jito, BlockRazor, Astralane, etc.)
- Middleware system for custom instruction modification
- Shared infrastructure for multi-wallet scenarios
- Address Lookup Table (ALT) support
- Durable Nonce management
- Gas fee strategy optimization
Repository: 0xfnzero/sol-trade-sdk
sol-parser-sdk
Transaction parsing SDK with gRPC streaming support for real-time event processing.
Features:
- Parse PumpFun, PumpSwap, Raydium, and other DEX transactions
- gRPC-based streaming for low-latency event processing
- Event filtering and transformation
- Trade event extraction
- Account filler for optimized account lookups
Repository: 0xfnzero/sol-parser-sdk
sol-safekey
Encrypted key management library for secure Solana keypair storage.
Features:
- Encrypt/decrypt Solana keypairs with password protection
- JSON-based keystore format
- Base58 private key support
- CLI tools for key management
- Integration with trading examples