Traders (or liquidity providers) positions may move below margin requirements as a result of price movements in the market. Such cases can put the solvency of the protocol at risk.
Thus, it is desirable to remove these positions from the market to keep the accounting of the pool balanced. Liquidators are the ones helping the protocol complete this task by spotting positions below margin requirements and closing them.
As a reward for their services, liquidators get a percentage of the positions they close. Currently, this reward is at 1.5% of the
openNotionalvalue of the position when opened for traders or the
openNotionalof the active position for liquidity providers.
Additionally, liquidators settles the liquidatee debts arising from their PnL losses by seizing/buying their collateral at a discount.
Anyone can propose a trader (or a LP) position to liquidate with a call to the liquidate function in the ClearingHouse contract.
Example 1: Liquidator proposes a trader position that is worth liquidating.
- 1.Liquidator calls
liquidatefunction with 1) the index of the trading pair in which the faulty position is located, 2) the address of the user to liquidate (called the "liquidatee"), 3) a number of tokens to use to sell the liquidatee position, at its current value (called
proposedAmount) and 4) whether or not this user is a trader.
- 2.Check whether or not the position is meeting the margin requirements, as we don't want liquidators to close valid positions.
- 3.Close the liquidatee's position on the market. Note: if the position is not closed in its entirety at this point, the function will revert and the liquidator will have to call the
liquidatefunction again with a bigger
- 4.Increment computes the liquidation reward of the closed position in UA, using the initial open notional amount and the liquidation reward ratio. This UA liquidation reward is added to the vault balance of the liquidator and is substracted to the vault balance of the liquidatee.
- 5.[Optional] At this point, assuming some conditions are met (see the liquidation section for the exact conditions), the liquidator is offered the possibility to buy the non-UA collaterals of the liquidatee at a discounted price with the seizeCollateral function.
It's worth noting that a liquidator might decide to only liquidate a position and not seize the non-UA collaterals of the liquidatee (e.g. if the liquidator is low in capital), or vice-versa.
Also worth noting, the liquidate function operates on 1 market alone while the seizeCollateral function assumes that all positions of the liquidatee are closed. The implication for a liquidator wanting to liquidate a trader under margin requirements and seize his non-UA collaterals is that they will have to call the liquidate function for each of the positions of the user to liquidate then call the seizeCollateral function once.
Example 2: Liquidator proposes a trader position that is still valid (not below margin requirements).
- 1.Liquidator calls
liquidatefunction with 1) the index of the trading pair in which the faulty position is located, 2) the address of the trader to liquidate, 3) the number of tokens used to close liquidatee position, at its current value (called
proposedAmount) and 4) whether or not the user is a trader.
- 2.The check for the margin requirement returns that the position is still within the margin requirements, so the liquidation is canceled and the position remains open. The trader is not impacted, but the liquidator is penalized (paying the gas fee).
It is worth mentioning that LPs too can be liquidated. This might sound surprizing as LPs don't have access to leverage as traders do. This can nevertheless happen for example if the value of the collateral that a LP uses drops tremendously in value suddenly, making the USD value of their collateral insufficient to meet the
freeCollateralrequirement for his LP position (see margin).
Last modified 20d ago