-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtoken_analyzer.py
More file actions
170 lines (145 loc) · 5.77 KB
/
token_analyzer.py
File metadata and controls
170 lines (145 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
"""
Token Analysis Tool - Check if token is tradeable
"""
import requests
import json
def analyze_token(token_mint):
"""Analyze token to see if it's tradeable"""
print(f"🔍 Analyzing Token: {token_mint}")
print("=" * 60)
# 1. Check if token exists on Solana
print("1️⃣ Checking token existence...")
rpc_payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [token_mint, {"encoding": "base64"}]
}
try:
response = requests.post(
"https://api.mainnet-beta.solana.com",
json=rpc_payload,
timeout=10
)
if response.status_code == 200:
data = response.json()
if data.get("result", {}).get("value"):
print(" ✅ Token exists on Solana")
owner = data["result"]["value"]["owner"]
print(f" Token Program: {owner}")
else:
print(" ❌ Token not found on Solana")
return False
else:
print(f" ❌ RPC error: {response.status_code}")
return False
except Exception as e:
print(f" ❌ Error: {e}")
return False
# 2. Check Jupiter for possible routes
print("\n2️⃣ Checking Jupiter routing...")
try:
quote_url = "https://quote-api.jup.ag/v6/quote"
quote_params = {
"inputMint": "So11111111111111111111111111111111111111112", # SOL
"outputMint": token_mint,
"amount": 1000000, # 0.001 SOL
"slippageBps": 1000
}
quote_response = requests.get(quote_url, params=quote_params, timeout=10)
print(f" Jupiter response: {quote_response.status_code}")
if quote_response.status_code == 200:
quote_data = quote_response.json()
if "routePlan" in quote_data:
print(" ✅ Jupiter found trading routes!")
routes = quote_data["routePlan"]
print(f" Routes found: {len(routes)}")
for i, route in enumerate(routes[:3]): # Show first 3 routes
dex = route.get("swapInfo", {}).get("label", "Unknown")
print(f" Route {i+1}: {dex}")
return True
else:
print(" ❌ No Jupiter routes found")
else:
error_text = quote_response.text
print(f" ❌ Jupiter error: {error_text[:100]}...")
except Exception as e:
print(f" ❌ Jupiter check failed: {e}")
# 3. Check popular DEX APIs
print("\n3️⃣ Checking other DEX support...")
# Check DexScreener (popular token info site)
try:
dexscreener_url = f"https://api.dexscreener.com/latest/dex/tokens/{token_mint}"
dex_response = requests.get(dexscreener_url, timeout=10)
if dex_response.status_code == 200:
dex_data = dex_response.json()
pairs = dex_data.get("pairs", [])
if pairs:
print(f" ✅ DexScreener found {len(pairs)} trading pairs")
for pair in pairs[:3]:
dex_name = pair.get("dexId", "Unknown")
base_token = pair.get("baseToken", {}).get("symbol", "?")
quote_token = pair.get("quoteToken", {}).get("symbol", "?")
print(f" {dex_name}: {base_token}/{quote_token}")
return True
else:
print(" ❌ No pairs found on DexScreener")
else:
print(f" ❌ DexScreener error: {dex_response.status_code}")
except Exception as e:
print(f" ❌ DexScreener check failed: {e}")
# 4. Check CoinGecko
print("\n4️⃣ Checking CoinGecko...")
try:
# CoinGecko doesn't have direct mint lookup, but we can try
print(" ℹ️ CoinGecko requires symbol lookup (skipping for now)")
except Exception as e:
print(f" ❌ CoinGecko check failed: {e}")
print(f"\n📊 Analysis Results:")
print(" Token exists but has no active trading pairs")
print(" Possible reasons:")
print(" - New token with no liquidity yet")
print(" - Dead/abandoned project")
print(" - Very low volume token")
print(" - Only trades on specific/private DEXs")
return False
def suggest_working_tokens():
"""Suggest some tokens that are known to work"""
print(f"\n💡 Suggested Working Tokens:")
print("=" * 40)
working_tokens = [
{
"name": "Bonk",
"mint": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"type": "Meme token, high liquidity"
},
{
"name": "Raydium",
"mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
"type": "DEX token, very liquid"
},
{
"name": "Jupiter",
"mint": "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
"type": "Aggregator token"
},
{
"name": "Solana (Wrapped)",
"mint": "So11111111111111111111111111111111111111112",
"type": "Native SOL"
}
]
for token in working_tokens:
print(f"✅ {token['name']}")
print(f" Mint: {token['mint']}")
print(f" Type: {token['type']}")
print()
if __name__ == "__main__":
# Analyze the problematic token
problem_token = "972LTtg2krARR7ysu6jHWLmdKqeVw7xT5Hs1Mt413dR9"
success = analyze_token(problem_token)
if not success:
suggest_working_tokens()
print(f"\n🔧 Recommendation:")
print("Test with one of the suggested tokens above to verify")
print("that your enhanced trading client works correctly.")