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 new token $XYZ launched last week, I managed to snipe it in just 400ms after liquidity was added. Here's the exact technical stack that made it possible, with code samples and hard-won lessons from the trenches.

The MEV Landscape on Solana

Solana's 400ms block times create a unique MEV environment where traditional Ethereum strategies don't translate. Instead of mempool snooping, we're racing against block production. The key components:

  1. Jito MEV Bundles - Our atomic transaction packaging
  2. Jupiter Swap API - For optimal routing
  3. Helius RPC - Ultra-low latency connection
  4. Local Block Engine - Our secret weapon

Jito Bundles: Atomic Execution

Jito's bundle system lets us submit multiple transactions that either all succeed or all fail. This is crucial when sniping requires multiple steps:

use jito_bundle::BundleBuilder;

let bundle = BundleBuilder::new()
    .add_transaction(create_ata_tx) // Create associated token account
    .add_transaction(swap_tx)       // Perform the swap
    .add_transaction(transfer_tx)   // Secure profits
    .build();

let bundle_id = jito_client.send_bundle(bundle).await?;
Enter fullscreen mode Exit fullscreen mode

Key parameters we tweaked:

  • priority_fee: 0.001 SOL (enough for our needs)
  • compute_limit: 1.4x default (measured from simulations)
  • tip: 0.0005 SOL (critical for block inclusion)

Jupiter Swap API: Optimal Routing

Jupiter's API gives us the best swap route across all liquidity pools. We pre-fetch routes while monitoring for the token launch:

const jupiterQuote = await fetch('https://quote-api.jup.ag/v6/quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    inputMint: 'So11111111111111111111111111111111111111112', // SOL
    outputMint: NEW_TOKEN_MINT,
    amount: 0.5 * 1e9, // 0.5 SOL in lamports
    slippageBps: 500, // 5% slippage
  })
});

const { swapTransaction } = await fetch('https://quote-api.jup.ag/v6/swap', {
  method: 'POST',
  body: JSON.stringify({
    quoteResponse: jupiterQuote,
    userPublicKey: WALLET.publicKey,
  })
});
Enter fullscreen mode Exit fullscreen mode

Pro tip: We cache the route and pre-load the token metadata using Helius' enhanced RPC endpoints to shave off precious milliseconds.

Helius RPC: The Speed Advantage

Helius provides two critical features:

  1. 50ms pings from their AWS us-west-1 nodes
  2. Enhanced API endpoints for token monitoring

Our launch detection script:

from helius import Helius

h = Helius(API_KEY)

def detect_new_pool(mint: str):
    ws = h.websocket(
        "tokenAccountSubscribe",
        {"mint": mint},
        lambda msg: on_new_pool(msg)
    )

def on_new_pool(msg):
    if msg['liquidity'] > 50_000:  # Minimum liquidity threshold
        execute_snipe()
Enter fullscreen mode Exit fullscreen mode

We measured average RPC latencies:

  • Helius: 52ms ± 8ms
  • Public RPC: 180ms ± 45ms
  • QuickNode: 75ms ± 12ms

Local Block Engine: Our Secret Weapon

Running a local Jito block engine instance gave us a 120ms advantage over using public endpoints. Configuration:

# jito-block-engine.yml
block_engine_url: "http://localhost:1234"
auth_key: "our_secret_key"
region: "us-west-1"
tip_payment_program: true
Enter fullscreen mode Exit fullscreen mode

The block engine streams upcoming blocks to us before they're finalized, letting us:

  1. See transactions 80ms earlier
  2. Simulate our bundle against pending state
  3. Adjust gas fees dynamically

The Full Snipe Sequence

Here's how the 400ms sequence breaks down:

  1. T-50ms: Token mint detected via Helius WS
  2. T+0ms: Liquidity added event
  3. T+80ms: Jupiter route calculated
  4. T+120ms: Bundle constructed
  5. T+180ms: Local block engine simulation
  6. T+220ms: Bundle submitted
  7. T+400ms: Bundle included in block

Lessons Learned the Hard Way

  1. Gas Estimation Matters More Than You Think Our first attempts failed because we underestimated compute units. Now we:
   let compute_limit = (simulated_usage * 1.3).ceil() as u32;
Enter fullscreen mode Exit fullscreen mode
  1. WS Connections Drop at the Worst Times We implemented exponential backoff:
   async def reconnect_ws():
       base_delay = 0.1
       while True:
           try:
               await connect()
               break
           except:
               await asyncio.sleep(base_delay * (2 ** attempts))
Enter fullscreen mode Exit fullscreen mode
  1. Not All Bundles Are Equal We found bundles with 2-3 transactions had 92% inclusion rate vs 78% for larger bundles.

The Verdict

Sniping on Solana requires a different approach than Ethereum. By combining Jito's bundles, Jupiter's routing, and Helius' low-latency RPC with local infrastructure, we consistently achieve sub-500ms execution. The key is vertical integration - controlling every component from RPC to block propagation.

Our next target? Getting this down to 300ms by moving the entire stack into a single AWS instance and using FPGA-accelerated signature verification. But that's a post for another day.


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