Skip to content

Add helper for converting a Stellar stroop amount to a human-readable XLM string with correct decimal places #185

Description

@Chucks1093

Summary

XLM amounts from the Stellar network arrive as stroop integers (1 XLM = 10,000,000 stroops). Several endpoints convert stroops to XLM inline with inconsistent decimal handling. A shared stroopsToXlm(stroops: bigint): string helper should centralise the conversion.

Scope

  • Add stroopsToXlm(stroops: bigint): string returning a string with exactly 7 decimal places
  • Add unit tests: 10000000 stroops → '1.0000000', 1 stroop → '0.0000001', 0 stroops → '0.0000000'
  • Test a large value (e.g. 1000000000000 stroops) does not lose precision
  • Replace all inline stroop-to-XLM conversions in existing endpoints with the helper
  • Helper must not use floating-point arithmetic (use bigint throughout)

Acceptance Criteria

  • 10,000,000 stroops returns '1.0000000'
  • 1 stroop returns '0.0000001'
  • 0 stroops returns '0.0000000'
  • Large values handled without precision loss
  • No floating-point arithmetic in the implementation

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions