{"id":31037065,"url":"https://github.com/0xfnzero/sol-trade-sdk","last_synced_at":"2026-05-16T00:14:58.855Z","repository":{"id":297807510,"uuid":"991774915","full_name":"0xfnzero/sol-trade-sdk","owner":"0xfnzero","description":"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, Meteora DAMM v2, Raydium AMM v4, and Raydium CPMM for latency-critical trading strategies.","archived":false,"fork":false,"pushed_at":"2026-04-11T11:45:02.000Z","size":1834,"stargazers_count":294,"open_issues_count":1,"forks_count":147,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-04-11T13:11:55.260Z","etag":null,"topics":["0slot","0xfnzero","bonk","copy-trading","fnzero","jito-bundle","letsbonk","nextblock","nozomi","pumpfun","pumpfun-bot","pumpfun-sdk","pumpswap","raydium","raydium-launchlab","raydium-launchpad","raydium-swap","rust","solana","solana-bot"],"latest_commit_sha":null,"homepage":"https://fnzero.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xfnzero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-28T06:14:09.000Z","updated_at":"2026-04-11T11:45:05.000Z","dependencies_parsed_at":"2025-06-07T16:31:53.275Z","dependency_job_id":"8c1e7bbd-3172-4218-bc4f-7be9426f6de2","html_url":"https://github.com/0xfnzero/sol-trade-sdk","commit_stats":null,"previous_names":["0xfnzero/sol-trade-sdk"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/0xfnzero/sol-trade-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Fsol-trade-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Fsol-trade-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Fsol-trade-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Fsol-trade-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xfnzero","download_url":"https://codeload.github.com/0xfnzero/sol-trade-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Fsol-trade-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31687927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["0slot","0xfnzero","bonk","copy-trading","fnzero","jito-bundle","letsbonk","nextblock","nozomi","pumpfun","pumpfun-bot","pumpfun-sdk","pumpswap","raydium","raydium-launchlab","raydium-launchpad","raydium-swap","rust","solana","solana-bot"],"created_at":"2025-09-14T04:48:33.067Z","updated_at":"2026-05-16T00:14:58.841Z","avatar_url":"https://github.com/0xfnzero.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003e🚀 Sol Trade SDK\u003c/h1\u003e\n    \u003ch3\u003e\u003cem\u003eA comprehensive Rust SDK for seamless Solana DEX trading\u003c/em\u003e\u003c/h3\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eA 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, Meteora DAMM v2, Raydium AMM v4, and Raydium CPMM for latency-critical trading strategies.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://crates.io/crates/sol-trade-sdk\"\u003e\n        \u003cimg src=\"https://img.shields.io/crates/v/sol-trade-sdk.svg\" alt=\"Crates.io\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://docs.rs/sol-trade-sdk\"\u003e\n        \u003cimg src=\"https://docs.rs/sol-trade-sdk/badge.svg\" alt=\"Documentation\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/0xfnzero/sol-trade-sdk/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/0xfnzero/sol-trade-sdk\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/0xfnzero/sol-trade-sdk?style=social\" alt=\"GitHub stars\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/0xfnzero/sol-trade-sdk/network\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/forks/0xfnzero/sol-trade-sdk?style=social\" alt=\"GitHub forks\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Rust-000000?style=for-the-badge\u0026logo=rust\u0026logoColor=white\" alt=\"Rust\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Solana-9945FF?style=for-the-badge\u0026logo=solana\u0026logoColor=white\" alt=\"Solana\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/DEX-4B8BBE?style=for-the-badge\u0026logo=bitcoin\u0026logoColor=white\" alt=\"DEX Trading\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/0xfnzero/sol-trade-sdk/blob/main/README_CN.md\"\u003e中文\u003c/a\u003e |\n    \u003ca href=\"https://github.com/0xfnzero/sol-trade-sdk/blob/main/README.md\"\u003eEnglish\u003c/a\u003e |\n    \u003ca href=\"https://fnzero.dev/\"\u003eWebsite\u003c/a\u003e |\n    \u003ca href=\"https://t.me/fnzero_group\"\u003eTelegram\u003c/a\u003e |\n    \u003ca href=\"https://discord.gg/vuazbGkqQE\"\u003eDiscord\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e ☕ **Support This Project**\n\u003e\n\u003e 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 trading development, consider making a monthly SOL donation — any amount is appreciated and helps keep this project alive!\n\u003e\n\u003e **Donation Wallet:** `6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8`\n\n## 📋 Table of Contents\n\n- [✨ Features](#-features)\n- [📦 Installation](#-installation)\n- [🛠️ Usage Examples](#️-usage-examples)\n  - [📋 Example Usage](#-example-usage)\n  - [⚡ Trading Parameters](#-trading-parameters)\n  - [📊 Usage Examples Summary Table](#-usage-examples-summary-table)\n  - [⚙️ SWQoS Service Configuration](#️-swqos-service-configuration)\n  - [Astralane (Binary / Plain / QUIC)](#astralane-binary--plain--quic)\n  - [🔧 Middleware System](#-middleware-system)\n  - [🔍 Address Lookup Tables](#-address-lookup-tables)\n  - [🔍 Nonce Cache](#-nonce-cache)\n- [💰 Cashback Support (PumpFun / PumpSwap)](#-cashback-support-pumpfun--pumpswap)\n- [🔄 PumpFun V1 vs V2 Instructions](#-pumpfun-v1-vs-v2-instructions)\n- [🛡️ MEV Protection Services](#️-mev-protection-services)\n- [📁 Project Structure](#-project-structure)\n- [📄 License](#-license)\n- [💬 Contact](#-contact)\n- [⚠️ Important Notes](#️-important-notes)\n\n---\n\n## 📦 SDK Versions\n\nThis SDK is available in multiple languages:\n\n| Language | Repository | Description |\n|----------|------------|-------------|\n| **Rust** | [sol-trade-sdk](https://github.com/0xfnzero/sol-trade-sdk) | Ultra-low latency with zero-copy optimization |\n| **Node.js** | [sol-trade-sdk-nodejs](https://github.com/0xfnzero/sol-trade-sdk-nodejs) | TypeScript/JavaScript for Node.js |\n| **Python** | [sol-trade-sdk-python](https://github.com/0xfnzero/sol-trade-sdk-python) | Async/await native support |\n| **Go** | [sol-trade-sdk-golang](https://github.com/0xfnzero/sol-trade-sdk-golang) | Concurrent-safe with goroutine support |\n\n## ✨ Features\n\n1. **PumpFun Trading**: Support for `buy`, `sell`, `buy_exact_sol_in`, and the new unified `buy_v2`/`sell_v2`/`buy_exact_quote_in_v2` instructions (SOL + USDC)\n2. **PumpSwap Trading**: Support for PumpSwap pool trading operations\n3. **Bonk Trading**: Support for Bonk trading operations\n4. **Raydium CPMM Trading**: Support for Raydium CPMM (Concentrated Pool Market Maker) trading operations\n5. **Raydium AMM V4 Trading**: Support for Raydium AMM V4 (Automated Market Maker) trading operations\n6. **Meteora DAMM V2 Trading**: Support for Meteora DAMM V2 (Dynamic AMM) trading operations\n7. **Multiple MEV Protection**: Support for Jito, Nextblock, ZeroSlot, Temporal, Bloxroute, FlashBlock, BlockRazor, Node1, Astralane and other services\n8. **Concurrent Trading**: Send transactions using multiple MEV services simultaneously; the fastest succeeds while others fail\n9. **Unified Trading Interface**: Use unified trading protocol enums for trading operations\n10. **Middleware System**: Support for custom instruction middleware to modify, add, or remove instructions before transaction execution\n11. **Shared Infrastructure**: Share expensive RPC and SWQoS clients across multiple wallets for reduced resource usage\n\n## 📦 Installation\n\n### Direct Clone\n\nClone this project to your project directory:\n\n```bash\ncd your_project_root_directory\ngit clone https://github.com/0xfnzero/sol-trade-sdk\n```\n\nAdd the dependency to your `Cargo.toml`:\n\n```toml\n# Add to your Cargo.toml\nsol-trade-sdk = { path = \"./sol-trade-sdk\", version = \"4.0.9\" }\n```\n\n### Use crates.io\n\n```toml\n# Add to your Cargo.toml\nsol-trade-sdk = \"4.0.9\"\n```\n\n## 🛠️ Usage Examples\n\n### 📋 Example Usage\n\n#### 1. Create TradingClient Instance\n\nYou can refer to [Example: Create TradingClient Instance](examples/trading_client/src/main.rs).\n\n**Method 1: Simple (single wallet)**\n```rust\n// Wallet\nlet payer = Keypair::from_base58_string(\"use_your_payer_keypair_here\");\n// RPC URL\nlet rpc_url = \"https://mainnet.helius-rpc.com/?api-key=xxxxxx\".to_string();\nlet commitment = CommitmentConfig::processed();\n// Multiple SWQoS services can be configured\nlet swqos_configs: Vec\u003cSwqosConfig\u003e = vec![\n    SwqosConfig::Default(rpc_url.clone()),\n    SwqosConfig::Jito(\"your uuid\".to_string(), SwqosRegion::Frankfurt, None),\n    SwqosConfig::Temporal(\"your api_token\".to_string(), SwqosRegion::Frankfurt, None),\n    SwqosConfig::FlashBlock(\"your api_token\".to_string(), SwqosRegion::Frankfurt, None),\n    SwqosConfig::BlockRazor(\"your api_token\".to_string(), SwqosRegion::Frankfurt, None),\n    // Astralane: 4th param = AstralaneTransport — Binary (default), Plain (/iris), or Quic\n    SwqosConfig::Astralane(\"your_astralane_api_key\".to_string(), SwqosRegion::Frankfurt, None, None), // Binary HTTP /irisb\n    SwqosConfig::SpeedLanding(\"your api_token\".to_string(), SwqosRegion::Frankfurt, None),\n];\n// Create TradeConfig instance\nlet trade_config = TradeConfig::builder(rpc_url, swqos_configs, commitment)\n    // .create_wsol_ata_on_startup(true)  // default: true  - check \u0026 create WSOL ATA on init\n    // .use_seed_optimize(true)            // default: true  - seed optimization for ATA ops\n    // .log_enabled(true)                  // default: true  - SDK timing / SWQOS logs\n    // .check_min_tip(false)               // default: false - filter SWQOS below min tip\n    // .swqos_cores_from_end(false)        // default: false - bind SWQOS to last N CPU cores\n    // .mev_protection(false)              // default: false - MEV (Astralane QUIC :9000 or HTTP mev-protect / BlockRazor)\n    // .use_pumpfun_v2(false)             // default: false - V1 (18 accounts); set true for V2 (27 accounts, quote_mint) when PumpFun deploys V2\n    .build();\n\n// Create TradingClient\nlet client = TradingClient::new(Arc::new(payer), trade_config).await;\n```\n\n**Method 2: Shared infrastructure (multiple wallets)**\n\nFor multi-wallet scenarios, create the infrastructure once and share it across wallets.\nSee [Example: Shared Infrastructure](examples/shared_infrastructure/src/main.rs).\n\n```rust\n// Create infrastructure once (expensive)\nlet infra_config = InfrastructureConfig::new(rpc_url, swqos_configs, commitment);\nlet infrastructure = Arc::new(TradingInfrastructure::new(infra_config).await);\n\n// Create multiple clients sharing the same infrastructure (fast)\nlet client1 = TradingClient::from_infrastructure(Arc::new(payer1), infrastructure.clone(), true);\nlet client2 = TradingClient::from_infrastructure(Arc::new(payer2), infrastructure.clone(), true);\n```\n\n#### 2. Configure Gas Fee Strategy\n\nFor detailed information about Gas Fee Strategy, see the [Gas Fee Strategy Reference](docs/GAS_FEE_STRATEGY.md).\n\n```rust\n// Create GasFeeStrategy instance\nlet gas_fee_strategy = GasFeeStrategy::new();\n// Set global strategy\ngas_fee_strategy.set_global_fee_strategy(150000, 150000, 500000, 500000, 0.001, 0.001);\n```\n\n#### 3. Build Trading Parameters\n\nFor detailed information about all trading parameters, see the [Trading Parameters Reference](docs/TRADING_PARAMETERS.md).\n\n```rust\n// Import DexParamEnum for protocol-specific parameters\nuse sol_trade_sdk::trading::core::params::DexParamEnum;\n\nlet buy_params = sol_trade_sdk::TradeBuyParams {\n  dex_type: DexType::PumpSwap,\n  input_token_type: TradeTokenType::WSOL,\n  mint: mint_pubkey,\n  input_token_amount: buy_sol_amount,\n  slippage_basis_points: slippage_basis_points,\n  recent_blockhash: Some(recent_blockhash),\n  // Use DexParamEnum for type-safe protocol parameters (zero-overhead abstraction)\n  extension_params: DexParamEnum::PumpSwap(params.clone()),\n  address_lookup_table_account: None,\n  wait_transaction_confirmed: true,\n  create_input_token_ata: true,\n  close_input_token_ata: true,\n  create_mint_ata: true,\n  durable_nonce: None,\n  fixed_output_token_amount: None,  // Optional: specify exact output amount\n  gas_fee_strategy: gas_fee_strategy.clone(),  // Gas fee strategy configuration\n  simulate: false,  // Set to true for simulation only\n  use_exact_sol_amount: None,  // Use exact SOL input for PumpFun/PumpSwap (defaults to true)\n};\n```\n\n#### 4. Execute Trading\n\n```rust\nclient.buy(buy_params).await?;\n```\n\n### ⚡ Trading Parameters\n\nFor comprehensive information about all trading parameters including `TradeBuyParams` and `TradeSellParams`, see the dedicated [Trading Parameters Reference](docs/TRADING_PARAMETERS.md).\n\n#### About ShredStream\n\nWhen using shred to subscribe to events, due to the nature of shreds, you cannot get complete information about transaction events.\nPlease ensure that the parameters your trading logic depends on are available in shreds when using them.\n\n### 📊 Usage Examples Summary Table\n\n| Description | Run Command | Source Code |\n|-------------|-------------|-------------|\n| Create and configure TradingClient instance | `cargo run --package trading_client` | [examples/trading_client](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/trading_client/src/main.rs) |\n| Share infrastructure across multiple wallets | `cargo run --package shared_infrastructure` | [examples/shared_infrastructure](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/shared_infrastructure/src/main.rs) |\n| PumpFun token sniping trading | `cargo run --package pumpfun_sniper_trading` | [examples/pumpfun_sniper_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpfun_sniper_trading/src/main.rs) |\n| PumpFun token copy trading | `cargo run --package pumpfun_copy_trading` | [examples/pumpfun_copy_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpfun_copy_trading/src/main.rs) |\n| PumpSwap trading operations | `cargo run --package pumpswap_trading` | [examples/pumpswap_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/pumpswap_trading/src/main.rs) |\n| Raydium CPMM trading operations | `cargo run --package raydium_cpmm_trading` | [examples/raydium_cpmm_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/raydium_cpmm_trading/src/main.rs) |\n| Raydium AMM V4 trading operations | `cargo run --package raydium_amm_v4_trading` | [examples/raydium_amm_v4_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/raydium_amm_v4_trading/src/main.rs) |\n| Meteora DAMM V2 trading operations | `cargo run --package meteora_damm_v2_direct_trading` | [examples/meteora_damm_v2_direct_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/meteora_damm_v2_direct_trading/src/main.rs) |\n| Bonk token sniping trading | `cargo run --package bonk_sniper_trading` | [examples/bonk_sniper_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/bonk_sniper_trading/src/main.rs) |\n| Bonk token copy trading | `cargo run --package bonk_copy_trading` | [examples/bonk_copy_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/bonk_copy_trading/src/main.rs) |\n| Custom instruction middleware example | `cargo run --package middleware_system` | [examples/middleware_system](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/middleware_system/src/main.rs) |\n| Address lookup table example | `cargo run --package address_lookup` | [examples/address_lookup](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/address_lookup/src/main.rs) |\n| Nonce example | `cargo run --package nonce_cache` | [examples/nonce_cache](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/nonce_cache/src/main.rs) |\n| Wrap/unwrap SOL to/from WSOL example | `cargo run --package wsol_wrapper` | [examples/wsol_wrapper](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/wsol_wrapper/src/main.rs) |\n| Seed trading example | `cargo run --package seed_trading` | [examples/seed_trading](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/seed_trading/src/main.rs) |\n| Gas fee strategy example | `cargo run --package gas_fee_strategy` | [examples/gas_fee_strategy](https://github.com/0xfnzero/sol-trade-sdk/tree/main/examples/gas_fee_strategy/src/main.rs) |\n\n### ⚙️ SWQoS Service Configuration\n\nWhen configuring SWQoS services, note the different parameter requirements for each service:\n\n- **Jito**: The first parameter is UUID (if no UUID, pass an empty string `\"\"`)\n- **Other MEV services**: The first parameter is the API Token\n\n#### Custom URL Support\n\nEach SWQoS service now supports an optional custom URL parameter:\n\n```rust\n// Using custom URL (third parameter)\nlet jito_config = SwqosConfig::Jito(\n    \"your_uuid\".to_string(),\n    SwqosRegion::Frankfurt, // This parameter is still required but will be ignored\n    Some(\"https://custom-jito-endpoint.com\".to_string()) // Custom URL\n);\n\n// Using default regional endpoint (third parameter is None)\nlet temporal_config = SwqosConfig::Temporal(\n    \"your_api_token\".to_string(),\n    SwqosRegion::NewYork, // Will use the default endpoint for this region\n    None // No custom URL, uses SwqosRegion\n);\n```\n\n**URL Priority Logic**:\n- If a custom URL is provided (`Some(url)`), it will be used instead of the regional endpoint\n- If no custom URL is provided (`None`), the system will use the default endpoint for the specified `SwqosRegion`\n- This allows for maximum flexibility while maintaining backward compatibility \n\nWhen using multiple MEV services, you need to use `Durable Nonce`. You need to use the `fetch_nonce_info` function to get the latest `nonce` value, and use it as the `durable_nonce` when trading.\n\n#### Astralane (Binary / Plain HTTP / QUIC)\n\nAstralane supports **Binary** HTTP (`/irisb`), **Plain** HTTP (`/iris`), and **QUIC** (`host:7000`, or `:9000` when global `mev_protection` is true). Pass `Some(AstralaneTransport::Plain)`, `Some(AstralaneTransport::Quic)`, or use `None` / omit for **Binary** (default). Global `mev_protection` adds `mev-protect=true` on HTTP or selects QUIC port 9000.\n\n```rust\nuse sol_trade_sdk::{SwqosConfig, SwqosRegion, AstralaneTransport};\n\nlet swqos_configs: Vec\u003cSwqosConfig\u003e = vec![\n    SwqosConfig::Default(rpc_url.clone()),\n    SwqosConfig::Astralane(\n        \"your_astralane_api_key\".to_string(),\n        SwqosRegion::Frankfurt,\n        None,\n        Some(AstralaneTransport::Quic),\n    ),\n];\n// Then create TradeConfig / TradingClient as usual with swqos_configs\n```\n\n- **Binary** (default): `None` or `Some(AstralaneTransport::Binary)` — `/irisb`, bincode body.\n- **Plain**: `Some(AstralaneTransport::Plain)` — `/iris`.\n- **QUIC**: `Some(AstralaneTransport::Quic)` — regional `host:7000` / `:9000` (MEV); same API key.\n\n---\n\n### 🔧 Middleware System\n\nThe 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:\n\n```rust\nlet middleware_manager = MiddlewareManager::new()\n    .add_middleware(Box::new(FirstMiddleware))   // Executes first\n    .add_middleware(Box::new(SecondMiddleware))  // Executes second\n    .add_middleware(Box::new(ThirdMiddleware));  // Executes last\n```\n\n### 🔍 Address Lookup Tables\n\nAddress Lookup Tables (ALT) allow you to optimize transaction size and reduce fees by storing frequently used addresses in a compact table format. For detailed information, see the [Address Lookup Tables Guide](docs/ADDRESS_LOOKUP_TABLE.md).\n\n### 🔍 Durable Nonce\n\nUse Durable Nonce to implement transaction replay protection and optimize transaction processing. For detailed information, see the [Durable Nonce Guide](docs/NONCE_CACHE.md).\n\n## 💰 Cashback Support (PumpFun / PumpSwap)\n\nPumpFun 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 (e.g. `UserVolumeAccumulator` as remaining account for cashback coins).\n\n- **When params come from RPC**: If you use `PumpFunParams::from_mint_by_rpc` or `PumpSwapParams::from_pool_address_by_rpc` / `from_mint_by_rpc`, the SDK reads `is_cashback_coin` from chain—no extra step.\n- **When params come from event/parser**: If you build params from trade events (e.g. [sol-parser-sdk](https://github.com/0xfnzero/sol-parser-sdk)), you **must** pass the cashback flag into the SDK:\n  - **PumpFun**: `PumpFunParams::from_trade(..., is_cashback_coin)` and `PumpFunParams::from_dev_trade(..., is_cashback_coin)` take an `is_cashback_coin` parameter. Set it from the parsed event (e.g. CreateEvent’s `is_cashback_enabled` or BondingCurve’s `is_cashback_coin`).\n  - **PumpSwap**: `PumpSwapParams` has a field `is_cashback_coin`. When constructing params manually (e.g. from pool/trade events), set it from the parsed pool or event data.\n- The **pumpfun_copy_trading** and **pumpfun_sniper_trading** examples use sol-parser-sdk for gRPC subscription and pass `e.is_cashback_coin` when building params.\n- **Claim**: Use `client.claim_cashback_pumpfun()` and `client.claim_cashback_pumpswap(...)` to claim accumulated cashback.\n\n#### PumpFun: troubleshooting (on-chain errors)\n\nFor **Anchor 2006 / `NotAuthorized` (6000) / wrong token program / BuyZeroAmount (6020) / slippage (6042)** and related issues, see **[docs/PUMP_ERRORS_AND_TROUBLESHOOTING_CN.md](docs/PUMP_ERRORS_AND_TROUBLESHOOTING_CN.md)** (Chinese). An English appendix may be added later.\n\n#### PumpFun: Creator Rewards Sharing (creator_vault)\n\nSome PumpFun coins use **Creator Rewards Sharing**, so the on-chain `creator_vault` can differ from the default derivation. If you reuse cached params from a **buy** when **selling**, you may see program error **2006 (seeds constraint violated)**. To avoid this:\n\n- **From gRPC/events (no RPC needed)**: You can get both `creator` and `creator_vault` from parsed transaction events:\n  - **sol-parser-sdk**: Before pushing events, the pipeline calls `fill_trade_accounts`, which fills `creator_vault` from the buy/sell instruction accounts (buy index 9, sell index 8). `creator` comes from the TradeEvent log. Use `PumpFunParams::from_trade(..., e.creator, e.creator_vault, ...)` or `from_dev_trade(..., e.creator, e.creator_vault, ...)` with the event `e`.\n  - **solana-streamer**: Instruction parsers set `creator_vault` from accounts[9] (buy) or accounts[8] (sell); `creator` comes from the merged CPI TradeEvent log. Use the same `from_trade` / `from_dev_trade` with `e.creator` and `e.creator_vault`.\n- **Override after RPC**: If you get params via `PumpFunParams::from_mint_by_rpc` but later receive a newer `creator_vault` from gRPC, call `.with_creator_vault(latest_creator_vault)` on the params before selling.\n\nThe SDK does not fetch creator_vault from RPC on every sell (to avoid latency); pass the up-to-date vault from gRPC/events when available.\n\n#### PumpFun V1 vs V2 Instructions\n\nPumpFun has two instruction sets for bonding-curve trading:\n\n| | V1 (default) | V2 (opt-in) |\n|---|---|---|\n| Instructions | `buy` / `buy_exact_sol_in` / `sell` | `buy_v2` / `buy_exact_quote_in_v2` / `sell_v2` |\n| Account metas | 18 | 27 |\n| Quote mint | SOL only (legacy) | SOL or USDC (via `quote_mint` field) |\n| Transaction size | Smaller (fits `PACKET_DATA_SIZE` without LUT) | Larger (requires LUT for most transactions) |\n\n**Default: V1** (`use_pumpfun_v2 = false`). The SDK uses V1 instructions which produce smaller transactions that fit within the 1232-byte `PACKET_DATA_SIZE` limit without requiring an Address Lookup Table.\n\n**Key changes in v2 instructions:**\n- `quote_mint` parameter — pass wrapped SOL for SOL-paired, or USDC mint for USDC-paired\n- 27 fixed accounts (buy) / 26 fixed accounts (sell) — **no optional accounts**\n- `buyback_fee_recipient`, `sharing_config`, and 6 `associated_quote_*` ATAs are now mandatory\n- Same pricing and cost as legacy instructions for SOL-paired coins\n\n**How to enable V2:**\n\n**Method 1 — Global runtime flag** (recommended when PumpFun officially deploys V2 on mainnet):\n\n```rust\nlet trade_config = TradeConfig::builder(rpc_url, swqos_configs, commitment)\n    .use_pumpfun_v2(true)  // Switch all PumpFun trades to V2 instructions (27 accounts)\n    .build();\n```\n\n**Method 2 — Per-trade via `quote_mint`** (for USDC-paired coins or mixed V1/V2 scenarios):\n\n```rust\nuse sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT;\nuse sol_trade_sdk::constants::USDC_TOKEN_ACCOUNT;\n\n// SOL-paired coin with v2 layout\nlet params = PumpFunParams::from_trade(/* ... */)\n    .with_quote_mint(WSOL_TOKEN_ACCOUNT);\n\n// USDC-paired coin (requires v2)\nlet params = PumpFunParams::from_trade(/* ... */)\n    .with_quote_mint(USDC_TOKEN_ACCOUNT);\n```\n\n\u003e **Note**: V2 transactions with ATA creation + durable nonce may exceed `PACKET_DATA_SIZE`. Enable an Address Lookup Table (`address_lookup_table_account`) when using V2.\n\n#### PumpSwap: coin_creator_vault from events (no RPC)\n\nFor **PumpSwap** (Pump AMM), `coin_creator_vault_ata` and `coin_creator_vault_authority` are required in buy/sell instructions. Both are available from parsed events without RPC:\n\n- **sol-parser-sdk**: Instruction parser sets them from accounts 17 and 18; the account filler also fills them when the event comes from logs. Use `PumpSwapParams::from_trade(..., e.coin_creator_vault_ata, e.coin_creator_vault_authority, ...)` with the buy/sell event `e`.\n- **solana-streamer**: Instruction parser sets them from `accounts.get(17)` and `accounts.get(18)`. Use the same `from_trade` with the event's `coin_creator_vault_ata` and `coin_creator_vault_authority`.\n\n## 🛡️ MEV Protection Services\n\nYou can apply for a key through the official website: [Community Website](https://fnzero.dev/swqos)\n\n- **Jito**: High-performance block space\n- **Temporal**: Time-sensitive transactions\n- **FlashBlock**: High-speed transaction execution with API key authentication\n- **BlockRazor**: High-speed transaction execution with API key authentication\n- **Astralane**: Blockchain network acceleration (Binary/Plain HTTP and QUIC)\n- **SpeedLanding**: High-speed transaction execution with API key authentication\n\n## 📁 Project Structure\n\n```\nsrc/\n├── common/           # Common functionality and tools\n├── constants/        # Constant definitions\n├── instruction/      # Instruction building\n│   └── utils/        # Instruction utilities\n├── swqos/            # MEV service clients\n├── trading/          # Unified trading engine\n│   ├── common/       # Common trading tools\n│   ├── core/         # Core trading engine\n│   ├── middleware/   # Middleware system\n│   └── factory.rs    # Trading factory\n├── utils/            # Utility functions\n│   ├── calc/         # Amount calculation utilities\n│   └── price/        # Price calculation utilities\n└── lib.rs            # Main library file\n```\n\n## 📄 License\n\nMIT License\n\n## 💬 Contact\n\n- Official Website: https://fnzero.dev/\n- Project Repository: https://github.com/0xfnzero/sol-trade-sdk\n- Telegram Group: https://t.me/fnzero_group\n- Discord: https://discord.gg/vuazbGkqQE\n\n## ⏱️ Timing metrics (v3.5.0+)\n\nWhen `log_enabled` and SDK log are on, the executor prints `[SDK] Buy/Sell timing(...)`. **Semantics changed in v3.5.0**: `submit` is now only the send to SWQOS/RPC; `confirm` is separate; `start_to_submit` (when `grpc_recv_us` is set) is **end-to-end from gRPC event to submit**, so it is larger than in-process timings. See [docs/TIMING_METRICS.md](docs/TIMING_METRICS.md) for definitions and how to compare with older versions.\n\n## ⚠️ Important Notes\n\n1. Test thoroughly before using on mainnet\n2. Properly configure private keys and API tokens\n3. Pay attention to slippage settings to avoid transaction failures\n4. Monitor balances and transaction fees\n5. Comply with relevant laws and regulations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xfnzero%2Fsol-trade-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xfnzero%2Fsol-trade-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xfnzero%2Fsol-trade-sdk/lists"}