* Liquidators can liquidate unhealthy positions by repaying debt and seizing collateral. The function calculates amounts but doesn't validate they don't exceed user balances.
* The `liquidate()` function doesn't explicitly check that `debt_to_cover` doesn't exceed the user's actual debt, or that the collateral amount to redeem doesn't exceed the user's collateral balance. While these will revert due to underflow, the error messages are unclear.
```vyper
@external
def liquidate(collateral: address, user: address, debt_to_cover: uint256):
assert debt_to_cover > 0, "DSCEngine__NeedsMoreThanZero"
starting_user_health_factor: uint256 = self._health_factor(user)
assert (
starting_user_health_factor < MIN_HEALTH_FACTOR
), "DSCEngine__HealthFactorOk"
token_amount_from_debt_covered: uint256 = self._get_token_amount_from_usd(
collateral, debt_to_cover // @> No check that debt_to_cover <= user_debt
)
bonus_collateral: uint256 = (
token_amount_from_debt_covered * LIQUIDATION_BONUS
) // LIQUIDATION_PRECISION
self._redeem_collateral(
collateral,
token_amount_from_debt_covered + bonus_collateral, // @> No check that this <= user_collateral
user,
msg.sender,
)
```
Likelihood:
* Liquidators might miscalculate amounts and attempt to liquidate more than available
* Front-running or price changes between calculation and execution could cause amounts to exceed balances
* Integration with external interfaces could pass incorrect amounts
Impact:
* Unclear error messages when liquidation fails, wasting gas
* Poor user experience for liquidators
* Potential for repeated failed transactions
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.