Skip to content

Add token amount formatting with decimal precision #242

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

Soroban token amounts are i128 integers (smallest unit, like stroops for XLM or units for USDC at 7 decimals). The frontend currently has no utilities for converting between raw on-chain values and human-readable amounts.

What Needs to Happen

  • Create frontend/src/utils/amount.ts with:
    • fromStroops(amount: bigint, decimals: number): string
    • toStroops(amount: string, decimals: number): bigint
    • formatStreamRate(ratePerSecond: bigint, decimals: number): string (e.g., "0.0001 USDC/sec")
    • hasValidPrecision(amount: string, decimals: number): boolean
  • Apply to all amount inputs and displays throughout the app
  • Fetch token decimals from contract once and cache per token address

Files

  • frontend/src/utils/amount.ts (create)

Acceptance Criteria

  • All amounts display in human-readable format
  • Inputs reject invalid precision
  • Stream rate shown per second and per month

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programfrontendFrontend related tasks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions