The IDLs under idl/ are vendored verbatim from github.com/pump-fun/pump-public-docs
(idl/pump.json → pump_fun_idl.json, pump_amm.json → pump_swap_idl.json,
pump_fees.json). Refresh them from upstream rather than hand-editing. They are
not the reference for account counts: they under-report PumpSwap's buy and
sell, create_v2 (accounts 17-20) and migrate_v2, all listed below, and
buy_exact_sol_in, documented in cookbook/pumpfun/trade/pumpfun_instructions.py.
- pump.fun supports quote assets other than SOL, and no longer just SOL and USDC.
BondingCurve.quote_mintisPubkey::default()(all zeros) for SOL-paired coins; USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v) is one whitelisted entry inGlobal, but coins paired with Token-2022 quote mints are live on chain too. Legacybuy/sellcannot trade non-SOL-paired coins at all. - Two registries are live and neither contains the other. A
QuoteControlaccount (PDA["quote-control"]) carries its own mint list, which is how a coin pairs with a mintGlobalnever lists. ButGlobal.whitelisted_quote_mintsis not merely a subset: USDC is inGlobaland not inQuoteControl, so validating against either alone refuses a mint the program accepts. Their opening reserves come from different fields too — aQuoteControlentry carries its own, while aGlobal-only mint takesGlobal.initial_virtual_quote_reserves. Error6064accepts SPL Token or Token-2022. - Mayhem mode and a non-SOL quote asset are mutually exclusive. The
program rejects the pairing with
MayhemModeQuoteMintNotAllowed(6071), so a mayhem coin is always SOL-paired and can never carry a creator fee. - The opening reserve differs per quote mint by orders of magnitude, so no default approximates a missing one: an unlisted mint is refused, not priced.
- The quote mint's token program is resolved from chain, not assumed.
resolve_quote_token_program(src/core/pubkeys.py) reads a mint's owner once — pre-seeded with WSOL/USDC so those stay free — and caches it for the process;cached_quote_token_programis the hot-path read used by event parsing and address resolution. The bot warms the cache at startup for every configured quote mint, soextreme_fast_mode's zero-RPC contract still holds. - The decimals come from the same read. Amounts like
max_sol_costandmin_sol_outputare in the quote mint's raw units, so assuming 9 decimals for a 6-decimal mint overstates the cap by 1000x and effectively disables slippage protection.getAccountInforeturns the owner and the mint data together, so decimals cost no extra call; they are cached alongside the token program and pre-seeded for WSOL (9) and USDC (6). A quote mint whose decimals cannot be resolved fails at startup rather than silently mis-scaling a trade. Thedecimalsbyte sits at offset 44 in both SPL Token and Token-2022 mints — extensions are appended after the base struct and never move it. - The bot uses
buy_v2(27 accounts) andsell_v2(26 accounts). Every account is mandatory and the order is identical for every coin — whatever quote mint, mayhem or not, cashback or not.sell_v2isbuy_v2minusglobal_volume_accumulator. Layouts live in_BUY_V2_ACCOUNTS/_SELL_V2_ACCOUNTSinplatforms/pumpfun/instruction_builder.pyand are machine-checked against the IDL bytests/regression/verify_v2_account_layout.py. - v2 args carry no
track_volumeOptionBool (24-byte data: discriminator + two u64). Volume tracking is unconditional now thatuser_volume_accumulatoris mandatory.max_sol_cost/min_sol_outputare in the quote mint's raw units — lamports for SOL, 1e-6 for USDC. - A sell can't pay out more than
real_quote_reserves. It is priced on the virtual reserves,amount * virtual_quote / (virtual_token + amount)rounded down, and that payout, fees included, comes out of the real reserves and the curve's lamports; past them the program reverts 6024 Overflow. The virtual reserves normally cover the real ones, but on a mayhem-mode coin they drift far apart, so the seller sells the largest part of a position the curve can pay for, and the position stays open with the rest for a later attempt. - Even for SOL-paired coins you must pass wrapped SOL as
quote_mint, notPubkey::default(). Transfers still happen in native SOL, and theassociated_quote_*accounts are only seed-constrained — do not create the user's WSOL ATA, it would burn ~0.002 SOL of rent for nothing. - Every v2 buy/sell needs a
fee_recipientand abuyback_fee_recipient. The bot picks the fee recipient at random fromNORMAL_FEE_RECIPIENTS(MAYHEM_FEEon a mayhem coin) and the buyback recipient fromBUYBACK_FEE_RECIPIENTS(platforms/pumpfun/address_provider.py). PumpSwap trades on a normal pool use the sameNORMAL_FEE_RECIPIENTS. - pump.fun rotated the normal fee recipients on 2026-11-25 and the old set stopped
working. PumpSwap's
GlobalConfigmay still list the old set, so normal recipients come fromNORMAL_FEE_RECIPIENTS, never fromGlobalConfig. Mayhem and buyback recipients were not rotated. sharing_config(PDA["sharing-config", base_mint]) lives under the pump fees program, not the pump program. Easy to derive against the wrong program.
-
create_v2allocates 125 bytes. Three fields followquote_mint:creator_fee_bps(u64),can_edit_creator_fee(bool, reserved — always false) andis_holder_reward(bool). Every field the bot reads sits before where the padding used to start. -
extend_accountcan grow a curve past 125 bytes, and a length allowlist is whack-a-mole against that. Don't filter on account length — decode any length at or above 125 the same way:Length What it is 125 bytes What create_v2allocates151 bytes The old allocation size; still reachable via extend_account256 bytes A rarer extend_accounttargettests/regression/verify_curve_account_sizes.pychecks that all three decode and that the graduating-token examples don't filter on length. -
pump.fun's October 2026 upgrade appended six fields:
creator_fee,protocol_fees,depth,initial_virtual_quote_reserves,post_complete_base_outandpost_complete_quote_in(166 bytes in all). A curve grows to hold them on its first trade after the upgrade, so 125- and 151-byte curves still occur.decode_bonding_curveinplatforms/pumpfun/curve_manager.pyreads missing trailing fields as zero and refuses a curve under 125 bytes. -
Curve
buy_v3/sell_v3keep the fees on the curve. They take 17 accounts, with no fee recipient or creator vault, and record the protocol and creator fee inprotocol_feesandcreator_feeuntilsweep_protocol_fee/sweep_creator_feepays them out. A creator collecting fees sweeps first (cookbook/pumpfun/trade/pumpfun_collect_creator_fee.py --mint). The bot trades v2, which still pays fees on every trade. -
The SOL-named fields were renamed:
virtual_sol_reserves→virtual_quote_reserves,real_sol_reserves→real_quote_reserves. The curve manager exposes the old names as aliases, so callers keep working for SOL-paired coins — but anything doing arithmetic must scale by the quote mint's decimals (quote_units_per_token), not a hardcoded 1e9. -
PumpSwap
Poolhasvirtual_quote_reserves: i128at offset 245 (16 bytes), thencreator_fee_bps(u64),can_edit_creator_feeandis_holder_reward(bools), thenprotocol_feesandcreator_fees(u64s); fields end at 287 and live accounts are 301 bytes with trailing padding. Quote against effective reserves:pool_quote_token_account.amount + virtual_quote_reserves; quoting off the raw vault balance mis-prices any pool where it is nonzero. It isi128, notu64, and it goes negative: fees a trade keeps in the vault are subtracted from it until swept, so the effective reserves stay right. -
PumpSwap
buy_v2/sell_v2(17 accounts) keep the protocol and creator fees in the pool, inprotocol_feesandcreator_fees. The bot trades the v1 instructions, which still pay fees on every trade. -
Pool.coin_creatortells you whether a pool is canonical, i.e. graduated from a pump.fun bonding curve. It isPubkey::default()on every other pool. Two things follow:pool-v2is sent only for a canonical pool. The buyback fee recipient and its quote ATA are always the last two accounts and are read positionally, so addingpool-v2on a non-canonical pool shifts them and the program rejects thepool-v2PDA withBuybackFeeRecipientNotAuthorized(6053), while leaving it out of a canonical pool's trade throwsAnchorError 6023 (Overflow)after the transfers complete. Account counts: buy 26/27 canonical, 25/26 not; sell 24/26 canonical, 23/25 not.- 6 base-token decimals hold only for canonical pools. Every graduated
coin has 6, which
PumpSwapMarketrelies on; non-canonical pools often carry 9, and a factor of 1000 scales the quote and the slippage floor together, so a sell revertsExceededSlippage(6004). For any other pool, read the mint's owner and decimals from onegetAccountInfo, asget_mint_infoincookbook/pumpswap/pumpswap_sell_token.pydoes.
-
The vendored
pump_swap_idl.jsonunder-reports these accounts and is byte-identical to upstream, so it cannot be the reference: it lists 23 forbuyagainst 25-26 on chain, and 21 forsellagainst 23-26.
A complete curve has handed its reserves to PumpSwap: every reserve reads zero
and complete is set. The curve manager reports graduated instead of raising
on the zero reserves, and calculate_price raises CurveGraduatedError.
The pool a migration creates is canonical and derived, not searched for:
PDA(["pool", u16 0, pool_authority, base_mint, quote_mint]) under pump-amm, with
pool_authority = PDA(["pool-authority", base_mint]) under the pump.fun program.
platforms/pumpfun/pumpswap_market.py buys and sells in it with the account
rules above, taking the fee, mayhem and buyback recipients from PumpSwap's
GlobalConfig — the mayhem one is reserved_fee_recipient, at offset 385.
The buy is buy_exact_quote_in(spendable_quote_in, min_base_amount_out, track_volume): it spends exactly spendable_quote_in, fees included, so the
buyer passes the configured amount unpadded and puts the slippage on the token
floor. track_volume is an OptionBool sent as one byte, 1, so volume
tracking is on. After the IDL's first 19 accounts a buy sends
global_volume_accumulator and the user's user_volume_accumulator (writable;
the program creates it on first use, no init instruction needed), then
fee_config and the fee program. On a cashback pool a buy adds only the
accumulator's quote ATA, where a sell adds that ATA and the accumulator.
A SOL buy pays through the wallet's WSOL ATA (create idempotent, transfer the
spend, sync_native, close after the swap), not the throwaway seeded account
the sells use: that account's creation carries a seed and an owner key, and
beside a buy's account list it pushes a v0 transaction without lookup tables
to the 1232-byte limit, past it on a cashback pool. Closing the ATA also
unwraps any WSOL the wallet held there.
The buyer reaches the pool when the curve it reads reports graduated. In
extreme_fast_mode it skips the coin instead: the pool buy is sized from the
pool's reserves, which that mode does not read.
The fee the market reports is GlobalConfig's lp + protocol + coin_creator
bps. The fee program can charge more on a pool (GetFeesWithQuoteMint picks a
tier), so the buy's token floor and the sell's quote floor sit that much above
what arrives; a slippage setting of a few percent covers it.
Anyone can migrate a complete curve: migrate_v2(base_mint, quote_mint, …), or
legacy migrate for a SOL-paired coin, both still sent. The migrate has
pump-amm's create_pool make the canonical pool. Most migrate calls arrive
after another one already moved the curve: they succeed, log Bonding curve already migrated and create nothing, so a migrate instruction alone does not
mean a new pool.
The two events of a real migration travel differently:
- pump.fun's
CompletePumpAmmMigrationEvent(mint, pool, quote mint, the default key for SOL) is an event CPI only, an inner instruction, never aProgram data:log line. logsSubscribe cannot see it. - pump-amm's
CreatePoolEvent(base mint, quote mint as wrapped SOL for SOL, pool, …) is logged under pump-amm's own invocation, as well as emitted as an event CPI.
So the listeners with logs (logs, blocks, geyser) read CreatePoolEvent,
counting it only when pump-amm's invocation emitted it and its pool is the
coin's canonical one: that pool's creator is pump.fun's pool-authority PDA, so
nothing but a migration can create it. shreds has no logs and decodes the
top-level migrate instruction: base mint at account 2, quote mint at 3 and pool
at 10 for migrate_v2; mint at 2 and pool at 9 for migrate. It subscribes on
Global.withdraw_authority (39azUYFW…), account 1 of both and of no trade.
migrate_v2 needs two remaining accounts after the IDL's 27, for pump-amm's
init_boost: boost_vault_authority = PDA(["boost_vault", pool]) under pump-amm,
then its quote-mint ATA (writable). Without them it reverts 6027
NotEnoughRemainingAccounts after create_pool ran, so a reverted migration
can still log a CreatePoolEvent.
create_v2takes eight args:name (str), symbol (str), uri (str), creator (pubkey), is_mayhem_mode (bool), is_cashback_enabled (OptionBool), creator_fee_bps (OptionU64), is_holder_reward (OptionBool).OptionBoolandOptionU64are single-field Anchor structs with no presence tag — each serializes as its bare inner value, 1 byte and 8 bytes, never a discriminated Option.is_cashback_enabled = [true]is rejected with6082 CashbackDeprecated:create_v2can no longer mint a new cashback coin. Existing cashback coins keep trading, accruing and claiming, so every cashback code path in this repo (the PumpSwap sell's cashback accounts,is_cashback_coinonTokenInfo) stays live and must not be treated as dead.- The trailing args are positional, not independently optional. Reaching
is_holder_reward(arg 8) means sendingis_cashback_enabled(6) andcreator_fee_bps(7) first, even when both are false/zero. The committed fixtures show three wire lengths: all trailing args omitted (0 bytes afteris_mayhem_mode),is_cashback_enabledonly (1 byte), andis_cashback_enabled+creator_fee_bps(9 bytes); the three-arg form is sent too. Because the args are positional, a shorter form cannot have set a later one — a truncated instruction is proof the coin is not holder-reward, not merely silence about it, which is what lets a pre-execution listener classify every coin. A decoder that reads a fixed number of trailing bytes raisesIndexErroron the shorter forms, so decode defensively and report a missing arg as unset;utils/idl_parser.pydoes, andtests/regression/verify_create_v2_optional_args.pychecks it. create_v2accounts 1-16 are in the IDL; accounts 17-20 are remaining accounts (quote_mint,associated_quote_bonding_curve,quote_token_program,quote_control), all four or none. The fourth is theQuoteControlPDA (["quote-control"]), and it is easy to miss because the IDL does not list any of them. They are appended for SOL-paired coins too, carrying wrapped SOL, so a 20-accountcreate_v2is not proof of a non-SOL quote asset. Readquote_mintoff the curve instead.- Omitting them is accepted. A 16-account
create_v2lands and produces a SOL-paired coin, so nothing tells you the accounts were missing. What it also does is silently dropcreator_fee_bps, because: - A creator fee is applied only on a coin priced in a
QuoteControlmint. Anywhere else the program acceptscreator_fee_bps, emitsCreateEvent.creator_fee_bps = 0and stores 0 on the curve, with no error. The fee lands on aQuoteControlmint, SPL Token or Token-2022, and not on wrapped SOL or USDC: registry membership decides, not the token program. - The associated bonding curve is an ordinary ATA, so its address depends on
which token program owns the mint: Token2022 for
create_v2coins, SPL Token for legacycreate. Deriving with the wrong program returns a valid-looking address that does not exist on chain. extreme_fast_modeskips the curve-state price fetch. Whether it also reads the curve for mayhem/cashback/creator/quote_mint depends onstate_from_event(see Invariants inAGENTS.md): set, the buy trades on the listener's data with zero RPC calls; unset, or withtrade.trust_create_event: false, it refreshes from chain. The CreateEvent parsers and theshredslistener set it; instruction-parsed tokens from other listeners don't. The wrong quote mint means spending the wrong balance entirely.CreateEventcarriesquote_mintandvirtual_quote_reservesas trailing fields.BondingCurve.creatorcan change after launch. Setting up creator-fee sharing (MigrateBondingCurveCreator, often in its own transaction a slot after the create) moves it to the coin's fee-sharing config, soCreateEvent.creatorgoes stale and acreator_vaultderived from it revertsConstraintSeeds(2006). Every path that reads the curve before a buy or sell takes the creator from that read; only the zero-RPCextreme_fast_modebuy trades on the event's.
create_v2 can set is_holder_reward so the creator fee is set aside for holders
instead of paid to a creator wallet. On such a coin BondingCurve.creator holds a
pump.fun address rather than the actual creator's; the creator_vault derivation
is unchanged and still correct, since it derives from whatever creator the curve
carries.
That substituted address is PDA(["holder-rewards", mint]) under the pump
program — the same account the IDL declares for holder_rewards on
distribute_fee_to_holders, which is how the ordinary creator-vault route
delivers the fee to the holder pool without a second payout path. It depends on
nothing but the mint, so args.creator being unusable on these coins costs no RPC
call to work around: PumpFunAddresses.find_holder_reward_creator derives it.
No trade instruction changed: buy, sell, buy_v2, sell_v2 and the
PumpSwap instructions take identical accounts and arguments either way.
Global.is_holder_reward_enabled can switch creation off globally.
TokenInfo.is_holder_reward and TokenInfo.creator_fee_bps surface this to the
bot (src/interfaces/core.py).