Algo Ssstablecoinsss

AI First Flight #2
Beginner FriendlyDeFi
EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

Redundant Health Factor Check in burn_dsc Wastes Gas

Redundant Health Factor Check in burn_dsc Wastes Gas

Description

The burn_dsc function checks the caller's health factor after burning DSC:

@external
def burn_dsc(amount_dsc_to_burn: uint256):
self._burn_dsc(amount_dsc_to_burn, msg.sender, msg.sender)
self._revert_if_health_factor_is_broken(msg.sender)

Burning DSC reduces debt, which can only improve (or maintain) the health factor. It is mathematically impossible for burning DSC to break the health factor:

  • Health factor = (collateral_usd * LIQUIDATION_THRESHOLD / LIQUIDATION_PRECISION * 1e18) / total_dsc_minted

  • Burning DSC decreases total_dsc_minted in the denominator

  • Decreasing the denominator increases the fraction

  • Therefore health factor always improves or remains max_value(uint256) (if debt becomes 0)

The _revert_if_health_factor_is_broken check on line 151 will never revert for a burn_dsc call, making it a wasted gas cost (2 SLOAD + oracle calls + arithmetic).

Risk

Likelihood: High -- Every burn_dsc call pays for this unnecessary check.

Impact: Informational -- No security impact, only gas waste. Each unnecessary health factor check costs approximately 5,000-10,000 gas (two storage reads for minted amount and collateral, plus oracle call overhead).

Proof of Concept

def test_burning_dsc_always_improves_health_factor(self, dsce_minted, dsc, some_user):
hf_before = dsce_minted.health_factor(some_user)
burn_amount = AMOUNT_TO_MINT // 2
with boa.env.prank(some_user):
dsc.approve(dsce_minted.address, burn_amount)
dsce_minted.burn_dsc(burn_amount)
hf_after = dsce_minted.health_factor(some_user)
assert hf_after > hf_before # Always improves — check is redundant

Recommended Mitigation

Remove the health factor check from burn_dsc:

@external
def burn_dsc(amount_dsc_to_burn: uint256):
self._burn_dsc(amount_dsc_to_burn, msg.sender, msg.sender)
# Health factor check removed -- burning DSC can only improve health factor
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge 5 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!