DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: high
Valid

Liqudation fee is not take in cosideration during liqudation

Summary

The protocol currently does not account for the liquidation fee when determining if a trading account is liquidatable. It is stated in the official documentation that this fee should be accounted during the check does a position is liquidatable.

Vulnerability Details

When checking if a trading account should be liquidated, the protocol doesn't take in consideration the liquidation fee. This oversight can lead to scenarios where an account is considered non-liquidatable, even though, after accounting for the liquidation fee, it should be liquidated.

Impact

If the margin goes below the required threshold without considering the liquidation fee, the fee may not be covered during liquidation. This could result in the protocol failing to collect the necessary fees.

Tools Used

Manual review

Recommendations

To fix this issue, update the isLiquidatable function to include the liquidation fee in its calculations:

function isLiquidatable(
UD60x18 requiredMaintenanceMarginUsdX18,
SD59x18 marginBalanceUsdX18
)
internal
pure
returns (bool)
{
+ GlobalConfiguration.Data storage globalConfiguration = GlobalConfiguration.load();
+ return requiredMaintenanceMarginUsdX18.intoSD59x18().add(globalConfiguration.liquidationFeeUsdX18).gt(marginBalanceUsdX18);
- return requiredMaintenanceMarginUsdX18.intoSD59x18().gt(marginBalanceUsdX18);
}

This adjustment ensures that the liquidation process properly accounts for the liquidation fee, maintaining the protocol's financial integrity and preventing potential shortfalls.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Liquidation doesn't take the liquidation fee in consideration inside the isLiquidatable check

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.