package binancex import ( "strings" "me.thuanle/bbot/internal/configs/binance" "me.thuanle/bbot/internal/data" "me.thuanle/bbot/internal/utils/stringx" ) func Token2FutureSymbols(token string) []string { if !stringx.IsAlphaNumeric(token) { return nil } token = strings.ToUpper(token) if mapped, ok := data.Market.GetFutureSymbolByToken(token); ok { return []string{mapped} } for futureToken, spotToken := range binance.FutureToken2SpotTokenMap { if strings.ToUpper(spotToken) != token { continue } if mapped, ok := data.Market.GetFutureSymbolByToken(strings.ToUpper(futureToken)); ok { return []string{mapped} } } return nil } func Token2SpotSymbols(token string) []string { if !stringx.IsAlphaNumeric(token) { return nil } token = strings.ToUpper(token) if mapped, ok := data.Market.GetSpotSymbolByToken(token); ok { return []string{mapped} } return nil } func Token2RelatedSpotSymbols(token string) []string { token = strings.ToUpper(token) seen := make(map[string]struct{}, 2) spots := make([]string, 0, 2) for _, futureSymbol := range Token2FutureSymbols(token) { spotSymbol := Future2SpotSymbol(futureSymbol) if _, ok := seen[spotSymbol]; ok { continue } if data.Market.IsSpotPair(spotSymbol) { seen[spotSymbol] = struct{}{} spots = append(spots, spotSymbol) } } for _, spotSymbol := range Token2SpotSymbols(token) { if _, ok := seen[spotSymbol]; ok { continue } seen[spotSymbol] = struct{}{} spots = append(spots, spotSymbol) } return spots }