The calculation of pnlUsdX18
used in deducting the account margin during liquidation is incorrect due to the use of abs()
(absolute value) on the unrealized PnL.
The pnlUsdX18
is intended to represent the total amount the trader owes due to unrealized losses and required maintenance margin.
By applying abs()
to accountTotalUnrealizedPnlUsdX18
, we lose the sign of the PnL. Both gains and losses become positive values.
Adding the required maintenance margin to this absolute value can lead to an incorrect total, either undercharging or overcharging the trader.
The abs()
function makes the loss positive.
Adding this positive value to the required maintenance margin inflates the amount deducted.
The trader is overcharged, leading to negative account balances.
If the trader has a positive unrealized PnL (gain):
The abs()
function keeps the gain positive. Adding it to the required maintenance margin overstates the amount to deduct. The trader's profit is wrongly considered a liability.
Manual Review
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.