A high-performance Go 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, Meteora DAMM v2, Raydium AMM v4, and Raydium CPMM for latency-critical trading strategies.
中文 | English | Website | Telegram | Discord
Current version: 9.0.1. Read the migration notes before upgrading; see the changelog for historical changes.
Pump.fun defaults to V3 with per-request V1/V2/V3 overrides. See version configuration, multi-hop examples and simulation limits.
- SDK Versions and Related SDKs
- Installation
- What This SDK Is For
- Features
- Usage Examples
- Documentation
- PumpSwap cached routes
Repositories are versioned independently; follow each SDK’s installation guide for compatible dependencies.
| Language | Repository | Purpose | Version |
|---|---|---|---|
| Rust | sol-parser-sdk | DEX transaction and account event parsing | v0.9.1 |
| Node.js | sol-parser-sdk-nodejs | DEX transaction and account event parsing | v0.9.1 |
| Python | sol-parser-sdk-python | DEX transaction and account event parsing | v0.9.1 |
| Go | sol-parser-sdk-golang | DEX transaction and account event parsing | v0.9.1 |
| Rust | sol-trade-sdk | Transaction building, signing and multi-channel submission | v9.0.1 |
| Node.js | sol-trade-sdk-nodejs | Transaction building, signing and multi-channel submission | v9.0.1 |
| Python | sol-trade-sdk-python | Transaction building, signing and multi-channel submission | v9.0.1 |
| Go | sol-trade-sdk-golang | Transaction building, signing and multi-channel submission | v9.0.1 |
| Rust | sol-shred-sdk | Raw shred decoding and ShredStream instruction events | v6.0.1 |
| Rust | solana-streamer | gRPC / ShredStream subscriptions and event streaming | v5.0.0 |
| Rust | sol-trade-router-sdk | On-chain multi-hop router and client SDK | v0.3.0 |
go get github.com/0xfnzero/sol-trade-sdk-golang/v9@v9.0.1To run repository examples or contribute, clone the source:
git clone https://github.com/0xfnzero/sol-trade-sdk-golang
cd sol-trade-sdk-golang
go mod downloadSee the example index for configuration and offline versus live workflows.
sol-trade-sdk-golang brings the FnZero Solana trading SDK to Go. It is built for Go trading services, copy-trading systems, sniper bots, backend workers, and DEX integrations that need typed builders, reusable execution components, and Rust SDK behavior parity.
| Area | Coverage |
|---|---|
| DEX protocols | PumpFun, PumpSwap, Bonk, Meteora DAMM v2, Raydium AMM v4, Raydium CPMM |
| Submit lanes | Default Solana RPC plus Jito, ZeroSlot, Temporal, Bloxroute, FlashBlock, BlockRazor, Astralane, Stellium, Lightspeed, Soyas, Speedlanding, Helius, and Solami; NextBlock remains Rust-blacklisted by default |
| Trading workflows | BuySimple / SellSimple, legacy buy/sell params, copy trading, sniper trading, address lookup tables, durable nonce, middleware, prebuilt transaction execution |
| Runtime | Go 1.25+, backend services, workers, and latency-sensitive bot infrastructure |
- PumpFun Builders: Instruction builders and params for legacy/V2 PumpFun SOL and USDC quote-pool flows
- PumpSwap Builders: Instruction builders and params for PumpSwap pool operations
- Bonk Builders: Instruction builders and params for Bonk routing
- Raydium CPMM Builders: Instruction builders and params for Raydium CPMM fixed-input and fixed-output swaps
- Raydium AMM V4 Builders: Instruction builders and params for Raydium AMM V4 swaps
- Meteora DAMM V2 Builders: Instruction builders and params for Meteora DAMM V2 operations
- Multiple MEV Protection: Support for the Rust v5.0.2 SWQoS set, including Jito, ZeroSlot, Temporal, Bloxroute, FlashBlock, BlockRazor, Astralane, Stellium, Lightspeed, Soyas, Speedlanding, Helius, Solami, LunarLander, Glaive, and Default RPC
- 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
- Unified Trading Interface: Use unified trading protocol types for trading operations, including Rust-parity
BuySimple/SellSimpleintent params - Middleware System: Support for custom instruction middleware in lower-level instruction/executor paths
- Reusable Execution Components: Build and submit prebuilt transactions through
pkg/trading,pkg/trading/core, orpkg/hotpath - Hot-Path RPC Boundary: Trade execution uses caller-supplied blockhash or durable nonce and never queries RPC for blockhash, account, or balance data
For the high-level intent API, see Simple Trading. It shows AccountPolicyAuto, BuyWithMaxInput, and the conversion to legacy TradeBuyParams.
You can refer to Example: Create TradingClient Instance.
Method 1: Simple (single wallet)
package main
import (
"context"
"fmt"
"log"
soltradesdk "github.com/0xfnzero/sol-trade-sdk-golang/v9/pkg"
"github.com/gagliardetto/solana-go"
)
func main() {
ctx := context.Background()
// Wallet
wallet := solana.NewWallet()
payer := wallet.PrivateKey
// RPC URL
rpcURL := "https://mainnet.helius-rpc.com/?api-key=xxxxxx"
// Multiple SWQoS services can be configured
swqosConfigs := []soltradesdk.SwqosConfig{
{Type: soltradesdk.SwqosTypeJito, APIKey: "your_uuid", Region: soltradesdk.SwqosRegionFrankfurt},
{Type: soltradesdk.SwqosTypeBloxroute, APIKey: "your_api_token", Region: soltradesdk.SwqosRegionFrankfurt},
{Type: soltradesdk.SwqosTypeAstralane, APIKey: "your_api_key", Region: soltradesdk.SwqosRegionFrankfurt},
}
config := soltradesdk.NewTradeConfig(rpcURL, swqosConfigs)
client, err := soltradesdk.NewTradingClient(ctx, &payer, config)
if err != nil {
log.Fatal(err)
}
fmt.Println("wallet:", client.GetPayer())
}Temporal uses HTTP/3 QUIC first and Binary Batch HTTP as its default fallback. BlockRazor uses gRPC SendBinaryTransaction first and JSON HTTP as fallback. Astralane uses persistent QUIC first and Binary HTTP as fallback. Explicit transport settings force one protocol; a custom URL without a transport remains an explicit HTTP route.
Method 2: Prebuilt transaction executor
The root TradingClient converts high-level simple params but intentionally does not build or submit protocol trades in Go. Submit already-built transactions with pkg/trading.TradeExecutor, pkg/trading/core, or pkg/hotpath.
rpcClient := rpc.New(rpcURL)
executor := trading.NewTradeExecutor(rpcClient, config, soltradesdk.NewGasFeeStrategy())
executor.AddSwqosClient(swqos.NewDefaultClient(rpcURL))
result := executor.Execute(ctx, soltradesdk.TradeTypeBuy, signedTx, trading.DefaultExecuteOptions())
if !result.Success {
log.Fatal(result.Error)
}// Create GasFeeStrategy instance
gasStrategy := common.NewGasFeeStrategy()
// Set global strategy
gasStrategy.SetGlobalFeeStrategy(150000, 150000, 500000, 500000, 0.001, 0.001)simple := soltradesdk.NewSimpleBuyParams(
soltradesdk.DexTypePumpSwap,
soltradesdk.TradeTokenTypeWSOL,
mintPubkey,
soltradesdk.BuyWithMaxInput(buySolAmount),
pumpSwapParams,
recentBlockhash,
gasStrategy,
).
SetSlippageBasisPoints(500).
SetAccountPolicy(soltradesdk.AccountPolicyAuto)
buyParams := client.BuildBuyParamsFromSimple(simple)result, err := client.Buy(ctx, buyParams)
if errors.Is(err, soltradesdk.ErrTradingExecutionUnavailable) {
log.Fatal("root TradingClient converted params only; use a lower-level executor for live submission")
}
if err != nil {
log.Fatal(err)
}
fmt.Printf("Transaction signature: %s\n", result.Signature)For comprehensive information about all trading parameters including TradeBuyParams and TradeSellParams, see the Trading Parameters documentation.
When using shred to subscribe to events, due to the nature of shreds, you cannot get complete information about transaction events. Please ensure that the parameters your trading logic depends on are available in shreds when using them.
See the example index for workflows, commands and configuration requirements.
When configuring SWQoS services, use APIKey for provider credentials:
- Jito:
APIKeyis the Jito UUID (or""if not required) - Other MEV services:
APIKeyis the provider API token
Each SWQoS service supports an optional custom URL parameter:
// Using custom URL
jitoConfig := soltradesdk.SwqosConfig{
Type: soltradesdk.SwqosTypeJito,
APIKey: "your_uuid",
Region: soltradesdk.SwqosRegionFrankfurt,
CustomURL: "https://custom-jito-endpoint.com",
}
// Using default regional endpoint
bloxrouteConfig := soltradesdk.SwqosConfig{
Type: soltradesdk.SwqosTypeBloxroute,
APIKey: "your_api_token",
Region: soltradesdk.SwqosRegionNewYork,
}URL Priority Logic:
- If a custom URL is provided, it will be used instead of the regional endpoint
- If no custom URL is provided, the system will use the default endpoint for the specified region
- This allows for maximum flexibility while maintaining backward compatibility
When using multiple MEV services, you need to use Durable Nonce. You need to use the FetchNonceInfo function to get the latest nonce value, and use it as the DurableNonce when trading.
The SDK provides a powerful middleware system that allows you to modify, add, or remove instructions before transaction execution. Middleware executes in the order they are added:
import "github.com/0xfnzero/sol-trade-sdk-golang/v9/pkg/middleware"
manager := middleware.NewManager()
manager.Add(FirstMiddleware{}) // Executes first
manager.Add(SecondMiddleware{}) // Executes second
manager.Add(ThirdMiddleware{}) // Executes lastAddress Lookup Tables (ALT) allow you to optimize transaction size and reduce fees by storing frequently used addresses in a compact table format.
import "github.com/0xfnzero/sol-trade-sdk-golang/v9/pkg/addresslookup"
// Fetch ALT from chain
alt, err := addresslookup.FetchAddressLookupTableAccount(ctx, rpcClient, altAddress)
if err != nil {
log.Fatal(err)
}
fmt.Printf("ALT contains %d addresses\n", len(alt.Addresses))Use Durable Nonce to implement transaction replay protection and optimize transaction processing.
import "github.com/0xfnzero/sol-trade-sdk-golang/v9/pkg/nonce"
// Fetch nonce info
nonceInfo, err := nonce.FetchNonceInfo(ctx, rpcClient, nonceAccount)
if err != nil {
log.Fatal(err)
}Direct PumpSwap builders match explicit input/output mints, including custom Token-2022 quote tokens. Cache preparation supports independent buy/sell routes, bounded best-protected path selection, quote freshness checks and offline V0/V1 signing with explicit nonce/tip/ALT policies. Every hop spends protected credit; preparation and signing require no RPC.
Run go run ./examples/pumpswap_cached_prepare and
go test ./examples/pumpswap_cached_prepare -count=2 for historical TTWO replay.
See the API, limits and native tests.
Run go run ./examples/hotpath_latency from the repository root to measure
cached three-hop buy/sell search and preparation, V0+ALT build/sign and V1
build/sign. Edit examples/hotpath_latency/config.json for warmup, samples and
batch size; an alternate config path is optional. The native benchmark uses a
public deterministic test key and frozen accounts, reports p50/p95/p99
nanoseconds and allocations, and makes no RPC calls or submissions. Keep real
wallets out of this example. Local CPU results do not measure network landing.
PumpFun and PumpSwap support cashback for eligible tokens: part of the trading fee can be returned to the user. The SDK must know whether the token has cashback enabled so that buy/sell instructions include the correct accounts.
- When params come from RPC: If you use
PumpFunParams.FromMintByRPCorPumpSwapParams.FromPoolAddressByRPC, the SDK readsIsCashbackCoinfrom chain—no extra step. - When params come from decoded events: If you build params from already-decoded trade events (for example from a parser service), you must pass the cashback flag into the SDK:
- PumpFun: Set
IsCashbackCoinwhen building params from decoded events. - PumpSwap: Set
IsCashbackCoinfield when constructing params manually.
- PumpFun: Set
You can apply for a key through the official website: Community Website
- Jito: High-performance block space
- ZeroSlot: Zero-latency transactions
- Temporal: Time-sensitive transactions
- Bloxroute: Blockchain network acceleration
- FlashBlock: High-speed transaction execution with API key authentication
- BlockRazor: High-speed transaction execution with API key authentication
- Astralane: Blockchain network acceleration
pkg/
├── addresslookup/ # Address Lookup Table support
├── cache/ # LRU, TTL, and sharded caches
├── calc/ # AMM calculations with overflow detection
├── common/ # Core types, gas strategies, errors
├── execution/ # Branch optimization, prefetching
├── hotpath/ # Zero-RPC hot path execution
├── instruction/ # Instruction builders for all DEXes
├── middleware/ # Instruction middleware system
├── perf/ # Performance optimizations
├── pool/ # Connection and worker pools
├── rpc/ # High-performance RPC clients
├── seed/ # PDA derivation for all protocols
├── security/ # Secure key storage, validators
├── swqos/ # MEV provider clients
└── trading/ # High-performance trade executor
- Test thoroughly before using on mainnet
- Properly configure private keys and API tokens
- Pay attention to slippage settings to avoid transaction failures
- Monitor balances and transaction fees
- Comply with relevant laws and regulations
Full cross-language API parity is still in progress. See the API migration guide for public behavior and support boundaries, and the examples directory for usage.
Live parser-to-trade integration uses Yellowstone gRPC. See gRPC cache integration and language examples. Quoting and construction read cached state without hot-path RPC.
See cached_damm_v2 for single-hop DAMM v2 cached preparation and explicit simulation. Callers supply a minimum output; expected net receipts remain unknown. Native SOL and existing WSOL settle through different accounts. Reading PumpFun configuration alone does not provide complete fee quotes or a cached factory.
Native Go PumpSwap bank replay executes
12 direct/three-hop buy/sell scenarios using real signatures and frozen public
SBF programs, including ALT rejection and final-swap rollback. Run
go test ./examples/pumpswap_offline_bank -count=1 -v from this repository.
Local preparation/signing benchmarks:
go test ./examples/pumpswap_cached_prepare -run '^$' -bench BenchmarkPumpSwapCached -benchmem.
Replay and construction make no RPC calls. Mixed historical captures and synthetic
local funding are documented; these checks do not measure production latency.
MIT License
- Official Website: https://fnzero.dev/
- Project Repository: https://github.com/0xfnzero/sol-trade-sdk-golang
- Telegram Group: https://t.me/fnzero_group
- Discord: https://discord.gg/vuazbGkqQE
Shared stock bridges: 33 official stock/ETF mints and 58 pools. See eleven-SDK catalog and routing alignment for configuration, USDC routing and cache-only boundaries.