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) opportunities, milliseconds matter. Last week, I successfully frontran a trending token launch by executing a snipe in just 400ms from block appearance to confirmed transaction. Here's the exact technical breakdown of how I built this system.

The MEV Landscape on Solana

Unlike Ethereum's mempool-based MEV, Solana's parallel execution requires different strategies. Jito's MEV bundles (called "bundles" instead of "flashbots bundles") let us guarantee transaction ordering when we pay enough priority fees. Combined with Jupiter's liquidity aggregation and Helius's optimized RPC, we can create an unfair speed advantage.

Core Components

  1. Jito MEV Bundle System
    • Uses a dedicated jito-relayer.xyz endpoint
    • Requires 0.001 SOL deposit (refundable)
    • Bundle lifetime: ~200ms before rejection
from solders.keypair import Keypair
from jito_protos.bundle_pb2 import Bundle
from jito_searcher_client.searcher_client import SearcherClient

client = SearcherClient("jito-relayer.xyz:443", Keypair())
bundle = Bundle(
    transactions=[tx1, tx2],  # Pre-signed txs
    blockhash=latest_blockhash,
    priority_fee=500_000  # Micro-lamports
)
response = client.send_bundle(bundle)
Enter fullscreen mode Exit fullscreen mode
  1. Helius RPC Optimization
    • helius.xyz RPC with 50ms p99 latency
    • Custom getBlock subscription for new blocks
    • 10,000 RPM rate limit (critical for sniping)
const connection = new Connection(
  "https://mainnet.helius-rpc.com/?api-key=YOUR_KEY",
  {
    wsEndpoint: "wss://mainnet.helius-rpc.com",
    commitment: "confirmed" 
  }
);

connection.onBlock((slot) => {
  // Trigger snipe logic here
});
Enter fullscreen mode Exit fullscreen mode
  1. Jupiter Swap API
    • Pre-computed swap routes with /quote API
    • 3-hop max route for speed
    • 0.3% slippage tolerance
const quote = await fetch(
  `https://quote-api.jup.ag/v6/quote?inputMint=SOL&outputMint=${NEW_TOKEN}&amount=0.1`
);
const { swapTransaction } = await fetch(
  "https://quote-api.jup.ag/v6/swap",
  {
    method: "POST",
    body: JSON.stringify({
      quoteResponse: quote,
      userPublicKey: wallet.publicKey,
    }),
  }
);
Enter fullscreen mode Exit fullscreen mode

The 400ms Snipe Sequence

  1. Block Detection (0ms): Helius WebSocket emits new block
  2. Target Identification (50ms): Scan new transactions for token creation
  3. Route Calculation (100ms): Jupiter pre-fetched quotes
  4. Bundle Construction (150ms):
    • Swap SOL → NEW_TOKEN
    • Approve token account
    • Limit sell order
  5. Jito Submission (250ms): Bundle sent with 500k priority fee
  6. Confirmation (400ms): Transaction landed in block

Critical Optimizations

  • Pre-Signed Transactions: All txs signed before block arrival
  • RAM Disk Storage: Token list cached in /dev/shm
  • Binary Protobuf: Jito bundle serialization is 40% faster than JSON
  • GPU-accelerated Ed25519: Keypair signing via CUDA

Pain Points & Lessons

  1. False Positives Cost Money: Early versions wasted $1.2k on failed bundles before I added stricter token filters.

  2. Blockhash Lifetime: Solana blockhashes expire after ~2 minutes, requiring rapid retries.

  3. Jito Queue Priority: During congestion, bundles with <100k priority fees get dropped.

Full Snipe Script (Python)

import asyncio
from solders.pubkey import Pubkey
from helius import Helius
from jito_client import BundleSender

async def snipe():
    helius = Helius("API_KEY")
    jito = BundleSender("jito-relayer.xyz")

    async for slot in helius.block_subscription():
        new_tokens = scan_token_creations(slot)
        for token in new_tokens:
            quote = jupiter.get_quote(token)
            bundle = build_bundle(quote)
            await jito.send(bundle)

asyncio.run(snipe())
Enter fullscreen mode Exit fullscreen mode

Conclusion

This stack demonstrates how Solana's technical constraints (short block times, parallel execution) create unique MEV opportunities. By combining Jito's bundle system for transaction ordering, Helius for low-latency block data, and Jupiter for optimal routing, we can consistently snipe tokens before retail traders even see them.

The next frontier? FPGA-based signature acceleration and leveraging Solana's new priority fee markets. 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)