requiredMaintenanceMargin
does not take into account the liquidationFee
, which will prevent some accounts from being liquidated.
When is checked if a user is for liquidation, it gets the requiredMaintenanceMargin
for the specific position and then compares it to the trader's marginBalance
(margin + PnL + funding).
The account can be liquidated if requiredMaintenanceMargin
> marginBalance
But since liquidation has a liquidationFee
, requiredMaintenanceMargin
must include the fee before checking if it is liquidatable, since every liquidation must pay the liquidationFee
.
Consider this example:
requiredMaintenanceMargin = 100
, marginBalance = 101
, liquidationFee = 5
→ With the current implementation, this position cannot be liquidated, but in fact it should be liquidated, because liquidation will cost 105 tokens and only marginBalance
above requiredMaintenanceMargin + liquidationFee
should be treated as healthy.
In Synthetix
's code, this check adds the liquidationFee
.
Note:
_liquidationMargin
=requiredMaintenanceMargin
PerpsV2MarketBase.sol#L433-L440
PerpsV2MarketBase.sol#L391-L395
Positions that, upon liquidation, will lose requiredMaintenanceMargin
+ liquidationFee
, but their marginBalance
is less than requiredMaintenanceMargin
+ liquidationFee
and higher than requiredMaintenanceMargin
, will not be liquidated.
Manual Review
When TradingAccount.isLiquidatable
is called requiredMaintenanceMarginUsdX18
should add liquidationFeeUsdX18
.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.