pump-swap-sdk
Rust SDK for Pump.fun's PumpSwap (pump-amm) AMM on Solana.
A small, focused library for building Solana applications on top of PumpSwap — trading, providing liquidity, claiming creator fees, anything the protocol supports.
- Focused — one library, one protocol; every public API maps to a pump-amm concept.
- Current — tracks the live program's account layout, not a snapshot of last year's IDL.
- Ergonomic — pass a pool pubkey, get back a working transaction.
- Composable — high-level convenience methods or raw instruction
builders; bring your own
RpcClient.
Features
- Fetching and decoding pump-amm pool accounts into
PoolInfo. - Automatic SPL Token vs SPL Token-2022 detection for each pool mint.
- Buy /
buy_exact_quote_in/ sell / deposit / withdraw / claim-cashback instruction builders for the current pump-amm account layouts. - Pool creation and creator-fee distribution instruction helpers.
- Reserve-aware buy/sell quote helpers.
- High-level
PumpSwapClientfor loading pools, simulating swaps, building transaction instruction sets, and submitting convenience buys/sells. - Jito bundle submission helpers with a round-robin endpoint pool.
Install
Install from crates.io:
[]
= "0.2.0"
Requires Rust 1.85+.
Or install directly from Git:
[]
= { = "https://github.com/v0idum/pump-swap-sdk", = "master" }
For the quickstart or examples below, a binary crate will also need the Solana client types and an async runtime:
[]
= "0.2.0"
= "1"
= { = "1", = ["macros", "rt-multi-thread"] }
= "2"
= "2"
Quickstart
This first example is read-only. It loads a pool, detects the token programs, and prints current reserves.
use FromStr;
use Arc;
use PumpSwapClient;
use RpcClient;
use CommitmentConfig;
use Pubkey;
async
Run it with:
RPC_URL=https://api.mainnet-beta.solana.com \
POOL=<pool_pubkey> \
cargo
Usage
The high-level client gives you two levels of control:
buy,sell,simulate_buy, andsimulate_sellare convenience helpers.build_buy_ixsandbuild_sell_ixsreturn instructions so you can set your own slippage, compute budget, priority fee, signing, retry, and confirmation policy.
Build buy instructions
For common WSOL-quoted pools, build_buy_ixs creates the ephemeral WSOL
account, optionally creates the user's token ATA, builds the pump-amm Buy
instruction, and closes the WSOL account back to the payer.
use buy_amount_out;
use sol_to_lamports;
use Signer;
let = client.fetch_pool_reserves.await?;
let amount_in = sol_to_lamports;
let base_amount_out = buy_amount_out;
let instructions = client.build_buy_ixs?;
Spend-exact-quote buys (buy_exact_quote_in)
For "spend exactly N SOL, accept ≥ min base out" semantics — what most
trader bots want — use the buy_exact_quote_in family:
use sol_to_lamports;
let spend = sol_to_lamports;
let instructions = client.build_buy_exact_quote_in_ixs?;
// Or the full convenience: client.buy_exact_quote_in(spend, min_out, &pool_info, &payer).await?;
Build sell instructions
Sell amounts are token base units. build_sell_ixs creates the ephemeral WSOL
account for quote output, builds the pump-amm Sell instruction, and closes the
WSOL account after the swap.
use sell_amount_out;
use Signer;
let = client.fetch_pool_reserves.await?;
let base_amount_in = 1_000_000;
let min_quote_amount_out = sell_amount_out;
let instructions = client.build_sell_ixs?;
Customize transaction options
Use the instruction builders when you need explicit compute budget, priority fee, signing, or send behavior.
use ComputeBudgetInstruction;
use Signer;
use Transaction;
let mut instructions = vec!;
instructions.extend;
let mut tx = new_with_payer;
tx.sign;
let sig = client.rpc.send_and_confirm_transaction.await?;
println!;
Simulate before sending
client.simulate_buy.await?;
client.simulate_sell.await?;
Send through Jito
use Arc;
use Duration;
use ;
let jito_pool = new;
send_jito_bundle.await?;
Examples
Every example is driven by environment variables. The examples print useful status to stdout and return errors for missing or malformed inputs.
Basic examples
| Example | Purpose | Command |
|---|---|---|
load_pool |
Fetch pool metadata and reserves. | RPC_URL=<url> POOL=<pool> cargo run --example load_pool |
verify_layout |
Simulate Buy/Sell account layouts without signing. | RPC_URL=<url> POOL=<pool> USER=<funded_pubkey> cargo run --example verify_layout |
simulate_buy |
Build and simulate a buy transaction. | RPC_URL=<url> POOL=<pool> KEYPAIR=<base58_secret> AMOUNT_SOL=0.001 cargo run --example simulate_buy |
Advanced examples
| Example | Purpose | Command |
|---|---|---|
batch_buy |
Send paced buys across multiple wallets, optionally via Jito. | RPC_URL=<url> POOL=<pool> KEYPAIRS=<secret1>,<secret2> AMOUNT_LAMPORTS=500000 cargo run --example batch_buy |
creator_fees_runner |
Claim creator fees and sweep surplus SOL. | See the module docstring for required creator-fee accounts. |
Start with load_pool or verify_layout. They are the safest way to validate
pool decoding and account layout compatibility before signing a transaction.
Important behavior
Token programs
load_pool and PumpSwapClient::load_pool read the owner of each mint account
and populate:
PoolInfo.base_token_programPoolInfo.quote_token_program
Instruction builders use those fields when deriving ATAs and adding token program accounts. Mixed SPL Token / Token-2022 pools are supported.
Buy and sell direction
The raw instruction names follow the pump-amm IDL:
- Buy means quote -> base.
- Sell means base -> quote.
For common WSOL-quoted pools, this maps to SOL -> token and token -> SOL. If
you work with a pool whose WSOL side is base_mint, be explicit about reserve
ordering and simulate before sending.
Protocol compatibility
The swap builders include the live program accounts required for current
pump-amm pools, including cashback, creator, fee, and buyback-related accounts.
Most callers should not add those accounts manually; pass PoolInfo, the user,
and the user's token accounts or use build_buy_ixs / build_sell_ixs.
API overview
Generate local API docs with:
PumpSwapClient: high-level RPC client wrapper. Exposesbuy,sell,buy_exact_quote_in,simulate_*,deposit_into_wsol_pool,withdraw_from_wsol_pool,claim_cashback,withdraw_creator_fees, andcreate_wsol_poolconvenience methods plus theirbuild_*_ixscounterparts.make_buy_instruction,make_buy_exact_quote_in_instruction,make_sell_instruction: raw swap instruction builders. The buy variants take atrack_volume: boolthat accrues cashback eligibility on the caller'suser_volume_accumulatorPDA.make_deposit_instruction,withdraw_instruction: LP-side builders.make_claim_cashback_instruction: pulls accrued cashback for a user from their volume-accumulator PDA.create_pool_instruction,transfer_creator_fees_to_pump_instruction,distribute_creator_fees_instruction: additional pump-amm and pump.fun instruction builders.load_pool,load_pool_with_token_program: pool account decoding helpers.calc_amount_out,buy_amount_out,sell_amount_out: quote math helpers.- PDA helpers such as
calc_pool_pda,calc_lp_mint_pda,find_coin_creator_vault_authority,find_coin_creator_vault_ata,find_user_vol_accumulator, andfee_config_pda. JitoPool,send_jito_bundle,send_bundle_with_retry: Jito bundle helpers.
Safety
This SDK can build and submit mainnet transactions. Treat every example that uses a keypair as capable of spending real funds.
- This project is not audited.
- This project is not an official Pump.fun product.
- Simulate transactions before sending them.
- Do not commit
.envfiles, keypair JSON, or base58 secret keys. - Review default slippage, compute budget, and priority fee values before using
the convenience
buy/sellmethods in production.
Development
This section is for maintainers and contributors. Run the check set before opening a pull request:
RUSTDOCFLAGS="-D warnings"
License
MIT