> ## 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 integration has since been deactivated.

<Warning>
  **AMM v4 no longer shares liquidity to OpenBook.** All current swaps execute on the AMM-only path (`SwapBaseInV2` / `SwapBaseOutV2`); the on-chain OpenBook wiring (limit-order grid, `MonitorStep`, market accounts) is preserved in the program but inert — pools no longer post or maintain orders on OpenBook. The OpenBook integration is documented for completeness and historical context, and continues to apply only as account-level invariants (e.g. `AmmInfo` still references the original market), not as an active liquidity source.
</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 side is no longer active** (see warning above); AMM v4 today is, in practice, a pure constant-product AMM with the original OpenBook accounts retained as inert state.

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. Includes the historical formulas for the (now inert) OpenBook limit-order grid.
  </Card>

  <Card title="Instructions" icon="terminal" href="/products/amm-v4/instructions">
    Initialize, Deposit, Withdraw, SwapBaseIn / V2, SwapBaseOut / V2, MonitorStep (legacy), SetParams, WithdrawPnl.
  </Card>

  <Card title="Fees" icon="percent" href="/products/amm-v4/fees">
    LP fee, protocol fee, trade fee split. Historical PnL handling for orderbook fills.
  </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.
