Compare commits

..

13 Commits

Author SHA1 Message Date
tequ
10e76c0475 Merge branch 'dev' into test-hook-fee 2026-03-01 13:28:00 +09:00
tequ
8cfee6c8a3 Merge fixAMMClawbackRounding amendment into featureAMMClawback amendment 2026-02-25 19:07:45 +10:00
yinyiqian1
8673599d2b fixAMMClawbackRounding: adjust last holder's LPToken balance (#5513)
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`.
2026-02-25 19:07:45 +10:00
tequ
ec65e622aa Merge fixAMMv1_3 amendment into featureAMM amendment 2026-02-25 16:20:43 +10:00
Gregory Tsipenyuk
65837f49e1 fix: Add AMMv1_3 amendment (#5203)
* Add AMM bid/create/deposit/swap/withdraw/vote invariants:
  - Deposit, Withdrawal invariants: `sqrt(asset1Balance * asset2Balance) >= LPTokens`.
  - Bid: `sqrt(asset1Balance * asset2Balance) > LPTokens` and the pool balances don't change.
  - Create: `sqrt(asset1Balance * assetBalance2) == LPTokens`.
  - Swap: `asset1BalanceAfter * asset2BalanceAfter >= asset1BalanceBefore * asset2BalanceBefore`
     and `LPTokens` don't change.
  - Vote: `LPTokens` and pool balances don't change.
  - All AMM and swap transactions: amounts and tokens are greater than zero, except on withdrawal if all tokens
    are withdrawn.
* Add AMM deposit and withdraw rounding to ensure AMM invariant:
  - On deposit, tokens out are rounded downward and deposit amount is rounded upward.
  - On withdrawal, tokens in are rounded upward and withdrawal amount is rounded downward.
* Add Order Book Offer invariant to verify consumed amounts. Consumed amounts are less than the offer.
* Fix Bid validation. `AuthAccount` can't have duplicate accounts or the submitter account.
2026-02-25 16:20:43 +10:00
tequ
b2b160e9ea Update util_keylet fee test 2026-02-24 17:23:11 +09:00
tequ
164b1765b6 Merge branch 'dev' into test-hook-fee 2026-02-24 16:47:28 +09:00
RichardAH
3a2e3e99c4 Merge branch 'dev' into test-hook-fee 2026-02-18 09:35:05 +10:00
tequ
176de80369 Updated tests to align with the changes merged into the dev branch. 2026-02-17 10:37:27 +09:00
RichardAH
508a16cbe4 Merge branch 'dev' into test-hook-fee 2026-02-17 11:34:28 +10:00
tequ
9eb539da2b Merge branch 'dev' into test-hook-fee 2026-02-16 14:25:00 +09:00
tequ
335dcb1351 Merge branch 'dev' into test-hook-fee 2026-01-27 21:00:06 +09:00
tequ
5d9071695a Add tests for Hooks fee 2026-01-20 12:12:45 +09:00

File diff suppressed because it is too large Load Diff