# Margining

__Basic Margining (Trader)__

### How do I manage my margin?

There are two values to manage the state of your account:

**Required Maintanance Margin:**The minimum margin required to avoid liquidation. If account value < required maintance margin, then your account will be liquidated.**Free Collateral:**The collateral available for withdrawal and/or opening new positions. As your PnL increases, so will your free collateral. Rage trade enables you to withdraw your unrealized PnL from your free collateral (as long as your account value > required initial margin).

### As a trader, how do I calculate my required margin?

Traders can calculate their required margin using their token position, current price, and maintanance margin fraction (MMF).

Maintanance Margin Fraction (MMF) = 1/10

Required Margin (Trader) = Token Position x Current Price x MMF.

__Advanced Margining (LP)__

**NOTE:** This section is **not intended for LPs in 80-20 vaults**. LP margin calculation is more involved than trader margin calculation. For this reason, we recommend using **80-20 vaults** to provide liquidity without worrying about margin or liquidation risk (read about 80-20 here).

### As an LP, how do I calculate my required margin?

Let's use the visualization of the range order below to understand LP margin calculation:

In the above diagram an LP has provided a range order with **vUSD** and **vETH** around the current price. To calculate the LPs required margin, let's analyze the downside risk (price going down) and upside risk (price going up) of the LP.

__Upside Risk:__ As price moves up, the LP sells vETH for vUSD (i.e. the LP shorts ETH). To calculate the worst-case risk of the LP we use **(1) maximum ETH short position **and **(2) current perp price.**

Up Risk = Maximum Short Position * Current Price

__Downside Risk__: As price moves down, the LP buys vETH with vUSD (i.e. the LP longs ETH). To calculate the worst-case risk of the LP we use **(1) maximum vETH long position** and **(2) execution price bounded by high/low range price**.

Execution Price = SQRT(MIN(Low Price, Current Price) * MIN(Current Price, High Price))

Down Risk = Maximum Long Position * Execution Price

Knowing the upside risk and downside risk of a range, we can take the maximum to calculate the required margin:

Required Margin (LP) = MAX(Up Risk, Down Risk) * MMF

### What if I am both an LP and a trader?

For users that are both providing liquidity and trading, we can sum the risks to calculate the required margin:

Trade Risk = Token Position * Current Price

Required Margin = MAX(Up Risk + Trade Risk, Down Risk + Trade Risk) * MMF