Comment on page

## Order Risk Check

### Order Risk Check Conditions

An order is accepted if :
• The account meets the Initial Margin Requirement after including the new order, i.e.
$\text{Account Value}\ge\text{Account Initial Margin Requirement}$
• Including the order does not result in an increase of the Initial Margin Requirement

### Example

Setup :
• Alice has 100 USD worth of collateral and uses Cross Margin mode
• $\text{Mark Price}_\text{ XYZ-USD-PERP}=100$
Alice successfully submits a buy XYZ-USD-PERP order of size 10
Assuming Initial Margin Fraction (IMF) of 10% (i.e. a maximum leverage of 10x), the Initial Margin Requirement is :
$10\%*10*100=100~\text{USD}$
Alice has no open position and therefore has an Account Value of 100 USD. The order is then accepted since the account meets the IMR condition.
Price drop :
The Mark Price of XYZ-USD-PERP drops to 98.
$\text{Account IMR}=10\%*10*98=98~\text{USD}$
$\text{Unrealized PnL}=10*(98-100)=-20~ \text{USD}$
$\text{Account Value}=100-20=80~\text{USD}<\text{Account IMR}$
Although Alice's account value is below IMR, deleveraging check does not monitor the account since it has no open orders
Submission of an offsetting order :
Alice submits a sell order of size 5. Since this is an offsetting order which is smaller than the position size, it does not increase the Open Size therefore does not increase the Account IMR. The order is accepted.
Submission of another order that brings the total sell orders size above the position size
Later, Alice submits a new sell order of size 8. This is also an offsetting order but it does result in an increase in Alice's XYZ-USD-PERP Open Size from 10 to 13. Therefore, this order increases the account IMR. Since the account also does not meet IMR, this order is rejected.

## Health Check

Health Check is a periodic check that compares the Account Value to the Account Maintenance Margin Requirement (Account MMR)
If
$\text{Account Value}<\text{Account Maintenance Margin Requirement}$
: The account is marked in Unhealthy Mode. Accounts in Unhealthy Mode are available for Liquidation.
The account cannot submit any new order and will be available to be taken over by liquidators

## Withdrawal Check

The amount of USDC that can be withdrawn is subject to an upper limit that depends on the Free Collateral Balance expressed in USDC terms. However, the user cannot withdraw more than the Account USDC Balance :
$\small\text{Withdrawable USDC Amount}=\min\Bigg(\text{Account USDC Balance} ,~\max\Big(0, \frac{\text{Free Collateral Balance}}{\text{USDC Oracle Price}}\Big)\Bigg)$