Skip to content

fix: clamp decimals in format utils to prevent Simulate crash - #114

Merged
stackdapp-dev merged 4 commits into
mainfrom
develop
Mar 16, 2026
Merged

stackdapp-dev merged 4 commits into
mainfrom
develop

Conversation

@stackdapp-dev

@stackdapp-dev stackdapp-dev commented Mar 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes the app crash when tapping "Simulate" on /wallet
  • Root cause: formatAmount(value, 0) set minimumFractionDigits: 2 but maximumFractionDigits: 0, causing toLocaleString to throw RangeError that crashed the entire React tree
  • Clamped decimal parameters in formatAmount, formatCurrency, and formatPercent to valid ranges
  • Added 6 regression tests covering edge cases (decimals=0, decimals=1, negative decimals)

Test plan

  • 6 new unit tests for decimal clamping edge cases
  • Full suite: 1630/1630 tests passing
  • Manual: tap Simulate on /wallet after deploy — should open simulator without crashing

🤖 Generated with Claude Code

sd and others added 2 commits March 16, 2026 21:30
…revent RangeError

When formatAmount was called with decimals=0 (e.g., in LoanSimulator simulate mode),
minimumFractionDigits (hardcoded at 2) exceeded maximumFractionDigits (0), causing
toLocaleString to throw RangeError that crashed the entire React tree.

Also added clamping to formatCurrency and formatPercent for negative decimals values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ange-error

fix: clamp decimals in format utils to prevent RangeError crash
@vercel

vercel Bot commented Mar 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stackd-web Ready Ready Preview, Comment Mar 16, 2026 2:09pm

…simulate mode

Reorders the simulate mode layout so Borrow Amount (USDT) field and slider
appear directly under the LTV gauge, before the collateral type selector
and collateral input fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stackdapp-dev
stackdapp-dev merged commit 1a20f30 into main Mar 16, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — cfc9ff6e Deployed Mar 16, 2026 by vercel[bot]
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.

2 participants