As of the 2026-07 program upgrade, AMM v4’s OpenBook / Serum dependency has been removed. The legacy v1
SwapBaseIn / SwapBaseOut, Deposit, and Withdraw instructions keep their old account layouts for backwards compatibility: the market accounts are still accepted in their old positions, but they are no longer validated or used (no CPI is issued). New integrations should use the V2 swap entrypoints, which omit the market accounts entirely. Several instructions have been removed and now revert — see the changelog entry. The account lists below use the field names from the Raydium SDK; the underlying IDL sometimes uses serum_* prefixes.Instruction inventory
The SDK exposes builders for the user-facing instructions only. Upkeep instructions are typically invoked by the Raydium keeper.
Removed / no longer callable (they now revert with
unimplemented!, and their client builders were deleted): Initialize (tag 0, use Initialize2), MonitorStep (2), MigrateToOpenBook (5), WithdrawSrm (8), PreInitialize (10, use Initialize2), SimulateInfo (12), AdminCancelOrders (13).
Initialize2
Bootstrap a new AMM v4 pool bound to an existing OpenBook market.
Arguments
W, signer S)
Postconditions
lp_supply = sqrt(init_coin_amount × init_pc_amount) − INIT_BURN, whereINIT_BURN≈ 100 LP units are kept out of circulation.- No OpenBook orders are posted (the order-book grid has been removed).
market_program/marketare still passed but only stored as reference fields;coin_lot_size/pc_lot_size/min_sizeare initialized to0.
InvalidInput (mismatched decimals, non-sorted), NotAllowed.
Deposit
Add liquidity.
Arguments
Math — standard pro-rata. Using the pool’s effective reserves (vaults + on-book), the SDK computes the coin/pc pair that yields the given LP amount and checks it against
max_*. Reverts with ExceededSlippage if either side exceeds the cap.
Withdraw
Burn LP, receive both sides.
Arguments
Deposit with the direction reversed; lp_mint is writable for burn, the user ATAs are receivers. The account layout is unchanged (market accounts still passed positionally, ignored). There is no longer any settle-from-OpenBook step — the pro-rata math uses the vault balances directly.
SwapBaseIn
Exact-input swap. Always an AMM-path swap (does not route through OpenBook matching).
Use the V2 variants for new code. Since AMM v4’s OpenBook dependency has been removed, the V1 entrypoints (
SwapBaseIn, SwapBaseOut) still expect the full 17-account list (or 18 with the optional target-orders account), but the OpenBook/market accounts are now accepted positionally and ignored — they are not validated and no CPI is issued. Passing a wrong account count still reverts with WrongAccountsNumber, but the market account contents are no longer checked. New integrations should use SwapBaseInV2 / SwapBaseOutV2, which take a much smaller account list and represent the canonical execution path today. The V1 forms are documented here for completeness and for reading existing on-chain transactions.
Math — see
products/amm-v4/math.
Preconditions
amm.statusallows swap (bit 0 of the status bitmask not set).amm.state_data.pool_open_time <= now.amount_in > 0.user_source_token_accountholds at leastamount_in.
- User loses
amount_inof source token, gainsamount_out ≥ minimum_amount_outof dest token. need_take_pnl_*incremented by the protocol fee share.- Note: the
state_data.swap_*_in_amount/swap_*_out_amountanalytics counters are no longer updated — their values are frozen. Use trade logs for volume analytics.
ExceededSlippage, InvalidInput, InvalidStatus, NotAllowed (coin/pc mint identical).
SwapBaseOut
Exact-output, inverse of SwapBaseIn. Same accounts.
Arguments
SwapBaseInV2 / SwapBaseOutV2
Variant swap entrypoints (tags 16 / 17) that skip the OpenBook accounts entirely. The math is identical to the V1 path, but the account list shrinks to just the AMM side and the user — 8 accounts, and amm_open_orders is not passed:
Pool reserves are now the vault balances (minus pending PnL), so quote math is straightforward and identical to the v1 path. Use V2 to save compute and avoid passing the (now-ignored) market accounts. The Raydium router always uses the V2 form when routing through AMM v4.
Arguments are the same as the V1 forms (
amount_in / minimum_amount_out for SwapBaseInV2; max_amount_in / amount_out for SwapBaseOutV2).
MonitorStep and other removed instructions
Historically, MonitorStep cranked the pool’s OpenBook interaction: it settled filled orders (moving proceeds from the market vaults into the pool vaults via OpenBook CPI), cancelled stale orders, and posted new orders to close the gap between target_orders and amm_open_orders. With the OpenBook dependency removed, there is nothing to crank and the instruction is gone. Any keeper or integration that still calls it must remove the call.
WithdrawPnl / TakePnl
Admin sweep of accrued protocol fees.
Arguments
WithdrawPnltakes no args; it readsneed_take_pnl_*and moves those exact amounts.
Effect
- Transfers
need_take_pnl_coinfrompool_coin_token_accounttopnl_coin_token_account. - Same for pc.
- Zeros
need_take_pnl_coinandneed_take_pnl_pc. - Logic change: if the vault balance is insufficient to cover accrued PnL, the instruction returns
TakePnlErrordirectly (it no longer manipulates order-book state).
SetParams
Admin param changes, called by the Raydium multisig. Arguments are a param: u8 tag + payload.
State-change matrix
The OpenBook column is gone — no instruction touches an order book anymore.Where to go next
products/amm-v4/code-demos— TypeScript examples for swap and LP flows.products/amm-v4/fees—WithdrawPnldetails and the fee split.reference/error-codes— forward-reference table (AMM v4 errors are listed on that page).
- Raydium AMM program —
raydium-io/raydium-amm - Raydium SDK v2
Liquiditymodule - OpenBook program — account validations on the market side

