# Clearinghouse

The **Clearinghouse** is the backbone of trading on Hyperliquid L1. It manages all user balances, open positions, and risk parameters to ensure seamless and fair trading. Every aspect of perpetual and spot trading, from deposits to liquidations, runs through this core component.

### **Key Responsibilities** 🛠️

* **📊 Balance & Position Management:**\
  Tracks user deposits, withdrawals, and margin balances while managing all open positions. This includes both perpetual and spot trading states.
* **⚖️ Margin Modes (Cross & Isolated):**\
  Supports flexible margin setups—cross margin for shared collateral across positions and isolated margin for independent risk management on specific positions.
* **📉 Leverage & Maintenance Margin:**\
  Ensures traders stay within their selected leverage limits and maintains system stability by enforcing initial and maintenance margin requirements.
* **🚨 Liquidations:**\
  Monitors account equity to prevent insolvency. When equity drops below maintenance requirements, the Clearinghouse handles liquidation processes through the order book or liquidator vault.
* **📈 Funding Rates:**\
  Calculates periodic funding rates to align perpetual contract prices with the underlying asset, ensuring market fairness.
* **📡 Oracle Integration:**\
  The Clearinghouse relies on an **oracle system** for price accuracy. The final price used is a **weighted median** of validator-submitted oracle prices, ensuring transparency and reliability. Validators' weights are based on their stakes.

All this ensures that the on-chain order book exchange operates efficiently, securely, and in harmony with the broader ecosystem components—including oracles, vaults, and spot tokens.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hyperliquid-co.gitbook.io/wiki/architecture/hypercore/dex/clearinghouse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
