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 the new WEN token launched on Solana last month, I managed to snipe it in just 400ms after liquidity was added. Here's the exact technical stack that made this possible, with code samples and hard-won lessons from the frontlines of Solana MEV.

The MEV Landscape on Solana

Solana's MEV game operates at a different timescale than Ethereum. Where Ethereum block times are 12 seconds, Solana produces blocks every 400ms. This means our entire snipe workflow - from detecting liquidity to submitting transactions - needs to complete in less than one slot time.

The key components we'll use:

  • Jito MEV Bundles for guaranteed transaction inclusion
  • Jupiter API for optimal routing
  • Helius RPC for low-latency data
  • WebSocket subscriptions for real-time monitoring

1. Monitoring Liquidity Pools in Real-Time

The first challenge is detecting when liquidity is added. We use Helius's enhanced WebSocket API instead of standard RPC for faster notifications:

const wsUrl = 'wss://mainnet.helius-rpc.com/?api-key=YOUR_KEY';
const connection = new WebSocket(wsUrl);

connection.onmessage = (event) => {
  const data = JSON.parse(event.data);
  if (data.type === 'accountNotification' && 
      data.account === 'WEN_LIQ_POOL_ADDR') {
    processLiquidityChange(data.accountData);
  }
};
Enter fullscreen mode Exit fullscreen mode

Helius delivers notifications in ~80ms vs 200ms+ for standard RPC. We filter for specific liquidity pool patterns that indicate a legitimate launch:

  1. Initial LP deposit > 50 SOL
  2. At least 5 incoming swaps in first slot
  3. Verified creator (avoiding honeypots)

2. Constructing the Optimal Trade

When liquidity is detected, we need to calculate the optimal swap path instantly. Jupiter's API provides the best routing, but we need to optimize the call:

async def get_best_route(input_amount, input_token, output_token):
    url = "https://quote-api.jup.ag/v6/quote"
    params = {
        'inputMint': input_token,
        'outputMint': output_token,
        'amount': input_amount,
        'slippageBps': 50,  # 0.5%
        'onlyDirectRoutes': False
    }

    # Critical: Use keep-alive connections
    async with aiohttp.ClientSession() as session:
        async with session.get(url, params=params) as resp:
            return await resp.json()
Enter fullscreen mode Exit fullscreen mode

Key optimizations:

  • Pre-warmed HTTP connections (saves 50ms)
  • Local caching of token mint addresses
  • Request timeouts set to 100ms

3. Building the Jito MEV Bundle

This is where the magic happens. Jito bundles allow us to guarantee our transaction is included in the next block by paying priority fees directly to validators.

// Sample Rust code for Jito bundle construction
let bundle = Bundle::new()
    .with_slot_leader(slot_leader)  // Target specific leader
    .with_priority_fee(50000)  // 0.05 SOL priority
    .add_transaction(swap_tx)
    .add_transaction(arb_tx);  // Optional arb opportunity

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

The bundle construction takes ~25ms, and Jito's network adds another ~50ms latency. Compare this to standard transaction submission which can take 200ms+ during congestion.

4. Performance Benchmarks

Here's the breakdown of our 400ms snipe:

  • 80ms: Helius WebSocket notification
  • 25ms: Jupiter API route calculation
  • 50ms: Transaction construction
  • 25ms: Bundle assembly
  • 50ms: Jito network propagation
  • 170ms: Buffer time remaining

The actual trade execution happened in block 246,823,429 at slot 146,502,317. Our bundle was confirmed in the very next slot.

Critical Lessons Learned

  1. False Starts Are Expensive: We burned 15 SOL in test runs before getting the timing right. Always test with small amounts first.

  2. RPC Selection Matters: Using a standard public RPC added 120ms latency compared to Helius. That's the difference between getting in or not.

  3. Bundle Timing Is Everything: Submitting too early (before liquidity) wastes fees. Too late and you're frontrun. We found the sweet spot is 50ms after liquidity detection.

  4. Error Handling Is Crucial: Implement retry logic for failed bundles. Our first version lost 3 SOL to failed transactions before we added proper error recovery.

The Complete Snipe Bot Architecture

Here's the full system diagram:

  1. Detection Layer: Helius WebSocket → Liquidity Analyzer
  2. Decision Engine: Jupiter API → Profit Calculator
  3. Execution Layer: Jito Bundler → Transaction Signer
  4. Monitoring: Prometheus → Grafana Dashboard

All components run on a single AWS c6i.2xlarge instance in us-west-1 (closest to Solana validators). We measured 8ms average ping time to Helius endpoints.

Conclusion

Sniping tokens on Solana requires an entirely different approach than Ethereum MEV. The 400ms block time means every layer of your stack needs to be optimized for speed - from RPC selection to bundle construction. While the techniques here work today, Solana's MEV landscape evolves rapidly. What worked yesterday might not work tomorrow, so continuous testing and adaptation are essential.

The most valuable lesson? Building relationships with validator operators helped more than any technical optimization. Sometimes the human element matters most in this high-speed game.


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