Skip to content

Conversation

@fengtality
Copy link
Contributor

@fengtality fengtality commented Dec 27, 2025

Summary

  • Remove in-memory token cache (tokenList, tokenMap) from both Solana and Ethereum classes
  • Tokens are now read from disk on each request (~0.1ms for small files)
  • Both token endpoints now work immediately without restart

Changes

Solana

  • Solana class: Removed tokenList and _tokenMap cache, updated getTokenList() to read from TokenService each time
  • POST /tokens/: Changed requiresRestart: false - tokens work immediately
  • /tokens/save/{address}: Removed cache reload logic (no longer needed)

Ethereum

  • Ethereum class: Removed tokenList and tokenMap cache, added async getTokenList() method
  • Updated routes: allowances.ts, wrap.ts, unwrap.ts to use async token methods

Motivation

Previously, both Solana and Ethereum cached tokens in memory at startup. Adding a token via POST /tokens/ only saved to disk without refreshing the cache, requiring a restart. The /tokens/save/{address} endpoint had special logic to reload the cache, creating inconsistent behavior.

Since token files are small (~4KB for 10-20 tokens), reading from disk takes <0.2ms - negligible compared to RPC calls (50-500ms). This simplifies the code and makes both endpoints behave consistently.

Test plan

  • Add token via POST /tokens/ for Solana and verify it appears in /solana/balances without restart
  • Add token via POST /tokens/ for Ethereum and verify it appears in /ethereum/balances without restart
  • Add token via /tokens/save/{address} and verify it appears in balances
  • Verify typecheck passes

🤖 Generated with Claude Code

nikspz and others added 8 commits November 3, 2025 14:41
sync / Gateway staging -> main for Hummingbot version 2.10.0
sync / Client development -> staging v2.11
Sync / staging to main v2.11
- Remove tokenList and _tokenMap in-memory cache from Solana class
- Update getTokenList() to read from TokenService on each call
- Update getToken() and balance methods to use fresh token list
- Remove cache reload logic from /tokens/save/{address} endpoint
- Update POST /tokens/ to indicate requiresRestart: false

Tokens added via any endpoint are now immediately available without
restart. File reads for small token lists (~4KB) take <0.2ms which
is negligible compared to RPC calls (50-500ms).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@fengtality fengtality added this to the v2.12 milestone Dec 27, 2025
fengtality and others added 3 commits December 26, 2025 19:31
- Remove tokenList and tokenMap in-memory cache from Ethereum class
- Add getTokenList() method to read from TokenService on each call
- Update getToken() to use fresh token list from disk
- Update getAllTokenBalances() to use getTokenList()
- Update allowances, wrap, and unwrap routes to use async token methods

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Since tokens are now read from disk on each request, no restart
is ever needed. Remove the requiresRestart field entirely from
the schema and all token operation responses.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Contributor

@nikspz nikspz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • commit 0ecb92c
    • Add token via POST /tokens/ for Solana ✅
      • token appears in /solana/balances without restart ✅
      • image
    • Add token via POST /tokens/ for Ethereum ✅
      • added for bsc / arbitrum / mainnet ✅
      • token appears in /ethereum/balances without restart ✅
      • image
      • image
      • image
    • Add token via /tokens/save/{address}
      • verify it appears in balances ✅
      • image
      • image

@fengtality fengtality merged commit 5f33218 into development Jan 2, 2026
2 of 3 checks passed
@fengtality fengtality deleted the remove-token-cache branch January 2, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants