Skip to content

[Bug] ReaderPortfolio scans all storylines for balanceOf — N+1 scaling #93

@realproject7

Description

@realproject7

Bug

src/components/ReaderPortfolio.tsx fetches every non-hidden storyline from the DB, then calls balanceOf() for each one to check if the user holds tokens. With N storylines, this is N RPC calls just to find holdings.

Impact: Does not scale. With 100+ storylines, the reader dashboard becomes very slow.

Fix options:

  1. Use viem multicall to batch all balanceOf checks into a single RPC call
  2. Add a subgraph or indexer for token holdings (heavier lift)
  3. At minimum, add caching with a reasonable TTL

Context: Introduced in PR #87.

Checklist:

  • Batch balanceOf calls using multicall
  • 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