IsToken không nhận diện spot-only token #24

Closed
opened 2026-04-27 03:42:50 +07:00 by codex · 0 comments
Owner

Summary

binancex.IsToken hiện chỉ kiểm tra token có futures pair qua Token2FutureSymbols, sau đó kiểm tra Alpha token. Hàm chưa kiểm tra spot pair/token, nên các token chỉ có spot market sẽ không được nhận diện là token hợp lệ.

Evidence

  • internal/helper/binancex/symbol.go:32: IsToken trả true nếu len(Token2FutureSymbols(s)) > 0, sau đó mới check data.Market.IsAlphaToken(s).
  • internal/services/tele/commands/chat.go:19: chat text chỉ đi vào OnTokenInfo khi binancex.IsToken(text) trả true.
  • internal/services/tele/commands/token.go:90: sau khi đã vào handler, collectRichTokenData có xử lý spot qua Token2SpotSymbols.
  • internal/helper/binancex/resolver.go:63: Token2SpotSymbols đã có fallback spot-only dạng TOKENUSDT và gọi data.Market.IsSpotPair.
  • internal/data/market/trading_pairs.go:29: hệ thống đã cache danh sách spot pairs.
  • internal/data/market/trading_pairs.go:36: hệ thống đã cache danh sách futures pairs.
  • internal/data/imarket.go:19: interface đã expose IsSpotPairIsFuturesPair.

Current Behavior

Nếu user gửi token spot-only trong chat, ví dụ token có ABCUSDT trên spot nhưng không có futures pair:

  1. OnChatHandler gọi binancex.IsToken("abc").
  2. Token2FutureSymbols("abc") trả empty.
  3. IsAlphaToken("ABC") trả false.
  4. IsToken trả false.
  5. Chat message bị ignore, dù spot data có thể lấy được nếu vào OnTokenInfo.

Expected Behavior

IsToken nên nhận diện token hợp lệ nếu token có ít nhất một nguồn dữ liệu sau:

  • spot pair/token
  • futures pair/token
  • Alpha token

Root Cause

IsToken đang dùng futures availability làm proxy cho token validity. Điều này không đúng với spot-only tokens, trong khi codebase đã có cache pair/token và helper Token2SpotSymbols để kiểm tra spot.

Suggested Direction

Cập nhật predicate để kiểm tra cả spot và futures trước Alpha, ví dụ theo logic:

  • len(Token2FutureSymbols(s)) > 0, hoặc
  • len(Token2SpotSymbols(s)) > 0, hoặc
  • data.Market.IsAlphaToken(strings.ToUpper(s))

Cần lưu ý tránh gọi trùng/đệ quy không cần thiết nếu dùng Token2SpotSymbols, vì hàm này hiện gọi Token2FutureSymbols trước rồi mới fallback spot-only.

## Summary `binancex.IsToken` hiện chỉ kiểm tra token có futures pair qua `Token2FutureSymbols`, sau đó kiểm tra Alpha token. Hàm chưa kiểm tra spot pair/token, nên các token chỉ có spot market sẽ không được nhận diện là token hợp lệ. ## Evidence - `internal/helper/binancex/symbol.go:32`: `IsToken` trả `true` nếu `len(Token2FutureSymbols(s)) > 0`, sau đó mới check `data.Market.IsAlphaToken(s)`. - `internal/services/tele/commands/chat.go:19`: chat text chỉ đi vào `OnTokenInfo` khi `binancex.IsToken(text)` trả `true`. - `internal/services/tele/commands/token.go:90`: sau khi đã vào handler, `collectRichTokenData` có xử lý spot qua `Token2SpotSymbols`. - `internal/helper/binancex/resolver.go:63`: `Token2SpotSymbols` đã có fallback spot-only dạng `TOKENUSDT` và gọi `data.Market.IsSpotPair`. - `internal/data/market/trading_pairs.go:29`: hệ thống đã cache danh sách spot pairs. - `internal/data/market/trading_pairs.go:36`: hệ thống đã cache danh sách futures pairs. - `internal/data/imarket.go:19`: interface đã expose `IsSpotPair` và `IsFuturesPair`. ## Current Behavior Nếu user gửi token spot-only trong chat, ví dụ token có `ABCUSDT` trên spot nhưng không có futures pair: 1. `OnChatHandler` gọi `binancex.IsToken("abc")`. 2. `Token2FutureSymbols("abc")` trả empty. 3. `IsAlphaToken("ABC")` trả false. 4. `IsToken` trả false. 5. Chat message bị ignore, dù spot data có thể lấy được nếu vào `OnTokenInfo`. ## Expected Behavior `IsToken` nên nhận diện token hợp lệ nếu token có ít nhất một nguồn dữ liệu sau: - spot pair/token - futures pair/token - Alpha token ## Root Cause `IsToken` đang dùng futures availability làm proxy cho token validity. Điều này không đúng với spot-only tokens, trong khi codebase đã có cache pair/token và helper `Token2SpotSymbols` để kiểm tra spot. ## Suggested Direction Cập nhật predicate để kiểm tra cả spot và futures trước Alpha, ví dụ theo logic: - `len(Token2FutureSymbols(s)) > 0`, hoặc - `len(Token2SpotSymbols(s)) > 0`, hoặc - `data.Market.IsAlphaToken(strings.ToUpper(s))` Cần lưu ý tránh gọi trùng/đệ quy không cần thiết nếu dùng `Token2SpotSymbols`, vì hàm này hiện gọi `Token2FutureSymbols` trước rồi mới fallback spot-only.
thuanle added reference fix/issue-24-is-token-spot-only 2026-04-27 04:01:14 +07:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: public/crypto-price-bot#24