> ## 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.

# Stable AMM overview

> Stable AMM is a standalone Raydium program that replaces the constant-product curve with an interpolated lookup table, reducing slippage for correlated assets.

## One-paragraph summary

Stable AMM is a **standalone Raydium program** — its own deployment, not a mode of AMM v4 — 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. It is a **pure AMM**: all liquidity sits in the pool's own vaults. (It carried an OpenBook market-making path early in its life, but that path has been dormant for years; the [2026-06-22 upgrade](/reference/changelog) finally removed the dead market code.) Liquidity is currently thin; most integrators reach Stable pools through the [AMM Routing program](/products/routing).

## 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 now **fixed** — it was populated historically via the `UpdateModelData` instruction, which has since been removed, so existing pools keep their tables as-is. 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

| 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    | **No** (market path long dormant; dead code removed 2026-06) | **Yes**                              | No                             |
| Token-2022             | No                                                           | No                                   | Yes                            |
| Slippage profile       | Minimal at 1:1                                               | High at tight ratios                 | Moderate across range          |
| Admin-tunable curve    | No longer (`UpdateModelData` removed; tables now fixed)      | 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 | 9 (new layout; 18 old-compat)                                | \~18 (AMM + OpenBook)                | \~11                           |

## Mental model

A Stable AMM pool is an **interpolated lookup-table AMM** that holds all of its liquidity in its own vaults. The key difference from a constant-product pool is that the price-discovery curve is not hardcoded — it is a sparse array baked into the pool's `ModelDataInfo` account. The currently callable operations are **direct swap** (user ↔ pool), **deposit / withdraw** (LP ops), and **`WithdrawPnl`** (admin fee sweep). The OpenBook crank (`MonitorStep`) — long dormant since the pool stopped posting orders — and the pool-setup/admin instructions have been removed.

## 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](/products/cpmm) is the simpler and more liquid default.

## Where to go next

* [Accounts](/products/stable/accounts) — `AmmInfo`, `ModelDataInfo`, `DataElement` field reference.
* [Math](/products/stable/math) — binary search, interpolation, and fee application.
* [Instructions](/products/stable/instructions) — the callable set (swap, deposit, withdraw, `WithdrawPnl`) and the removed instructions.
* [Fees](/products/stable/fees) — the 0.25% split (identical to AMM v4).
* [Code demos](/products/stable/code-demos) — routing and direct integration.

Sources:

* [`reference/program-addresses`](/reference/program-addresses) for the canonical program ID
* [`reference/changelog`](/reference/changelog) for the 2026-06-22 market-code-removal upgrade
