Algo Ssstablecoinsss

First Flight #30
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Severity: medium
Invalid

Protocol can enter unliquidatable state during catastrophic price crashes

Summary

During extreme price crashes, the protocol can enter a state where undercollateralized positions become mathematically impossible to liquidate, leading to permanent bad debt. This occurs because liquidators cannot mint enough DSC to perform liquidations, even with large amounts of collateral, due to the protocol's 50% collateralization requirement.

Vulnerability Details

The issue manifests when collateral prices fall so low that the value of even large amounts of collateral isn't sufficient to mint the DSC needed for liquidation. This creates a mathematical deadlock in the liquidation mechanism.

This test proves the mathematical deadlock by testing lower collateral prices:

def test_liquidation_limit_price(dsce, weth, eth_usd, dsc):
"""Find the price at which liquidation becomes mathematically impossible"""
USER = boa.env.generate_address()
LIQUIDATOR = boa.env.generate_address()
# Initial setup at $2000/ETH
INITIAL_PRICE = 2_000 * 10**8
eth_usd.updateAnswer(INITIAL_PRICE)
# User deposits 1 ETH and mints 500 DSC
DEPOSIT_AMOUNT = to_wei(1, "ether")
MINT_AMOUNT = to_wei(500, "ether")
weth.mint(USER, DEPOSIT_AMOUNT)
with boa.env.prank(USER):
weth.approve(dsce.address, DEPOSIT_AMOUNT)
dsce.deposit_collateral_and_mint_dsc(weth, DEPOSIT_AMOUNT, MINT_AMOUNT)
# Test prices around the theoretical limit
test_prices = [
10 * 10**7, # $0.10
9 * 10**7, # $0.09
8 * 10**7, # $0.08
7 * 10**7, # $0.07
6 * 10**7, # $0.06
5 * 10**7, # $0.05
4 * 10**7, # $0.04
3 * 10**7, # $0.03
2 * 10**7, # $0.02
1 * 10**7, # $0.01
9 * 10**6, # $0.009
]
LIQUIDATOR_COLLATERAL = to_wei(10000, "ether") # 10000 ETH
debt_to_cover = MINT_AMOUNT # 500 DSC
limit_price_found = False
for price in test_prices:
eth_usd.updateAnswer(price)
# Calculate liquidator's maximum possible DSC mint
collateral_value = dsce.get_usd_value(weth, LIQUIDATOR_COLLATERAL)
max_dsc_possible = collateral_value * 50 // 100 # 50% collateralization ratio
health_factor = dsce.health_factor(USER)
can_liquidate = max_dsc_possible >= debt_to_cover
print(f"\nTesting price: ${price/10**8}")
print(f"- Liquidator's 10000 ETH value: ${collateral_value/1e18}")
print(f"- Max DSC possible to mint: ${max_dsc_possible/1e18}")
print(f"- DSC needed for liquidation: ${debt_to_cover/1e18}")
print(f"- Liquidation possible: {can_liquidate}")
if not can_liquidate and not limit_price_found:
limit_price_found = True
print(f"\n=== Limit Price Found: ${price/10**8} ===")
print("At this price, liquidation becomes mathematically impossible because:")
print(f"- Even with {LIQUIDATOR_COLLATERAL/1e18} ETH as collateral")
print(f"- Worth only ${collateral_value/1e18}")
print(f"- Can only mint ${max_dsc_possible/1e18} DSC")
print(f"- But need ${debt_to_cover/1e18} DSC for liquidation")
# Verify we can't actually perform the liquidation
weth.mint(LIQUIDATOR, LIQUIDATOR_COLLATERAL)
with boa.env.prank(LIQUIDATOR):
weth.approve(dsce.address, LIQUIDATOR_COLLATERAL)
try:
dsce.deposit_collateral_and_mint_dsc(weth, LIQUIDATOR_COLLATERAL, debt_to_cover)
assert False, "Should not be able to mint this much DSC"
except Exception as e:
assert "DSCEngine__BreaksHealthFactor" in str(e), "Should fail due to health factor"
break
assert limit_price_found, "Limit price should have been found"

Impact

  • Protocol can contain permanently unliquidatable bad debt

  • Liquidation mechanism becomes non-functional

  • Could lead to technical insolvency

  • However, requires such extreme market conditions (99.99%+ price crash) that the practical impact is limited

Tools Used

  • Manual review

  • Custom test suite

  • AI

Recommendations

  1. Add a minimum liquidation price threshold

  2. Implement an emergency shutdown mechanism that triggers when prices fall below critical thresholds

  3. Add circuit breakers that temporarily pause liquidations during extreme price volatility until governance can assess the situation

The choice of which strategies to implement would depend on the protocol's design goals, risk tolerance, and governance structure. In practice, a combination of these strategies might be used to provide robust protection against extreme market conditions.

Updates

Lead Judging Commences

bube Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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