Message: MsgMultiLiquidate
The MsgMultiLiquidate
handler is responsible for liquidating underwater positions. It can be called by anyone with a list of trader and pair mappings and will attempt to partially or fully liquidate each position.
The parameter that is controllable by the user is
liquidationRequests
— This is an array consisting of groups of a trader address and a pair. Each address and pair is validated to ensure they are well-formed.
When liquidating multiple positions, the transaction will fail if all the liquidations are unsuccessful, but it will return a success if there is at least one valid liquidation.
For each position, the margin ratio is checked, and if it is greater than the market's specified MaintenanceMarginRatio
, then the liquidation fails with LiquidationFailedEvent_POSITION_HEALTHY
. Otherwise, if the spot margin ratio is greater or equal to the market's LiquidationFeeRatio
(there is enough margin to pay the liquidation fee), a partial liquidation is performed by reducing the size to the market's PartialLiquidationRatio
. If there is not enough margin to pay the liquidation fee, then a full liquidation is performed and the position is closed out.