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.
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 aModelDataInfo account — a 50,000-element array of DataElement structs. Each element holds:
valid_data_count elements are populated; the rest are zeroed. On swap, the program:
- Computes a ratio from the current pool reserves and uses binary search to find which two table elements bracket that ratio.
- Interpolates linearly between the two bracketing points to get the quote price.
- Applies fees (same 0.25% as AMM v4) and returns the result to the user.
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
| Dimension | Stable AMM | AMM v4 | CPMM |
|---|---|---|---|
| Curve | Lookup table + interpolation | Constant product (xy=k) | Constant product |
| Primary use case | Stablecoins, pegged pairs | General pairs, legacy deep liquidity | General pairs, new deployments |
| OpenBook dependency | Yes | Yes | No |
| Token-2022 | No | No | Yes |
| Slippage profile | Minimal at 1:1 | High at tight ratios | Moderate across range |
| Admin-tunable curve | Yes (UpdateModelData) | No (SetParams only) | No |
| Table size | ~50k elements × 24 bytes | N/A | N/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.
Where to go next
- Accounts —
AmmInfo,ModelDataInfo,DataElementfield reference. - Math — binary search, interpolation, and fee application.
- Instructions —
InitModelData,UpdateModelData, swap and LP instructions. - Fees — the 0.25% split (identical to AMM v4).
- Code demos — routing and direct integration.
reference/program-addressesfor the canonical program IDproducts/amm-v4/overviewfor OpenBook integration details


