For the complete documentation index, see llms.txt. This page is also available as Markdown.

直接重路由到交易场所

要将每一笔历史成交与某个交易场所在赢得该 swap 时的成交结果进行比较,请使用 sim run 命令,将重路由模式设为 venue,并提供一个模板文件。模板定义了模拟器如何与该交易场所集成,以及要包含哪个交易对。

sim run \
  --start-slot 400000000 \
  --end-slot 400010000 \
  --reroute-order-flow venue \
  --venue-templates <FILE>
template.json
[
  {
    "label": "pool/my-pool/usdc-to-token",
    "mode": "ExactIn",
    "inputMint": "<USDC>",
    "outputMint": "<TOKEN>",
    "instruction": {
      "programId": "<PROGRAM_ID>",
      "accounts": [
        {"address": "<SIGNER>", "writable": true, "signer": true},
        {"address": "<ADDRESS_A>", "writable": true},
        {"address": "<ADDRESS_B>", "writable": true},
        {"address": "<POOL_ADDRESS>", "writable": true},
        {"address": "<VAULT_A>", "writable": true},
        {"address": "<VAULT_B>", "writable": true}
      ],
      "data": {"data": "<ENCODED_SWAP_INSTRUCTION>", "encoding": "base64"}
    },
    "amountOffset": 8,
    "taker": {"user": [0], "inputTokenAccount": 1, "outputTokenAccount": 2}
  }
]

这能显示该交易场所在价格上是否会赢,但不能显示路由器是否真的会把该 swap 路由给它。

这种模式通常用于 DEX 尚未接入任何聚合器的情况,但也适合在不受聚合器路由决策影响的前提下,比较交易场所报价的竞争力。换句话说,它反映的是 “真实的现实”,而不是 “路由器眼中的现实”。

最后更新于