Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bond balance getting lower on 1 or 2 wei due to rounding down integer math after deposit #30

Open
vgorkavenko opened this issue Oct 13, 2023 · 1 comment

Comments

@vgorkavenko
Copy link
Contributor

The root of the problem is described here lidofinance/lido-dao#442

It affects the flows described below

ETH\stETH deposit

  • Node operator's manager deposits bond in ETH\stETH with 1 validator key
  • CSMAccounting stakes\transfer (depends on token) this amount and increases Node operator's bond with resulting shares
  • Node operator's manager checks for the required bond for the already added key by corresponding contract method and expects to get 0 Wei in ETH\stETH

Current behavior: The contract gives 1 Wei because the conversion from shares to ethers include rounding error and it is reflected in diff between required bond and the current NO bone

wstETH deposit

  • Node operator's manager deposits bond in wstETH with 1 validator key
  • CSMAccounting unwrap this amount to stETH and increases Node operator's bond with resulting shares
  • Node operator's manager checks for the required bond for the already added key by corresponding contract method and expects to get 0 Wei in ETH\stETH\wstETH

Current behavior: The contract gives 2 Wei (includes rounding error after wstETH unwrapping on deposit) because the conversion from shares to ethers include rounding error and it is reflected in diff between required bond and the current NO bone

Current mitigation

Method returning the required bond value for the next key(s) to deposit takes into account the missing Wei

@dgusakov
Copy link
Contributor

🍌 valid issue. Yet, I suppose it should be fixed on the stETH side. Anyway, thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants