Spaces:
Sleeping

LAEGEND's picture
Update: remove all sssss wallets and bundlers, 20k MC filter (70k RH), mandatory description, charity buyback bypass, entry calls with rich signals
a7d50b7 verified
Raw History Blame Contribute Delete
48.9 kB
import os
import sys
import json
import time
import asyncio
import threading
import logging
import html
from typing import Dict, List, Optional
# Reconfigure stdout for utf-8
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
# Configure logging
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO
)
logger = logging.getLogger("SolanaRunnerSpace")
# ZeroGPU compliance helper
try:
import spaces
HAS_ZEROGPU = True
except ImportError:
HAS_ZEROGPU = False
def gpu_noop(fn):
if HAS_ZEROGPU:
return spaces.GPU(duration=5)(fn)
return fn
import gradio as gr
from config import load_config, save_config
from cluster_engine import ClusterEngine
from tracker_listener import WalletTracker
from metadata import get_token_details
from card_formatter import format_telegram_card
# Global instances
cfg_initial = load_config()
cluster_engine = ClusterEngine(sssss_bundler_wallets=cfg_initial.get("SSSSS_BUNDLER_WALLETS", []))
tg_bot_app = None
tg_bot_loop = None
tg_bot_thread = None
def get_status_overview():
cfg = load_config()
wallets = cfg.get("WALLETS", {})
sol_wallets = [a for a in wallets.keys() if not a.startswith("0x")]
bsc_wallets = []
rh_wallets = []
for a, name in wallets.items():
if a.startswith("0x"):
n_low = name.lower()
if "rh" in n_low or "robinhood" in n_low or "robin" in n_low:
rh_wallets.append(a)
else:
bsc_wallets.append(a)
token = cfg.get("TELEGRAM_BOT_TOKEN", "")
has_token = bool(token and token != "YOUR_TELEGRAM_BOT_TOKEN_HERE" and token != "MOCK_TOKEN")
chat_ids = cfg.get("TELEGRAM_CHAT_IDS", [])
if cfg.get("TELEGRAM_CHAT_ID"):
chat_ids = list(set([str(cfg.get("TELEGRAM_CHAT_ID"))] + [str(c) for c in chat_ids if c]))
return {
"is_online": True,
"has_token": has_token,
"bot_username": "@takurukugetspaidbot" if has_token else "Not Configured",
"wallets_count": len(wallets),
"sol_wallets_count": len(sol_wallets),
"bsc_wallets_count": len(bsc_wallets),
"rh_wallets_count": len(rh_wallets),
"chats_count": len(chat_ids),
"max_mc": cfg.get("MAX_ENTRY_MC", 20000),
"max_mc_rh": cfg.get("MAX_ENTRY_MC_ROBINHOOD", 70000),
"min_buy_sol": cfg.get("MIN_BUY_SOL", 0.2),
"min_buy_bnb": cfg.get("MIN_BUY_BNB", 0.05),
"min_buy_eth": cfg.get("MIN_BUY_ETH", 0.01),
"time_window": cfg.get("COBUY_TIME_WINDOW_SECONDS", 300),
"min_cobuy": cfg.get("MIN_WALLETS_COBUY", 2),
"conviction_sol": cfg.get("CONVICTION_SOL_THRESHOLD", 1.5),
"conviction_bnb": cfg.get("CONVICTION_BNB_THRESHOLD", 0.4),
"conviction_eth": cfg.get("CONVICTION_ETH_THRESHOLD", 0.1)
}
# -------------------------------------------------------------
# Background Telegram Bot Runner
# -------------------------------------------------------------
def start_telegram_bot_background():
global tg_bot_app, tg_bot_loop
cfg = load_config()
token = cfg.get("TELEGRAM_BOT_TOKEN", "")
if not token or token in ["YOUR_TELEGRAM_BOT_TOKEN_HERE", "MOCK_TOKEN"]:
logger.info("TELEGRAM_BOT_TOKEN is not configured. Running in Web Demo Mode.")
return
def run_loop():
global tg_bot_app, tg_bot_loop
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
tg_bot_loop = loop
async def bot_coroutine():
global tg_bot_app
from telegram import Update
from telegram.ext import ApplicationBuilder, ChatMemberHandler, CommandHandler, MessageHandler, filters
from bot import (
chat_member_update, start_command, wallets_command,
addwallet_command, addwallets_command, removewallet_command, minbuy_command,
maxmc_command, volratio_command, check_command, chats_command,
testalert_command, status_command, send_alert,
id_command, addchat_command, removechat_command,
phanes_command,
global_message_listener
)
try:
logger.info("Initializing Telegram Bot in background...")
app = ApplicationBuilder().token(token).build()
tg_bot_app = app
app.add_handler(MessageHandler(filters.ALL, global_message_listener), group=-1)
app.add_handler(ChatMemberHandler(chat_member_update, ChatMemberHandler.MY_CHAT_MEMBER))
app.add_handler(CommandHandler("start", start_command))
app.add_handler(CommandHandler("wallets", wallets_command))
app.add_handler(CommandHandler("addwallet", addwallet_command))
app.add_handler(CommandHandler("addwallets", addwallets_command))
app.add_handler(CommandHandler("removewallet", removewallet_command))
app.add_handler(CommandHandler("minbuy", minbuy_command))
app.add_handler(CommandHandler("maxmc", maxmc_command))
app.add_handler(CommandHandler("volratio", volratio_command))
app.add_handler(CommandHandler("check", check_command))
app.add_handler(CommandHandler("chats", chats_command))
app.add_handler(CommandHandler("id", id_command))
app.add_handler(CommandHandler("addchat", addchat_command))
app.add_handler(CommandHandler("removechat", removechat_command))
app.add_handler(CommandHandler("testalert", testalert_command))
app.add_handler(CommandHandler("status", status_command))
app.add_handler(CommandHandler("phanes", phanes_command))
tracker = WalletTracker(
cluster_engine=cluster_engine,
alert_callback=lambda text, img, mint: send_alert(app, text, img, mint)
)
await app.initialize()
await app.start()
await app.updater.start_polling(allowed_updates=Update.ALL_TYPES)
logger.info("Telegram Bot Polling started with all updates enabled.")
# Start Solana RPC transaction polling loop
await tracker.run_loop()
except Exception as e:
logger.error(f"Error starting background Telegram Bot: {e}")
try:
loop.run_until_complete(bot_coroutine())
except Exception as e:
logger.error(f"Background bot loop exited: {e}")
t = threading.Thread(target=run_loop, daemon=True)
t.start()
return t
# Start background bot immediately
tg_bot_thread = start_telegram_bot_background()
# -------------------------------------------------------------
# Gradio UI Functions
# -------------------------------------------------------------
@gpu_noop
def noop_gpu_check():
return "βœ… ZeroGPU Worker Verified (No Quota Consumed)"
def render_telegram_card_html(card_text: str, mint: str) -> str:
"""Format Telegram HTML card with native Telegram dark styling for Solana, BSC, or Robinhood"""
escaped_body = card_text.replace("\n", "<br>")
is_rh = ("ROBINHOOD" in card_text or "🏹" in card_text)
is_bsc = mint.startswith("0x") and not is_rh
if is_rh:
buttons_html = f"""
<div style="margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
<a href="https://x.com/search?q={mint}&f=live" target="_blank" style="grid-column: span 2; background: #1e293b; color: #38bdf8; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ” Check CA on 𝕏</a>
<a href="https://dexscreener.com/robinhood/{mint}" target="_blank" style="background: #1e293b; color: #4ade80; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ¦… DexScreener</a>
<a href="https://robinscreener.io/token/{mint}" target="_blank" style="background: #1e293b; color: #fbbf24; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ“ˆ RobinScreener</a>
<a href="https://robinhoodchain.blockscout.com/token/{mint}" target="_blank" style="grid-column: span 2; background: #1e293b; color: #f472b6; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">🏹 Robinhood Explorer</a>
</div>
"""
chain_label = "Robinhood"
elif is_bsc:
buttons_html = f"""
<div style="margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
<a href="https://x.com/search?q={mint}&f=live" target="_blank" style="grid-column: span 2; background: #1e293b; color: #38bdf8; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ” Check CA on 𝕏</a>
<a href="https://pancakeswap.finance/swap?outputCurrency={mint}" target="_blank" style="background: #1e293b; color: #4ade80; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ₯ž PancakeSwap</a>
<a href="https://gmgn.ai/bsc/token/{mint}" target="_blank" style="background: #1e293b; color: #fbbf24; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ“ˆ GMGN</a>
<a href="https://neo.bullx.io/terminal?chainId=56&address={mint}" target="_blank" style="background: #1e293b; color: #f472b6; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ‚ BullX</a>
<a href="https://dexscreener.com/bsc/{mint}" target="_blank" style="background: #1e293b; color: #a78bfa; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ¦… DexScreener</a>
</div>
"""
chain_label = "BSC"
else:
buttons_html = f"""
<div style="margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
<a href="https://x.com/search?q={mint}&f=live" target="_blank" style="grid-column: span 2; background: #1e293b; color: #38bdf8; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ” Check CA on 𝕏</a>
<a href="https://pump.fun/{mint}" target="_blank" style="background: #1e293b; color: #4ade80; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ’Š Pump.fun</a>
<a href="https://gmgn.ai/sol/token/{mint}" target="_blank" style="background: #1e293b; color: #fbbf24; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ“ˆ GMGN</a>
<a href="https://photon-sol.tinyastro.io/en/r/@runner/{mint}" target="_blank" style="background: #1e293b; color: #f472b6; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">⚑ Photon</a>
<a href="https://dexscreener.com/solana/{mint}" target="_blank" style="background: #1e293b; color: #a78bfa; text-decoration: none; padding: 8px 12px; border-radius: 6px; text-align: center; font-size: 13px; font-weight: 600; border: 1px solid #334155;">πŸ¦… DexScreener</a>
</div>
"""
chain_label = "Solana"
return f"""
<div style="background: #0f172a; border: 1px solid #1e293b; border-radius: 12px; padding: 18px; max-width: 580px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);">
<div style="display: flex; align-items: center; margin-bottom: 12px; border-bottom: 1px solid #1e293b; padding-bottom: 8px;">
<div style="width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #06b6d4, #8b5cf6); display: flex; align-items: center; justify-content: center; font-size: 16px; margin-right: 10px;">πŸš€</div>
<div>
<div style="color: #f8fafc; font-weight: bold; font-size: 14px;">Runner Radar Bot ({chain_label})</div>
<div style="color: #64748b; font-size: 11px;">bot β€’ just now</div>
</div>
</div>
<div style="color: #e2e8f0; font-size: 13.5px; line-height: 1.55;">
{escaped_body}
</div>
{buttons_html}
</div>
"""
def simulate_alert(scenario: str, custom_mint: str, custom_name: str, custom_mc: float, custom_amt: float):
mint = custom_mint.strip()
name = custom_name.strip()
mc = float(custom_mc)
amount = float(custom_amt)
is_rh = "[RH]" in scenario
is_bsc = ("[BSC]" in scenario or (mint.startswith("0x") and not is_rh))
if is_rh:
chain = "robinhood"
currency = "ETH"
default_mint = "0x008df4b3e857d06c4603aeb11f267ccd32ce2005"
default_name = "Robinhood Runner ($ROBIN)"
max_allowed_mc = 70000.0
cap_desc = "Strict Sub-$70k Cap (Robinhood Chain Only)"
min_label = "0.01 ETH"
elif is_bsc:
chain = "bsc"
currency = "BNB"
default_mint = "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"
default_name = "Pancake Meme ($CAKE)"
max_allowed_mc = 20000.0
cap_desc = "Strict Sub-$20k Cap (BSC)"
min_label = "0.05 BNB"
else:
chain = "solana"
currency = "SOL"
default_mint = "FnB8Dsq1kYv8hK4R8o5q4tXmU7eW1Gg2"
default_name = "Doge Pepe ($DOPE)"
max_allowed_mc = 20000.0
cap_desc = "Strict Sub-$20k Cap (Solana)"
min_label = "0.2 SOL"
if not mint:
mint = default_mint
if not name:
name = default_name
symbol = name.split()[0].replace("(", "").replace(")", "").replace("$", "").upper()
token_data = {
"name": name,
"symbol": symbol,
"mint": mint,
"chain": chain,
"currency": currency,
"market_cap": mc,
"vol_5m": 8420.0,
"buy_ratio_5m": 2.8,
"bonding_curve_pct": min(100.0, round((mc / (70000.0 if is_rh else 69000.0)) * 100, 1)),
"multiplier": round(mc / 6000.0, 1),
"lore": "🐦 <b>Viral Tweet Narrative:</b>\n\"Insane community traction. Deployer burned liquidity and viral meme is trending across Crypto Twitter!\"",
"dev_description": f"Official {chain.capitalize()} runner token. Liquidity locked on-chain.",
"image": "https://pump.mypinata.cloud/ipfs/QmExample"
}
if "Co-Buy Cluster" in scenario:
if is_rh:
w1_name, w1_addr = "RH_Deployer", "0x008df4b3e857d06c4603aeb11f267ccd32ce2005"
w2_name, w2_addr = "RH_Sniper1", "0x534631Bcf1b101e379740716f3c18bbfe97050e0"
elif is_bsc:
w1_name, w1_addr = "BSC_Whale", "0x4982085c9e2f89f2ecb8131eca71afad896e89cb"
w2_name, w2_addr = "BSC_Sniper1", "0x48b6c86a2217c062c3666504a7ee9a3c0e35f8cf"
else:
w1_name, w1_addr = "HENN", "FRbUNvGxYNC1eFngpn7AD3f14aKKTJVC6zSMtvj2dyCS"
w2_name, w2_addr = "Mrdevvvv", "GZVSEAajExLJEvACHHQcujBw7nJq98GWUEZtood9LM9b"
signal_data = {
"type": "CLUSTER",
"chain": chain,
"currency": currency,
"unique_wallets_count": 2,
"total_amount": round(amount * 2, 3),
"total_sol": round(amount * 2, 3),
"time_span_seconds": 18,
"buys": [
{"wallet_name": w1_name, "wallet_addr": w1_addr, "amount": amount, "sol_amount": amount, "time": time.time() - 18},
{"wallet_name": w2_name, "wallet_addr": w2_addr, "amount": amount, "sol_amount": amount, "time": time.time()}
]
}
card_html = format_telegram_card(token_data, signal_data)
filter_status = f"🟒 <b>PASSED ALL FILTERS</b>: Under {cap_desc} (${mc:,.0f} &le; ${max_allowed_mc:,.0f}), &ge;{min_label} Min Buy, Viral Lore Present."
return render_telegram_card_html(card_html, mint), filter_status
elif "Conviction" in scenario:
if is_rh:
w_name, w_addr = "RH_Deployer", "0x008df4b3e857d06c4603aeb11f267ccd32ce2005"
conv_amt = max(amount, 0.25)
elif is_bsc:
w_name, w_addr = "BSC_Whale", "0x4982085c9e2f89f2ecb8131eca71afad896e89cb"
conv_amt = max(amount, 1.5)
else:
w_name, w_addr = "Mrdevvvv", "GZVSEAajExLJEvACHHQcujBw7nJq98GWUEZtood9LM9b"
conv_amt = max(amount, 5.0)
signal_data = {
"type": "CONVICTION",
"chain": chain,
"currency": currency,
"unique_wallets_count": 1,
"primary_wallet": w_name,
"total_amount": conv_amt,
"total_sol": conv_amt,
"buys": [
{"wallet_name": w_name, "wallet_addr": w_addr, "amount": conv_amt, "sol_amount": conv_amt, "time": time.time()}
]
}
card_html = format_telegram_card(token_data, signal_data)
filter_status = f"🟒 <b>PASSED ALL FILTERS</b>: Sized up to {conv_amt} {currency} (Conviction anomaly triggered!), {cap_desc} (${mc:,.0f})."
return render_telegram_card_html(card_html, mint), filter_status
elif "Accumulation" in scenario:
if is_rh:
w_name, w_addr = "RH_Deployer", "0x008df4b3e857d06c4603aeb11f267ccd32ce2005"
elif is_bsc:
w_name, w_addr = "BSC_Whale", "0x4982085c9e2f89f2ecb8131eca71afad896e89cb"
else:
w_name, w_addr = "Putrick", "AVjEtg2ECYKXYeqdRQXvaaAZBjfTjYuSMTR4WLhKoeQN"
tot_accum = round(amount * 2.8, 3)
signal_data = {
"type": "ACCUMULATION",
"chain": chain,
"currency": currency,
"primary_wallet": w_name,
"wallet_addr": w_addr,
"buy_count": 3,
"total_amount": tot_accum,
"total_sol": tot_accum,
"amount": amount,
"sol_amount": amount,
"time_span_seconds": 185,
"buys": [
{"wallet_name": w_name, "wallet_addr": w_addr, "amount": round(amount * 0.8, 3), "time": time.time() - 185, "sig": "acc1"},
{"wallet_name": w_name, "wallet_addr": w_addr, "amount": round(amount * 1.2, 3), "time": time.time() - 95, "sig": "acc2"},
{"wallet_name": w_name, "wallet_addr": w_addr, "amount": round(amount * 0.8, 3), "time": time.time(), "sig": "acc3"}
]
}
card_html = format_telegram_card(token_data, signal_data)
filter_status = f"πŸ’Ž <b>SMART MONEY ACCUMULATION DETECTED</b>: {w_name} bought across 3 separate occasions on {chain.capitalize()} with <b>0 SELLS</b>. Clean DCA accumulation signal."
return render_telegram_card_html(card_html, mint), filter_status
elif "Micro-Spray" in scenario:
spray_val = 0.002 if is_rh else (0.01 if is_bsc else 0.05)
min_thresh = "0.01 ETH" if is_rh else ("0.05 BNB" if is_bsc else "0.2 SOL")
filter_status = f"β›” <b>FILTERED OUT</b>: Buy size was {spray_val} {currency}, below minimum threshold ({min_thresh}). Anti-spray filter eliminated noise."
return f"<div style='color: #ef4444; padding: 20px; background: #1e1b4b; border-radius: 8px;'>🚫 Alert suppressed: Buy size ({spray_val} {currency}) is below {min_thresh} anti-spray threshold.</div>", filter_status
elif "Cap Approved" in scenario:
# Specifically demonstrates Robinhood $45k MC allowed under $70k cap
token_data["market_cap"] = 45000.0
w1_name, w1_addr = "RH_Deployer", "0x008df4b3e857d06c4603aeb11f267ccd32ce2005"
w2_name, w2_addr = "RH_Sniper1", "0x534631Bcf1b101e379740716f3c18bbfe97050e0"
signal_data = {
"type": "CLUSTER",
"chain": "robinhood",
"currency": "ETH",
"unique_wallets_count": 2,
"total_amount": 0.5,
"total_sol": 0.5,
"time_span_seconds": 20,
"buys": [
{"wallet_name": w1_name, "wallet_addr": w1_addr, "amount": 0.3, "time": time.time() - 20},
{"wallet_name": w2_name, "wallet_addr": w2_addr, "amount": 0.2, "time": time.time()}
]
}
card_html = format_telegram_card(token_data, signal_data)
filter_status = "🟒 <b>PASSED ROBINHOOD $70K CAP</b>: Token Market Cap is $45,000 (well under Robinhood's dedicated $70,000 cap!). Would be rejected on Solana/BSC ($20k cap), but <b>APPROVED for Robinhood Chain</b>."
return render_telegram_card_html(card_html, mint), filter_status
else: # High MC blocked
if is_rh:
filter_status = "β›” <b>FILTERED OUT</b>: Market cap was $85,000, exceeding Robinhood MAX_ENTRY_MC_ROBINHOOD ($70,000). Filtered out to protect against top-buying."
return "<div style='color: #ef4444; padding: 20px; background: #1e1b4b; border-radius: 8px;'>🚫 Alert suppressed: Token MC ($85,000) exceeds Robinhood strict sub-$70k cap.</div>", filter_status
else:
filter_status = "β›” <b>FILTERED OUT</b>: Market cap was $850,000, exceeding MAX_ENTRY_MC ($20,000). Filtered out to protect against top-buying."
return "<div style='color: #ef4444; padding: 20px; background: #1e1b4b; border-radius: 8px;'>🚫 Alert suppressed: Token MC ($850,000) exceeds strict sub-$20k cap.</div>", filter_status
def inspect_token_lore(mint_input: str):
mint = mint_input.strip()
if not mint:
return "Please enter a valid Solana mint, BSC contract address, or Robinhood CA.", ""
try:
details = get_token_details(mint)
lore = details.get("lore", "No lore found.")
dev_desc = details.get("dev_description", "No description provided.")
mc = details.get("market_cap", 0)
bonding = details.get("bonding_curve_pct", 0)
chain = details.get("chain", "solana")
is_rh = (chain == "robinhood" or "rh" in chain)
is_bsc = (chain == "bsc")
if is_rh:
chain_label = "🏹 Robinhood Chain"
max_allowed = 70000.0
cap_label = "$70,000 (Robinhood Only)"
elif is_bsc:
chain_label = "🟑 BSC / BNB Chain"
max_allowed = 20000.0
cap_label = "$20,000"
else:
chain_label = "πŸͺ Solana"
max_allowed = 20000.0
cap_label = "$20,000"
passes_mc = (mc <= max_allowed)
status_mc = f"🟒 YES (Under ${max_allowed:,.0f})" if passes_mc else f"πŸ”΄ NO (Exceeds ${max_allowed:,.0f})"
info = f"""
### Token Audit: {details.get('name', 'Unknown')} ({details.get('symbol', '???')})
- **Chain:** `{chain_label}`
- **Address / CA:** `{mint}`
- **Market Cap:** ${mc:,.2f}
- **Bonding Progress:** {bonding:.1f}%
- **Socials Extracted:** {'Yes' if details.get('twitter') or details.get('telegram') else 'None'}
- **Max Entry Cap Filter:** `{status_mc}` (Threshold: `{cap_label}`)
- **Developer Description:** {'🟒 Present' if details.get('has_dev_description') else 'πŸ”΄ Missing'}
#### πŸ“œ Developer Thesis & Lore:
> {dev_desc}
{lore}
"""
return info, details.get("image_url", "")
except Exception as e:
return f"Error auditing token: {e}", ""
def get_wallets_dataframe():
cfg = load_config()
wallets = cfg.get("WALLETS", {})
data = []
for addr, name in wallets.items():
if addr.startswith("0x"):
n_low = name.lower()
if "rh" in n_low or "robinhood" in n_low or "robin" in n_low:
chain_badge = "🏹 Robinhood"
explorer = f"https://robinhoodchain.blockscout.com/address/{addr}"
strategy = "Robinhood L2 Smart-Money Sniper"
else:
chain_badge = "🟑 BSC"
explorer = f"https://bscscan.com/address/{addr}"
strategy = "BNB Chain Smart-Money Sniper"
else:
chain_badge = "πŸͺ Solana"
explorer = f"https://solscan.io/account/{addr}"
strategy = "Top Tier Solana Sniper"
data.append([
chain_badge,
name,
addr,
explorer,
strategy
])
return data
def add_new_wallet(addr: str, label: str):
addr = addr.strip()
label = label.strip()
is_evm = addr.startswith("0x") and len(addr) == 42
is_sol = not addr.startswith("0x") and len(addr) >= 32
if not (is_evm or is_sol) or not label:
return "❌ Error: Invalid address or label (must be valid Solana Base58 or EVM 0x address).", get_wallets_dataframe()
cfg = load_config()
cfg.setdefault("WALLETS", {})[addr] = label
save_config(cfg)
if is_evm:
n_low = label.lower()
chain_name = "Robinhood" if ("rh" in n_low or "robinhood" in n_low or "robin" in n_low) else "BSC"
else:
chain_name = "Solana"
return f"βœ… Successfully added {chain_name} wallet **{label}** (`{addr[:6]}...{addr[-4:]}`)", get_wallets_dataframe()
def bulk_add_wallets(raw_text: str):
from bot import extract_wallets_from_text
extracted = extract_wallets_from_text(raw_text)
if not extracted:
return "❌ Error: No valid Solana Base58 or BSC 0x addresses detected. Paste one or more addresses.", get_wallets_dataframe()
cfg = load_config()
wallets = cfg.setdefault("WALLETS", {})
count = 0
for addr, nickname, chain in extracted:
wallets[addr] = nickname
count += 1
save_config(cfg)
return f"βœ… Successfully imported {count} smart-money wallet(s) into active tracking!", get_wallets_dataframe()
def ui_scan_early_buyers(token_addr: str, chain_hint: str, max_mc_input: str):
if not token_addr or not token_addr.strip():
return "⚠️ Please enter a token contract address.", get_wallets_dataframe()
from early_buyer_scanner import scan_and_add_early_buyers, format_scanner_telegram_card
try:
mc_val = float(max_mc_input.strip().replace("$", "").replace(",", "")) if max_mc_input and max_mc_input.strip() else None
except ValueError:
mc_val = None
chain_arg = chain_hint.lower().strip() if chain_hint and chain_hint != "Auto-Detect" else None
res = scan_and_add_early_buyers(token_addr.strip(), chain_hint=chain_arg, custom_max_mc=mc_val, auto_add_to_config=True)
card_text = format_scanner_telegram_card(res)
clean_md = card_text.replace("<b>", "**").replace("</b>", "**").replace("<code>", "`").replace("</code>", "`").replace("<i>", "*").replace("</i>", "*")
clean_md = clean_md.replace("<blockquote>", "> ").replace("</blockquote>", "\n")
return clean_md, get_wallets_dataframe()
def broadcast_test_to_telegram():
from bot import get_registered_chat_ids
from telegram.constants import ParseMode
from card_formatter import get_token_keyboard
chat_ids = list(get_registered_chat_ids())
if not chat_ids:
return "⚠️ No Telegram chats or groups are registered yet! Message @takurukugetspaidbot and send /start or /addchat in your group first."
if not tg_bot_app:
return "⚠️ Telegram bot engine is not initialized or TELEGRAM_BOT_TOKEN is missing."
test_mint = "33jENUQnjoitkMFpvNJcSHyLAHFWJuHwT6E3E8CNpump"
token_sample = {
"name": "Doge Pepe",
"symbol": "DOPE",
"mint": test_mint,
"chain": "solana",
"currency": "SOL",
"market_cap": 14500,
"vol_5m": 8420.0,
"buy_ratio_5m": 2.8,
"bonding_curve_pct": 28.5,
"multiplier": 1.45,
"dev_description": "First community-backed memecoin run by verified smart money snipers.",
"lore": "Viral Solana narrative syndicated by top crypto researchers.",
"image_url": "https://pump.mypinata.cloud/ipfs/QmExample"
}
signal = {
"type": "ACCUMULATION",
"chain": "solana",
"currency": "SOL",
"primary_wallet": "Putrick",
"buy_count": 3,
"unique_wallets_count": 1,
"total_amount": 4.5,
"total_sol": 4.5,
"amount": 1.75,
"time_span_seconds": 185,
"buys": [
{"wallet_name": "Putrick", "amount": 1.25, "time": 100, "sig": "4aBcDeFg1234"},
{"wallet_name": "Putrick", "amount": 1.50, "time": 190, "sig": "7hIjKlMn5678"},
{"wallet_name": "Putrick", "amount": 1.75, "time": 285, "sig": "9oPqRsTu9012"}
]
}
card = format_telegram_card(token_sample, signal)
reply_markup = get_token_keyboard(test_mint)
success = 0
async def _send():
nonlocal success
for cid in chat_ids:
try:
await tg_bot_app.bot.send_message(
chat_id=cid,
text=card,
parse_mode=ParseMode.HTML,
disable_web_page_preview=False,
reply_markup=reply_markup
)
success += 1
except Exception as e:
logger.error(f"Error sending test broadcast to {cid}: {e}")
try:
if tg_bot_loop and tg_bot_loop.is_running():
fut = asyncio.run_coroutine_threadsafe(_send(), tg_bot_loop)
fut.result(timeout=10)
return f"βœ… Successfully broadcasted test card to {success} chat(s)/group(s): {', '.join(chat_ids)}"
except Exception as e:
return f"❌ Broadcast failed: {e}"
# -------------------------------------------------------------
# Gradio Blocks App Layout
# -------------------------------------------------------------
custom_css = """
body, .gradio-container {
background-color: #0b0f19 !important;
color: #f8fafc !important;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
}
.metric-box {
background: #111827;
border: 1px solid #1f2937;
border-radius: 10px;
padding: 16px;
text-align: center;
}
.stat-title {
color: #94a3b8;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.stat-value {
color: #38bdf8;
font-size: 24px;
font-weight: 700;
margin-top: 4px;
}
"""
with gr.Blocks(title="Solana, BSC & Robinhood Runner Radar Bot Demo") as demo:
gr.Markdown("""
# πŸš€ Multi-Chain (Solana, BSC & Robinhood) Runner Radar Bot
**Live Real-Time On-Chain Anomaly Detection & Smart-Money Syndicate Tracking across Solana, BNB Chain & Robinhood Chain**
""")
# Overview Metrics Row
with gr.Row():
with gr.Column(scale=1):
gr.HTML("""
<div class="metric-box">
<div class="stat-title">Engine Health</div>
<div class="stat-value" style="color: #4ade80; font-size: 18px;">🟒 SOL, BSC & RH 24/7</div>
</div>
""")
with gr.Column(scale=1):
gr.HTML("""
<div class="metric-box">
<div class="stat-title">Telegram Bot</div>
<div class="stat-value" style="font-size: 18px; margin-top: 8px;">
<a href="https://t.me/takurukugetspaidbot" target="_blank" style="color: #38bdf8; text-decoration: none;">@takurukugetspaidbot β†—</a>
</div>
</div>
""")
with gr.Column(scale=1):
gr.HTML("""
<div class="metric-box">
<div class="stat-title">Anti-Spray Filters</div>
<div class="stat-value" style="font-size: 16px;">&ge; 0.2 SOL | 0.05 BNB | 0.01 ETH</div>
</div>
""")
with gr.Column(scale=1):
gr.HTML("""
<div class="metric-box">
<div class="stat-title">Max Entry Cap</div>
<div class="stat-value" style="color: #fbbf24; font-size: 16px;">&lt; $20k (SOL/BSC) | &lt; $70k (RH)</div>
</div>
""")
with gr.Tabs():
# TAB 1: Alert Simulator
with gr.TabItem("⚑ Live Alert Simulator"):
gr.Markdown("Test how the bot filters out micro-spray noise and renders aesthetic Telegram alert cards across Solana, BSC, and Robinhood Chain.")
with gr.Row():
with gr.Column(scale=1):
scenario_dropdown = gr.Dropdown(
choices=[
"πŸ”₯ [SOL] Co-Buy Cluster (2 Wallets: HENN + Mrdevvvv)",
"⚑ [SOL] Conviction Whale Snipe (Mrdevvvv 5.0 SOL)",
"πŸ’Ž [SOL] Accumulation DCA (Putrick: 3 Buys, 0 Sells)",
"πŸ”₯ [BSC] Co-Buy Cluster (2 Wallets: BSC_Whale + BSC_Sniper1)",
"⚑ [BSC] Conviction Snipe (BSC_Whale 1.5 BNB)",
"πŸ’Ž [BSC] Accumulation DCA (BSC_Whale: 3 Buys, 0 Sells)",
"🏹 [RH] Co-Buy Cluster (2 Wallets: RH_Deployer + RH_Sniper1)",
"🏹 [RH] Conviction Snipe (RH_Deployer 0.25 ETH)",
"🏹 [RH] Accumulation DCA (RH_Deployer: 3 Buys, 0 Sells)",
"🏹 [RH] Sub-$70k Cap Approved ($45k MC - Approved under $70k cap)",
"❌ [RH] Over-$70k Cap Blocked ($85k MC - Blocked by $70k cap)",
"πŸ€– Bot Micro-Spray (Filtered Out)",
"❌ High Market Cap ($850k - Filtered Out)"
],
value="πŸ”₯ [SOL] Co-Buy Cluster (2 Wallets: HENN + Mrdevvvv)",
label="Choose Simulation Scenario"
)
sim_name = gr.Textbox(value="Doge Pepe ($DOPE)", label="Token Name & Symbol")
sim_mint = gr.Textbox(value="FnB8Dsq1kYv8hK4R8o5q4tXmU7eW1Gg2", label="Contract Address (Solana Mint, BSC 0x, or Robinhood 0x)")
sim_mc = gr.Number(value=14500, label="Market Cap ($)")
sim_sol = gr.Number(value=0.45, label="Buy Amount (SOL, BNB, or ETH)")
sim_btn = gr.Button("πŸš€ Trigger Alert Simulation", variant="primary")
filter_status_output = gr.HTML(label="Filter Evaluation")
with gr.Column(scale=1):
gr.Markdown("### πŸ“± Telegram Card Preview")
card_preview = gr.HTML(
value=render_telegram_card_html(
format_telegram_card(
{
"name": "Doge Pepe",
"symbol": "DOPE",
"mint": "FnB8Dsq1kYv8hK4R8o5q4tXmU7eW1Gg2",
"market_cap": 14500,
"vol_5m": 8420.0,
"buy_ratio_5m": 2.8,
"bonding_curve_pct": 28.5,
"multiplier": 1.45,
"lore": "🐦 <b>Viral Tweet by @essence:</b>\n\"Okay this is an insane narra.\nThis guy IS GOING VIRAL in the r/ClaudeAi subreddit calling Claude an actual autonomous entity. Already 400 retweets and rising!\""
},
{
"type": "CLUSTER",
"chain": "solana",
"currency": "SOL",
"unique_wallets_count": 2,
"total_amount": 0.9,
"total_sol": 0.9,
"time_span_seconds": 18,
"buys": [
{"wallet_name": "HENN", "amount": 0.45, "time": time.time() - 18},
{"wallet_name": "Mrdevvvv", "amount": 0.45, "time": time.time()}
]
}
),
"FnB8Dsq1kYv8hK4R8o5q4tXmU7eW1Gg2"
)
)
sim_btn.click(
fn=simulate_alert,
inputs=[scenario_dropdown, sim_mint, sim_name, sim_mc, sim_sol],
outputs=[card_preview, filter_status_output]
)
# TAB 2: Wallets
with gr.TabItem("πŸ‘› Tracked Smart-Money Wallets"):
gr.Markdown("These top snipers and syndicate wallets are actively polled in real time on Solana Mainnet, BNB Chain (BSC), and Robinhood Chain.")
wallets_df = gr.Dataframe(
value=get_wallets_dataframe(),
headers=["Chain", "Sniper Name", "Wallet Address", "Explorer", "Strategy"],
datatype=["str", "str", "str", "str", "str"],
interactive=False
)
with gr.Row():
new_wallet_addr = gr.Textbox(placeholder="Enter Solana Base58 or EVM 0x address...", label="Wallet Address")
new_wallet_name = gr.Textbox(placeholder="e.g. AlphaLeader (add 'rh' or 'RH_' for Robinhood)", label="Label / Sniper Name")
add_wallet_btn = gr.Button("βž• Add Wallet to Live Radar", variant="secondary")
add_status = gr.Markdown()
add_wallet_btn.click(
fn=add_new_wallet,
inputs=[new_wallet_addr, new_wallet_name],
outputs=[add_status, wallets_df]
)
with gr.Accordion("πŸ“₯ Bulk Import Wallets (Paste Multiple Addresses)", open=False):
gr.Markdown("Paste a list of Solana, BSC, or Robinhood addresses (one per line, with optional nickname or 'rh' tag next to each address).")
bulk_wallets_input = gr.Textbox(
lines=4,
placeholder="Example:\nBi4rd5FH5bYEN8scZ7wevxNZyNmKHdaBcvewdPFxYdLt Theo\n0x48b6c86a2217c062c3666504a7ee9a3c0e35f8cf BSC_Sniper1\n0x008df4b3e857d06c4603aeb11f267ccd32ce2005 RH_Deployer rh\nAVjEtg2ECYKXYeqdRQXvaaAZBjfTjYuSMTR4WLhKoeQN",
label="Bulk Addresses Input"
)
bulk_add_btn = gr.Button("πŸ“₯ Import All Wallets", variant="primary")
bulk_status = gr.Markdown()
bulk_add_btn.click(
fn=bulk_add_wallets,
inputs=[bulk_wallets_input],
outputs=[bulk_status, wallets_df]
)
# TAB 3: Sub-$20k Early Sniper Scanner
with gr.TabItem("🎯 Sub-$20k Early Sniper Scanner"):
gr.Markdown("""
### 🎯 Automated Sub-$20k Sniper Scanner & Tracker
Input any token Contract Address across **Solana, BNB Chain (BSC), or Robinhood Chain**.
The bot scans early on-chain & GMGN trade history for addresses that bought **sub-$20,000 market cap** ($70,000 for Robinhood) and **automatically adds them to the live smart-money tracker**!
""")
with gr.Row():
with gr.Column(scale=3):
scan_token_input = gr.Textbox(
placeholder="Paste Token CA (e.g. 4vRRbUAt... for SOL, 0x7d0443... for BSC, or 0x008df4... for Robinhood)",
label="Token Contract Address (CA)"
)
with gr.Column(scale=1):
scan_chain_dropdown = gr.Dropdown(
choices=["Auto-Detect", "sol", "bsc", "robinhood"],
value="Auto-Detect",
label="Blockchain Network"
)
with gr.Column(scale=1):
scan_mc_input = gr.Textbox(
placeholder="Default: $20,000 ($70,000 RH)",
label="Custom Max MC Threshold (Optional)"
)
scan_run_btn = gr.Button("πŸ” Scan Sub-$20k Buyers & Auto-Track", variant="primary")
scan_output_card = gr.Markdown()
scan_run_btn.click(
fn=ui_scan_early_buyers,
inputs=[scan_token_input, scan_chain_dropdown, scan_mc_input],
outputs=[scan_output_card, wallets_df]
)
# TAB 4: Lore & Token Inspector
with gr.TabItem("πŸ” On-Chain Lore & Token Inspector"):
gr.Markdown("Audit any Solana, BSC, or Robinhood token contract address to extract deep tweet lore, developer thesis, and market liquidity stats.")
with gr.Row():
token_input = gr.Textbox(placeholder="Paste Solana mint or EVM CA (e.g. 0x008df4b3e857d06c4603aeb11f267ccd32ce2005 for Robinhood)", label="Token Address / Mint")
inspect_btn = gr.Button("πŸ”Ž Inspect Token", variant="primary")
with gr.Row():
lore_output = gr.Markdown()
token_img = gr.Image(label="Token Logo", visible=True)
inspect_btn.click(
fn=inspect_token_lore,
inputs=[token_input],
outputs=[lore_output, token_img]
)
# TAB 5: Bot Commands & Setup
with gr.TabItem("πŸ€– Telegram Bot Setup"):
gr.Markdown("""
### πŸ“² How to Connect Live Telegram Alerts:
1. Open Telegram and search for [@takurukugetspaidbot](https://t.me/takurukugetspaidbot).
2. Send `/start` to immediately register your private direct messages.
### πŸ‘₯ How to Add to a Telegram Group / Channel:
1. Add [@takurukugetspaidbot](https://t.me/takurukugetspaidbot) to your group.
2. **Make the bot an Administrator** with message permissions (Telegram's privacy mode suppresses messages from non-admin bots).
3. Send `/start` or `/addchat` directly in the group (or send `/id` to get the group ID and register it).
4. The bot will automatically broadcast every detected cluster and conviction snipe to all registered groups!
### ⌨️ Available Telegram Commands:
| Command | Description |
| :--- | :--- |
| `/start` | Register chat/group & view live status |
| `/wallets` | List all tracked smart-money sniper wallets by chain |
| `/addwallet <addr> [name] [rh]` | Add a single wallet (supports Solana, BSC, and Robinhood) |
| `/addwallets <bulk paste>` | Bulk import multiple addresses at once |
| `/removewallet <addr/name>` | Remove a wallet by address or nickname |
| `/minbuy <amount> [sol|bnb|rh]` | Adjust anti-spray filter threshold (e.g. `/minbuy 1.0 sol`) |
| `/maxmc <usd> [rh]` | Adjust max entry MC filter ($20,000 SOL/BSC, $70,000 Robinhood) |
| `/volratio <ratio|off>` | Volume >> MarketCap turnover signal filter (e.g. `/volratio 1.0`) |
| `/check <mint>` | Manually inspect any token and generate its Lore card |
| `/status` | View live engine status, active filters, and signal triggers |
| `/testalert [sol|bsc|rh|charity]` | Broadcast test runner card across all registered chats & groups |
| `/chats` | List all active broadcast destinations |
| `/addchat <id>` | Manually add any group/channel ID to broadcast list |
| `/removechat <id>` | Remove a group/channel ID from broadcast list |
| `/phanes [on/off]` | Toggle automatic 1-tap CA follow-up & /c@phanes_bot trigger |
""")
gr.Markdown("### πŸ“‘ Test Telegram Broadcast Engine")
with gr.Row():
broadcast_btn = gr.Button("πŸ“’ Broadcast Live Test Alert to All Registered Telegram Groups", variant="primary")
broadcast_output = gr.Markdown()
broadcast_btn.click(fn=broadcast_test_to_telegram, outputs=[broadcast_output])
# TAB 6: Alpha Strategy & Architecture
with gr.TabItem("🧠 Alpha Strategy & Architecture"):
gr.Markdown("""
### πŸ’‘ Multi-Chain Syndicate Architecture: Filters vs. Signals
Top snipers spray tens of tokens daily. This engine monitors **Solana, BNB Chain (BSC), and Robinhood Chain** with specialized architectural separation between **Filters** and **Signals**:
---
### πŸ›‘οΈ FILTERS (Hard Gating β€” Discard Non-Compliant Tokens)
A token MUST pass all enabled filters to be considered. Non-compliant tokens are discarded immediately:
1. **Strict Max Entry Market Cap:**
- **Solana & BSC:** Max Entry Market Cap is strictly **$20,000**.
- **Robinhood Chain:** Max Entry Market Cap is strictly **$70,000**.
- *(Exception: Verified Charity Coins with automated buybacks bypass the MC filter).*
2. **Mandatory Developer Thesis & Description:**
Tokens lacking an on-chain developer thesis or description are discarded to eliminate low-effort zero-narrative rugs.
3. **Official Socials Requirement:**
Tokens must have verified social links (Twitter/X, Telegram, or Website).
4. **Anti-Spray Minimum Buy Filter:**
Individual buys must be $\ge 1.0\text{ SOL}$, $\ge 0.25\text{ BNB}$, or $\ge 0.05\text{ ETH}$ to eliminate bot spray noise.
5. **Anti-Rotator Throttle:**
180-second rolling window prevents alert spam from rapid rotation wallets.
---
### 🚨 SIGNALS (High-Conviction Triggers & Alert Badges)
When a token passes the filters, these signals trigger alerts and display badges on the VIP card:
1. **🌊 Volume >> MarketCap Turnover Signal:**
When **Volume $\ge 1.0\text{x}$ MarketCap**, it proves organic hand-to-hand distribution and confirms the supply isn't controlled by a bundled floor-holding cartel.
2. **πŸ’Ž 3x Consecutive Accumulation Signal:**
Alerts when a tracked smart-money wallet buys the token **3 times in a row without selling** (0 sells detected, buys $\ge 1.0\text{ SOL}$).
3. **πŸŽ—οΈ Charity & Buyback Radar Signal:**
Instantly flags verified charity coins with automated buybacks and donations, bypassing market cap restrictions.
4. **πŸ‘₯ Smart-Money Cluster Convergence:**
When **$\ge 2$ tracked independent wallets co-buy** the same token within a rolling 5-minute window.
5. **🎯 Conviction Sizing Anomaly:**
Flags sudden size-ups ($\ge 1.5\text{ SOL}$, $\ge 0.4\text{ BNB}$, or $\ge 0.1\text{ ETH}$) by elite snipers.
""")
# Hidden ZeroGPU heartbeat handler
dummy_btn = gr.Button("ZeroGPU Check", visible=False)
dummy_out = gr.Textbox(visible=False)
dummy_btn.click(fn=noop_gpu_check, outputs=dummy_out)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860, theme=gr.themes.Base(), css=custom_css)