DEV Community

Apollo
Apollo

Posted on

I Sniped a Solana Token in 400ms — Here's the Full Tech Stack

I Sniped a Solana Token in 400ms — Here's the Full Tech Stack

When Solana's latest meme token dropped last week, I executed a snipe in just 400ms from block inclusion to successful arbitrage. Here's the technical deep-dive into how I built this sniper bot using Jito MEV bundles, Jupiter routing, and Helius RPC—with real code, benchmarks, and hard-earned lessons.

The Challenge: Solana's 400ms Window

Solana's 400ms block times mean traditional Ethereum-style MEV strategies won't work. You need:

  • Sub-100ms RPC latency (Helius)
  • Pre-constructed bundles (Jito)
  • Optimal swap routing (Jupiter)
  • Local transaction simulation (no time for RPC roundtrips)

1. Jito MEV Bundles: Pre-Execution Arbitrage

Jito bundles let you submit multiple transactions atomically. My sniper watches for new token mints (via Helius webhooks) and pre-constructs two transactions:

# Bundle 1: Buy the new token  
buy_tx = Transaction().add(  
    create_associated_token_account(wallet, mint),  
    token_swap_instruction(jupiter_route, amount_in)  
)  

# Bundle 2: Sell to pre-set liquidity pool  
sell_tx = Transaction().add(  
    token_swap_instruction(  
        route=precomputed_raydium_pool,  
        amount_in="ALL"  # Dump entire balance  
    )  
)  

# Submit as atomic bundle  
jito_client.send_bundle([buy_tx, sell_tx])  
Enter fullscreen mode Exit fullscreen mode

Key Insight: Jito bundles execute in sequence but can fail individually. Always include a cleanup TX to reclaim rent.

2. Jupiter Routing: Finding the Optimal Path

Jupiter's API is too slow for real-time sniping. Instead, I pre-fetch routes for common liquidity pools and cache them:

// Pre-warm route cache  
const routes = await jupiter.getRoutes({  
  inputMint: SOL.mint,  
  outputMint: TARGET.mint,  
  amount: 0.1 * LAMPORTS_PER_SOL,  // Sample amount  
  slippage: 5,  // Aggressive for snipes  
});  

// Store in-memory with TTL  
cache.set(`route:${TARGET.mint}`, routes, 300_000);  
Enter fullscreen mode Exit fullscreen mode

Pro Tip: Monitor Jupiter's route compute units (CU). I've seen routes fail because they exceeded 1.4M CU—always include a fallback route.

3. Helius RPC: The Speed Difference

Standard RPCs introduce 200-300ms latency. Helius's prioritized endpoints cut this to 80ms during tests. Configuration matters:

const helius = new Connection("https://rpc.helius.xyz/?api-key=YOUR_KEY", {  
  commitment: "confirmed",  
  wsEndpoint: "wss://rpc.helius.xyz/ws",  // For real-time updates  
  disableRetryOnRateLimit: true,  // Fail fast during congestion  
});  
Enter fullscreen mode Exit fullscreen mode

Critical: Use getRecentPrioritizationFees to estimate next-block gas costs. I set priority fees at 2x the 90th percentile of recent fees.

4. Local Simulation: Avoiding RPC Roundtrips

Simulating via RPC adds 150ms. Instead, I run local simulations using Solana's @solana/web3.js and Anchor:

// Anchor test snippet for local sim  
let mut program = Program::new(&id, provider);  
let sim_result = program  
    .simulate(instruction, accounts, Some(remaining_accounts))  
    .unwrap();  

assert!(sim_result.units_consumed < 1_200_000);  // Safety check  
Enter fullscreen mode Exit fullscreen mode

Gotcha: Local sims don't account for chain state changes. Cross-validate with Helius's simulateBundle endpoint periodically.

The 400ms Breakdown

Here's where the time went in my fastest snipe:

  • 0-50ms: Helius websocket detects new mint
  • 50-150ms: Local simulation completes
  • 150-250ms: Jito bundle submission
  • 250-400ms: Block inclusion and arbitrage

Lessons Learned the Hard Way

  1. Wallet warmup is mandatory: New wallets take 1-2 blocks to initialize. Pre-fund and pre-create token accounts.
  2. Bundle expiration: Jito bundles expire after 20 slots (~10s). Resubmit if not included.
  3. False positives: 30% of new mints are scams. Filter for verified creators or high initial liquidity.

Final Thoughts

Sniping on Solana demands a different approach than Ethereum. By combining Jito's bundles, Jupiter's pre-computed routes, and Helius's low-latency RPC, sub-500ms execution is achievable—but only with meticulous local testing and real-time monitoring.

Next, I'm experimenting with embedding Flash Loan logic directly into bundles. If you've tried this, let's compare notes in the comments.


🚀 Try It Yourself & Get Airdropped

If you want to test this without building from scratch, use @ApolloSniper_Bot — the fastest non-custodial Solana sniper. When the bot hits $10M trading volume, the new $APOLLOSNIPER token will be minted and a massive 20% of the token supply will be airdropped to wallets that traded through the bot, based on their volume!

Join the revolution today.

Top comments (0)