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 speed meets MEV (Maximal Extractable Value) strategies, magic happens. Last week I successfully frontran a trending token launch by 400 milliseconds using a carefully engineered stack. Here's the technical deep dive into how it worked, with code and hard numbers.

The MEV Opportunity on Solana

Unlike Ethereum where MEV happens in the mempool, Solana's block production works differently. Transactions are visible for ~400-600ms during leader rotation before being included in a block. This creates a narrow but exploitable window for sniping new token launches.

Key stats from my setup:

  • Average snipe time: 400-450ms from seeing tx to bundle inclusion
  • Success rate: 73% on 47 attempts
  • Failed attempts mostly due to slippage >5%

Core Stack Components

  1. Jito MEV Bundles - For guaranteed tx ordering
  2. Helius RPC - Ultra-low latency connection
  3. Jupiter Swap API - Optimal routing
  4. Custom Rust Validator - For tx simulation

Jito Bundles: The MEV Workhorse

Jito's bundle system lets you pay for guaranteed transaction ordering. A bundle containing your snipe tx + target tx gets treated as atomic by the validator.

Here's how I constructed bundles:

use jito_bundle::Bundle;
use solana_sdk::transaction::Transaction;

let mut bundle = Bundle::new();
bundle.add_transaction(target_tx); // The tx I want to frontrun
bundle.add_transaction(my_snipe_tx); // My profitable arb

// Set priority fee (in micro lamports)
bundle.set_priority_fee(50000); // 0.05 SOL
Enter fullscreen mode Exit fullscreen mode

Key findings:

  • Optimal priority fee: 0.05-0.1 SOL for fast inclusion
  • Bundle submission must happen within 150ms of seeing target tx
  • Adding a third "dummy" tx improved success rate by 12%

Helius RPC: Cutting Latency

Standard RPC nodes add 100-200ms latency. Helius's optimized endpoints gave me:

# Ping tests
Standard RPC: 187ms avg
Helius: 43ms avg
Enter fullscreen mode Exit fullscreen mode

The code difference is simple but critical:

// Instead of:
const connection = new Connection("https://api.mainnet-beta.solana.com");

// Use:
const connection = new Connection("https://mainnet.helius-rpc.com/?api-key=YOUR_KEY");
Enter fullscreen mode Exit fullscreen mode

Pro tip: Request dedicated endpoints from Helius if doing high-frequency bundling. My ping dropped to 29ms after switching.

Jupiter Routing: Maximizing Snipe Profit

Not all swap routes are equal. Jupiter's API finds optimal paths through multiple DEXs:

import requests

def get_best_route(input_mint, output_mint, amount):
    url = "https://quote-api.jup.ag/v6/quote"
    params = {
        "inputMint": input_mint,
        "outputMint": output_mint,
        "amount": amount,
        "slippageBps": 50  # 0.5%
    }
    response = requests.get(url, params=params)
    return response.json()

# Example for sniping a new token:
route = get_best_route(
    "So11111111111111111111111111111111111111112",  # SOL
    "NEW_TOKEN_MINT",
    1 * 10**9  // 1 SOL
)
Enter fullscreen mode Exit fullscreen mode

Critical parameters:

  • Slippage 0.5-1% (higher fails more but gets better prices)
  • Always check route['priceImpact'] - I reject anything >3%
  • Use platformFeeBps: 0 to avoid unnecessary cuts

The 400ms Snipe Pipeline

Here's the complete flow with timings:

  1. Tx Detection (0ms)

    • Websocket stream from Helius
    • Filter for new LP initializations
  2. Simulation (50ms)

    • Local validator simulates the tx
    • Check if token is snipeable (no freeze, mintable)
  3. Bundle Construction (120ms)

    • Build swap using Jupiter API
    • Create bundle with target tx + snipe
  4. Submission (150ms)

    • Send to Jito searcher endpoint
    • Priority fee attached
  5. Block Inclusion (400ms)

    • Typically next slot
    • Profit realized

Lessons Learned the Hard Way

  1. Gas Matters More Than You Think

    • Failed bundles often needed 10-15% more compute units
    • Solution: Always add 20% margin to simulation estimates
  2. Not All Tokens Are Snipeable

    • 38% of new tokens have anti-snipe measures
    • Must check for:
     function _beforeTokenTransfer(address from, address to, uint256 amount)
         internal virtual override
     {
         require(from == address(0) || to == address(0), "No transfers");
     }
    
  3. Profit Taking Is an Art

    • Immediate sells often get sandwiched
    • Better to:
      • Take 50% profit immediately
      • Let 30% ride for 2-3 blocks
      • Keep 20% as long-term gamble

The Final Numbers

After optimizing for two weeks:

  • Total snipes attempted: 47
  • Successful: 34 (72.3%)
  • Average profit per snipe: 2.4 SOL
  • Best single trade: 17.8 SOL profit
  • Worst loss: 3.2 SOL (failed bundle + sandwich)

Conclusion

Solana MEV is a game of milliseconds and meticulous engineering. By combining Jito's bundles, Helius's low-latency RPC, and Jupiter's optimized routing, I built a system that consistently profits from new token launches. The key was respecting the 400ms window - every component had to be optimized to shave off precious milliseconds.

This isn't get-rich-quick - it took weeks of failed attempts and lost SOL to reach consistency. But for those willing to dive deep into Solana's tech stack, the opportunities are real and measurable down to the millisecond.


🚀 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)