pump-rust-client

Rust SDK for the pump and pump_amm Solana programs. Three things in one
crate:
- Instruction builders for buy / sell / create on both the bonding
curve (
pump) and the AMM (pump_amm), with auto-routing across the
two.
- Quoting for both venues, with slippage applied — drives UI prices
and the
*_threshold arguments that the trade builders need.
- Transaction building (
AsyncPumpClient,
behind the client feature): fetches on-chain state, prepends
compute-budget, signs, simulates, and sends.
Canonical sources:
Quickstart — buy
Adapted from examples/buy_v2.rs:
use solana_sdk::compute_budget::ComputeBudgetInstruction;
use solana_sdk::native_token::LAMPORTS_PER_SOL;
use solana_sdk::signature::{Keypair, Signer};
use pump_rust_client::{constants, AsyncPumpClient, PumpSdk};
let sdk = PumpSdk::new();
let client = AsyncPumpClient::new(rpc.clone()); // requires the `client` feature
let global = client.fetch_global().await?;
let bonding_curve = client.fetch_bonding_curve(&mint).await?;
// `buy_v2_instructions` returns idempotent ATA creates + the trade ix.
let mut ixs = vec![ComputeBudgetInstruction::set_compute_unit_limit(400_000)];
ixs.extend(
sdk.buy_v2_instructions(
&global,
&bonding_curve,
mint,
constants::SPL_TOKEN_PROGRAM_ID, // quote token program
user.pubkey(),
300_000_000, // base tokens to buy
LAMPORTS_PER_SOL, // max quote spent
)
.expect("buy_v2_instructions"),
);
The other examples follow the same shape:
examples/sell_v2.rs,
examples/create_v2_and_buy.rs,
examples/buy_amm.rs, and
examples/sell_amm.rs.
Quoting
Every trade builder takes a *_threshold (max quote spent on a buy, min
quote out on a sell). The quote helpers compute that threshold from a
slippage in basis points:
use pump_rust_client::PumpSdk;
let sdk = PumpSdk::new();
let global = client.fetch_global().await?;
let fee_config = client.fetch_fee_config().await?;
let bonding_curve = client.fetch_bonding_curve(&mint).await?;
let quote = sdk.buy_quote_bonding_curve_sol_in(
&global,
&fee_config,
&bonding_curve,
mint_supply, // base mint supply
LAMPORTS_PER_SOL, // sol_amount in
100, // 1% slippage
)?;
// quote.amount — tokens out at the current curve
// quote.min_out — slippage-protected floor; pass to sell builders
// quote.max_input — slippage-protected ceiling; pass to buy builders
For code that doesn't know yet whether the curve has graduated, use the
auto-routed quote_trade — it dispatches to bonding-curve or AMM math
based on bonding_curve.complete, mirroring trade_tx_instructions:
use pump_rust_client::{PumpSdk, TradeQuoteParams};
let quote = sdk.quote_trade(TradeQuoteParams {
is_buy: true,
base_amount: 300_000_000,
slippage_bps: 100,
base_mint_supply: mint_supply,
pump_global: &global,
pump_fee_config: &fee_config,
bonding_curve: &bonding_curve,
pump_pool: None, // Some(PumpPoolQuoteCtx { … }) required when curve.complete
}); // returns None if the curve is complete and pump_pool was not supplied