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.
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 for new deployments. Program ID: see reference/program-addresses. Token-2022: not supported. AMM v4 pools only accept classic SPL tokens.Chapter contents
Overview
Conceptual model: how AMM v4 couples a constant-product curve to an OpenBook market, and why the design exists.
Accounts
AmmInfo, TargetOrders, OpenOrders, LP mint, token vaults, market vault signer. Seeds, field layouts, invariants.
Math
xy=k invariant, price calculation. Includes the historical formulas for the (now inert) OpenBook limit-order grid.
Instructions
Initialize, Deposit, Withdraw, SwapBaseIn / V2, SwapBaseOut / V2, MonitorStep (legacy), SetParams, WithdrawPnl.
Fees
LP fee, protocol fee, trade fee split. Historical PnL handling for orderbook fills.
Code demos
TypeScript (raydium-sdk-v2) and Rust CPI examples for deposit, withdraw, and swap.
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.


