Clearinghouse
Exchange component that updates balances, positions, margin, and PnL after trades and triggers liquidations when risk thresholds are breached.
Clearinghouse is the exchange component responsible for settling trades and maintaining accurate financial state after every transaction. In traditional finance, clearinghouses act as intermediaries between buyers and sellers, guaranteeing trade settlement and managing counterparty risk. In Hyperliquid's HyperCore, the clearinghouse is a native protocol component that updates balances, positions, margin requirements, profit and loss (PnL), and triggers liquidations when risk thresholds are breached—all deterministically and without external dependencies.
Role in the Exchange Architecture
Within HyperCore, two critical components work together:
Matching Engine: Determines which orders match, at what price, with what priority, and in what sequence.
Clearinghouse: Takes matched trades and updates all financial state—who owns what, how much margin they have, what their positions are worth, and whether any positions must be liquidated.
The matching engine answers "what trades happened?" while the clearinghouse answers "what does the financial state look like now?"
Clearinghouse Responsibilities
Balance Updates
After every trade, the clearinghouse adjusts:
- Buyer's quote currency decreases (payment)
- Seller's quote currency increases (receipt)
- Buyer's base currency/position increases
- Seller's base currency/position decreases
Position Management
For perpetual futures, the clearinghouse tracks:
- Position size (long or short exposure)
- Entry price (average cost basis)
- Unrealized PnL (current value vs. entry)
- Realized PnL (from closed portions)
Margin Calculations
The clearinghouse continuously calculates:
- Initial Margin: Required to open a position
- Maintenance Margin: Minimum to keep a position open
- Available Margin: Funds available for new positions
- Margin Ratio: Current margin relative to requirements
Risk Monitoring
After every state update, the clearinghouse checks:
- Does the account meet maintenance margin requirements?
- Has the position exceeded maximum leverage?
- Are there any positions that must be liquidated?
Liquidation Triggering
When margin becomes insufficient, the clearinghouse triggers liquidations directly—no external bots required. This is a critical distinction from most DeFi protocols where liquidation depends on third-party actors monitoring positions and submitting transactions.
Why Native Liquidations Matter
In typical DeFi lending/trading protocols, liquidations work like this:
- Position becomes undercollateralized
- External bot detects the opportunity
- Bot submits liquidation transaction
- Transaction competes for block inclusion
- If successful, bot receives liquidation bonus
This model has several failure modes:
- Bots may be offline or slow
- Gas spikes can make liquidations unprofitable
- Network congestion can delay liquidations
- Cascading liquidations can overwhelm bot infrastructure
Hyperliquid's clearinghouse eliminates these risks by making liquidations protocol-native:
- Position margin falls below maintenance
- Clearinghouse immediately triggers liquidation
- Liquidation executes in the same block
- No external dependencies, no gas competition
Deterministic Execution
Every clearinghouse operation in HyperCore is deterministic—given the same inputs, every validator node produces the exact same financial state. This is essential because:
- No disputes: All nodes agree on positions, balances, and liquidations
- No front-running: Execution order is consensus-determined
- No manipulation: State transitions follow strict rules
- Full auditability: Anyone can verify any state transition
Clearinghouse vs. Smart Contract Settlement
| Aspect | HyperCore Clearinghouse | Smart Contract Settlement |
|---|---|---|
| Execution | Protocol-native | User-triggered |
| Liquidations | Automatic | Bot-dependent |
| Gas Competition | None | High during volatility |
| Latency | Sub-second | Block-dependent |
| Determinism | Guaranteed | Transaction-order dependent |
| Transparency | Full state visible | Contract state visible |
Integration with Other HyperCore Components
Oracles
The clearinghouse uses HyperCore's native price oracles to:
- Calculate unrealized PnL
- Determine liquidation prices
- Evaluate margin adequacy
- Compute mark prices for risk
Vaults
Protocol vaults like HLP interact with the clearinghouse for:
- Position management (vault strategies)
- Liquidation participation
- PnL attribution to vault depositors
Spot vs. Perps
The clearinghouse handles both markets:
- Spot: Simple balance swaps between assets
- Perps: Complex position management with leverage, funding, and risk
Security Guarantees
Solvency: The clearinghouse ensures the exchange remains solvent by:
- Enforcing margin requirements before trade execution
- Triggering liquidations before positions go underwater
- Settling all trades atomically (no partial states)
Consistency: All state transitions are atomic—either a trade fully settles or it doesn't happen. There are no intermediate states where balances are inconsistent.
Finality: Once the clearinghouse processes a block, that financial state is final. There are no reversals, no pending settlements, no counterparty risk.
What Developers Should Know
If you're building on HyperEVM:
- Observe, don't modify: Your contracts can read clearinghouse state but cannot directly influence it
- State is final: When you read positions or balances, that data is definitive
- Liquidations are instant: Don't design systems assuming liquidation delays
- No gas competition for core ops: HyperCore operations don't compete with your contracts
The clearinghouse is the financial backbone that makes Hyperliquid function as a real exchange—handling the complex accounting that ensures every trade settles correctly and every risk is managed appropriately.
Articles Using This Term
Learn more about Clearinghouse in these articles:
Related Terms
HyperCore
Hyperliquid's native financial execution engine running spot, perps, risk, and liquidations outside the EVM for deterministic, low-latency trading.
Matching Engine
Core system pairing buy and sell orders within exchange ensuring trades execute under consensus without external servers or latency.
Perpetual Futures
Derivative contracts without expiration dates allowing indefinite leveraged positions settled through funding rate mechanisms.
Mark Price
Fair value reference price calculated from spot markets used for unrealized PnL and liquidation calculations preventing manipulation.
Need expert guidance on Clearinghouse?
Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.
Get a Quote
