Skip to content

Wrong formula in ETH for rebalance calculation #718

@fsosa98

Description

@fsosa98

The formula in the docs seems to have misplaced parentheses.

Current (incorrect):

ETH for rebalance = stETH Liability - (1 - Reserve Ratio * Total Value) / Reserve Ratio

Should be:

ETH for rebalance = (stETH Liability - (1 - Reserve Ratio) * Total Value) / Reserve Ratio

Derivation:

X  - ETH for rebalance
L  - stETH Liability
RR - Reserve Ratio
TV - Total Value

HF = (TV * (1 - RR)) / L
We want to deduct X from TV and L to return health factor to 100% (1)

L - X = (TV - X) * (1 - RR)
L - X = TV - X - TV * RR + RR * X
X = (L - TV * (1 - RR)) / RR

Which gives:

ETH for rebalance = (stETH Liability - Total Value * (1 - Reserve Ratio)) / Reserve Ratio

Example:
For stETH Liability = 90, Total Value = 99, Reserve Ratio = 0.1:

  • Current formula → ETH for rebalance = 90 - (1 - 0.1 * 99) / 0.1 = 179
  • Correct formula → ETH for rebalance = (90 - (1 - 0.1) * 99) / 0.1 = 9

The result 179 is incorrect, it would mean rebalancing more ETH than exists in the stVault (99), which makes no sense.
With the corrected formula, the rebalance amount is 9, and checking the health factor after rebalancing confirms it returns to exactly 1, as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions