Algo Ssstablecoinsss

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

[H-01] Liquidation can revert when seized collateral (+bonus) exceeds user collateral, making positions unliquidatable

Root + Impact

Description

The liquidate() function calculates the collateral to seize from a borrower based on:

  • The debt being repaid

  • The liquidation bonus

However, there is no validation ensuring that:

collateral_to_seize <= user_collateral_balance

If the calculated collateral_to_seize (including liquidation bonus) exceeds the borrower’s actual deposited collateral, the liquidation attempt will revert.

This creates a scenario where undercollateralized positions become unliquidatable, breaking a core stability mechanism of the protocol.

Risk

Likelihood: High

  • Reason 1 Happens during sharp market volatility.

  • Reason 2 Common in oracle-based liquidation systems.

  • Reason 3 Especially possible with high liquidation bonuses.

Impact: High

  • Impact 1 Prevents liquidation.

  • Impact 2 Allows toxic debt to remain.

  • Impact 3 Can cause systemic insolvency.

  • Impact 4 Breaks protocol core invariant.

Proof of Concept

def test_liquidation_reverts_if_bonus_exceeds_collateral():
# Assume user collateral = 1 ETH
# ETH price drops drastically
# Liquidation bonus = 10%
debt_to_cover = 1000
collateral_equivalent = 1 ETH
bonus = 0.1 ETH
collateral_to_seize = 1.1 ETH
# User only has 1 ETH
# Redeem attempts to seize 1.1 ETH
# Reverts

Expected behavior:
Liquidation should succeed and seize up to available collateral.

Actual behavior:
Liquidation reverts entirely.

Recommended Mitigation

1. Cap Seizable Collateral

Modify liquidation logic:

collateral_to_seize = min(
collateral_equivalent + bonus,
user_collateral
)

This ensures:

*Liquidation always executes

*No revert due to over-seizure

*Protocol captures maximum available value

2.Adjust Debt Accounting

If full debt cannot be covered due to insufficient collateral:

Burn only proportional debt

Or track remaining bad debt explicitly.

3.Defensive Programming

At the external boundary:

assert user_collateral > 0
assert debt_to_cover > 0

And internally:

if collateral_to_seize > user_collateral:
collateral_to_seize = user_collateral

Design Principle Reminder

Liquidation must:

  • Never revert for arithmetic reasons

  • Never assume sufficient collateral

  • Always preserve solvency over strict bonus rules

Liquidation logic must prioritize protocol survival.

Conclusion:

This issue allows unhealthy positions to become permanently unliquidatable when liquidation bonus pushes seized collateral above user balance.

That:

  • Breaks protocol core invariant

  • Threatens stablecoin backing

  • Introduces systemic insolvency risk

Fixing this requires capping collateral seizure to available balance and adjusting debt settlement accordingly.

Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 3 hours 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!