Skip to main content
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
Accounts (writable W, signer S) Postconditions
  • lp_supply = sqrt(init_coin_amount × init_pc_amount) − INIT_BURN, where INIT_BURN ≈ 100 LP units are kept out of circulation.
  • No OpenBook orders are posted (the order-book grid has been removed). market_program / market are still passed but only stored as reference fields; coin_lot_size / pc_lot_size / min_size are initialized to 0.
Common errorsInvalidInput (mismatched decimals, non-sorted), NotAllowed.

Deposit

Add liquidity. Arguments
Accounts (abridged) 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
Accounts — like 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.
Arguments
Accounts (abridged) Math — see products/amm-v4/math. Preconditions
  • amm.status allows swap (bit 0 of the status bitmask not set).
  • amm.state_data.pool_open_time <= now.
  • amount_in > 0.
  • user_source_token_account holds at least amount_in.
Postconditions
  • User loses amount_in of source token, gains amount_out ≥ minimum_amount_out of dest token.
  • need_take_pnl_* incremented by the protocol fee share.
  • Note: the state_data.swap_*_in_amount / swap_*_out_amount analytics counters are no longer updated — their values are frozen. Use trade logs for volume analytics.
Common errorsExceededSlippage, 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

Removed — no longer callable. As of the 2026-07 upgrade, MonitorStep (tag 2) has been removed from the program and now reverts (unimplemented!) if invoked. Its client builder was also deleted. The same applies to MigrateToOpenBook (5), WithdrawSrm (8), SimulateInfo (12), AdminCancelOrders (13), and the legacy Initialize (0) / PreInitialize (10) pool-creation entrypoints — use Initialize2 instead.
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
  • WithdrawPnl takes no args; it reads need_take_pnl_* and moves those exact amounts.
Breaking change (admin only). The account list dropped from 17 (+1 optional) to 10amm_open_orders and all six market accounts were removed — with no compatibility parsing. The old layout misaligns (old #5 was amm_open_orders, now pool_coin_token_account) and fails with errors such as InvalidCoinVault. Admin tooling must be updated.
Accounts (new 10-account layout) Effect
  • Transfers need_take_pnl_coin from pool_coin_token_account to pnl_coin_token_account.
  • Same for pc.
  • Zeros need_take_pnl_coin and need_take_pnl_pc.
  • Logic change: if the vault balance is insufficient to cover accrued PnL, the instruction returns TakePnlError directly (it no longer manipulates order-book state).
No change to reserves since accrued PnL was already excluded from the invariant.

SetParams

Admin param changes, called by the Raydium multisig. Arguments are a param: u8 tag + payload.
Breaking change (admin only). The account list was reduced to just [amm (W), admin (S)] (the authority, open-orders, target-orders, vault, and all market accounts were removed). The param enum was renumbered and trimmed: Status = 0, State = 1, Fees = 2 (was 9), SetOpenTime = 3 (was 11). All order-book-grid params and AmmOwner, LastOrderDistance, UpdateOpenOrder were removed, and the SetParamsInstruction struct dropped new_pubkey and last_order_distance. Admin tooling must be updated.

State-change matrix

The OpenBook column is gone — no instruction touches an order book anymore.

Where to go next

Sources: