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.
One-paragraph summary
AMM v4 is the program Raydium launched with. It maintains a constant-product invariant (x · y = k). It was originally designed as a hybrid AMM: each pool sat on top of an OpenBook (formerly Serum) limit-order-book market and mirrored portions of its curve as limit orders on that book, so users and aggregators could swap directly against the pool (AMM path) or against the limit orders the pool owned on OpenBook (CLOB path). The OpenBook side has since been deactivated — pools no longer post or maintain orders on OpenBook, and all current swap traffic flows through the AMM-only V2 swap entrypoints. Token-2022 is not supported. AMM v4 is still fully operational as a constant-product AMM — every pool keeps trading, fees still accrue, LPs still earn — but the UI and SDK default new pool creation to CPMM because CPMM is cheaper and supports more mint types.
Hybrid history (context)
At launch, standing up a pool alongside Serum’s order book risked fragmenting liquidity. The hybrid design published the AMM’s curve onto the book as limit orders, so order-book routers saw the pool’s depth for free. After OpenBook forked Serum in late 2022, the program continued working against OpenBook with minimal changes. As CPMM and on-chain aggregators matured, the orderbook-side benefit faded, and AMM v4’s OpenBook integration was eventually turned off — the curve is now the pool’s only execution surface.What AMM v4 gives you (that CPMM does not)
- Deep liquidity for legacy pairs. Major pairs (SOL-USDC, mSOL-USDC, etc.) with large AMM v4 TVL remain the deepest venue for those trades.
What AMM v4 does not give you
- Token-2022. Not supported. AMM v4 was written before Token-2022 existed; its account layouts presume classic SPL Token.
- Low account count. A swap touches the pool, authority, vaults, plus the entire OpenBook event/request queue and bids/asks sides. Even a direct AMM swap (bypassing CLOB) drags all OpenBook accounts along because the instruction validates them.
- Low compute usage. Account validation alone costs more than a full CPMM swap.
- Default new-pool flow. The program is still functional and still accepts
Initialize, but the Raydium UI, SDK, andapi-v3.raydium.iono longer surface a “create AMM v4 pool” button — the default path for new pools is CPMM.
How AMM v4 differs from CPMM
| Dimension | AMM v4 | CPMM |
|---|---|---|
| Curve | Constant product | Constant product |
| OpenBook dependency | Inert (originally yes; now disabled) | No |
| Token-2022 | No | Yes |
| Account count per V2 swap | ~9 | ~11 |
| Compute units per swap | ~80k–120k (V2 path) | ~60k–100k |
| LP fee | 0.22% of volume | Varies by AmmConfig |
| Protocol fee | 0.03% of volume (fixed) | Varies by AmmConfig |
| Fund fee | None | Yes |
| TWAP oracle | No native observation account | observation ring buffer |
| Default for new pools | No (still accepted) | Yes |
products/amm-v4/fees and reference/fee-comparison.
Mental model
An AMM v4 pool today is a constant-productx · y = k AMM. Both vaults are entirely available to the curve — no fraction is committed to OpenBook orders, because the OpenBook integration is no longer active. Operations are swap (user ↔ pool, via SwapBaseInV2 / SwapBaseOutV2), deposit / withdraw (LP ops), and a now-vestigial crank (MonitorStep, retained on-chain but no longer needed and not posted by Raydium’s keeper).
Historical mental model (pre-deactivation): a fraction of each vault was escrowed as open-book orders; settlement of filled orders happened during swap and LP operations; routed swaps could fill against the pool’s own OpenBook orders. None of this is in operation today.
Why CPMM is the recommended default
CPMM drops the OpenBook dependency. The tradeoffs:- CPMM transactions are 2×–3× cheaper in compute.
- CPMM supports Token-2022 mints.
- Aggregators now integrate CPMM directly via Raydium SDK, so the order-book-visibility benefit is largely moot.
- Operational risk: OpenBook outages or pauses degrade AMM v4 pools (
CrankError, stale orders). CPMM has no such coupling.
protocol-overview/versions-and-migration for the migration guidance.
When AMM v4 is the right choice
- You are routing a swap and one of the candidate pools is an AMM v4 pool with the best price.
- You are providing or managing liquidity in an existing AMM v4 pool — migration is a choice, not required; the pool continues to function as a pure AMM.
- You maintain an integration built against AMM v4 and have no reason to migrate.
Where to go next
- Accounts — the AMM’s accounts plus the OpenBook accounts it serves.
- Math — constant-product swap math with AMM v4’s fee convention.
- Instructions — the instruction surface:
Initialize,Swap,Deposit,Withdraw, crank helpers. - Fees — the 0.25% split and how it’s collected.
- Code demos — TypeScript examples for swap and LP flows.
reference/program-addressesfor the canonical program ID- OpenBook program repository for the counterparty accounts this page references


