Skip to main content

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.

What it is

The AMM Routing program is a CPI router that executes multi-hop swaps across Raydium’s AMM pools in one on-chain transaction. Instead of bundling N child-program CPIs in your client code, you can invoke the router once and pass the route as a list of accounts. The router dispatches each hop to the correct pool program (AMM v4, CPMM, CLMM, or Stable) and chains the output of one hop as the input to the next. Program ID: see reference/program-addresses. Devnet: DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd. Account model: every intermediate token flows through a user-owned ATA. The user signs with their input ATA and provides each intermediate ATA in the accounts list. The recommended swap entrypoints are tag 8 (SwapBaseIn) and tag 9 (SwapBaseOut), which accept an empty limit_prices deque when no CLMM hop is involved.

Chapter contents

Overview

What the router does, why it exists, and when you should use it vs. client-side stitching.

Accounts

User-ATA layout, per-hop account block, and how the router dispatches by reading the program ID slot.

Math

The router does no math. Each hop prices off its own curve. Slippage compounds over hops; limit_prices for CLMM.

Instructions

Reference for the six enabled instruction variants: exact-input / exact-output Current (8 / 9) and Legacy (0 / 1) swaps, plus the wSOL utilities (5 / 6).

Fees

No router fee. Each hop pays its underlying program’s fee. CU cost scales linearly with hop count.

Code demos

TypeScript examples using the SDK and raw instruction building.

When to read this

  • You need to execute a route with 2+ hops in one transaction.
  • You are implementing a program that CPIs into the router.
  • You are an aggregator deciding between client-side stitching and on-chain routing.

Where to go next

Sources: