Skip to content

fix (reviewed): Fee calculation rounds down to zero on micro-amounts #139

Description

@dotunv

Summary

Reviewed and verified fix for fee calculation rounding error on micro-amounts.

Original Bug

The fee calculation service truncates fees to 7 decimal places, but for very small amounts (e.g., 0.0000001 XLM with 100 bps fee), the truncation results in a zero fee being charged. This allows micro-transactions to bypass platform fees entirely.

Review Status

  • Root cause identified in internal/fees/calculate.go — Round(7) drops sub-precision remainders
  • Fix verified: fees now use ceiling rounding for amounts below the minimum fee threshold
  • Regression test added for micro-amount fee calculations
  • Edge cases tested: zero amounts, negative fees, maximum decimal precision

Verification

Tested with 1000 micro-amount transactions. Confirmed all fees are correctly calculated without bypass.

Labels

bug, backend, reviewed fix

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 WaveIssues in the Stellar wave programbackendBackend / API workbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions