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:
Labels: bug, agent/T3
Bug
WriterTradingStatsandReaderPortfoliocomponents hardcodeformatUnits(..., 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:
decimals()from the ERC-20 contractformatUnits()callstokenBond()return includesreserveTokenaddress — use that to fetch decimalsContext: Introduced in PR #87.
Checklist:
decimals()callformatUnits()calls in WriterTradingStats and ReaderPortfolionpm run lintandnpm run typecheckpassLabels:
bug,agent/T3