组件与观测
组件名:oracle · liquidator · hedger · bridge_deposit · bridge_withdraw。
下列接口均需 Bearer,除非另注。
进程健康字段为 tagged JSON:
{ "status": "Running" }
{ "status": "Stopped" }
{ "status": "Error", "detail": "…" }
GET /api/status
聚合状态。
| 字段 | 说明 |
|---|---|
chain_rpc_url | zepto-server 连接的链 RPC |
components | { oracle_enabled, liquidator_enabled, hedger_enabled, bridge_deposit_enabled, bridge_withdraw_enabled } |
health | 五组件 Running / Stopped / Error |
oracle / liquidator / hedger / bridge | 与下列分项接口相同 |
GET /api/oracle/status
| 字段 | 说明 |
|---|---|
last_tick_ms / last_success_ms | 最近一轮 / 最近成功 |
markets_quoted | 本轮报价市场数 |
latest_quotes | symbol → { symbol, coin, mid_price, bid, ask, seq } |
error_count / last_error | 累计错误 |
tick_count / submit_count | 轮询次数 / 提交次数 |
GET /api/liquidator/status
含 liquidatable[]、at_risk[](账户、symbol、market_id、仓位、保证金健康度等)、
last_liquidation、错误计数。
GET /api/liquidator/watch
实时可清算 / 近清算快照(字段为 status 的子集:计数 + 两个数组 + 时间戳)。
GET /api/hedger/status
| 字段 | 说明 |
|---|---|
positions | coin → 净仓、目标对冲、当前对冲、漂移、状态 |
active_account_count | 启用的对冲账户数 |
default_ratio / default_mode | 全局默认 |
last_order_error / last_order_error_at_ms | 最近下单错误 |
GET /api/bridge/status
待入金 / 待出金计数、累计 credit/settle、settlement_paused、
可选 evm_deposit_count / evm_deposit_cursor / pending_settle_backlog。
POST /api/components/toggle
Body: { "component": "oracle", "enabled": true }
未知组件 → 400。200: { "ok": true, "message": "oracle enabled" }
POST /api/components/restart
Body: { "component": "oracle" }
重启失败 → 500。200: { "ok": true, "message": "oracle 已重启" }
POST /api/components/config
Body: { "component": "oracle", "interval_ms"?, "dry_run"?, "spread_bps"?, "cooldown_ms"?, "threshold_notional"? }
当前只记事件,不落库改运行参数。运行参数以编译期 env + 密钥与服务 绑定为准。
GET /api/events
进程内环形事件缓冲。
| Query | 默认 | 说明 |
|---|---|---|
offset | 0 | 偏移 |
limit | 50 | 最大 500 |
200: { "events": [{ "timestamp_ms", "level", "component", "message" }], "offset", "limit", "total" }
GET /api/logs
SQLite 持久日志。
| Query | 默认 | 说明 |
|---|---|---|
component | — | 组件名过滤 |
level | — | 级别过滤 |
start_ms / end_ms | — | 时间窗 |
offset | 0 | 偏移 |
limit | 100 | 最大 1000 |
200: { "data": [{ "id", "ts_ms", "level", "component", "message" }], "page": { "offset", "limit", "total" } }