# Margin

Margin is the collateral required to open perp contracts.

#### Margin Mode

By default, positions are cross margined and access account equity. In cross margin mode, unrealized PnL is available as initial margin for new positions.

Users can select isolated margin for precise control. Unrealized PnL in isolated positions is used as additional margin for the open contract. At any time, margin can be added or removed from isolated positions within the bounds of the initial margin and account equity. Isolated margin liquidations do not affect other positions.

#### Margin Requirements

Leverage can be set by a user between 1 and the max leverage. Max leverage [depends on the asset](/trading/vdexcore/contract-specifications.md). The leverage of an existing position can be increased without closing the position, decreasing the initial margin requirement (IMR).

The margin required to open a position or create an order is the dollarized position size divided by the leverage. Margin supporting open orders cannot be withdrawn.

Positions will be liquidated when isolated margin or account equity is less than the maintenance margin requirement (MMR). &#x20;

#### Supported Collateral

Account equity is the sum of collateral value, PnL, and net funding. Users can add margin by depositing supported collateral, including USDC, USDT, WETH, and WBTC. All collateral adds margin at face value. [Volatile Asset Collateral](/protocol/whitepaper/volatile-asset-collateral.md), such as WETH and WBTC, is dynamic according to the mark price.

For example, a user deposits 1 Bitcoin when $BTC = $100,000, so they have $100,000 margin. If $BTC increases to $110,000, then margin updates proportionally to $110,000. Within margin accounts, this enables capital efficient funding arbitrage and delta-neutral hedging.

In cases of profit and positive yield, USD-denominated state is added. In cases of loss, USD-denominated state is subtracted, but the underlying VAC is not converted until withdrawal or liquidation. This means that if losses are reversed, the principle VAC is untouched.

#### Formulas

<details>

<summary>Margin Requirements</summary>

**Variables**

* `s` = position size
* `p` = entry price
* `p'` = liquidation price

**Formulas**

`Initial Margin Fraction (IMF) = 1/leverage`\
`Maintenance Margin Fraction (MMF) = IMF(max_leverage)/2`

`Initial Margin Requirement (IMR) = |s| * p * IMF`\
`Isolated Maintenance Margin Requirement (MMR) = |s| * p * MMF`

`MMR for Other Positions (MMR_o) = ∑(|s| * p * MMF)`\
`Cross Maintenance Margin Requirement = MMR_o + |s| * p' * MMF`

</details>


---

# 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://docs.vdex.trade/trading/vdexcore/margin.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.
