Step 1: Alice Sends a Limit Order, and the Application Matches it to Bob's Undercollateralized Position

Let's look at the following example. Alice wants to sell 1 synthetic BTC for 30000 USDC and pay a maximum amount of 5 USDC as a fee for the trade. Bob has a vault with -1 BTC and +31000 USDC. Notice that Bob's position can be matched against Alice's order. If Bob's position is below the maintenance margin according to the system parameters, the application can match between Alice's limit order and Bob's position without his signature or any consent from him.
Concretely, after Alice sends a limit order as specified here, the application sends StarkEx a Liquidation request that includes Alice's limit order and the following:
  • The positionId of Bob
  • The actual amount of collateral transferred
  • The actual amount of synthetic transferred
  • The actual fee paid by Alice (Bob is not required to pay a fee, as he is liquidated)

Step 2: StarkEx Checks the Validity of the Request

StarkEx checks the following constraints:
  • The amounts and fees transferred are compatible with Alice's order, as described here
  • Bob's position is indeed liquidatable, i.e. the Total Account Value / Total Maintenance Margin Requirement ratio is below 1.
  • The Total Account Value / Total Maintenance Margin Requirement ratio of Bob's position is improved due to the liquidation
  • Bob's amount of synthetic holdings was reduced due to the trade

Step 3: Liquidate Included in a Batch

If the Liquidation request is valid, it is included in a batch to be submitted on-chain along with validity proof. See here for a detailed description of the on-chain state update.