# Margining

BasedApp uses Hyperliquid's margining system. Margin calculations follow standard practices used by major centralized derivatives exchanges, ensuring a familiar and transparent experience for traders.

## Margin Modes

When opening a position, users must choose a margin mode:

<figure><img src="/files/AJOk2e4FB1Fr9HS1uImO" alt="" width="375"><figcaption></figcaption></figure>

* **Cross Margin** (default)

  Collateral is shared across all cross-margin positions, maximizing capital efficiency. Your entire available balance acts as margin, meaning unrealized gains from one position can offset losses from another. However, this also means a large loss on any single position can affect your overall account and other cross-margin positions.
* **Isolated Margin**

  Collateral is confined to a single position. The maximum you can lose is the margin allocated to that position. If the position is liquidated, it does not impact other positions — whether cross or isolated. Likewise, losses from elsewhere will not affect this position. Users can add or remove margin from an isolated position at any time after opening.

## Initial Margin & Leverage

<figure><img src="/files/x36XMMr5xKBK6EUyaspw" alt="" width="375"><figcaption></figcaption></figure>

* Users can set leverage to any integer between 1x and the asset's maximum leverage.
* The margin required to open a position is:

  **`Position Size × Mark Price ÷ Leverage`**
* In cross margin, the initial margin is locked and cannot be withdrawn.
* In isolated margin, users can adjust margin (add or remove) even after the position is opened.

For cross positions, unrealized PnL is available as initial margin for new positions. For isolated positions, unrealized PnL is applied as additional margin for the open position.

{% hint style="info" %}
Leverage is only checked when opening a position. The leverage of an existing position can be increased without closing it.
{% endhint %}

Users must monitor their risk and can adjust by:

* Closing part or all of the position
* Adding margin (if isolated)
* Depositing USDC (if cross)

## Maintenance Margin & Liquidation

<figure><img src="/files/hybXG2D7sDKVfqaEhTUj" alt="" width="375"><figcaption></figcaption></figure>

{% hint style="danger" %}
Cross positions are liquidated when your account value (including unrealized PnL) falls below the maintenance margin multiplied by total open notional. Maintenance margin is 50% of the initial margin at max leverage, which ranges from **1.25%** (at 40x max leverage) to **16.7%** (at 3x max leverage).
{% endhint %}

* Isolated positions follow the same logic, but only the isolated margin and notional value of that individual position are used in the calculation.
* The higher your max leverage, the lower the maintenance margin percentage — and the closer your liquidation price will be to your entry.

For more details on how liquidations are triggered and processed, see [Liquidation](/docs/trading/liquidation.md).

## Margin Tiers

Maximum leverage varies per asset. Higher-value positions may be subject to lower maximum leverage through tiered margining. This means that as your position size increases, the allowed leverage may decrease to ensure adequate margin coverage and reduce systemic risk.


---

# 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://basedapp.gitbook.io/docs/trading/margining.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.
