架構概述
CloudBank是BNB智慧鏈(BSC)上的去中心化預測市場平台。該系統使用戶能夠使用二元 (YES/NO) 和多結果市場對現實世界事件的結果進行交易,並透過 AI 支援的結算和無 Gas 交易。
系統架構
┌─────────────────────────────────────────────────────────────┐
│ Frontend Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Web App │ │ Admin │ │ Presale │ │ Docs │ │
│ │ React 19 │ │ Ant Dsn │ │ Next.js │ │VitePress │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └──────────┘ │
│ │ │ │ │
├───────┼──────────────┼──────────────┼────────────────────────┤
│ │ Backend Layer │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ Custodial Wallet Service │ │
│ │ Go + Gin + GORM + JWT │ │
│ │ ┌─────────┐ ┌────────────────┐ │ │
│ │ │Orderbook│ │ Signing/Auth │ │ │
│ │ │ Engine │ │ EIP-191/712 │ │ │
│ │ └─────────┘ └────────────────┘ │ │
│ └──────────┬───────────────────────────┘ │
│ │ │
├─────────────┼────────────────────────────────────────────────┤
│ │ Smart Contract Layer │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ BSC (BNB Smart Chain) │ │
│ │ ┌──────────┐ ┌────────────────┐ │ │
│ │ │ Factory │ │ Optimistic │ │ │
│ │ │ Registry │ │ Controller │ │ │
│ │ └──────────┘ └────────────────┘ │ │
│ │ ┌──────────┐ ┌────────────────┐ │ │
│ │ │ Binary │ │ Sora Oracle │ │ │
│ │ │ CPMM │ │ + Adapters │ │ │
│ │ └──────────┘ └────────────────┘ │ │
│ │ ┌──────────┐ ┌────────────────┐ │ │
│ │ │ Gnosis │ │ Verifying │ │ │
│ │ │ CTF │ │ Paymaster │ │ │
│ │ └──────────┘ └────────────────┘ │ │
│ └──────────────────────────────────────┘ │
│ │
├──────────────────────────────────────────────────────────────┤
│ Indexing Layer │
│ ┌──────────────────────────────────────┐ │
│ │ The Graph (Goldsky hosted) │ │
│ │ AssemblyScript mappings │ │
│ │ GraphQL API │ │
│ └──────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘技術堆疊
| Layer | Technology | Purpose |
|---|---|---|
| 智能合約 | Solidity ^0.8.19,鑄造廠 | 市場邏輯、AMM、預言機、出納員 |
| 後端 | 去 1.23,杜松子酒,GORM | 託管錢包、訂單引擎、簽名 |
| 前端 | 反應19,Vite,TanStack | 交易 UI,管理面板 |
| 預售 | Next.js 16,瓦格米 | 節點預售申請 |
| 資料庫 | MySQL (GORM),Redis | 使用者資料、會話、速率限制 |
| 索引 | 圖表,Goldsky,AssemblyScript | 鏈上事件索引,GraphQL API |
| 基礎設施 | GitHub 操作、Cloudflare 頁面、EC2 | CI/CD,靜態託管,後端部署 |
| 錢包 | 瓦格米、維姆、EIP-191/712 | 錢包連接、簽名 |
| AA | ERC-4337、EntryPoint v0.6 | 無gas交易的帳戶抽象 |
模組圖
- 智能合約 — Solidity 合約、市場生命週期、CTF 集成
- 訂單簿 & AMM — CPMM 公式、訂單簿引擎、混合路由
- 結算 — 樂觀預言機,AI 自動結算,爭議流
- Gas 贊助 — ERC-4337 AA、Paymaster、無 Gas 交易
- 後端服務 — 前往API,託管錢包,驗證
- Frontend — React 應用程式、錢包整合、狀態管理
- Indexing — 圖子圖、GraphQL 模式、事件處理程序
- 基礎設施 — CI/CD、部署、monorepo 結構
- API 參考 — REST API、合約 ABI、GraphQL 查詢
資料流
從使用者操作到結算的完整交易流程:
User Action Backend Blockchain
──────────── ─────── ──────────
1. Connect Wallet →
2. Sign EIP-191 message → Verify signature
3. Receive JWT ← Issue JWT token
4. Place order → Validate + match
5. Submit transaction → Sign with custodial key → Execute on BSC
6. Confirm ← ← Tx receipt
7. Position updated ← Subgraph indexes event
...
8. Market expires → Oracle resolves
9. AI verifies result → Sora Keeper proposes → OptimisticController
10. Settlement ← ← CTF reports payouts
11. Redeem positions → → CTF.redeemPositions外部依賴
| Dependency | Purpose | Integration |
|---|---|---|
| 靈知CTF | ERC-1155 條件標記 | 倉位鑄造、分割、合併、贖回 |
| ERC-4337 EntryPoint v0.6 | 帳戶抽象 | UserOperation 驗證,gas 贊助 |
| 金天 | 子圖託管 | GraphQL API 用於索引鏈上數據 |
| 煉金術 | RPC 提供者 | BSC 節點存取(主) |
| Cloudflare 頁面 | 靜態託管 | 前端部署 |