> For the complete documentation index, see [llms.txt](https://docs.termina.technology/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.termina.technology/documentation/developer-docs-zh/liu-cheng/sheng-cheng-shu-ju-ji/yu-gou-jian-shu-ju-ji.md).

# 预构建数据集

#### 数据

与 bundle 类似，有一些预构建的数据集可以直接使用。借助它们，无需搭建重放流水线就能分析各交易场所的执行质量和流动性，即使是刚接触 Solana 编程模型的团队也可以上手。

更具体地说，这些数据集可以回答这样的问题：某个交易场所的报价在哪些地方与聚合器看到的不一致、每个池子在给定规模下的实际深度，以及该交易场所输掉了哪些 swap、价格是多少。

| 数据集        | 说明                                | 下载路径                            |
| ---------- | --------------------------------- | ------------------------------- |
| 链上深度       | 每个交易场所的流动性深度，直接根据链上池子状态计算。        | `datasets/depth/v2/`            |
| 聚合器深度      | 同一批交易场所在 Jupiter Metis 报价中的流动性深度。 | `datasets/depth-diagnostic/v2/` |
| 已执行 + 假设成交 | 实际执行的成交，以及各交易场所若赢得该 swap 本应获得的成交。 | `datasets/estimated_fills/v2/`  |

#### 数据结构

所有数据集均以 Parquet 格式存储，并按日期、市场和交易场所分区。每个数据集的路径模式见各自小节。

代币数量以基本单位表示（例如 SOL 为 9 位小数，BTC 为 8 位，USDC 为 6 位）。

<details>

<summary>链上深度</summary>

`datasets/depth/v{version_number}/date=YYYY-MM-DD/market={token_pair}/venue={venue}/part-{start_slot}-{end_slot}.parquet`

<table><thead><tr><th width="236.91796875">列</th><th>备注</th></tr></thead><tbody><tr><td>slot</td><td></td></tr><tr><td>input_token</td><td>代币符号（例如 SOL）</td></tr><tr><td>output_token</td><td></td></tr><tr><td>in_amount</td><td></td></tr><tr><td>out_amount</td><td></td></tr><tr><td>price_impact_bps</td><td>与第 0 档相比的汇率</td></tr><tr><td>trigger</td><td><ul><li>by grid：每个 slot 固定一次</li><li>by event：可能在 slot 内触发，也可能每隔几个 slot 触发一次</li></ul></td></tr><tr><td>rung_index</td><td>每一档的规模逐步翻倍；第 0 档为基准</td></tr></tbody></table>

</details>

<details>

<summary>聚合器深度</summary>

`datasets/depth-diagnostic/v{version_number}/date=YYYY-MM-DD/market={token_pair}/venue={venue}/part-{start_slot}-{end_slot}.parquet`

<table><thead><tr><th width="223.55859375">列</th><th>备注</th></tr></thead><tbody><tr><td>slot</td><td></td></tr><tr><td>router_slot</td><td>Jupiter Metis 响应时已处理到的 slot（可能落后于 <code>slot</code>）</td></tr><tr><td>pool</td><td>池子地址</td></tr><tr><td>router_label</td><td>池子的可读名称（例如 SolFi V2）</td></tr><tr><td>input_token</td><td>代币符号（例如 SOL）</td></tr><tr><td>output_token</td><td></td></tr><tr><td>in_amount</td><td></td></tr><tr><td>out_amount</td><td></td></tr><tr><td>usd_value</td><td>以 USD 计的 <code>in_amount</code></td></tr><tr><td>account_hashes</td><td>Metis 定价所依据的每个账户的指纹</td></tr><tr><td>quote_error</td><td>Metis 无法访问的原因</td></tr><tr><td>error</td><td>Metis 未返回价格的原因（例如池子流动性不足）</td></tr><tr><td>raw_entry</td><td>Metis 的完整 JSON 响应</td></tr></tbody></table>

</details>

<details>

<summary>已执行 + 假设成交</summary>

`datasets/estimated-fills/v1/date=YYYY-MM-DD/dex={program_id}/part-{start_slot}-{end_slot}.parquet`

<table><thead><tr><th width="284.50390625">列</th><th>说明</th></tr></thead><tbody><tr><td>slot</td><td></td></tr><tr><td>block_time</td><td>时间戳</td></tr><tr><td>swap_mode</td><td><ul><li>exact in：输入数量固定，输出数量变化（例如卖出正好 10 USDC）</li><li>exact out：输出数量固定，输入数量变化（例如收到正好 1 SOL）</li></ul></td></tr><tr><td>input_mint</td><td>代币符号（例如 SOL）</td></tr><tr><td>output_mint</td><td></td></tr><tr><td>amount</td><td>原始 swap 的数量</td></tr><tr><td>l1_fill</td><td>原始 swap 的成交量</td></tr><tr><td>l1_program</td><td>成交原始 swap 的 DEX 地址</td></tr><tr><td>l1_venue</td><td>DEX 的可读名称</td></tr><tr><td>input_amount</td><td><ul><li>当 <code>swap_mode</code> 为 exact out 时，等于 <code>l1_fill</code></li><li>当 <code>swap_mode</code> 为 exact in 时，等于 <code>amount</code></li></ul></td></tr><tr><td>output_amount</td><td><ul><li>当 <code>swap_mode</code> 为 时，等于 <code>l1_fill</code></li><li>当 <code>swap_mode</code> 为 时，等于 <code>amount</code></li></ul></td></tr><tr><td>original_failed</td><td>原始 swap 成功还是失败</td></tr><tr><td>quote_lag_blocks</td><td></td></tr><tr><td>estimate_fill</td><td>模拟交易场所版本的 <code>l1_fill</code></td></tr><tr><td>replay_input_amount</td><td>模拟交易场所的 <code>input_amount</code></td></tr><tr><td>replay_output_amount</td><td>模拟交易场所的 <code>output_amount</code></td></tr><tr><td>outcome</td><td><ul><li>模拟 swap 的结果</li><li>取值为 filled、reverted、unattributed、unsimulatable 之一</li></ul></td></tr><tr><td>category</td><td>模拟 swap 回滚的原因</td></tr></tbody></table>

</details>

#### 访问

数据集以 Parquet 文件的形式托管在 S3 上。先通过下方的认证 URL 获取凭证，然后按示例代码所示直接访问存储桶。

<table><thead><tr><th width="170.87890625"></th><th>URL</th></tr></thead><tbody><tr><td>数据集认证</td><td><pre><code>https://simulator.termina.technology/datasets/credentials
</code></pre></td></tr><tr><td>S3 存储桶</td><td><pre><code>s3://data.termina.technology
</code></pre></td></tr></tbody></table>

<details>

<summary>example_access.py</summary>

```python
import boto3
import requests

API_KEY = ""
AUTH_URL = "https://simulator.termina.technology/datasets/credentials"
DATA_URL = "data.termina.technology"

# 获取访问凭证
creds = requests.post(AUTH_URL, headers={"X-API-Key": API_KEY}).json()
print(f"creds: {creds.keys()}\n")

# 创建已认证的 s3 客户端
s3 = boto3.client(
    "s3",
    aws_access_key_id=creds["access_key_id"],
    aws_secret_access_key=creds["secret_access_key"],
    aws_session_token=creds["session_token"],
    region_name=creds["region"],
)

# 列出数据集中的所有 parquet 文件
resp = s3.list_objects_v2(Bucket=DATA_URL, Prefix="datasets/")
files = [obj["Key"] for obj in resp.get("Contents", [])]
print(files)
```

</details>
