Within the TradingAccount#isLiquidatable(), the liquidationFeeUsd is supposed to be used in the calculation of the isLiquidatable.
However, within the TradingAccount#isLiquidatable(), the liquidationFeeUsd is not used in the calculation of the isLiquidatable.
This lead the liquidation threshold (isLiquidatable) to always being miscalculated.
Within the LiquidationBranch#checkLiquidatableAccounts(), the TradingAccount#isLiquidatable() would be called like this:
https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/branches/LiquidationBranch.sol#L82
Within the TradingAccount#isLiquidatable(), whether or not the account is liquidatable would be calculated and validated.
Then, the result of validation will be returned like this:
https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/leaves/TradingAccount.sol#L350
According to the "Liquidation Criteria" in the document, the liquidationFeeUsd is supposed to be used in the calculation of the isLiquidatable like this:
isLiquidatable = requiredMM + liquidationFeeUsd >= marginBalanceUsd
However, within the TradingAccount#isLiquidatable(), the liquidationFeeUsd is not used in the calculation of the isLiquidatable like this:
This lead the isLiquidatable to always be miscalculated.
This means that the liquidation threshold would always be miscalculated.
And therefore, both impact and likelihood is "High". Hence, this severity can be "High".
Foundry
Within the TradingAccount#isLiquidatable(), consider adding the liquidationFeeUsd to the calculation of the isLiquidatable like this:
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.