Skip to content

TronChainAdapter: Hardcoded token precision causes incorrect balance display for TRC20 tokens #11222

@coderabbitai

Description

@coderabbitai

Problem

In packages/chain-adapters/src/tron/TronChainAdapter.ts (lines 146-152), all tokens are assigned a hardcoded precision of 6. However, TRC20 tokens can have varying decimals (commonly 6, 8, or 18), which will cause incorrect balance display for tokens with different precision.

This currently works for USDT/USDC (which use 6 decimals) but will fail for other tokens.

Solution

Token metadata should be fetched or looked up from an asset registry. If not available locally, fall back to an on-chain call to the token contract's decimals() method.

Context

Related Files

  • packages/chain-adapters/src/tron/TronChainAdapter.ts

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions