Skip to content

formatCurrency's amount parameter has no upper-bound/sanity guard, so a corrupted or misconfigured backend value renders as an implausibly large figure with no visual distinction from a real one #285

Closed

Description

@chonilius

src/lib/utils.ts#formatCurrency guards against non-finite input:

export function formatCurrency(amount: number, asset: "USDC" | "XLM" = "USDC") {
  if (!Number.isFinite(amount)) return `0 ${asset}`;
  return `${amount.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${asset}`;
}

but has no upper-bound sanity check. Every numeric field that eventually flows through
this function is coerced only for sign (coerceNonNegative clamps negatives to the
fallback) — nothing clamps an implausibly large value. A backend data-entry error, a unit
mismatch (e.g. a value accidentally sent in the asset's smallest unit — stroops for XLM,
or a wei-style base unit — instead of whole units), or simple corruption would produce a
technically-finite but nonsensical figure like 1,000,000,000,000 USDC, which
formatCurrency renders exactly as confidently as a real 1,200 USDC — same font size
band (per StatCard's valueFontClass, which only reacts to string length, not
plausibility), same styling, no warning indicator of any kind.

For a platform whose entire premise is trustworthy on-chain accounting, a stat card or
bounty reward that silently displays an absurd, corrupted figure with total visual
confidence — rather than at least a subtle "this looks unusually large" affordance — is a
real trust/quality-of-data gap, distinct from the sign-only clamping coerceNonNegative
already provides.

Suggested fix: consider a soft sanity ceiling in the adapters (coerceNonNegative or a
sibling helper) that flags/logs (or visually distinguishes) an implausibly large amount
rather than treating it identically to any other valid figure.

Activity

  1. added
    enhancement
    on Aug 21, 2026
  2. Y33t-dev commented on Aug 21, 2026

    @Y33t-dev

    Hello maintainers! I'd like to be assigned to this issue. I've reviewed the task thoroughly and understand both the problem and the expected outcome. I'm confident I can implement the solution efficiently while keeping the codebase clean and maintainable.

  3. added
    bug
    help wanted
    very hard
    on Aug 21, 2026
  4. added
    Stellar Wave
    on Aug 25, 2026
  5. Oluoma123 commented on Aug 25, 2026

    @Oluoma123

    @Oluoma123 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Good day I am a full stack developer with Over 6 years of experience and I have good practical knowledge on this kindle assign this to me.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Oluoma123 to this issue.

  6. Alimzy commented on Aug 25, 2026

    @Alimzy

    @Alimzy has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi,I'd like to work on this issue.

    I'm a software engineer with hands-on experience in testing, debugging, and building reliable features across the stack. I'm confident I can take this on and deliver a solid, well-tested solution that follows the project's existing conventions.

    I'll make sure to cover the core functionality as well as relevant edge cases to keep things reliable and regression-resistant.

    Let me know if I can get started, and I'll provide updates as I progress.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Alimzy to this issue.

  7. Demilade10 commented on Aug 25, 2026

    @Demilade10

    @Demilade10 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi maintainer I will like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Demilade10 to this issue.

  8. ritaifeoluwa commented on Aug 25, 2026

    @ritaifeoluwa

    @ritaifeoluwa has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    I would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @ritaifeoluwa to this issue.

  9. sarah-obasi-analytics commented on Aug 25, 2026

    @sarah-obasi-analytics

    @sarah-obasi-analytics has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    hello, can i WORK on this issue?, i can fix it.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @sarah-obasi-analytics to this issue.

  10. Olumide-01 commented on Aug 25, 2026

    @Olumide-01

    @Olumide-01 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi Maintainer, I have relevant experience on this issue and would deliver an excellent job if assigned to me.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Olumide-01 to this issue.

  11. drips-wave commented on Aug 25, 2026

    @drips-wave

    Congratulations, @ritaifeoluwa! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @ritaifeoluwa: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  12. drips-wave commented on Aug 25, 2026

    @drips-wave

    This issue has been completed by @ritaifeoluwa as part of the Stellar Wave Program's 8th Wave 🥳

    😎 @ritaifeoluwa: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  13. removed
    Stellar Wave
    on Oct 15, 2026
  14. added
    Stellar Wave
    on Oct 15, 2026
  15. removed
    Stellar Wave
    on Oct 15, 2026
  16. added
    Stellar Wave
    on Oct 15, 2026
  17. removed
    Stellar Wave
    on Oct 15, 2026
  18. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar Wavebugenhancementhelp wantedvery hard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions