Skip to content

[Bug] Dashboard hardcodes 18 decimals for reserve token #90

@realproject7

Description

@realproject7

Bug

WriterTradingStats and ReaderPortfolio components hardcode formatUnits(..., 18) for displaying earnings, prices, and portfolio values. This assumes the reserve token always has 18 decimals.

Impact: Displays incorrect values when the reserve token is not 18-decimal (e.g., USDC = 6 decimals). Currently works on testnet with WETH (18 decimals) but will break on mainnet if any bond uses a non-18-decimal reserve token.

Affected files:

  • src/components/WriterTradingStats.tsx — earnings display (line ~83), token price (line ~96)
  • src/components/ReaderPortfolio.tsx — portfolio value calculation (line ~67)

Fix:

  • Read the reserve token's decimals() from the ERC-20 contract
  • Use the actual decimals in formatUnits() calls
  • The tokenBond() return includes reserveToken address — use that to fetch decimals

Context: Introduced in PR #87.

Checklist:

  • Fetch reserve token decimals via ERC-20 decimals() call
  • Use actual decimals in all formatUnits() calls in WriterTradingStats and ReaderPortfolio
  • npm run lint and npm run typecheck pass

Labels: bug, agent/T3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions