Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
Buy V2
The buy_v2 instruction buys base tokens from a bonding curve using the curve's quote mint. Unlike the legacy buy instruction, all accounts are passed through a single unified interface for both SOL-paired and non-SOL-paired coins.
New, smaller version:
buy_v3andbuy_exact_quote_in_v3do the same buy with 17 accounts instead of 27. Same price, same fees; the protocol and creator fee stay on the curve until they are swept. See Bonding Curve Trades V3. For pools after migration see PumpSwap Trades V2, and to buy a coin paired with another pump coin straight from SOL or USDC see Multi-hop swap.buy_v2keeps working unchanged.
Accounts
| # | Account | Seeds / derivation | init_if_needed / SOL cost |
|---|---|---|---|
| 1 | global |
Pump PDA: seeds [b"global"]. |
- |
| 2 | base_mint |
Base token mint for the coin being bought. | - |
| 3 | quote_mint |
Quote mint for the coin. For SOL-paired coins, pass wrapped SOL: So11111111111111111111111111111111111111112. |
- |
| 4 | base_token_program |
Token program for base_mint. For create_v2 coins this is Token-2022: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb. |
- |
| 5 | quote_token_program |
Token program for quote_mint. This is not necessarily the same as base_token_program. |
- |
| 6 | associated_token_program |
Associated Token Program: ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL. |
- |
| 7 | fee_recipient |
Fee recipient selected from the global config. | - |
| 8 | associated_quote_fee_recipient |
Associated token account for quote_mint, owned by fee_recipient, using quote_token_program. |
ATA rent if missing |
| 9 | buyback_fee_recipient |
Buyback fee recipient checked against the global config. | - |
| 10 | associated_quote_buyback_fee_recipient |
Associated token account for quote_mint, owned by buyback_fee_recipient, using quote_token_program. |
- |
| 11 | bonding_curve |
Pump PDA: seeds [b"bonding-curve", base_mint]. For SOL-paired coins, bonding_curve.quote_mint is Pubkey::default() and quote_mint should be wrapped SOL. |
Rent top-up to make the account data length 115 bytes if it is smaller |
| 12 | associated_base_bonding_curve |
Associated token account for base_mint, owned by bonding_curve, using base_token_program. |
- |
| 13 | associated_quote_bonding_curve |
Associated token account for quote_mint, owned by bonding_curve, using quote_token_program. |
- |
| 14 | user |
Transaction signer and buyer. | - |
| 15 | associated_base_user |
User's associated token account for base_mint, using base_token_program. |
- |
| 16 | associated_quote_user |
User's associated token account for quote_mint, using quote_token_program. For SOL-paired coins, this is seed constrained but native SOL is used for the transfer. |
- |
| 17 | creator_vault |
Pump PDA: seeds [b"creator-vault", bonding_curve.creator]. |
Rent-exempt top-up if needed |
| 18 | associated_creator_vault |
Associated token account for quote_mint, owned by creator_vault, using quote_token_program. |
ATA rent if missing |
| 19 | sharing_config |
Pump Fees PDA: seeds [b"sharing-config", base_mint]. |
- |
| 20 | global_volume_accumulator |
Pump PDA: seeds [b"global_volume_accumulator"]. |
- |
| 21 | user_volume_accumulator |
Pump PDA: seeds [b"user_volume_accumulator", user]. Initialized if needed, paid by user. |
Rent for 137-byte account if missing: 0.0018444 SOL |
| 22 | associated_user_volume_accumulator |
Associated token account for quote_mint, owned by user_volume_accumulator, using quote_token_program. |
ATA rent if missing |
| 23 | fee_config |
Pump Fees PDA: seeds [b"fee_config", pump_program_id]. |
- |
| 24 | fee_program |
Pump Fees Program. | - |
| 25 | system_program |
System Program: 11111111111111111111111111111111. |
- |
| 26 | event_authority |
Pump PDA: seeds [b"__event_authority"]. |
- |
| 27 | program |
Pump program account. | - |
Instruction Data
The buy_v2 instruction takes the following instruction data arguments.
| # | Argument | Type | Description / validation | Optional? |
|---|---|---|---|---|
| 1 | amount |
u64 |
Amount of base tokens to buy, in base token units. Must be greater than 0 and cannot exceed the bonding curve's real token reserves. |
No |
| 2 | max_sol_cost |
u64 |
Maximum quote amount the buyer is willing to pay, including fees to the protocol and creator | No |
Fee Recipients
All buy_v2 calls need a feeRecipient and a buybackFeeRecipient.
- For non-mayhem coins, choose one of the 8 normal fee recipients as
feeRecipient. - For mayhem mode coins, choose one of the 8 reserved fee recipients as
feeRecipient. - For all coins, choose one of the 8 buyback fee recipients as
buybackFeeRecipient.
See Fee Recipients for the full address lists.
TS SDK
Buy SOL-Paired Coin
For SOL-paired coins, use wrapped SOL as the quoteMint.
import { PUMP_SDK } from "@pump-fun/pump-sdk";
const amount = new BN(100_000 * 10 ** 6);
const quoteAmount = new BN(1_000_000_000);
const quoteMint = NATIVE_MINT;
const quoteTokenProgram = TOKEN_PROGRAM_ID;
const buyInstruction = await PUMP_SDK.getBuyV2InstructionRaw({
user,
mint,
creator,
amount,
quoteAmount,
tokenProgram: TOKEN_2022_PROGRAM_ID,
quoteMint,
quoteTokenProgram,
feeRecipient,
buybackFeeRecipient,
});
Buy Legacy SOL-Paired Coin
For legacy coins where the base mint uses the legacy SPL Token Program, pass TOKEN_PROGRAM_ID as both the base tokenProgram and quoteTokenProgram.
import { PUMP_SDK } from "@pump-fun/pump-sdk";
const amount = new BN(100_000 * 10 ** 6);
const quoteAmount = new BN(1_000_000_000);
const quoteMint = NATIVE_MINT;
const quoteTokenProgram = TOKEN_PROGRAM_ID;
const buyInstruction = await PUMP_SDK.getBuyV2InstructionRaw({
user,
mint,
creator,
amount,
quoteAmount,
tokenProgram: TOKEN_PROGRAM_ID,
quoteMint,
quoteTokenProgram,
feeRecipient,
buybackFeeRecipient,
});
Buy USDC-Paired Coin
For USDC-paired coins, pass the USDC mint as quoteMint and the quote mint's token program as quoteTokenProgram.
import { PUMP_SDK } from "@pump-fun/pump-sdk";
const amount = new BN(100_000 * 10 ** 6);
const quoteAmount = new BN(1000 * 10 ** 6);
const quoteMint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const quoteTokenProgram = TOKEN_PROGRAM_ID;
const buyInstruction = await PUMP_SDK.getBuyV2InstructionRaw({
user,
mint,
creator,
amount,
quoteAmount,
tokenProgram: TOKEN_2022_PROGRAM_ID,
quoteMint,
quoteTokenProgram,
feeRecipient,
buybackFeeRecipient,
});
Rust SDK
The Rust client exposes buy_v2_instructions, which prepends the user's
base/quote ATA creates and emits the buy_v2 instruction. The fetched
BondingCurve carries the coin's quote_mint, so the same builder works
for SOL-paired and non-native quote coins; only quote_token_program
needs to match the quote mint's token program.
use pump_rust_client::{constants, PumpSdk};
let sdk = PumpSdk::new();
let global = client.fetch_global().await.expect("fetch_global");
let bonding_curve = client
.fetch_bonding_curve(&mint)
.await
.expect("fetch_bonding_curve");
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; For native sol pass SPL_TOKEN_PROGRAM_ID
user.pubkey(),
300_000_000, // amount (base token units, 6 decimals)
LAMPORTS_PER_SOL, // max_quote_tokens (slippage cap, quote base units)
)
.expect("buy_v2_instructions"),
);