Skip to main content

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

Stable AMM is a variant of Raydium’s AMM that trades a curve formula for a pre-populated lookup table. Instead of using x·y=k, the pool stores a sparse array of (x, y, price) points and uses binary search + linear interpolation to quote prices. This design excels at stablecoin pairs and other assets with known price relationships: swaps between 1-to-1 pegged tokens have near-zero slippage. Like AMM v4, it ties to an OpenBook market and posts limit orders there. Liquidity is currently thin; most integrators access Stable pools through the AMM Routing program.

Why a lookup table instead of xy=k

Constant-product AMMs incur high slippage on pairs with tight price bands. A USDC-USDT swap should cost almost nothing; on a constant-product pool, k=x·y forces a price move even for tiny volume. A lookup table lets the pool admin express the actual price relationship:
  • For stablecoins: density the table around 1:1 so micro-swaps cost ~0 slippage.
  • For collateralized pairs: encode the target ratio and let the grid shape the fee/incentive surface.
The table is static between UpdateModelData calls (which the admin posts when the relationship changes), so the on-chain cost is just interpolation search — much cheaper than recomputing a formula.

How it works: the model-data account

The pool holds a ModelDataInfo account — a 50,000-element array of DataElement structs. Each element holds:
DataElement {
  x: u64,           // table X coordinate
  y: u64,           // table Y coordinate
  price: u64,       // price at (x, y)
}
Only the first valid_data_count elements are populated; the rest are zeroed. On swap, the program:
  1. Computes a ratio from the current pool reserves and uses binary search to find which two table elements bracket that ratio.
  2. Interpolates linearly between the two bracketing points to get the quote price.
  3. Applies fees (same 0.25% as AMM v4) and returns the result to the user.
The multiplier field on the table accounts for the possibility that x and y are stored at a reduced scale (e.g., with 6 decimals instead of 18). Price discovery rescales accordingly.

Comparison: Stable AMM vs. AMM v4 vs. CPMM

DimensionStable AMMAMM v4CPMM
CurveLookup table + interpolationConstant product (xy=k)Constant product
Primary use caseStablecoins, pegged pairsGeneral pairs, legacy deep liquidityGeneral pairs, new deployments
OpenBook dependencyYesYesNo
Token-2022NoNoYes
Slippage profileMinimal at 1:1High at tight ratiosModerate across range
Admin-tunable curveYes (UpdateModelData)No (SetParams only)No
Table size~50k elements × 24 bytesN/AN/A
Compute per swap~5k–15k CU (binary search + interpolation)~150k–200k CU~60k–100k CU
Account count per swap~17 (AMM + OpenBook)~18 (AMM + OpenBook)~11

Mental model

A Stable AMM pool is an interpolated lookup-table AMM whose vaults also escrow OpenBook limit orders, just like AMM v4. The key difference is that the price discovery curve is not hardcoded — it is a sparse array that the admin can populate and update. Operations are similar to AMM v4: direct swap (user ↔ pool), deposit / withdraw (LP ops), crank (MonitorStep), and admin upkeep (UpdateModelData, SetParams).

When Stable AMM is the right choice

  • You operate a stablecoin or other correlated-asset pair and want tight, predictable pricing.
  • You have deep knowledge of your pair’s price relationship and want to encode it directly as a curve.
  • You already have integrations for AMM v4 and simply need a different curve flavor.
For a fresh, general-purpose pool with no tight-correlation requirement, CPMM is the simpler and more liquid default.

Where to go next

  • AccountsAmmInfo, ModelDataInfo, DataElement field reference.
  • Math — binary search, interpolation, and fee application.
  • InstructionsInitModelData, UpdateModelData, swap and LP instructions.
  • Fees — the 0.25% split (identical to AMM v4).
  • Code demos — routing and direct integration.
Sources: