> ## 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.

# AMM v4 accounts

> The full account inventory of an AMM v4 pool — AmmInfo, TargetOrders, OpenOrders, vaults, LP mint, authority — plus the OpenBook accounts the pool is bound to.

<Info>
  As of the 2026-07 upgrade, AMM v4's OpenBook / Serum dependency has been **removed** — no instruction reads or writes OpenBook state anymore. The market accounts below are retained only as positional placeholders on the legacy v1 instruction layouts (accepted but ignored) and as reference fields on `AmmInfo`. Use the V2 swap entrypoints, which omit them entirely. This page still groups the accounts into "pool-owned" and "OpenBook (legacy)" sections for reading older transactions.
</Info>

## Inventory

An AMM v4 pool records one bound market on `AmmInfo` at creation. The full picture:

| Category          | Account                              | Owner          | Role                                                                                                           |
| ----------------- | ------------------------------------ | -------------- | -------------------------------------------------------------------------------------------------------------- |
| Pool              | `AmmInfo`                            | AMM v4 program | Pool state: fees accrued, status, references to vaults (and, as legacy fields, the market).                    |
| Pool              | `amm_authority`                      | AMM v4 program | Program-owned PDA that signs vault moves. Shared across all AMM v4 pools.                                      |
| Pool              | `amm_open_orders`                    | OpenBook       | Legacy `OpenOrders` reference. No longer read/written by the program; still passed positionally on v1 layouts. |
| Pool              | `amm_target_orders`                  | AMM v4 program | Legacy target-orders account. Still referenced by `WithdrawPnl` (as account #10) but no grid is built.         |
| Pool              | `pool_coin_token_account`            | SPL Token      | Pool's coin-side vault (ATA of `amm_authority`).                                                               |
| Pool              | `pool_pc_token_account`              | SPL Token      | Pool's pc-side vault.                                                                                          |
| Pool              | `lp_mint`                            | SPL Token      | Fungible LP mint.                                                                                              |
| Pool              | `pool_withdraw_queue`                | AMM v4 program | Legacy queue for delayed withdrawals; kept zero-length.                                                        |
| Pool              | `pool_temp_lp`                       | AMM v4 program | Auxiliary LP account.                                                                                          |
| Legacy (OpenBook) | `serum_market`                       | OpenBook       | The bound market. Passed on v1 layouts but no longer validated or used.                                        |
| Legacy            | `serum_bids`, `serum_asks`           | OpenBook       | Bid/ask queues. Ignored.                                                                                       |
| Legacy            | `serum_event_queue`                  | OpenBook       | Pending events. Ignored.                                                                                       |
| Legacy            | `serum_coin_vault`, `serum_pc_vault` | SPL Token      | Market-level vaults. Ignored.                                                                                  |
| Legacy            | `serum_vault_signer`                 | OpenBook       | Market-level PDA. Ignored.                                                                                     |

Note: "serum" is kept as the prefix in AMM v4's IDL and field names for backward compatibility. These accounts are no longer functional after the OpenBook removal.

## `AmmInfo`

The pool's root state account. Large (≈ 752 bytes) because it carries both pool and OpenBook references inline.

```rust theme={null}
// programs/amm/src/state.rs (abridged; field order / names follow the IDL)
pub struct AmmInfo {
    pub status: u64,           // bitmask: swap/deposit/withdraw/crank enabled
    pub nonce:  u64,           // bump used to derive amm_authority
    pub order_num: u64,
    pub depth: u64,
    pub coin_decimals: u64,
    pub pc_decimals:   u64,
    pub state:         u64,    // internal state machine
    pub reset_flag:    u64,
    pub min_size:      u64,
    pub vol_max_cut_ratio: u64,
    pub amount_wave: u64,
    pub coin_lot_size: u64,    // legacy (OpenBook lot size); now initialized to 0
    pub pc_lot_size:   u64,    // legacy; now initialized to 0
    pub min_price_multiplier: u64,
    pub max_price_multiplier: u64,
    pub sys_decimal_value: u64,

    pub fees: Fees,            // trade/protocol/fund fee rates
    pub state_data: StateData,

    // Pool-owned accounts:
    pub coin_vault: Pubkey,
    pub pc_vault:   Pubkey,
    pub coin_vault_mint: Pubkey,
    pub pc_vault_mint:   Pubkey,
    pub lp_mint:  Pubkey,
    pub open_orders: Pubkey,   // pool's OpenOrders on OpenBook
    pub market: Pubkey,        // OpenBook market
    pub market_program: Pubkey, // OpenBook program ID
    pub target_orders: Pubkey,
    pub withdraw_queue: Pubkey,
    pub lp_vault:       Pubkey, // = pool_temp_lp
    pub owner: Pubkey,          // admin (multisig)
    pub lp_reserve: u64,
    pub padding: [u64; 3],
}

pub struct Fees {
    pub min_separate_numerator:   u64,     // 5
    pub min_separate_denominator: u64,     // 10_000
    pub trade_fee_numerator:      u64,     // 25  → used by OpenBook integration
    pub trade_fee_denominator:    u64,     // 10_000
    pub pnl_numerator:            u64,     // 12  → protocol's share OF the swap fee
    pub pnl_denominator:          u64,     // 100 → so 12/100 = 12% of fee, = 0.03% of volume
    pub swap_fee_numerator:       u64,     // 25  → 0.25% gross swap fee
    pub swap_fee_denominator:     u64,     // 10_000
}

pub struct StateData {
    pub need_take_pnl_coin: u64,        // still updated — accrued protocol fee (coin side)
    pub need_take_pnl_pc:   u64,        // still updated — accrued protocol fee (pc side)
    pub total_pnl_pc:   u64,            // DEPRECATED — no longer updated
    pub total_pnl_coin: u64,            // DEPRECATED — no longer updated
    pub pool_open_time: u64,            // still used — pool open timestamp
    pub padding: [u64; 2],              // reserved
    pub orderbook_to_init_time: u64,    // DEPRECATED — no longer updated
    pub swap_coin_in_amount: u128,      // DEPRECATED — volume counters frozen
    pub swap_pc_out_amount:  u128,      // DEPRECATED
    pub swap_acc_pc_fee:    u64,        // DEPRECATED
    pub swap_pc_in_amount:  u128,       // DEPRECATED
    pub swap_coin_out_amount: u128,     // DEPRECATED
    pub swap_acc_coin_fee:  u64,        // DEPRECATED
}
```

<Note>
  The struct **layout is unchanged** (byte-compatible) so existing deserializers keep working, but after the OpenBook removal the fields marked `DEPRECATED` above are **no longer written** — the `swap_*` volume counters are frozen at their last value. For volume analytics, use trade logs rather than these fields. Only `need_take_pnl_*` and `pool_open_time` are actively maintained.
</Note>

Integrator-facing fields:

* **`coin_vault`**, **`pc_vault`** — the pool's SPL Token vaults. `coin` is `token_0` by Serum/OpenBook convention (base), `pc` is `token_1` (quote).
* **`coin_decimals`**, **`pc_decimals`** — matching the mints.
* **`open_orders`**, **`target_orders`**, **`market`** — legacy reference fields. Still present on `AmmInfo` and still passed positionally on the v1 instruction layouts, but the program no longer reads or validates them. The V2 swap entrypoints omit them.
* **`fees.swap_fee_numerator / swap_fee_denominator`** — the combined trade fee. Default `25 / 10_000 = 0.25%`.
* **`status`** — bitmask gating operations. Admin-settable via `AdminSetStatus`.
* **`state_data.need_take_pnl_*`** — delta between gross accrued fees and what's been swept. `TakePnl` zeroes these.

## The OpenBook wiring

<Note>
  **Removed.** The OpenBook / Serum dependency has been deleted from the program (2026-07 upgrade). The accounts described in this section are no longer validated or used. They remain as reference fields on `AmmInfo` and as positional placeholders on the legacy v1 instruction layouts. Use the **V2 swap entrypoints** ([`SwapBaseInV2` / `SwapBaseOutV2`](/products/amm-v4/instructions)) which skip these accounts entirely.
</Note>

When you call a legacy **v1** `SwapBaseIn` / `SwapBaseOut`, `Deposit`, or `Withdraw` instruction, the account **count** must still match the old layout (the market accounts occupy their historical positions), but their **contents are no longer checked** — no CPI is issued against them. New code should use the V2 swap variants, which do not take these accounts at all.

```ts theme={null}
const market = ...;  // OpenBook market PublicKey

// Fields OpenBook exposes on its market account:
const marketDecoded = OpenBookMarket.decode(marketAccountData);
const {
  bids:           serumBids,
  asks:           serumAsks,
  eventQueue:     serumEventQueue,
  requestQueue:   serumRequestQueue,
  baseVault:      serumCoinVault,
  quoteVault:     serumPcVault,
  vaultSignerNonce,
} = marketDecoded;

const serumVaultSigner = PublicKey.createProgramAddressSync(
  [market.toBuffer(), u64ToBytes(vaultSignerNonce)],
  OPENBOOK_PROGRAM_ID,
);
```

The AMM's `amm_open_orders` is an OpenBook-owned account holding the pool's limit-order state on this market: active orders, settled balances, referrers, etc. `amm_target_orders` is AMM-side: it holds the AMM's *intended* grid (price/size for each order slot) so the program can cheaply compare against what's currently posted and place / cancel the diff.

## Authority PDAs

There is exactly one `amm_authority` PDA for the entire AMM v4 program. Its seed is trivial (`["amm authority"]`) and its bump is stored on every `AmmInfo`. This authority signs all token moves for all AMM v4 pools.

```ts theme={null}
const AMM_V4_PROGRAM_ID = new PublicKey(
  "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
);
const [ammAuthority] = PublicKey.findProgramAddressSync(
  [Buffer.from("amm authority")],
  AMM_V4_PROGRAM_ID,
);
```

There is a separate **pool-scoped** authority derived per pool to sign OpenBook operations (`amm_authority` above actually covers both in this program's design; different versions used different derivation, so check the specific pool's `AmmInfo.nonce` in code).

## Vaults

The pool's SPL Token vaults are standard token accounts whose `owner` is `amm_authority`. Not ATAs — their addresses are specific PDAs derived at `Initialize` with `["amm_associated_seed", coin_mint_or_pc_mint, market, amm_id]` seeds. Addresses are stored on `AmmInfo`; derivation is a one-time curiosity.

Token-2022 is **not** supported. The program hardcodes SPL Token's program ID for all vault moves. Attempting to bind an AMM v4 pool to a Token-2022 mint fails at `Initialize`.

## LP mint

A classic SPL Token mint whose authority is `amm_authority`. Total supply tracks LP ownership of the pool; burning LP returns tokens from both vaults pro-rata. Because AMM v4 predates CPMM, there is no `lp_supply` mirror in the pool state — read the mint's on-chain supply directly.

## Status bitmask

`AmmInfo.status` gates operations. Bits (position may differ across program versions — confirm via the source):

| Bit | Flag                | Effect                           |
| --- | ------------------- | -------------------------------- |
| 0   | `SWAP_DISABLED`     | `Swap*` rejects.                 |
| 1   | `DEPOSIT_DISABLED`  | `Deposit` rejects.               |
| 2   | `WITHDRAW_DISABLED` | `Withdraw` rejects.              |
| 3   | `CLMM_LIKE_MIGRATE` | Migration-gate flag used by ops. |

The Raydium multisig sets these via `SetParams` (with `param = Status`). (`AdminCancelOrders` has been removed.)

## Observation / oracle

**AMM v4 has no dedicated observation account.** Other protocols that need an on-chain TWAP typically consume OpenBook's book crossings indirectly or read off-chain. If you need a Raydium TWAP with program support, use CPMM or CLMM.

## Deriving a pool's accounts from scratch

Because AMM v4 was not designed for deterministic per-pair PDAs (it pre-dates that Solana convention), the canonical `amm_id` is a **seeded keypair** derived with:

```
ammId = createWithSeed(
  owner: ammAuthority,
  seed:  marketPubkey.toBase58().slice(0, 32),
  programId: AMM_V4_PROGRAM_ID,
)
```

The same seeded-key pattern applies to `amm_open_orders`, `amm_target_orders`, `amm_withdraw_queue`, `pool_temp_lp`, `pool_coin_token_account`, `pool_pc_token_account`, and `lp_mint`. The SDK and API pre-compute these for you; see `raydium-sdk-v2`'s `Liquidity.getAssociatedPoolKeys`.

In practice, integrators read the pool's full account set from `GET https://api-v3.raydium.io/pools/info/ids?ids=<POOL_ID>` or from the SDK. Hand-deriving is rarely needed.

## Lifecycle quick reference

| Event                                  | Accounts created                                                                                             | Accounts destroyed |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------ |
| `Initialize2`                          | `amm_info`, `amm_open_orders`, `amm_target_orders`, vaults, `lp_mint`, `pool_withdraw_queue`, `pool_temp_lp` | —                  |
| `Deposit`                              | — (may create user LP ATA)                                                                                   | —                  |
| `Withdraw`                             | —                                                                                                            | —                  |
| `SwapBaseIn` / `SwapBaseOut` (v1 / V2) | — (may create user ATA)                                                                                      | —                  |
| `WithdrawPnl`                          | —                                                                                                            | —                  |

Pools and their accounts persist indefinitely. Even if liquidity is fully withdrawn, `AmmInfo` stays.

## What to read where

* **Math and fee arithmetic**: [`products/amm-v4/math`](/products/amm-v4/math).
* **Fee split and how it compares to CPMM/CLMM**: [`products/amm-v4/fees`](/products/amm-v4/fees).
* **Instruction account lists**: [`products/amm-v4/instructions`](/products/amm-v4/instructions).
* **OpenBook account derivation**: OpenBook program docs ([`github.com/openbook-dex/program`](https://github.com/openbook-dex/program)).

Sources:

* [Raydium AMM program — `raydium-io/raydium-amm`](https://github.com/raydium-io/raydium-amm)
* [`reference/program-addresses`](/reference/program-addresses) for canonical program IDs
* OpenBook / Serum protocol for the counterparty accounts
