Skip to content

[BUG] Floating-point arithmetic for percentage rule amounts - potential precision loss on XLM calculations #13

Description

@thisisouvik

Description

In processor.ts, percentage-based rule amounts use JavaScript floating-point arithmetic. IEEE 754 representation can produce imprecise results (e.g. 0.1 * 0.2 = 0.020000000000000004). While Stellar rounds to 7 decimal places, intermediate precision loss can cause edge cases where execAmount > paymentAmountXLM, incorrectly triggering the skip guard.

Expected Behavior

Use integer arithmetic (stroops) for all financial calculations. 1 XLM = 10,000,000 stroops. Convert to stroops before arithmetic, convert back to XLM strings for submission.

Impact

Low - Amounts are off by at most 1 stroop (0.0000001 XLM), but financial software must use exact arithmetic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveMarked as Stellar Wavebug: lowLow priority bugengineRelated to the rule processing engine

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions