fix: Use holder's balance for AMMClawback owner-reserve check#7796
fix: Use holder's balance for AMMClawback owner-reserve check#7796ckeshava wants to merge 7 commits into
Conversation
…w trustline is created; Legacy version of the code reads the Issuer's balance which is different from Holder's balance
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7796 +/- ##
=======================================
Coverage 82.8% 82.8%
=======================================
Files 1036 1036
Lines 80107 80110 +3
Branches 8932 8930 -2
=======================================
+ Hits 66300 66307 +7
+ Misses 13798 13794 -4
Partials 9 9
🚀 New features to boost your workflow:
|
|
@gregtatcam @yinyiqian1 Please review this PR and advise on the next steps. |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ckeshava I don't think this should be "fixed" by failing the transaction — the current outcome is correct; it's the intent that reads unclearly. Skip sufficientReserve on the clawback path (e.g. when authHandling == IgnoreAuth) so the outcome no longer depends on the issuer incidentally holding enough XRP, and This keeps the correct outcome, removes the ambiguity, and fixes a real edge case: for MPT the check consults the issuer's balance alone, so a low-XRP issuer can currently be blocked. |
…nderfunded Issuer / Holder
… into ammclawback-fixes
Summary
AMMClawbackreusesAMMWithdraw's helpers to return the paired asset to the holder. When the paired asset's trustline has to be auto-created, the reserve check was fed the issuer's pre-fee balance (sfAccountis the issuer) instead of the holder's. As a result, the issuer's XRP could satisfy a reserve requirement that is meant to protect the holder, forcing an under-reserved holder into a new trustline and an increased owner count — even though the equivalent holder-signedAMMWithdrawcorrectly fails withtecINSUFFICIENT_RESERVE.Fix
Gated behind the new
fixAMMClawbackReserve1amendment: the owner-reserve check now uses the holder's own XRP balance. Pre-amendment behavior is unchanged.Tests
Added a unit test covering both paths:
tecINSUFFICIENT_RESERVE, owner count unchanged (matches the controlAMMWithdraw).🤖 Generated with Claude Code