Anti-Rug Bots for Solana: Auto-Sell Before the Drain
Learn how real-time mint-authority and LP-removal monitoring lets a solana anti rug bot exit your position automatically before a rug pull drains your capital.
Solana's low fees and sub-second finality make it the fastest chain to trade on — and the fastest chain to get rugged on. A developer can remove liquidity, mint unlimited supply, or freeze every holder's token account in a single transaction. By the time you read the alert in Telegram, the exit window is already closed. The only viable defense is a bot that detects the signal and fires the sell in the same block.
What a Rug Actually Looks Like On-Chain
Most retail traders think of a rug as a dramatic price dump. On-chain, it is a specific sequence of program instructions. The three most common vectors are:
- Mint-authority exploit — the deployer still holds mint authority on the SPL token and calls
MintTo, inflating supply by orders of magnitude in a single instruction. - Freeze authority —
FreezeAccountis invoked on every holder's associated token account, making your balance non-transferable before the LP is drained. - LP removal — the deployer burns their LP tokens or calls the AMM's
RemoveLiquidityinstruction, withdrawing both sides of the pool and collapsing the price to near zero.
All three are visible in the transaction stream before the price feed even updates. That is the window your bot must live in.
The Detection Stack: Geyser Streams and Account Subscriptions
A production solana anti rug bot does not poll RPC endpoints for price data. It subscribes directly to account-change notifications for the three accounts that matter: the token mint, the mint-authority keypair, and the AMM pool account (Raydium, Orca, Meteora, or whichever venue holds the liquidity).
The industry standard here is a Geyser plugin — a streaming interface baked into the Solana validator that emits account and transaction updates with block-level latency, far below what a standard accountSubscribe WebSocket connection delivers over a shared RPC node. A co-located Geyser feed from a node in the same data center as the leading validator cluster routinely beats public RPC by 50–200 ms, which is the entire difference between getting filled and getting stuck.
When the bot receives an account-change event, it deserializes the mint account struct and checks two fields: mint_authority (should be None for a locked token) and freeze_authority (same). For pool accounts, it parses the AMM state to compare the current reserve ratio against the baseline it recorded at entry. A reserve drop beyond a configurable threshold — typically 80–95% in a single slot — triggers the exit signal immediately.
The Exit Path: Priority Fees, Jito Bundles, and Simulation
Speed of detection is worthless without speed of execution. The exit transaction needs to land in the very next block, ideally in the same bundle as the rug transaction itself if the attacker is using Jito.
The bot constructs a swap instruction — token-to-SOL on the relevant AMM — and attaches a priority fee computed dynamically from the current getRecentPrioritizationFees distribution. For high-value positions, it wraps the swap in a Jito bundle with a tip sized to outbid competing liquidation bots. Jito bundles guarantee atomic inclusion at the top of the block, which matters because multiple bots will detect the same signal and race to the exit.
Before sending, the transaction is run through simulateTransaction against the latest blockhash. If the simulation returns an error — because the pool is already empty or the token account is frozen — the bot switches to an alternative route: a direct offer on a secondary AMM, a Jupiter aggregator path, or, in the freeze case, a pre-signed ThawAccount instruction if the wallet holds delegate authority.
A kill-switch parameter caps the maximum loss the bot will accept. If the simulated output falls below the floor — say, recovering less than 10% of entry cost — the bot logs the event and halts rather than paying fees to receive dust. This is the same safety logic we applied in our Solana sniper bot, where simulation-gated exits prevented fee bleed on failed escape transactions during volatile launches.
Integrating Anti-Rug Logic Into a Broader Position Manager
Anti-rug detection is most valuable as a module inside a larger position lifecycle manager, not as a standalone script. A complete implementation typically layers:
- Entry validation — check mint and freeze authority, LP lock status, and deployer wallet history before any capital is committed.
- Continuous monitoring — maintain live Geyser subscriptions for all open positions, not just new entries.
- Tiered exit logic — small positions exit via a single market swap; large positions split across multiple AMMs to minimize price impact on the way out.
- Post-exit reporting — log the triggering instruction, exit price, recovered amount, and latency to a database for strategy iteration.
This architecture feeds cleanly into trading-bot services that handle the full stack — from on-chain data ingestion through position management and post-trade analytics.
If your current setup relies on Discord alpha calls or manual chart watching to catch rugs, you are operating on a timescale measured in seconds after the fact. A well-built solana anti rug bot operates on a timescale measured in slots — roughly 400 ms each. Start a project with TierZero and we will scope the detection and exit architecture that fits your token portfolio and risk parameters.
Need a bot like this built?
We design, build and run trading bots on Solana, Hyperliquid and Polymarket.
Start a projectMore from the blog
Public vs Paid RPC: How to Run a Fair Benchmark
A fair comparison of public and paid RPC endpoints must account for quotas, workload, freshness and support guarantees.
Read articleRPC Benchmark Percentiles Explained: p50, p95 and p99
Why averages hide the latency spikes that break trading bots, wallets and production blockchain applications.
Read articleHyperliquid REST vs WebSocket Benchmark: What to Measure
A benchmark plan for Hyperliquid market data that separates request latency from streaming freshness and recovery.
Read article