☠️Deleveraging

Mechanism

The deleveraging process is a periodic check for accounts with open orders to determine if the account has sufficient value to maintain those orders.

If the account does not meet the initial margin requirement, the exchange cancels open orders that increase the account's risk.

This prevents those orders from being matched resulting in a fill that is likely to be rejected on-chain since the order violates Order Risk Check.

The main objective of deleveraging is to prevent orders from resulting in invalid fills

This check compares the Account Value to the Initial Margin Requirement (check here how IMR is calculated in Cross Margin Mode).

  • If Account Value<Account IMR\text{Account Value}<\text{Account IMR}, Account Deleveraging kicks in :

    • All orders that do not offset an open position on the same instrument (i.e. the account does not have an open position in this instrument or has an open position on the same side as the open order) are cancelled since these non-offsetting

    • Order offsetting an open position (opposite side) are not cancelled unless the cumulative size of those orders exceeds the position size, in which case the most passive orders are cancelled until the remaining cumulative size of offsetting orders is equal or lower than the position size

Example

Alice account has :

  • A long ETH-USD-PERP position of size 10

  • A buy ETH-USD-PERP order of size 2 with a limit price of 1'900

  • A sell ETH-USD-PERP order of size 5 with a limit price of 2'150

  • A sell ETH-USD-PERP order of size 3 with a limit price of 2'100

  • A sell ETH-USD-PERP order of size 3 with a limit price of 2'200

Due to ETH-USD-PERP price decrease, Alice account value drops below the account IMR and the exchange puts the account in Deleveraging Mode :

  • First, the buy order is cancelled since it is on the same side as the position

  • The total size of sell orders is 11 which is higher than the position size (10) :

    • The exchange starts by cancelling the most passive order (sell order of size 3 at price 2'200)

    • The total remaining sell order is 8 which is less than the position size. Therefore, no more order cancellation is made

After deleveraging, Alice end up with :

  • A long ETH-USD-PERP position of size 10

  • A sell ETH-USD-PERP order of size 5 with a limit price of 2'150

  • A sell ETH-USD-PERP order of size 3 with a limit price of 2'100

Last updated