Skip to content

fix(api): format stream amounts with the token's real decimals - #28

Open
jayteemoney wants to merge 1 commit into
mainfrom
fix/api-token-decimals
Open

jayteemoney wants to merge 1 commit into
mainfrom
fix/api-token-decimals

Conversation

@jayteemoney

Copy link
Copy Markdown
Owner

Bug

/api/streams/:id formatted every amount as 8 decimals. USDA has 6, so stream 11 showed 0.012 instead of 1.20.

Fix

  • Read decimals from the token contract (get-decimals), cached per instance. Works for any SIP-010 token, not just listed ones.
  • If the read fails, formatted fields are null instead of wrong.
  • New tokenDecimals field in the response. Guide updated.

Verified

  • Lint and webpack build pass.
  • Local mainnet build: all 11 streams (USDA) format correctly, e.g. stream 11 1.20.
  • get-decimals parses as 8 for sBTC, ALEX, xBTC.

Not changed: /api/daos/:admin totalDepositedFormatted sums deposits across tokens, so no single decimal scale is correct for it.

🤖 Generated with Claude Code

https://claude.ai/code/session_011DndgWvvL6sUfzTgmC67Wq

/api/streams/:id formatted every amount as if the token had 8 decimals,
so USDA (6 decimals) showed 100x too small: stream 11 read "0.012"
instead of "1.20". Decimals are now read from the token contract's
SIP-010 get-decimals and cached per instance, so any token formats
correctly, listed or not. If the read fails the formatted fields are
null rather than a wrong number. Adds tokenDecimals to the response.

Verified on a local mainnet build: all 11 streams (USDA) format
correctly, and get-decimals parses as 8 for sBTC, ALEX and xBTC.

Claude-Session: https://claude.ai/code/session_011DndgWvvL6sUfzTgmC67Wq
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
stackstream Ready Ready Preview Sep 24, 2026 1:50pm UTC

This branch was successfully deployed

1 active deployment
Preview — bba29b48 Deployed Sep 24, 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.

1 participant