getMarginBalanceUsd() uses TradingAccount.marginCollateralBalanceX18 to calculate the current collateral balance.
If collateral is removed collateralLiquidationPriority is still counted in the total balance.
This way the user can still use the removed collateral to add a new position, but this collateral will not be liquidated in the event of a liquidation.
TradingAccount.getMarginBalanceUsd() is used to actuate the current collateral balance.
This method uses TradingAccount.data.marginCollateralBalanceX18 to loop through and calculate to get the total balance.
TradingAccount.deductAccountMargin() is used in liquidation to deduct the collateral.
This method uses globalConfiguration.collateralLiquidationPriority to loop through and deduct the corresponding collateral equivalent from it
So let's say collateral_C is removed from collateralLiquidationPriority, but the user has previously had collateral_C deposited .
Then the user's
marginCollateralBalanceX18 = [collateral_C]
But
globalConfiguration.collateralLiquidationPriority = [collateral_A,collateral_B]
it is used to increase the position using the valuation of collateral_C.
But there is no liquidation risk because collateral_C is not included in collateralLiquidationPriority.
Increase the position using the removed collateral, but without the risk of liquidation.
getMarginBalanceUsd() use globalConfiguration.collateralLiquidationPriority()
or
deductAccountMargin() to prioritize using globalConfiguration.collateralLiquidationPriority() and if that's not enough then TradingAccount.data. marginCollateralBalanceX18.
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.