Skip to content

fix: read mint decimals from on-chain account instead of hardcoding 6#3

Open
gitteri wants to merge 1 commit into
mainfrom
fix/rpc-mint-decimals
Open

fix: read mint decimals from on-chain account instead of hardcoding 6#3
gitteri wants to merge 1 commit into
mainfrom
fix/rpc-mint-decimals

Conversation

@gitteri

@gitteri gitteri commented Feb 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • The RPC getTokenAccountBalance handler was hardcoding decimals = 6 for all tokens, producing incorrect UI amounts for tokens with non-6 decimals (e.g. SOL with 9, USDT with varying decimals across chains).
  • Now reads the actual decimals byte (offset 44) from the on-chain mint account data, falling back to an error if the mint account is missing or malformed.

Changed files

  • core/src/rpc/get_token_account_balance_impl.rs

Test plan

  • Verify getTokenAccountBalance returns correct uiAmount for a 6-decimal token (e.g. USDC)
  • Verify correct uiAmount for a 9-decimal token (e.g. SOL wrapped)
  • Verify error is returned when mint account doesn't exist

Made with Cursor

The RPC getTokenAccountBalance handler was returning incorrect UI
amounts for tokens with non-6 decimals. Now reads the actual decimals
byte from the mint account data.
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