HLDArena
HLD-413·Payments & Ledger
Expert · 2,000 pts

High-Frequency Crypto Margin Engine & Hot-Wallet Settlement

Design Coinbase / Binance’s 24/7 perpetuals margin collateral engine and withdrawal hot-wallet ledger preventing race-condition double-withdrawals during flash crashes.

Max p99
≤ 95 ms
Availability
≥ 99.5%
Budget
≤ $11,500

Functional Requirements

  • FR-1POST /margin/{account_id}/withdraw — Atomically verifies free margin collateral, locks nonce, and debits ledger.
  • FR-2GET /margin/{account_id}/equity — Returns real-time mark-to-market collateral and liquidation buffer.
  • FR-3POST /margin/{account_id}/withdraw/reverse — Supports idempotent reversal/refund or campaign pause updates while keeping cached balances and deduplication keys consistent.
  • FR-4Zero negative-equity race withdrawals and RPO = 0 across primary ledger node crashes.

Workload Profile

24/7 Baseline Trading64,000 Equity Read RPS / 12,500 Margin/Ledger Write RPS
20% Flash-Crash Liquidation Cascade170,000 Read RPS / 38,000 Concurrent Write RPS
Active Working Set38 GB margin positions, nonces & hot-wallet UTXO locks
Consistency GateStrict serializable collateral check + RPO = 0 quorum ledger

Consistency Model

Strict serializable per-account margin lock + idempotent withdrawal nonce + synchronous/quorum durability.

Design Write-up
0 boxes · 0 edges
0 words
Hidden Cases #4–#7 run automatically on Submit
Case 1: Smoke & API ContractInput Workload
Read RPS
2,000 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 190 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology