The liquidateAccounts()function incorrectly assigns requiredMaintenanceMarginUsdX18 to the pnlUsdX18 parameter in the deductAccountMargin() function, which should represent the account's unrealized PnL. This misassignment can lead to incorrect margin deductions.
The current implementation of the deductAccountMargin() function call is as follows:
The issue lies in the incorrect parameter assignment for the pnlUsdX18 parameter in the deductAccountMargin() function call. The pnlUsdX18 parameter is supposed to represent the total unrealized PnL of the account, but the code is using requiredMaintenanceMarginUsdX18 instead.
Here is the deductAccountMargin() Signature:
A seen above:
pnlUsdX18 is the total unrealized PnL of the account.
Therefore, by using requiredMaintenanceMarginUsdX18 in place of pnlUsdX18, the function is essentially treating the required maintenance margin as the unrealized PnL, which is incorrect.
Incorrect margin deductions can severely impact a user's financial health, either by liquidating more collateral than necessary or by leaving insufficient collateral to cover potential losses. It can also lead to liquidity issues and undermine the protocol's integrity.
Manual Review
To ensure accurate margin deductions, the pnlUsdX18 parameter should be set to the account's unrealized PnL.
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.