Liquidation will always give less than requiredMaintenanceMarginUsdX18
to Zaros, because it doesn't want a certain margin to exist and what's left is transferred.
On liquidation, it checks if requiredMaintenanceMarginUsdX18 > marginBalanceUsdX18
(margin + PnL + funding) and if so, deducts requiredMaintenanceMarginUsdX18 + liquidation fee
from the margin balance of the tradingAccount. But in almost all cases, the margin that will be paid to the protocol will be less than the margin balance of the tradingAccount and they will never receive the required MaintenanceMarginUsdX18 + liquidation fee
.
As you can see it tries to send requiredMaintenanceMarginUsdX18
to marginCollateralRecipient
and liquidationFeeUsdX18
to liquidationFeeRecipient
. TradingAccount.deductAccountMargin()
is implemented to send the fees first and then the requiredMaintenanceMarginUsdX18
.
These are the possible cases where a liquidation will occur and in almost all cases they will not send the full desired amount. This value can also get smaller and smaller and even reach 0 because TradingAccount.deductAccountMargin()
only sends what is left over.
Note: liquidationFee = 10
requiredMaintenanceMargin
= 100, marginBalance
= 90 (Margin = 105, PnL = -20, funding = 0), in this case, due to the negative PnL, the position is liquidatable. But the trading account has only 105 margin and 10 will be sent to liquidationFeeRecipient
, the remaining 95 will be sent to marginCollateralRecipient
.
requiredMaintenanceMargin
= 100, marginBalance
= 99 (Margin = 90, PnL = 9, funding = 0), in this case the price of the margin collateral has dropped and again 10 will be sent to liquidationFeeRecipient
, the remaining 80 will be sent to marginCollateralRecipient
even if they wanted 100
requiredMaintenanceMargin
= 100, marginBalance
= 90 (Margin = 110, PnL = -10, funding = 0), this is the only case when both will be satisfied, when margin > requiredMaintenanceMargin + fee
.
Zaros will not receive the requested margin when liquidating a position.
Manual Review
Implement a check to ensure at least amount that is required to be sent upon liquidation.
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.