Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sol-trade-sdk

> 编程语言
Open source

Rust SDK for low-latency Solana DEX trading bots with PumpFun, PumpSwap, Bonk, Raydium, Meteora, Jito, and SWQoS submit lanes.

324 stars0 likes0 views
WebsiteGitHub

About

Rust SDK for low-latency Solana DEX trading bots with PumpFun, PumpSwap, Bonk, Raydium, Meteora, Jito, and SWQoS submit lanes.

A high-performance Rust SDK for low-latency Solana DEX trading bots. Built for speed and efficiency, it enables seamless, high-throughput interaction with PumpFun, Pump AMM (PumpSwap), Bonk, StonkFun, Meteora DAMM v2, Raydium AMM v4, and Raydium CPMM for latency-critical trading strategies.

中文 |
English |
Website |
Telegram |
Discord

Table of Contents

  • ✨ Features
  • Documentation Guides
  • Installation
  • ️ Usage Examples
    • Example Usage
    • ⚡ Trading Parameters
    • Usage Examples Summary Table
    • ⚙️ SWQoS Service Configuration
    • Astralane (Binary / Plain / QUIC)
    • Glaive (Binary HTTP / QUIC)
    • Middleware System
    • Address Lookup Tables
    • Nonce Cache
  • Cashback Support (PumpFun / PumpSwap)
  • PumpFun V1 vs V2 Instructions
  • ️ MEV Protection Services
  • Project Structure
  • License
  • Contact
  • ⚠️ Important Notes

SDK Versions

This SDK is available in multiple languages:

Language Repository Description
Rust sol-trade-sdk Ultra-low latency with zero-copy optimization
Node.js sol-trade-sdk-nodejs TypeScript/JavaScript for Node.js
Python sol-trade-sdk-python Async/await native support
Go sol-trade-sdk-golang Concurrent-safe with goroutine support

What This SDK Is For

sol-trade-sdk is the Rust implementation of the FnZero Solana trading SDK family. It focuses on low-latency transaction construction and submission for Solana DEX trading bots, copy-trading systems, sniper bots, arbitrage strategies, and private trading infrastructure.

Area Coverage
DEX protocols PumpFun, PumpSwap, LaunchLab, Bonk, StonkFun, Meteora DAMM v2, Raydium AMM v4, Raydium CPMM
Submit lanes Default Solana RPC plus Jito, Nextblock, ZeroSlot, Temporal, Bloxroute, FlashBlock, BlockRazor, Node1, Astralane, Glaive, SpeedLanding, and other SWQoS providers
Trading workflows Buy/sell, exact input/output, copy trading, sniper trading, address lookup tables, durable nonce, middleware, shared infrastructure
Hot-path design Caller supplies recent blockhash or durable nonce; trade execution avoids RPC reads for blockhash, account, or balance data

Current Release

Rust crate: sol-trade-sdk = "5.0.4"

This release adds first-class shared-program trading through DexType::LaunchLab, DexParamEnum::LaunchLab, and LaunchLabParams, plus platform-specific StonkFun names through DexType::StonkFun, DexParamEnum::StonkFun, and StonkFunParams. It supports dynamic quote mints and token programs, reads current LaunchLab pool and fee configuration by RPC, and builds the current 18-account buy/sell instruction layout. The same DexType::StonkFun routes graduated pools when paired with DexParamEnum::StonkFunSwap / StonkFunSwapParams: arbitrary token pairs, mixed SPL Token/Token-2022 programs, current AmmConfig and creator fees, transfer fees, vault balances, and both swap directions are resolved from mainnet state. Buy quotes also reduce the submitted input at the curve graduation boundary, matching the official LaunchLab SDK. Existing Bonk and RaydiumCpmm names remain available for compatibility and direct underlying-protocol access.

The gated mainnet regressions use a current StonkFun reward pool and the graduated KNOTS/STONK CPMM pool. Run them without submitting a transaction:

RUN_MAINNET_TESTS=1 cargo test --lib current_stonkfun_reward_pool_decodes_and_builds_both_trade_directions -- --nocapture
RUN_MAINNET_TESTS=1 cargo test --lib current_stonkfun_graduated_pool_decodes_and_builds_both_swap_directions -- --nocapture

✨ Features

  1. PumpFun Trading: Unified SDK-side buy, sell, and buy_exact_quote_in flow, preferring V1 for native SOL and selecting V2 for USDC/non-native quote mints or explicit WSOL settlement
  2. PumpSwap Trading: Support for PumpSwap pool trading operations
  3. LaunchLab Trading: First-class generic LaunchLab routing with Bonk compatibility names
  4. StonkFun Trading: First-class StonkFun routing over LaunchLab, plus graduated-pool swaps through CPMM, with arbitrary quote mints and Token-2022 support
  5. Raydium CPMM Trading: Support for Raydium CPMM (Concentrated Pool Market Maker) trading operations
  6. Raydium AMM V4 Trading: Support for Raydium AMM V4 (Automated Market Maker) trading operations
  7. Meteora DAMM V2 Trading: Support for Meteora DAMM V2 (Dynamic AMM) trading operations
  8. Multiple MEV Protection: Support for Jito, Nextblock, ZeroSlot, Temporal, Bloxroute, FlashBlock, BlockRazor, Node1, Astralane, Glaive, LunarLander and other services
  9. Concurrent Trading: Submit through every configured SWQoS provider plus the default RPC lane; the first accepted result can return early while slower routes continue submitting
  10. Unified Trading Interface: Use unified trading protocol enums for trading operations
  11. Middleware System: Support for custom instruction middleware to modify, add, or remove instructions before transaction execution
  12. Pre-Buy Risk Gate: Optional zero-allocation hot-path hook for cached mint authority, freeze authority, holder-cluster, allowlist, or blocklist checks before buy submission
  13. Shared Infrastructure: Share expensive RPC and SWQoS clients across multiple wallets for reduced resource usage
  14. Hot-Path RPC Boundary: Trade execution uses caller-supplied blockhash or durable nonce and never queries RPC for blockhash, account, or balance data

