lidofinance / lidofinance/docs
Wrong formula in `ETH for rebalance` calculation
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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