Skip to content

Add a memoized cache for token symbol/decimals lookups in src/utils/token.ts #174

Description

@Jagadeeshftw

📌 Description

Helper functions in src/utils/token.ts that resolve a token's symbol/decimals appear to be called repeatedly for the same address across a request lifecycle (and across requests), duplicating work that never changes for a given deployed token.

🧩 Requirements and context

  • Memoize symbol/decimals resolution by normalized token address.
  • Bound the cache size (LRU or similar) to avoid unbounded memory growth.
  • Provide a way to bypass/clear the cache for tests.

🛠️ Suggested execution

  1. Add a small bounded cache (map or LRU) around the resolution function(s) in src/utils/token.ts.
  2. Export a cache-clear function for test isolation.
  3. Add tests for cache-hit avoiding a repeated underlying call, and cache-size bounding.

✅ Acceptance criteria

  • Repeated lookups for the same address don't repeat the underlying resolution call.
  • Cache size stays bounded under many distinct addresses.

🔒 Security notes

Cache key must use the normalized/checksummed address so two case-variants of the same address don't create duplicate entries or a cache-poisoning opportunity.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions