Serve SDK-compatible order book snapshots from resident depth

This commit is contained in:
2026-12-03 07:24:13 +08:00
parent 5d82be0091
commit b1fe4c2fd5
10 changed files with 328 additions and 15 deletions
+25
View File
@@ -876,3 +876,28 @@ sequenceDiagram
E->>B: 用预算和保护价计算可成交数量
E-->>C: 估价返回预期成交,下单提交成功后返回实际成交
```
### 客户端读取订单簿快照
```mermaid
flowchart LR
entry["lib.rs"] --> catalog["catalog.rs"]
entry --> schema["book_snapshot_schema.sql"]
catalog --> snapshot["book_snapshot.rs"]
snapshot --> resident["resident.rs / matching"]
snapshot --> metadata["minimum_size.rs / tick_size.rs / quotes.rs"]
```
```mermaid
sequenceDiagram
participant C as 客户端
participant E as Exchange
participant D as SQLite
participant B as 常驻盘口
C->>E: clob_book(token_id)
E->>D: 同一读事务内读取变更、市场规格、时间和最近成交
E->>B: 应用已提交的订单增量,读取两边的聚合档位
B-->>E: 返回每档价格和总份额
E->>E: 转为协议字符串,最优档排最后,计算快照哈希
E-->>C: 快照、时间戳及 hash
```