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

# AMM 路由

> 一个程序，在单个交易中通过 CPI 在多个池（AMM v4、CPMM、CLMM、Stable）之间链式执行交换，使用用户控制的中间 ATA。

<Info>
  **本页内容由 AI 自动翻译，所有内容以英文版本为准。**

  [查看英文版 →](/products/routing/index)
</Info>

## 简介

AMM 路由程序是一个 CPI 路由器，在一个链上交易中执行跨 Raydium AMM 池的多跳交换。与其在客户端代码中捆绑 N 个子程序 CPI 不同，你可以调用路由器一次，并将路由作为账户列表传递。路由器将每跳分派给正确的池程序（AMM v4、CPMM、CLMM 或 Stable），并将一跳的输出链接为下一跳的输入。

**程序 ID**：见 [`reference/program-addresses`](/zh/reference/program-addresses)。

**Devnet**：`DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd`。

**账户模型**：每个中间代币都流经一个**用户拥有的 ATA**。用户使用其输入 ATA 签名，并在账户列表中提供每个中间 ATA。推荐的交换入口是标签 8（`SwapBaseIn`）和标签 9（`SwapBaseOut`），当不涉及 CLMM 跳时，它们接受空的 `limit_prices` 双端队列。

## 章节内容

<CardGroup cols={2}>
  <Card title="概述" icon="circle-info" href="/zh/products/routing/overview">
    路由器的功能、存在的原因以及何时应该使用它而不是客户端拼接。
  </Card>

  <Card title="账户" icon="database" href="/zh/products/routing/accounts">
    用户 ATA 布局、每跳账户块以及路由器如何通过读取程序 ID 槽来分派。
  </Card>

  <Card title="数学" icon="function" href="/zh/products/routing/math">
    路由器不进行数学运算。每跳从自己的曲线定价。滑点在跳间复合；CLMM 的 `limit_prices`。
  </Card>

  <Card title="指令" icon="terminal" href="/zh/products/routing/instructions">
    六个启用的指令变体的参考：精确输入/精确输出当前版本（8/9）和旧版本（0/1）交换，加上 wSOL 工具（5/6）。
  </Card>

  <Card title="费用" icon="percent" href="/zh/products/routing/fees">
    无路由器费用。每跳支付其基础程序的费用。CU 成本随跳数线性扩展。
  </Card>

  <Card title="代码示例" icon="code" href="/zh/products/routing/code-demos">
    使用 SDK 和原始指令构建的 TypeScript 示例。
  </Card>
</CardGroup>

## 何时阅读本文档

* 你需要在一个交易中执行 2 个或更多跳的路由。
* 你正在实现一个 CPI 进入路由器的程序。
* 你是一个聚合器，在客户端拼接和链上路由之间做决定。

## 接下来的去向

* [`products/routing/overview`](/zh/products/routing/overview) — 设计和动机。
* [`products/routing/instructions`](/zh/products/routing/instructions) — 完整的指令参考。
* [`integration-guides/routing-and-mev`](/zh/integration-guides/routing-and-mev) — 更广泛的路由策略。
* [`integration-guides/aggregator`](/zh/integration-guides/aggregator) — 何时在聚合器上下文中使用路由器。

来源：

* [`reference/program-addresses`](/zh/reference/program-addresses) 获取规范程序 ID
* `raydium-io/raydium-programs/raydium-route` 获取源代码
