Raydium

Raydium tutorial is a practical Solana swap-routing and slippage setup

Updated:

Raydium tutorial is a step-by-step Solana token swap procedure for comparing pool routes, setting slippage tolerance, and enforcing a minimum received amount before the wallet signature. Connect a compatible wallet, select the exact mint addresses, enter the input amount, inspect every route hop and fee, then choose a tolerance the trade can accept. Raydium submits an atomic swap transaction: every swap instruction succeeds together, or the token exchange does not settle.

Run the swap from quote to settlement

At a protocol level, Raydium swap execution follows a six-stage path: connect a wallet, confirm both mints, enter an amount, inspect the route, set transaction controls, and approve the transaction.

Prepare the wallet and token pair

Connect Phantom or Solflare, including a Ledger-backed account if used. Leave SOL available for network charges and new token accounts.

Build and inspect the quote

Choose input and output assets by mint address, not ticker alone. Enter the amount, then read the quoted output, price impact, pool fee, and every intermediate token. A SOL-to-RAY route might pass through USDC when that path returns more RAY after pool costs. The eligible pool set includes CPMM, CLMM, and AMM v4 pools, so the route label matters as much as the pair.

Set protections and sign

Set the minimum received through slippage tolerance, choose the priority fee, and inspect the wallet summary. After signing, wait for confirmation, then compare the input and output balance changes in Solscan or Solana Explorer. One transaction may contain several swap instructions and associated token-account instructions. Solana executes those instructions atomically, preventing a route from settling only its first hop.


Separate pool fees from network costs

Raydium swap cost has three separate drivers: the fee charged by each selected pool, the Solana transaction fee, and any Token-2022 transfer fee attached to a mint.

After the first pass, Raydium AMM v4 charges a 0.25% trade fee on the swap input and allocates 88% of that fee to liquidity providers. Raydium CLMM defines four standard base fee tiers: 0.01%, 0.05%, 0.25%, and 1%. CPMM reads its rate from the pool’s AmmConfig, so the quote, not a hard-coded assumption, controls the calculation. A two-hop route pays each pool’s fee once, while the routing layer adds no separate router fee. Since 100 basis points equal 1%, a 25-basis-point tier equals 0.25% of the fee-bearing amount.

Pool fees reduce the amount entering each curve. The Solana charge is paid separately in SOL, even when both traded assets are tokens.

How does Raydium choose a swap route?

Taken together, Raydium chooses the eligible route producing the highest quoted output after pool fees and price impact, then presents the path as one pool, multiple hops, or a split allocation.

CPMM and AMM v4 apply constant-product pricing, while CLMM concentrates liquidity in tick ranges. A direct SOL/USDC CLMM pool beats a direct CPMM pool when active liquidity near the traded price produces more output. The route SOL → USDC → RAY combines two pools and wins when their depth offsets the extra fee. The router orchestrates instructions; it does not replace the pool math.

Read the route from left to right. Count the hops, identify each pool type, and compare expected output after costs. Price impact measures how much the swap itself shifts the pool quote; slippage tolerance covers movement between quotation and execution. They are different numbers. A split route allocates 100% of the input across two or more parallel paths when their combined output beats either path alone. The allocation changes with the amount because depth is not uniform across pools.


Turn slippage into a minimum received amount

After that point, Raydium slippage tolerance converts the displayed output into a hard minimum, and the transaction reverts if the final route would deliver less than that threshold.

Convert tolerance into the threshold

The formula is expected output × (1 − tolerance). A quote of 100 USDC with 0.5% tolerance sets 99.5 USDC as the minimum. At 1%, the same quote sets 99 USDC. The tolerance is not an added fee, and raising it does not improve the quoted rate. It widens the acceptable execution range. Use the wallet’s minimum received field as the binding figure because the percentage alone hides rounding to the token’s smallest unit and any route-specific accounting. Raydium encodes that threshold in the transaction.

Handle multiple hops

Slippage compounds across sequential changes. Two successive 1% reductions retain 98.01% of the starting amount, an effective 1.99% reduction rather than 2%. Raydium enforces the final minimum across the route. A CLMM price-limit parameter also bounds the pool price when supplied. Requote when the displayed route changes because the old threshold belongs to the old path.

Compare one-hop, multi-hop, and split routes

Route comparison should prioritize final output, price impact, pool fees, account complexity, and freshness, rather than assuming the shortest path always produces the strongest quote. A one-hop route pays one pool fee and uses fewer accounts. A two-hop route pays two pool fees but wins when deeper intermediate pools offset those costs. A split route divides 100% of the input across at least two paths and recombines the outputs. The Raydium tutorial treats the highest acceptable minimum received as the deciding field, provided every intermediate mint is understood.


