Skip to content

fix(utils): preserve sign in formatCurrency for negative figures (#90) - #96

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix-format-currency-sign
Open

fix(utils): preserve sign in formatCurrency for negative figures (#90)#96
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix-format-currency-sign

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Closes #90

Problem

formatCurrency unconditionally applied Math.abs(amount), silently stripping the minus sign on negative figures (e.g. formatCurrency(-50) produced "50 USDC"). This contradicted StatCard's currency formatting which preserves negative signs.

Solution

  • Removed Math.abs(amount) from formatCurrency in src/lib/utils.ts.
  • Preserved negative sign and formatted values using amount.toLocaleString("en-US", { maximumFractionDigits: 2 }).
  • Added unit tests in src/lib/utils.test.ts verifying positive, negative, XLM, and non-finite inputs.

Verification

  • npx jest src/lib/utils.test.ts passed (all 4 tests green).

…geFi#90)

- remove unconditional Math.abs() in formatCurrency
- align behavior with StatCard currency formatting to preserve negative signs
- add unit test coverage in utils.test.ts
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatCurrency unconditionally applies Math.abs(), silently hiding the sign on negative financial figures

1 participant