📌 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
- Add a small bounded cache (map or LRU) around the resolution function(s) in
src/utils/token.ts.
- Export a cache-clear function for test isolation.
- Add tests for cache-hit avoiding a repeated underlying call, and cache-size bounding.
✅ Acceptance criteria
🔒 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
📌 Description
Helper functions in
src/utils/token.tsthat 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
🛠️ Suggested execution
src/utils/token.ts.✅ Acceptance criteria
🔒 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