Skip to content

fix(sdk-coin-xrp): set SendMax to cover MPT TransferFee on withdrawal#9193

Draft
0xPrabh wants to merge 1 commit into
masterfrom
CHALO-802
Draft

fix(sdk-coin-xrp): set SendMax to cover MPT TransferFee on withdrawal#9193
0xPrabh wants to merge 1 commit into
masterfrom
CHALO-802

Conversation

@0xPrabh

@0xPrabh 0xPrabh commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes broken withdrawal flow for XRP MPT tokens that have a non-zero TransferFee on their MPTokenIssuance ledger object (e.g. txrp:feesec).

Root cause: When an MPT issuance has TransferFee > 0, rippled deducts Amount + ⌈Amount × fee / 100_000⌉ from the sender. Without SendMax set, the transaction fails with tecPATH_PARTIAL.

Fix:

  • Added transferFee(fee: number) method to MPTokenTransferBuilder that accepts the MPTokenIssuance.TransferFee ledger field (integer in [0, 50_000])
  • Computes SendMax = Amount + ⌈Amount × fee / 100_000⌉ using ceiling division (BigInt)
  • Restores SendMax across the multi-sig rebuild round-trip so a second signer doesn't lose it

Issue Number: CHALO-802

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added unit tests covering:

  • SendMax set correctly when transferFee is non-zero (0.1% fee on 1,000,000 → SendMax = 1,001,000)
  • Ceiling division for fractional fees (1 unit × 0.1% → fee rounds up to 1)
  • SendMax preserved through serialize → rebuild round-trip (multi-sig path)
  • transferFee(0) omits SendMax
  • Rejects invalid fee values (negative, > 50,000, non-integer)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My commits follow Conventional Commits
  • The ticket was included in the commit message (CHALO-802)
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally

When an MPTokenIssuance has a non-zero TransferFee, rippled deducts
Amount + ceil(Amount * fee / 100_000) from the sender. Without SendMax
the tx fails with tecPATH_PARTIAL. This fix computes and sets SendMax
correctly, and restores it across the multi-sig rebuild round-trip.

Ticket: CHALO-802
@0xPrabh 0xPrabh requested a review from a team as a code owner July 7, 2026 09:54
@linear-code

linear-code Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

CHALO-802

@0xPrabh 0xPrabh marked this pull request as draft July 7, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant