The _calculateHealthFactor()
function in DSCEngine.sol
suffers from precision loss, leading to user funds getting stuck when collateralValueInUsd
is equal to 1. Although the amount getting stuck is minimal, users will still be unable to withdraw their 1 dollar.
The issue can be observed on line 334 of DSCEngine.sol
. When collateralValueInUsd
is set to 1, it results in precision loss during the calculations:
##Impact
A user with 1 dollar of collateralValueInUsd would not be able to withdraw their collateral unless they deposited more and then attempted to withdraw.
Tools Used
Manual review.
Recommendations
Consider checking if collateralValueInUsd = 1 and if it does, then return 1 instead.
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.