Skip to content

fixAMMClawbackRounding: adjust last holder's LPToken balance#694

Merged
RichardAH merged 2 commits intoXahau:fixAMMv1_3from
tequdev:fixAMMClawbackRounding
Feb 25, 2026
Merged

fixAMMClawbackRounding: adjust last holder's LPToken balance#694
RichardAH merged 2 commits intoXahau:fixAMMv1_3from
tequdev:fixAMMClawbackRounding

Conversation

@tequdev
Copy link
Member

@tequdev tequdev commented Feb 24, 2026

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 bothAMMWithdraw and AMMClawback call to adjust LPTokenBalance.
  2. Added the unit test testLastHolderLPTokenBalance to test the scenario.
  3. Modify the existing unit tests for fixAMMClawbackRounding.

yinyiqian1 and others added 2 commits February 24, 2026 16:30
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`.
@RichardAH RichardAH merged commit 64c2324 into Xahau:fixAMMv1_3 Feb 25, 2026
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants