fixAMMClawbackRounding: adjust last holder's LPToken balance#694
Merged
RichardAH merged 2 commits intoXahau:fixAMMv1_3from Feb 25, 2026
Merged
fixAMMClawbackRounding: adjust last holder's LPToken balance#694RichardAH merged 2 commits intoXahau:fixAMMv1_3from
RichardAH merged 2 commits intoXahau:fixAMMv1_3from
Conversation
Due to rounding, the LPTokenBalance of the last LP might not match the LP's trustline balance. This was fixed for `AMMWithdraw` in `fixAMMv1_1` by adjusting the LPTokenBalance to be the same as the trustline balance. Since `AMMClawback` is also performing a withdrawal, we need to adjust LPTokenBalance as well in `AMMClawback.` This change includes: 1. Refactored `verifyAndAdjustLPTokenBalance` function in `AMMUtils`, which both`AMMWithdraw` and `AMMClawback` call to adjust LPTokenBalance. 2. Added the unit test `testLastHolderLPTokenBalance` to test the scenario. 3. Modify the existing unit tests for `fixAMMClawbackRounding`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Due to rounding, the LPTokenBalance of the last LP might not match the LP's trustline balance. This was fixed for
AMMWithdrawinfixAMMv1_1by adjusting the LPTokenBalance to be the same as the trustline balance. SinceAMMClawbackis also performing a withdrawal, we need to adjust LPTokenBalance as well inAMMClawback.This change includes:
verifyAndAdjustLPTokenBalancefunction inAMMUtils, which bothAMMWithdrawandAMMClawbackcall to adjust LPTokenBalance.testLastHolderLPTokenBalanceto test the scenario.fixAMMClawbackRounding.