Skip to content

Commit c94e921

Browse files
committed
bug-fix_allow_partial_burn
1 parent d83330e commit c94e921

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/DSCEngine.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ contract DSCEngine is ReentrancyGuard {
182182
_revertIfHealthFactorIsBroken(msg.sender);
183183
}
184184

185-
//q I think here is an error of underflow
186185
function burnDSC(uint256 amount) public moreThanZero(amount) {
186+
uint256 startingUserHealthFactor = _healthFactor(msg.sender);
187187
_burnDSC(msg.sender, msg.sender, amount);
188-
_revertIfHealthFactorIsBroken(msg.sender);
188+
uint256 endingUserHealthFactor = _healthFactor(msg.sender);
189+
if (endingUserHealthFactor <= startingUserHealthFactor) revert DSCEngine__HealthFactorIsNotImproved(); // being extra safe
190+
// _revertIfHealthFactorIsBroken(msg.sender); // this does not allow liquidatable account to partially burn some DSC
189191
}
190192

191193
// $100 ETH backing $50 DSC

0 commit comments

Comments
 (0)