lidofinance / lidofinance/docs

Wrong formula in `ETH for rebalance` calculation

Open
#718 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
61
Forks
81
Avg merge
3d 11h
Merged PRs (30d)
14

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open run-on-lido/stvaults/building-guides/basic-stvault.md around line 447 and compare the displayed formula with the derivation and example in this issue. Update the documentation so the parentheses match the stated calculation, then verify the example produces the intended rebalance amount and health factor.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.