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

[Dedaub] L1: Partial claim of AVAX might result in rounding errors #126

Closed
0xchaosbi opened this issue Aug 11, 2022 · 2 comments · Fixed by #154
Closed

[Dedaub] L1: Partial claim of AVAX might result in rounding errors #126

0xchaosbi opened this issue Aug 11, 2022 · 2 comments · Fixed by #154
Assignees

Comments

@0xchaosbi
Copy link
Contributor

0xchaosbi commented Aug 11, 2022

According to a note in the AvaLido::claim function, the protocol allows partial claims of unstake requests so that users don't need to wait for the entire request to be filled to get some liquidity. This is the reason the exchange rate stAVAX:AVAX is set in function requestWithdrawal instead of in claim. The partial claim logic is implemented mainly in the following line:

uint256 amountOfStAVAXToBurn = Math.mulDiv(request.stAVAXLocked, amount, request.amountRequested);

The amount of stAVAX that are traded back, request.stAVAXLocked, is multiplied by the amount of AVAX claimed, amount, and the result is divided by the whole AVAX amount corresponding to the request, request.amountRequested to give us the corresponding amount of stAVAX that should be burned. This computation might suffer from rounding errors depending on the amount parameter, leading to a small amount of stAVAX not being burned. We believe that these amounts would be too small to really affect the exchange rate of stAVAX:AVAX, still it would make sense to verify this or get rid of the rounding error altogether.

@0xchaosbi
Copy link
Contributor Author

Need to discuss whether we will keep partial claims since Lido have raised this as something we might want to remove in simplifying the protocol.

@0xchaosbi
Copy link
Contributor Author

According to a note in the AvaLido::claim function, the protocol allows partial claims of unstake requests so that users don't need to wait for the entire request to be filled to get some liquidity. This is the reason the exchange rate stAVAX:AVAX is set in function requestWithdrawal instead of in claim.

It is also so we don't accrue rewards while you're in the withdrawal queue and you can get rewards risk-free while jumping in and out of the protocol.

This line is also used in any claim, not just partial claims.

Also related: lidofinance/core#442 (comment)

TODO

Let's start by writing a test to recreate the rounding error and go from there.

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

Successfully merging a pull request may close this issue.

2 participants