Set priority fees without changing the quote

Solana priority fees affect transaction scheduling, not Raydium’s exchange rate, so set them from network demand and transaction compute rather than from token volatility alone.

Solana charges a base fee of 5000 lamports per signature, and one SOL contains 1,000,000,000 lamports. The optional priority fee equals compute-unit price multiplied by compute-unit limit, divided by 1,000,000 because the price uses micro-lamports. Solana assigns 200,000 compute units per non-built-in instruction by default and caps a transaction at 1,400,000 compute units. Raydium’s automatic priority setting estimates a price; a higher setting improves scheduling probability but does not improve output. Compare the quoted network charge in the wallet with the minimum received before approving.


What should you do when a swap fails?

A failed Raydium swap needs one diagnosis before another signature: distinguish an exceeded minimum, an expired blockhash, insufficient SOL, and a possible token-account display delay.

Exceeded minimum amount

Refresh the quote first. If the route changed, compare its new output and set a tolerance from the minimum received, not from repeated retries.

Expired or delayed transaction

A standard Solana transaction uses a recent blockhash with a processing age of 150 slots. If it expires without landing, build and sign a fresh transaction; raising slippage does not solve scheduling. Increase the priority setting only when delayed inclusion caused the stale quote. A transaction failing after processing still pays its network fee, while Raydium rolls back the swap instructions atomically.

Token balance and account checks

Open the signature in Solscan or Solana Explorer. Confirm success, signer, input decrease, and output increase. Phantom and Solflare may hide a newly created associated token account until the wallet refreshes. Refresh the wallet token list after the explorer records success. The other half of this is described in Raydium limits.


Handle Token-2022 details before final approval

Token-2022 swaps require one extra review because a mint-level transfer fee sits outside Raydium’s pool fee and changes the balance reaching or leaving the pool.

SPL Token and Token-2022 identify assets by mint address. Token-2022 expresses a transfer fee in basis points over a 10,000-unit denominator and also stores a maximum fee cap. A 100-basis-point setting equals 1%. The mint can hold two fee configurations across an epoch transition. Raydium CPMM supports transfer-fee mints, and CLMM handles them through SwapV2 accounts; AMM v4 does not support Token-2022. The route quote must expose what the wallet sends and receives after these token-level deductions.

Use this pre-signing decision checklist when the pair is volatile, unfamiliar, or routed through more than one pool.

  • Match both mint addresses when tickers are duplicated.
  • Reject a route when its intermediate mint is not an asset you intend to touch.
  • Compare minimum received after pool and Token-2022 transfer fees.
  • Use a fresh quote after changing the input amount or slippage tolerance.
  • Keep SOL for the signature fee and any new associated token account.
  • Reduce the input when price impact outweighs the improvement from a multi-hop route.

Approve only after the route, minimum, network charge, and wallet instructions agree. The final wallet screen keeps every cost driver visible together.

Raydium wordmark above swaps, yield, and liquidity slogans

Raydium tutorial: reader questions

Can a Ledger account sign a Raydium swap through Phantom?

A Ledger account can sign a Raydium swap through Phantom when the hardware wallet holds the connected Solana address. Build the quote in Raydium, review the transaction in Phantom, and approve it on Ledger. The account still needs SOL for network fees and any associated token account creation.

When can a signed Raydium swap no longer be cancelled?

A submitted Raydium swap cannot be cancelled through a replacement transaction; it either lands while its recent blockhash remains valid or expires, so wait for a confirmed status or blockhash expiry before signing a fresh quote with a new transaction signature from the connected wallet.

Does a Raydium swap work from an exchange deposit address?

An exchange deposit address cannot act as the signing wallet for a Raydium swap because the exchange controls its private keys. Withdraw the tokens to a self-custody Solana wallet such as Phantom or Solflare, retain SOL for fees, and initiate the swap only from an address able to approve the transaction.

Is a memo required when swapping tokens on Raydium?

Raydium swaps do not require a memo for the exchange itself. The wallet signs program instructions identifying token accounts, amounts, and route limits. A memo becomes relevant only when a separate recipient, such as a centralized exchange, requires one for a later deposit; that requirement does not alter the Raydium transaction.

What happens when the output token account does not exist yet?

Raydium can include creation of the associated token account in the same Solana transaction before delivering the output asset. The wallet pays the account’s rent-exempt balance and transaction fee in SOL. Review the wallet instructions and total SOL charge, because the first swap into a mint costs more than a swap using an existing account.