# Margin and Risk Management

The NexaDex Clearinghouse is the protocol's high-speed nervous system, utilizing Solana’s parallel execution (Sealevel) to monitor account health across thousands of positions simultaneously.

* Dual Margin Modes: \* Isolated Margin: Standard for high-beta assets (like the TrendSurfer markets). Risk is siloed to a single position, protecting your broader vault from localized volatility.
  * Cross Margin: Enabled for professional accounts. All $USDC collateral in your trading account supports your entire portfolio, maximizing capital efficiency across multiple trades.
* Dynamic Maintenance Margins (DMM): Moving beyond static thresholds, Phase 1 introduces AI-driven DMM. As asset volatility increases—detected via real-time Pyth or Switchboard feeds—the protocol automatically scales margin requirements. This creates a "Volatility Buffer" that signals risk to traders before a liquidation event becomes necessary.

### The Risk Pillar: High-Velocity Liquidation

Liquidation on Solana is a race of micro-seconds. NexaDex is built to ensure the Single Liquidity Vault (SLV) remains solvent even during "Flash Crash" events.

#### The NexaDex Oracle Defense

To prevent the "Wrongful Liquidation" errors that plagued early DeFi, NexaDex employs a multi-layered price filter:

* Hybrid Price Discovery: While we use real-time spot prices for execution, liquidations are triggered using a Confidence-Interval Weighted Price. This requires a quorum of high-fidelity oracles (Pyth, Chainlink, and Switchboard) to confirm a price move, neutralizing "L2 lag" or single-feed anomalies.
* MEV-Resistant TWAP: For large-scale margin checks, we utilize a short-window Time-Weighted Average Price (TWAP). This protects traders from "Block-Space Attacks," where an adversary might attempt to temporarily manipulate a price within a single Jito-Bundle to trigger a liquidation.

#### Systemic Safeguards: The Standard

| **Security Feature** | **Legacy Platforms**        | **NexaDex**                        |
| -------------------- | --------------------------- | ---------------------------------- |
| Liquidation Trigger  | Static % (Fixed)            | Dynamic (Volatility-Adjusted)      |
| Price Feed           | Single Source / Opaque      | Multi-Oracle Consensus (Pyth/Link) |
| Solvency Buffer      | None / LP Haircuts          | On-Chain Insurance Fund            |
| MEV Protection       | Vulnerable to Front-running | Jito-Bundle Protection & TWAP      |

### The Insurance Fund & Solvency Shield

In Phase 1, the NexaDex Insurance Fund goes live as a decentralized backstop.

* Autonomous Recapitalization: A portion of protocol fees and "Liquidation Premiums" (the remaining collateral after a position is closed) flows directly into this fund.
* Bad Debt Absorption: In extreme market conditions where a position cannot be closed above its bankruptcy price, the Insurance Fund steps in instantly to cover the gap. This ensures that Liquidity Providers (LPs) never experience a loss of principal due to trader insolvency.

#### Oracle Transparency Benchmark

We prioritize "Execution Proofs." Every liquidation and margin adjustment on NexaDex is timestamped and linked to the specific Pyth Slot or Chainlink Aggregator report that triggered it. This creates a fully auditable trail, ensuring that NexaDex remains the most transparent and resilient trading venue on Solana.


---

# 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://nexadex.gitbook.io/nexadex-docs/trading-mechanics/margin-and-risk-management.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.
