Skip to content

[Bug]: Shortfall value might not be enough for vault to become healthy #1305

@shoham-certora

Description

@shoham-certora

Summary

When using VaultHub.rebalanceShortfall value for rebalancing an unhealthy vault (e.g. in VaultHub.forceRebalance), the vault may still remain unhealthy due to rounding issues. Particularly in cases where the vault's reserveRatioBP is equal to its forcedRebalanceThresholdBP.

Expected Behavior

After calling VaultHub.forceRebalance(vault) or VaultHub.rebalance(vault, rebalanceShortfall(vault) for an unhealthy vault, it is expected that the vault will be healthy (i.e. isVaultHealthy(vault) to return true).

Potential Impact

The vault will remain unhealthy, and will require additional rebalancing calls.

Steps to Reproduce

The example below was created by the Certora Prover, see this link for the full details.

  1. The vault's initial state:
    totalValue = 1000
    liabilityShares = 689
    sharesValue = 801 (internalEth = 100001, internalShares = 86021. ratio=1.162518454795922)
    reserveRatioBP = forcedRebalanceThresholdBP = 2000
    
  2. Shortfall calculation: yield 5:
    shortfall = 5
    sharesByTotalValue = 860
    liabilityShares - shortfall = 684
    sharesByTotalValue - shortfall = 855
    (liabilityShares - shortfall) / (sharesByTotalValue - shortfall) = 0.8 (80%)
    
  3. Call rebalance(vault, 5):
    liabilityShares = 684
    valueToRebalance = 6
    totalValue = 994
    (internalEth = 100007, internalShares = 86026. ratio = 1.1625206332969102)
    
  4. Is vault healthy returns false:
    liability = 796
    totalValue * (TOTAL_BASIS_POINTS - reserveRatioBP) / TOTAL_BASIS_POINTS = 795 (795.2)
    liability > 795
    

Note that even if we rebalanced by shortfall + 1 the vault remains unhealthy.

  • Call rebalance(vault, 6):
    liabilityShares = 683
    valueToRebalance = 7
    totalValue = 993
    (internalEth = 100008, internalShares = 86027. ratio = 1.1625187441152196)
    
  • Is vault healthy returns false:
    liability = 795 (by both the current and previous ratio)
    totalValue * (TOTAL_BASIS_POINTS - reserveRatioBP) / TOTAL_BASIS_POINTS = 794 (794.4)
    liability > 794
    

Possible Solutions

No response

Guidelines

Metadata

Metadata

Assignees

Labels

auditIssue comes as a result of an external auditbugSomething isn't workingvaultsLido stVaults related changes

Type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions