There is no precision scaling for tokenAmountFromDebtCovered
, this cause huge amount of user's collateral get liquidated.
For liquidating a user whose health factor is below the minimum health factor, users can call liquidate
function.
this function will take a debt amount in USDC from caller in order to liquidate the target user and it calls getTokenAmountFromUsd
function to calculate the collateral that can be liquidated, here is getTokenAmountFromUsd
:
As you can see it returns the price with 18 decimals, after that liquidate
function calculate bonusCollateral
and add the returned value from getTokenAmountFromUsd
with bonusCollateral
to get value that should be paid to liquidator (collaterlal of target user)
After this calculations it sends totalCollateralToRedeem
from target user's collateral to liquidator with help of _redeemCollateral
function.
But the problem is if the token that liquidator want to receive in return (collateral
token) has not 18 decimals the totalCollateralToRedeem
value will be incorrect since it has 18 decimals.
If liquidator wants to liquidate the target user's WBTC (WBTC has 8 decimals) the target user will lose alots of WBTC because the totalCollateralToRedeem
has 18 decimals.
Imagine the value that target should be liquidated is 1 WBTC:
expected totalCollateralToRedeem
: 100000000 (8 decimals)
actual value of totalCollateralToRedeem
: 1000000000000000000 (18 decimals)
then target will get liquidated by 10000000000
WBTC not 1
Manual Analysis
You should scale precision of tokenAmountFromDebtCovered
to token's precision in order to code work correctly, it should look like this:
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.