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.
Two distinct concepts
Price impact and slippage are frequently conflated in UIs but refer to different things.-
Price impact is a deterministic property of a trade against a specific pool state. Given
(Δin, reserves), price impact is fully computable before the trade is submitted. - Slippage is the realized difference between the price you expected at quote time and the price you actually got at execution time. It is a function of latency, concurrent transactions, and block inclusion order — not of the pool math.
Formal definitions
Price impact
impact ≈ 2 · Δin / reserve_in for small trades. For CLMM: depends on how many ticks the trade crosses; often flat within the current tick range, jumping at each tick cross.
Realized slippage
Sizing minAmountOut and maxAmountIn
Every Raydium swap takes a slippage-protection bound:
SwapBaseInput(amount_in, min_amount_out)— exact-input, lower-bound the output.SwapBaseOutput(max_amount_in, amount_out)— exact-output, upper-bound the input.
minAmountOut is 2.5% below the pre-trade spot — the sum of impact and tolerance, essentially.
Recommended slippage tolerances
There is no single right number; the right bound depends on:- Pair stability. Stablecoin-stablecoin pools can safely use 0.1%. Volatile meme-pair pools often need 3–5% just to reliably land.
- Trade size. Larger trades have larger price impacts, so tolerance needs to scale with them to avoid reversion. The SDK’s auto-slippage defaults around
max(0.5%, 2 × price_impact)for this reason. - Block inclusion latency. Transactions that sit in the mempool for multiple blocks are exposed to more concurrent trades. Jito bundles and priority fees reduce this.
| Pair type | Default tolerance |
|---|---|
| Stable-stable (USDC-USDT, USDC-USDS) | 0.1% |
| Stable-major (USDC-SOL, USDC-BTC) | 0.5% |
| Major-major (SOL-BTC, SOL-ETH) | 1% |
| Volatile (meme tokens, illiquid long-tail) | 3–5% |
Differences across AMM types
CPMM
Price impact is smooth and continuous (closed-form2 · Δin / reserve_in). Slippage tolerance scales linearly with trade size.
AMM v4
Same curve math as CPMM, but the “effective reserves” include the pool’s OpenBook-posted limit orders. In practice this means:- Quoting off raw vault balances underestimates reserves and therefore overestimates impact.
- The SDK fetches
AmmInfoand sumsvault + on_book.free + on_book.lockedto get the right number. - Stale OpenBook state (crank blocked) can cause the quoted impact to diverge from on-chain reality. Aggregators routinely pre-crank (permissionless
MonitorStep) before a large AMM-v4 trade.
CLMM
Price impact is piecewise. Within the current tick range, impact is approximately linear inΔin / L. Crossing a tick boundary can change L discretely, causing a sudden jump in the marginal price. A trade that crosses several sparsely-populated ticks can have much higher impact than the 2 · Δin / reserve rule of thumb suggests.
The SDK’s CLMM quote iterates the swap step deterministically to return an exact expected amountOut, so minAmountOut = amountOut · (1 − slippage) is correct. But the priceImpact return value should be interpreted as “the spread between pre-trade spot and post-trade spot”, which on CLMM can be much larger than the swap’s effective slippage for a user who only cares about amount_out.
LaunchLab curve
Similar to CPMM but with an asymmetric curve (quadratic or virtual-reserves). Impact grows faster for late buyers as the curve steepens toward graduation. Pre-buyer UIs should warn when a buy is expected to push the curve more than ~5% ofquote_reserve_target in one transaction.
MEV considerations
On Solana, MEV extraction against swaps mostly takes the form of sandwich attacks: a bot places a back-run transaction that trades after yours, plus a front-run that trades before, both at the same slot. Your trade fills at a worse price than it would have absent the sandwich; the back-run captures the difference. Mitigations:- Tight
minAmountOut. Aggressive slippage bounds cause the victim transaction to revert if sandwiched heavily, protecting funds (but wasting gas). On Solana this is standard practice — rejection is cheap. - Jito bundles. Submitting through Jito with a bundled tip excludes middlemen from reordering your tx. Bundles land as atomic blocks.
- Priority fees. A high priority fee increases the chance your trade lands in the current leader’s block before a sandwicher can react. Less robust than bundles, more standard.
- Private RPC. Submitting through a private RPC (or via a validator’s direct endpoint) reduces the window during which a mempool sandwicher can observe your transaction.
integration-guides/routing-and-mev for patterns.
Slippage for multi-hop routes
When a swap routes through multiple pools (e.g.USDC → SOL → RAY), slippage tolerance should be applied per-hop, not just end-to-end:
raydium.trade.swap. For custom routers, replicate the pattern.
Reporting to users
Rules-of-thumb for a good swap UI:- Display both expected price impact and slippage tolerance separately.
- Highlight when price impact exceeds ~2% — “high impact” warning.
- Highlight when price impact exceeds tolerance — the transaction is almost certain to revert.
- For volatile pairs, offer a “high slippage mode” that relaxes the bound and shows a stronger warning.
Pointers
products/cpmm/math,products/amm-v4/math,products/clmm/math— impact derivations per pool type.integration-guides/routing-and-mev— multi-hop routing + MEV defenses.integration-guides/priority-fee-tuning— sizing priority fees to reduce slippage.
- Raydium SDK v2 slippage / impact implementation.
- Flashbots / Jito on Solana MEV.


