> For the complete documentation index, see [llms.txt](https://docs.velio.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.velio.xyz/documentation/zh-tw/security/design-rationale.md).

# 設計理念

為什麼採用這套架構？

永續合約交易同時面對兩種需求：交易系統需要持續處理訂單與風險變化，帳戶記錄則需要有可供核對的依據。從使用者發出指令，到資產與持倉更新，再到鏈上確認，每個環節承擔的工作並不相同。

Velio Fabric 的設計思路，是將交易執行、帳戶狀態證明與鏈上確認分開，再以同一份帳戶狀態變更將它們連接起來。這讓執行系統專注處理交易，也讓帳戶更新有明確的驗證流程。

### 讓交易執行專注於市場操作

訂單撮合、風險檢查與持倉更新需要緊密協作。把這些工作放在鏈下執行層，可以將交易處理與主鏈的確認節奏分開安排；帳戶變更再進入後續證明與驗證流程。

### 為帳戶變更提供可驗證的依據

帳戶餘額與持倉是交易結果的核心記錄。ZK 對帳電路將更新前後的狀態、變更事件與所需授權連結起來，讓鏈上合約能核對這次帳戶更新是否符合電路定義的關係。

### 以鏈上確認建立共同的狀態基準

執行結果產生後，仍需要一個明確的接受步驟。驗證合約在證明通過後更新狀態根，為後續更新提供共同的起點。執行完成與鏈上確認的區分，也讓每個階段的責任更清楚。

### 讓證明與資料各自發揮作用

證明用來核對狀態變更，重建帳戶則需要實際資料。因此，架構另外將帳戶變更寫入 DA 層。在具備起始狀態與完整的帳戶變更資料時，可以沿著變更記錄重建帳戶狀態。

### 分工之後，如何連成完整流程？

執行層產生帳戶變更，證明引擎核對變更，鏈上合約接受通過驗證的新狀態。這些模組透過狀態與事件資料銜接，形成從交易操作到帳戶狀態確認的完整路徑。

1. **執行交易**：處理指令與帳戶變更
2. **產生證明**：核對變更與所需授權
3. **鏈上確認**：接受通過驗證的狀態

三個階段分工運作，以帳戶狀態變更相互銜接。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.velio.xyz/documentation/zh-tw/security/design-rationale.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
