Skip to content

Refactor refund logic to use UtilHelper for formatting XRPL amounts#437

Open
du1ana wants to merge 2 commits intoEvernodeXRPL:ubuntu-24from
du1ana:ubuntu-24-decimalfix
Open

Refactor refund logic to use UtilHelper for formatting XRPL amounts#437
du1ana wants to merge 2 commits intoEvernodeXRPL:ubuntu-24from
du1ana:ubuntu-24-decimalfix

Conversation

@du1ana
Copy link
Contributor

@du1ana du1ana commented Dec 26, 2025

When refunding tenants, the decimal multiplication of leaseAmount * remainingMoments can produce values exceeding XRPL's precision limits, causing Decimal precision out of range errors.

Steps to Reproduce

  1. Set a minimal lease amount (e.g., 0.000001 EVRs) on an Evernode host
  2. Create an instance using ev-devkit
  3. Delete the instance using evernode delete

Note: This error occurs intermittently, depending on the lease amount and remaining moment count at the time of deletion.

Error

Refunding tenant ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░...
Error: Decimal precision out of range
    at Amount.assertIouIsValid (...)

Fix

Introduced UtilHelper.formatXrplAmount() to ensure XRPL-compliant precision (15 significant digits) when calculating refund amounts.

Before:

(uriInfo.leaseAmount * remainingMoments).toString()

After:

UtilHelper.formatXrplAmount(uriInfo.leaseAmount, remainingMoments)

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