Documentation Guides

Guide Purpose
Pre-Buy Risk Gate Reject risky buys from a local cache before transaction construction and submission
Low-Latency Bot Integration Structure event processing, state refresh, blockhash, account, and submit paths
Trading Parameters Choose buy/sell amount modes, account policies, ALTs, and nonce settings
Gas Fee Strategy Configure compute-unit prices, limits, relay tips, and per-lane fees
Address Lookup Tables Reduce versioned transaction size with one or more ALTs
Durable Nonce Build and refresh durable-nonce transaction workflows

Installation

Direct Clone

Clone this project to your project directory:

cd your_project_root_directory
git clone https://github.com/0xfnzero/sol-trade-sdk

Add the dependency to your Cargo.toml:

# Add to your Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "5.0.4" }

Use crates.io

# Add to your Cargo.toml
sol-trade-sdk = "5.0.4"

️ Usage Examples

Example Usage

1. Create TradingClient Instance

You can refer to Example: Create TradingClient Instance.

Method 1: Simple (single wallet)

…

TradeTransactionVersion::V0 is the default and preserves the existing behavior: transactions without address lookup tables use Legacy messages, while transactions with lookup tables use V0. Select TradeTransactionVersion::V1 explicitly to build V1 messages. V1 embeds the compute-unit limit and total priority fee in its transaction config, does not include ComputeBudget instructions, does not support address lookup tables, and allows transactions up to 4096 bytes. The existing cu_price setting remains micro-lamports per compute unit and is converted to total lamports with ceiling division. Only enable V1 on a cluster and submission provider that supports it; individual providers may impose a smaller transport limit, and Mainnet V1 activation may lag Devnet/Testnet.

Method 2: Shared infrastructure (multiple wallets)

For multi-wallet scenarios, create the infrastructure once and share it across wallets. See Example: Shared Infrastructure.

// Create infrastructure once (expensive)
let infra_config = InfrastructureConfig::new(rpc_url, swqos_configs, commitment);
let infrastructure = Arc::new(TradingInfrastructure::new(infra_config).await);

// Create multiple clients sharing the same infrastructure (fast)
let client1 = TradingClient::from_infrastructure(Arc::new(payer1), infrastructure.clone(), true)
    .with_transaction_version(TradeTransactionVersion::V1);
let client2 = TradingClient::from_infrastructure(Arc::new(payer2), infrastructure.clone(), true);

2. Configure Gas Fee Strategy

For detailed information about Gas Fee Strategy, see the Gas Fee Strategy Reference.

// Create GasFeeStrategy instance
let gas_fee_strategy = GasFeeStrategy::new();
// Set global strategy
gas_fee_strategy.set_global_fee_strategy(150000, 150000, 500000, 500000, 0.001, 0.001);

3. Build Trading Parameters

For detailed information about all trading parameters, see the Trading Parameters Reference.

…

4. Execute Trading

client.buy_simple(buy_params).await?;

⚡ Trading Parameters

Use SimpleBuyParams / SimpleSellParams for new integrations. They describe trading intent and hide low-level ATA flags. Most users only choose:

  • pay_with / receive_as: quote token direction. Use SOL when the wallet spends or receives native SOL. For PumpFun V2 SOL-paired pools whose quote mint is WSOL, still use SOL if you want native SOL settlement.
  • amount: trade sizing intent. Pick one enum variant instead of combining input_token_amount, fixed_output_token_amount, and use_exact_sol_amount.
  • account_policy: account creation behavior. Bots usually use HotPathMinimal; normal apps can keep the default Auto.
Parameter Meaning Recommendation
BuyAmount::ExactInput(amount) Spend exactly this quote amount; slippage protects minimum output. Normal swaps
BuyAmount::WithMaxInput { quote_amount } Regular PumpFun/PumpSwap buy with slippage applied to max quote cost. Sniping/arbitrage
BuyAmount::ExactOutput { output_amount, max_input_amount } Buy an exact token amount with a max quote budget. Exact-output workflows
SellAmount::ExactInput(amount) Sell exactly this token amount. Normal sells
SellAmount::ExactOutput { output_amount, max_input_amount } Receive an exact quote amount while limiting token input, where the DEX supports it. Exact-output sells
AccountPolicy::Auto SDK creates practical ATAs when needed. General usage
AccountPolicy::HotPathMinimal Avoid ATA create/close instructions in the trade tx. Bots, sniping, latency-sensitive flows
AccountPolicy::CreateMissing Include ATA creation instructions where possible. Convenience over transaction size
AccountPolicy::AssumePrepared Caller prepared every required ATA. Deterministic advanced flows

Optional builder methods:

Method Meaning
.slippage_basis_points(300) Set slippage. 300 means 3%.
`.address_lookup_table_account(a

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust0xfnzeroarbitragebonkcopy-trading

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言