> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 2026-06-22 — Stable AMM: remove dead OpenBook (market) code

> Stable AMM removes its dormant OpenBook market-making accounts and code: smaller Swap/Deposit/Withdraw layouts, a hard-breaking WithdrawPnl change, and a simplified pool-asset formula.

<Info>
  A documentation changelog entry. For the index of all updates, see [`reference/changelog`](/reference/changelog). For the protocol's own historical timeline, see [`introduction/history-and-milestones`](/introduction/history-and-milestones).
</Info>

Stable AMM is an **independent program** (its own program ID — it is not traded through the AMM v4 program). It **stopped posting orders to OpenBook a long time ago**; the OpenBook market-making path has been dormant for years. This upgrade is the cleanup: it **removes the now-dead market-related accounts and code** from the instruction layouts. It does **not** change any live trading behavior — there were no OpenBook orders left to stop placing.

## TL;DR for integrators

* **Swap / Deposit / Withdraw keep working without changes.** Transactions built with the old account layouts still execute — the removed Serum/market accounts are simply ignored. You do **not** have to ship a client update to keep existing flows alive.
* **But you should migrate to the new, smaller layouts soon.** The new layouts drop the dead market accounts, cutting transaction size: `SwapBaseIn` / `SwapBaseOut` go **18 → 9** accounts, `Deposit` **14 → 12**, `Withdraw` **21 (+1 optional) → 12**. The compatibility path will be removed in a future release.
* **`WithdrawPnl` is a hard breaking change (admin only).** It goes **16 (+1 optional) → 10** accounts with **no compatibility parsing**. Sending the old layout fails with validation errors such as `InvalidTokenCoin` because of account misalignment (old #3 was `open_orders`). Any admin tooling that calls `WithdrawPnl` must be updated.
* **Referral fee removed on `Withdraw` and `WithdrawPnl`.** The optional `referrer_pc_wallet` account can still be passed for backwards compatibility on `Withdraw`'s old layout, but it no longer takes effect.
* **Pool-asset accounting simplified.** Total pool assets are now `vault balances − pending PnL`; the OpenBook open-order term — already zero in practice — is dropped from the formula. Indexers and quoting code that still added an OpenOrders term should remove it.
* **Most instructions are now removed.** Only `SwapBaseIn`, `SwapBaseOut`, `Deposit`, `Withdraw`, and `WithdrawPnl` remain callable. `Initialize`, `PreInitialize`, `InitModelData`, `UpdateModelData`, `MonitorStep`, `SetParams`, `WithdrawSrm`, and `SimulateInfo` are no longer callable.

## Why this matters (for traders, LPs, and integrators)

* **Traders** see no change in swap behavior or pricing shape — the lookup-table curve is unchanged. New-layout swaps are cheaper to land because the transaction carries nine fewer accounts.
* **LPs** keep the same deposit/withdraw economics. Liquidity has long sat entirely in the pool vaults, so pool value is fully on-pool; this upgrade only deletes the stale market plumbing.
* **Integrators** get smaller, simpler transactions and a quoting model with one fewer (already-vestigial) term. Existing integrations do not break (except admin `WithdrawPnl`), but the compatibility shim is temporary — migrate at your convenience, before it is removed.

## Instruction-level changes

### `SwapBaseIn` / `SwapBaseOut` — 18 → 9 accounts (old layout still compatible)

The nine OpenBook accounts (`amm_open_orders`, `serum_program`, `serum_market`, `serum_bids`, `serum_asks`, `serum_event_queue`, `serum_coin_vault`, `serum_pc_vault`, `serum_vault_signer`) are removed. **Compatibility**: if the instruction receives a number of accounts other than 9, it is parsed with the old 18-account layout; the Serum accounts must still occupy their positions but their contents are no longer validated or used.

### `Deposit` — 14 → 12 accounts (old layout still compatible)

`amm_open_orders` (old #3) and `serum_market` (old #9) are removed. When 14 accounts are passed, the old layout is parsed for compatibility.

### `Withdraw` — 21 (+1 optional) → 12 accounts (old layout still compatible)

The nine Serum accounts are removed. The old 21- or 22-account layouts are still accepted, **but the referral-fee logic for the 22nd optional `referrer_pc_wallet` has been removed** — the account can still be passed but no longer takes effect.

### `WithdrawPnl` — 16 (+1 optional) → 10 accounts (⚠️ no compatibility path, hard breaking)

Fixed 10-account, admin-only layout. There is **no** compatibility parsing for the old layout; sending it fails with errors such as `InvalidTokenCoin` due to account misalignment. **Logic change**: when the pool's available funds are insufficient to withdraw the accrued PnL, the pool is no longer put into `CancelAllOrdersState` / `Disabled`; the instruction returns `TakePnlError` directly. The optional `referrer_pc_wallet` has likewise been removed.

## Pool-asset calculation change

The formula historically added the funds the pool held as open orders in its OpenBook OpenOrders account. That term has been zero in practice since the pool stopped posting orders; this upgrade drops it from the formula entirely, leaving the vault-only calculation:

|     | Formula                                                                                                 |
| --- | ------------------------------------------------------------------------------------------------------- |
| Old | `vault balances + open-order funds (native_coin_total / native_pc_total) − pending PnL (need_take_pnl)` |
| New | `vault balances − pending PnL (need_take_pnl)`                                                          |

## Pages updated

* `products/stable/overview` — pure-AMM model, removed OpenBook dependency, updated comparison and account-count tables.
* `products/stable/index` — "What it is" and key-facts table no longer claim an OpenBook dependency.
* `products/stable/accounts` — OpenBook accounts removed from the inventory; `AmmInfo` Serum/open-orders fields marked legacy/unused; pool-asset note added.
* `products/stable/instructions` — new Swap / Deposit / Withdraw / WithdrawPnl account tables with compatibility callouts; all other instructions (`Initialize`, `PreInitialize`, `InitModelData`, `UpdateModelData`, `MonitorStep`, `SetParams`, `WithdrawSrm`, `SimulateInfo`) marked removed / no longer callable.
* `products/stable/math` — pool-asset formula update; `MonitorStep` / OpenBook section reframed as long-retired.
* `products/stable/fees` — "PnL from OpenBook" section retired; collection flow no longer settles OpenBook fills.
* `products/stable/code-demos` — account-count guidance updated; SDK still abstracts layout selection.

**Verified against**:

* `raydium-stable` program source (post-upgrade `instruction.rs` / `processor.rs`).
* On-chain Stable AMM program deployment on Solana mainnet-beta.
