Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Invalid

After withdrawing funds, you should still be far away from liquidation instead of just stepping on the liquidation line

Summary

After withdrawing funds, you should still be far away from liquidation instead of just stepping on the liquidation line.

Vulnerability Details

// Check if withdrawal would leave user undercollateralized
uint256 userDebt = user.scaledDebtBalance.rayMul(reserve.usageIndex);
uint256 collateralValue = getUserCollateralValue(msg.sender);
uint256 nftValue = getNFTPrice(tokenId);
if (collateralValue - nftValue < userDebt.percentMul(liquidationThreshold)) {
revert WithdrawalWouldLeaveUserUnderCollateralized();
}

Why <= instead of <?

• Assuming collateralValue - nftValue == userDebt.percentMul(liquidationThreshold), the user's health factor will become 1 after the withdrawal, which also meets the liquidation threshold, indicating that as long as the market price drops slightly, liquidation will be triggered immediately.

• In this case, the user will be liquidated instantly, which may lead to:
Very poor user experience (thinking that it can be safely withdrawn, but it is immediately liquidated).

Therefore, the collateral value after withdrawal must be strictly greater than the minimum collateral requirement to be safe.

Impact

After the withdrawal, the value of the user's collateral can be exactly equal to the liquidation threshold, which also meets the liquidation requirement and the liquidation will be triggered.

Tools Used

Manual review

Recommendations

Using <= can ensure that users are still far away from liquidation after withdrawing funds, rather than just stepping on the liquidation line.

if (collateralValue - nftValue <= userDebt.percentMul(liquidationThreshold)) {
revert WithdrawalWouldLeaveUserUnderCollateralized();
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!