in-solana by Supanode

Raydium AMM V4 — Program ID & Overview

675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8

Raydium AMM V4 is a constant-product (x*y=k) automated market maker on Solana. It was the first major AMM on Solana and remains widely used for token launches and liquidity bootstrapping.

Program ID

675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8

Pool structure

Each AMM V4 pool consists of:

AccountDescription
AMM accountPool state: nonce, token balances, fees
Pool token mintLP token mint address
Token A vaultSPL Token account holding token A reserves
Token B vaultSPL Token account holding token B reserves
OpenBook marketLinked OpenBook (Serum) orderbook market

AMM V4 pools are linked to an OpenBook market, which provides on-chain orderbook liquidity alongside the AMM curve.

Key instructions

InstructionDescription
InitializeCreates a new AMM pool linked to an OpenBook market
SwapBaseInSwap a fixed input amount for variable output
SwapBaseOutSwap variable input for a fixed output amount
DepositAdd liquidity to the pool, receive LP tokens
WithdrawRemove liquidity, burn LP tokens

Swap mechanics

AMM V4 uses the constant-product formula with fees:

amountOut = (reserveOut * amountIn * (10000 - feeBps)) / (reserveIn * 10000 + amountIn * (10000 - feeBps))

Default swap fee is 25 basis points (0.25%).

Finding pool accounts

Pool accounts for a token pair can be found by querying the AMM program’s accounts with the correct discriminator and token mint filters.

const RAYDIUM_AMM_V4 = new PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8");

const accounts = await connection.getProgramAccounts(RAYDIUM_AMM_V4, {
  filters: [
    { dataSize: 752 },
    { memcmp: { offset: 400, bytes: tokenAMint.toBase58() } },
    { memcmp: { offset: 432, bytes: tokenBMint.toBase58() } },
  ],
});

FAQ

Is Raydium AMM V4 still actively used? Yes. Despite newer pool types (CLMM, CPMM), AMM V4 remains the default for new token launches on Raydium and is heavily used by trading bots.

What is the relationship between AMM V4 and OpenBook? Each AMM V4 pool is linked to an OpenBook market. The AMM places orders on the orderbook to provide deeper liquidity. This hybrid model is unique to Raydium’s V4 design.

How much are the fees? The standard swap fee is 0.25% (25 bps). Of this, 0.22% goes to LPs and 0.03% goes to RAY buybacks.

Updated: