Comment on page

# Multi-position liquidation price calculation

### Multi-position liquidation price calculation:

• otTMM: Sum of maintenance margin of other contracts:
$\text { otTMM }=\sum_{k=1}^{n} a b s\left(S_{k} * P_{k} * M_{k}\right)-\operatorname{abs}\left(S_{i} * P_{i} * M_{i}\right)$
• otUPNL: Total unrealized gain or loss of other contracts:
$\text { otUPNL }=\sum_{k=1}^{n} S_{k} *\left(P_{k}-P_{k}^{o}\right)-S_{i} *\left(P_{i}-P_{i}^{o}\right)$
The liquidation price of the
$I^{\text {th}}\;$
contract (
$P_i^l$
):
$P_{i}^{l}=\frac{S_{i} * P_{i}^{o}-\mathrm{BI}+\text { otTMM - otUPNL }}{S_{i} *\left(1-\operatorname{dir}_{i} * M_{i}\right)}$

#### Variables:

• $BI$
: Static account equity
• $P_i:$
Current oracle price of the
$I^{\text {th}}\;$
contract
• $P_i^l:$
The liquidation price of the
$I^{\text {th}}\;$
contract
• $P_i^0$
: The opening price of the
$I^{\text {th}}\;$
contract
• $S_i:$
The number of open positions of the
$I^{\text {th}}\;$
contract, positive for long positions and negative for short positions.
• $dir_i:$
The opening direction of the
$I^{\text {th}}\;$
contract, +1 for long positions and -1 for short positions
• $M_i:$
Maintenance margin rate of the
$I^{\text {th}}\;$
contract

### Example:

Initial account balance
$BI = 1000$
, ETH-USDC maintenance margin rate
$M_i = 3%$
%, the opening price of ETH-USD
$P_i^0 = 3000$
, Current oracle price
$P_i$
= 2900; BTC-USDC maintenance margin rate
$M_i = 3%$
%, the opening price of BTC-USDC
$P_n^0 = 40000$
, Current oracle price
$P_n$
$S_i$
= 1.5 ETH-USDC, sells
$S_n$
= -0.1 BTC-USDC.

#### The liquidation price of the ETH contracts is:

otTMM =
$abs(-0.1*38000*3\%)=144$
otUPNL =
$-0.1*(38000-40000)=200$
$P_{i}^{l}=\frac{1.5 *3000 -1000+114-200}{1.5 *(1-3\%)}=2346.39$

#### The liquidation price of the BTC contracts is:

otTMM =
$abs(1.5*2900*3\%)=130.5$
otUPNL =
$1.5*(2900-3000)=-150$
$P_{n}^{l}=\frac{ -0.1*40000 -1000+130.5+150}{-0.1 *(1+3\%)}=45820.388$