DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Liquidate always liquiadte whole trading account

Summary

When user is liquidated his whole trading account is liquidated.

Vulnerability Details

User may have multiple positions and some of them can be liquidatable some of them may not be, but since the margin is not liked to a position, and is linked to whole margin of the trading account.

User have 2 positions that are healthy and one that is short and accrue a lot bad PnL, with that all positions will be liquidated since marginBalanceUsdX18 of all will be less than requiredMaintenanceMarginUsdX18.

ctx.marginBalanceUsdX18 = tradingAccount.getMarginBalanceUsd(accountTotalUnrealizedPnlUsdX18);
// if account is not liquidatable, skip to next account
// account is liquidatable if requiredMaintenanceMarginUsdX18 > ctx.marginBalanceUsdX18
if (!TradingAccount.isLiquidatable(requiredMaintenanceMarginUsdX18, ctx.marginBalanceUsdX18)) {
continue;
}
// deduct maintenance margin from the account's collateral
// settlementFee = liquidationFee
ctx.liquidatedCollateralUsdX18 = tradingAccount.deductAccountMargin({
feeRecipients: FeeRecipients.Data({
marginCollateralRecipient: globalConfiguration.marginCollateralRecipient,
orderFeeRecipient: address(0),
settlementFeeRecipient: globalConfiguration.liquidationFeeRecipient
}),
pnlUsdX18: requiredMaintenanceMarginUsdX18,
orderFeeUsdX18: UD60x18_ZERO,
settlementFeeUsdX18: ctx.liquidationFeeUsdX18
});

Impact

Positions that are healthy in their terms will be liquidated if other positions are far below maintenance margin.

Tools Used

Manual Review

Recommendations

Consider to allow liquidating single positions not the whole trading account.

Updates

Lead Judging Commences

inallhonesty Lead Judge
11 months ago
inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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