Overview of Raydium Swap System
Raydium’s swap system is the mechanism by which users exchange one token for another through liquidity pools on Solana. Unlike traditional centralized exchanges, Raydium’s model is permissionless and executed by smart contracts. :contentReference[oaicite:0]{index=0}
At the heart of its advanced architecture is the **Concentrated Liquidity Market Maker (CLMM)**, a system that allows more precise liquidity placement around active price ranges. This enhances capital efficiency and reduces price slippage for traders. :contentReference[oaicite:1]{index=1}
What Is CLMM (Concentrated Liquidity)?
In a CLMM pool, liquidity providers (LPs) don’t place liquidity across the entire price curve (0 to ∞). Instead, they choose a narrower range in which the liquidity is active. When the market trades within that range, the LP earns fees; if it exits, the position becomes inactive. :contentReference[oaicite:2]{index=2}
This design contrasts with standard constant-product AMMs where liquidity is spread uniformly, often resulting in less efficiency and greater price impact. :contentReference[oaicite:3]{index=3}
How Swapping Works in Raydium CLMM
When a user initiates a swap, the smart contracts determine the best path through CLMM pools and (if needed) standard AMM pools to optimize execution. Raydium’s routing logic may traverse multiple pools to reduce slippage. :contentReference[oaicite:4]{index=4}
Each swap transaction involves:
- Querying pool prices and liquidity depth
- Calculating price impact and slippage
- Constructing transaction instructions (possibly via Raydium’s trade API) :contentReference[oaicite:5]{index=5}
- Submitting the transaction to the Solana network
For example, Raydium offers a “clmm-swap” API endpoint to build unsigned transactions for swaps via CLMM pools. :contentReference[oaicite:6]{index=6}
Fees, Price Impact, and Slippage
Raydium charges fees on swaps, which vary depending on whether the swap is executed in a CLMM or AMM-type pool. In CLMM pools:
- 84% of fees go to liquidity providers
- 12% are used to buy back the RAY token
- 4% go to the protocol treasury
Price impact refers to how much a trade moves the market price due to the size relative to liquidity in the pool. Larger trades in low-liquidity pools will face higher price impact. :contentReference[oaicite:8]{index=8}
Slippage tolerance is a user-set parameter — if the market moves further than allowed, the swap will revert. Users pick this to avoid executing trades at extremely unfavorable rates. :contentReference[oaicite:9]{index=9}
How to Provide Liquidity in CLMM Pools
To function properly, the swap system needs active liquidity. Here's how LPs can contribute:
- Go to the “Liquidity” section in Raydium’s UI.
- Choose tokens and a pool, or create a new CLMM pool. :contentReference[oaicite:10]{index=10}
- Set a price range (min and max). Only within this range will the liquidity be active. :contentReference[oaicite:11]{index=11}
- Deposit matched amounts of both tokens according to the price range ratio.
- Confirm and mint an NFT representing your liquidity position. :contentReference[oaicite:12]{index=12}
LPs can later adjust (add or remove liquidity) or change the price range (by closing current position and opening a new one). :contentReference[oaicite:13]{index=13}
Advantages & Tradeoffs
The CLMM-based swap system offers several advantages:
- Higher capital efficiency: liquidity focused near active trades
- Reduced slippage: better execution even for moderately large trades
- Custom fee tiers: creators can choose fee levels (0.01% → 1%) :contentReference[oaicite:14]{index=14}
But there are tradeoffs:
- Impermanent loss can be more pronounced if the price exits your chosen range :contentReference[oaicite:15]{index=15}
- Greater management overhead: LPs must actively monitor and adjust ranges
- Switching or extending ranges requires closing and reopening positions (costs gas) :contentReference[oaicite:16]{index=16}
FAQs – Raydium CLMM Swap System
What is CLMM in Raydium?
CLMM stands for Concentrated Liquidity Market Maker — a system where liquidity providers choose a price range where their liquidity is active, enhancing capital efficiency. :contentReference[oaicite:17]{index=17}
How do I swap tokens using CLMM?
You initiate a swap via Raydium UI or API. The system will route through CLMM pools (or fallback to AMM if needed) and generate transaction instructions. :contentReference[oaicite:18]{index=18}
Can anyone create a CLMM pool?
Yes. Users or projects can create CLMM pools by selecting tokens, fee tier, and initial price range. :contentReference[oaicite:19]{index=19}
What happens if price moves outside my range?
Your liquidity becomes inactive — it no longer earns fees until the price returns within your range. :contentReference[oaicite:20]{index=20}
Why does Raydium use CLMM instead of just traditional AMM?
CLMM offers better capital efficiency and deeper liquidity around active prices, which is beneficial for both traders and LPs. :contentReference[oaicite:21]{index=21}