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

> Constant-product AMM. Originally a hybrid design that shared liquidity to OpenBook; the OpenBook dependency has since been removed from the program.

<Warning>
  **AMM v4's OpenBook / Serum dependency has been removed (2026-07 program upgrade).** All swaps execute on the AMM-only path. The order-book CPIs and market-making instructions (`MonitorStep`, `MigrateToOpenBook`, `WithdrawSrm`, etc.) have been **removed from the program** and now revert if called. The v1 `SwapBaseIn` / `SwapBaseOut`, `Deposit`, and `Withdraw` instructions keep their old account layouts for backwards compatibility — the market accounts are still accepted positionally but are **no longer validated or used**. New integrations should use the `SwapBaseInV2` / `SwapBaseOutV2` entrypoints. See the [2026-07-22 changelog entry](/reference/changelog/2026-07-22-amm-v4-openbook-removal).
</Warning>

## What it is

AMM v4 is Raydium's first-generation pool. It maintains a constant-product invariant (xy=k). The pool was originally designed as a **hybrid AMM**: alongside the curve, it posted a Fibonacci-spaced grid of limit orders onto a bound OpenBook market so that pool liquidity was visible to orderbook takers. **That OpenBook integration has since been removed from the program** (see warning above); AMM v4 today is a pure constant-product AMM. On-chain `AmmInfo` accounts retain their `market` / `open_orders` reference fields for layout compatibility, but the program no longer reads or acts on them.

It is still the highest-liquidity product on Raydium for many legacy pairs but is **no longer recommended for new pools** — see [CPMM](/products/cpmm) for new deployments.

**Program ID:** see [reference/program-addresses](/reference/program-addresses).

**Token-2022:** not supported. AMM v4 pools only accept classic SPL tokens.

## Chapter contents

<CardGroup cols={2}>
  <Card title="Overview" icon="circle-info" href="/products/amm-v4/overview">
    Conceptual model: how AMM v4 couples a constant-product curve to an OpenBook market, and why the design exists.
  </Card>

  <Card title="Accounts" icon="database" href="/products/amm-v4/accounts">
    AmmInfo, TargetOrders, OpenOrders, LP mint, token vaults, market vault signer. Seeds, field layouts, invariants.
  </Card>

  <Card title="Math" icon="function" href="/products/amm-v4/math">
    xy=k invariant, price calculation. The reserve formula is now vault-only; the OpenBook limit-order grid math is retained as historical context.
  </Card>

  <Card title="Instructions" icon="terminal" href="/products/amm-v4/instructions">
    Initialize2, Deposit, Withdraw, SwapBaseIn / V2, SwapBaseOut / V2, SetParams, WithdrawPnl. (Order-book instructions such as MonitorStep are removed.)
  </Card>

  <Card title="Fees" icon="percent" href="/products/amm-v4/fees">
    LP fee, protocol fee, trade fee split. Historical PnL handling for orderbook fills (retired).
  </Card>

  <Card title="Code demos" icon="code" href="/products/amm-v4/code-demos">
    TypeScript (raydium-sdk-v2) and Rust CPI examples for deposit, withdraw, and swap.
  </Card>
</CardGroup>

## When to read this

* You are auditing or integrating against existing AMM v4 pools.
* You are building a router that must support v4 liquidity.
* You are planning a migration from v4 to CPMM — see also [user-flows/migrate-amm-v4-to-cpmm](/user-flows/migrate-amm-v4-to-cpmm).

If you are creating a **new** pool, read [CPMM](/products/cpmm) instead.
