Wrong input paramater when checking account is liquidatable. The check that account can be liquidatable could get wrong result.
OrderBranch::simulateTrade:
From the above code we can see the first paramater of isLiquidatable function is obtained by getAccountMarginRequirementUsdAndUnrealizedPnlUsd(0, SD59x18_ZERO) which means the paramater is before trade.
For the second paramater ?
The second parameter is obtained from marginBalanceUsdX18 = tradingAccount.getMarginBalanceUsd(ctx.accountTotalUnrealizedPnlUsdX18);, and ctx.accountTotalUnrealizedPnlUsdX18 is derived from tradingAccount.getAccountMarginRequirementUsdAndUnrealizedPnlUsd(marketId, ctx.sizeDeltaX18). Therefore, it indicates that the margin balance takes into account the PnL after trade, representing the second paramater is after trade.
So the result of isLiquidatable can be wrong because of two inconsistent paramater.
The check that account can be liquidatable could get wrong result and lead to liquidatable accounts trading.
manual
Two paramater of isLiquidatable use the value before trade.
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.