Version banner.
- SDK:
@raydium-io/raydium-sdk-v2@0.2.42-alpha - Cluster: Solana
mainnet-beta - Stable AMM program ID:
5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h(seereference/program-addresses) - Last verified: 2026-04
liquidity module handles Stable AMM pools natively. Stable pools surface as version: 5 (or pooltype: "StablePool") on ApiV3PoolInfoStandardItem; the same addLiquidity / removeLiquidity / swap helpers work for them as for AMM v4 (version: 4) constant-product pools — the SDK detects the variant and emits the correct instructions automatically. The off-chain stable-curve math lives in src/raydium/liquidity/stable.ts.Setup
Identifying a Stable pool
Two equivalent signals onApiV3PoolInfoStandardItem:
version: 4, constant-product) and Stable AMM (version: 5) flow through the same LiquidityModule API on the SDK. Internally the module dispatches to:
InstructionType.AmmV4AddLiquidity/AmmV4RemoveLiquidityfor v4 poolsInstructionType.AmmV5AddLiquidity/AmmV5RemoveLiquidityfor v5 (Stable) pools
programId (returned with the pool keys) tells the SDK which program to CPI into; you do not need to hardcode it.
Find a pool by mint pair
Swap through a Stable pool
TheLiquidityModule.swap flow is the same shape as for v4 pools — just hand it a v5 pool object:
programId from the pool keys and dispatches into the Stable AMM program. No special programId argument is needed.
Add and remove liquidity
addLiquidity and removeLiquidity work identically across v4 and v5 pools:
InstructionType.AmmV5AddLiquidity because pooltype.includes("StablePool") is true. The corresponding removeLiquidity flow is symmetric — feed in lpAmount and the minimum amounts you will accept on each side.
Off-chain quote helpers (stable.ts)
For server-side quoting or backtesting, the SDK exposes the underlying stable-curve math:ModelDataInfo is fetched once by initLayout() and cached in raydium.liquidity.stableLayout. Pass current reserves (x, y) and the helpers compute by binary-searching the lookup table and linearly interpolating between the two surrounding DataElement rows. See products/stable/math for the underlying algorithm.
Routing through AMM Routing (multi-hop / best-price)
If you do not want to pick a venue yourself, the AMM Routing program will consider every Raydium AMM (v4 / CPMM / CLMM / Stable) and route through whichever combination is best:Recommendations
- For end-user swaps, prefer the
tradeV2routing flow. It handles every Raydium pool type including Stable. - For pool-specific operations (LP add / remove on a known Stable pool), use the
LiquidityModuledirectly — it auto-detects v5 pools. - For off-chain quoting / analytics, call
getStablePrice/getDyByDxBaseIn/getDxByDyBaseInafterinitLayout(). No RPC traffic per quote after the model data is cached. - Do not hand-encode raw
SwapBaseIninstructions. The 2026-06-22 upgrade removed the dead OpenBook accounts, so the new swap layout takes 9 accounts (the old 18-account layout still parses for backwards compatibility).Depositis now 12 accounts (old 14 compatible),Withdraw12 (old 21/22 compatible), andWithdrawPnl10 with no compatibility path. The SDK’s pre-built helpers select the correct layout and ordering for you; rolling your own is error-prone. Seeproducts/stable/instructionsfor the full account tables.
Where to go next
- Math — how the lookup-table interpolation works.
- Instructions — full instruction reference.
- AMM Routing — multi-pool routing across AMM v4, CPMM, CLMM, Stable.
raydium-sdk-V2/src/raydium/liquidity/liquidity.ts— module entry point; v4 / v5 dispatch.raydium-sdk-V2/src/raydium/liquidity/stable.ts—StableLayout,getStablePrice,getDxByDyBaseIn,getDyByDxBaseIn.

