> ## Documentation Index
> Fetch the complete documentation index at: https://docs.li.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# 示例

> LI.FI Intents MCP Server 的示例工作流、提示词以及端到端结算流程

## 示例工作流

### 跨链交换

从报价到结算的完整订单生命周期：

```
1. get-supported-routes          # Discover available routes
2. request-quote                 # Get pricing (chain names, symbols, or IDs all work)
3. prepare-order                 # Build order, auto-sign if key is configured
4. submit-order                  # Submit to order server
5. track-order                   # Monitor: Submitted -> Open -> Signed -> Delivered -> Settled
```

### 解算器运营

管理你的解算器存在状态并诊断问题：

```
1. register-solver               # Register wallet for reputation tracking
2. submit-standing-quotes        # Publish pricing for routes
3. get-quote-inventory           # Audit your published quotes
4. check-route-health            # Diagnose why orders aren't being filled
5. debug-order                   # Inspect a specific order's full lifecycle
```

***

## 示例提示词

这些提示词适用于任何连接到 LI.FI Intents MCP server 的、兼容 MCP 的 AI 工具。

### 发现路由

**提示词：** "LI.FI Intents 上有哪些可用的跨链路由？"

**调用的工具：** `get-supported-routes`

返回可用的链 + 代币对，包括费用、活跃状态和支持的结算方式。

### 获取报价

**提示词：** "帮我获取一份从 Ethereum 到 Base 的 5 USDC 报价，收款地址为 0x42fB...749b"

**调用的工具：** `request-quote`，带上链名、代币符号和接收地址。服务器在内部处理 EIP-7930 编码——无需将金额转换为最小单位。

### 提交订单

**提示词：** "根据那份报价准备并提交一个订单"

**调用的工具：**

1. `prepare-order` — 从缓存的报价构建 `StandardOrder`
2. AI 提示你使用 EIP-712 对订单签名
3. `submit-order` — 将已签名的订单提交到订单服务器

### 检查路由健康状况

**提示词：** "检查 Ethereum Sepolia 到 Base Sepolia 的 USDC 路由的健康状况"

**调用的工具：** `check-route-health` — 运行综合诊断，包括路由支持情况、报价库存和近期活动。可用于诊断为何订单未被履行。

### 调试订单

**提示词：** "调试订单 intent\_YaY\_b3qxF3..."

**调用的工具：** `debug-order` — 返回该订单的完整生命周期、两条链上的交易哈希、解算器信息以及结算状态。

***

## 端到端结算流程

要完成一次完整的跨链交换（不仅仅是提交订单，而是真正在链上转移代币），你需要：

1. **授权托管结算器**动用你的代币
2. 通过 MCP **请求报价、准备并提交**订单
3. 在链上向托管合约**存入资金**

存入后，解算器会接手该订单，在目标链上交付代币，然后结算自动完成。

### 步骤 1：代币授权

授权托管结算器合约动用你的输入代币。托管结算器地址在所有链上都相同：

```
0x00fC00edbe7C003b006f870068c548940000223e
```

使用 viem/TypeScript：

```typescript theme={"system"}
import { createWalletClient, http, parseAbi } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains"; // or baseSepolia for testnet

const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY");
const client = createWalletClient({ account, chain: mainnet, transport: http("YOUR_RPC_URL") });

const tx = await client.writeContract({
  address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // token address (e.g. WETH on mainnet)
  abi: parseAbi(["function approve(address spender, uint256 amount) returns (bool)"]),
  functionName: "approve",
  args: [
    "0x00fC00edbe7C003b006f870068c548940000223e", // escrow settler
    BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), // max approval
  ],
});
```

### 步骤 2：通过 MCP 提交订单

按顺序使用 MCP 工具：

```
1. request-quote    -> Get pricing (e.g., "0.001 WETH from Ethereum to Base")
2. prepare-order    -> Build + sign the order (auto-signs if SIGNER_PRIVATE_KEY is set locally)
3. submit-order     -> Submit to the LI.FI order server
```

提交后，订单状态为 `Signed`——但资金尚未在链上锁定。

### 步骤 3：存入托管

在托管结算器合约上调用 `open()` 来锁定你的代币。这会利用你之前的授权触发一次 `transferFrom`。

```typescript theme={"system"}
import { encodeFunctionData, createWalletClient, http, parseAbi } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";

const ESCROW_SETTLER = "0x00fC00edbe7C003b006f870068c548940000223e";

// The order object from prepare-order — pass the full encoded order bytes
const tx = await client.sendTransaction({
  to: ESCROW_SETTLER,
  data: encodeFunctionData({
    abi: parseAbi(["function open(bytes calldata order) external"]),
    functionName: "open",
    args: [orderBytes], // the encoded order from prepare-order
  }),
});
```

### 接下来会发生什么

托管一旦获得资金：

1. **解算器看到存款** 并在目标链上交付代币
2. 通过 Polymer 预言机自动完成 **结算**
3. **订单状态** 推进：`Signed -> Deposited -> Delivered -> Settled`

使用 `track-order` 监控完整的生命周期。典型的主网结算大约需要 10 分钟。

### 测试网 vs 主网

|             | 测试网                                                             | 主网                                |
| ----------- | --------------------------------------------------------------- | --------------------------------- |
| **链**       | Ethereum Sepolia、Base Sepolia、Optimism Sepolia、Arbitrum Sepolia | Ethereum、Base、Arbitrum、Optimism 等 |
| **代币**      | 测试网 USDC、测试网 WETH                                               | 真实 USDC、WETH、ETH 等                |
| **解算器可用性**  | 有限——可能没有活跃的解算器                                                  | 有活跃解算器在履行订单                       |
| **RPC**     | 公共 Sepolia RPC 可用                                               | 使用 Alchemy/Infura 以保证可靠性          |
| **MCP URL** | `https://intents-mcp-testnet.li.fi/mcp`                         | `https://intents-mcp.li.fi/mcp`   |
