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

Sniping new tokens on Solana is an art — and sometimes, a science. Recently, I managed to snipe a Solana token in just 400 milliseconds after its liquidity pool went live. Achieving this feat required a combination of MEV (Maximal Extractable Value) techniques, optimized RPCs, and precise routing logic. In this article, I’ll break down the full tech stack I used, including Jito MEV bundles, Jupiter routing, and Helius RPC, along with practical code examples and lessons learned.


The Problem: Timing is Everything

Sniping a token requires executing trades immediately after liquidity is added. The challenge is twofold:

  1. Speed: You need to submit your transaction within milliseconds of the token launch.
  2. Atomicity: Your transaction must succeed entirely or fail completely — no partial executions.

To solve these challenges, I leveraged Jito’s MEV bundles, which allow for atomic transaction sequencing, and Jupiter’s swap API for optimized routing. I also relied on Helius’s RPC, which provides low-latency access to Solana’s blockchain.


The Tech Stack

Here’s the core stack I used:

  1. Jito MEV Bundles: For atomic transaction sequencing.
  2. Jupiter Swap API: For optimized token swaps.
  3. Helius RPC: For low-latency blockchain access.
  4. Rust: For building the sniper bot.
  5. WebSocket: For real-time monitoring of liquidity pool creation.

Step 1: Monitoring Liquidity Pools

The first step is detecting when a new liquidity pool is created. I used Solana’s WebSocket API to listen for ProgramLog events emitted by the Raydium or Orca programs. Here’s how I set up the WebSocket listener:

use solana_client::websocket::WsClient;
use solana_sdk::commitment_config::CommitmentConfig;

async fn monitor_pools() {
    let ws_client = WsClient::new("wss://api.mainnet-beta.solana.com").await.unwrap();
    let subscription = ws_client
        .program_subscribe(
            &raydium_program_id,
            Some(CommitmentConfig::confirmed()),
        )
        .await
        .unwrap();

    while let Some(event) = subscription.next().await {
        if event.logs.contains("InitializePool") {
            println!("New pool detected!");
            // Trigger sniper logic
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

This listener triggers a sniper routine whenever a new pool is initialized.


Step 2: Building the Sniper Bot

The sniper bot needs to do three things:

  1. Fetch the token’s mint address and liquidity pool details.
  2. Calculate the optimal swap route using Jupiter.
  3. Submit the transaction as a Jito MEV bundle for atomic execution.

Fetching Token Details

Once a pool is detected, I fetch the token’s mint address and liquidity pool details using Helius RPC. Helius provides low-latency access, which is critical for snipe trades.

use helius_client::HeliusClient;

async fn fetch_token_details(mint_address: &str) -> TokenDetails {
    let client = HeliusClient::new("your_helius_api_key");
    let token_details = client.get_token_details(mint_address).await.unwrap();
    token_details
}
Enter fullscreen mode Exit fullscreen mode

Calculating the Swap Route

Jupiter’s API provides optimized swap routes for Solana tokens. Here’s how I fetched the best route:

use jupiter_swap::JupiterSwapClient;

async fn get_swap_route(input_mint: &str, output_mint: &str, amount: u64) -> SwapRoute {
    let client = JupiterSwapClient::new();
    let route = client.get_route(input_mint, output_mint, amount).await.unwrap();
    route
}
Enter fullscreen mode Exit fullscreen mode

Submitting the Transaction

To ensure atomic execution, I used Jito MEV bundles. These bundles allow you to submit multiple transactions as a single atomic unit. Here’s how I constructed and submitted the bundle:

use jito_bundle::JitoBundleClient;
use solana_sdk::transaction::Transaction;

async fn submit_bundle(transactions: Vec<Transaction>) {
    let client = JitoBundleClient::new("your_jito_api_key");
    client.submit_bundle(transactions).await.unwrap();
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Optimizing for Speed

The key to sniping is speed. Here’s how I minimized latency:

  1. Helius RPC: Helius provides sub-100ms latency, ensuring quick access to on-chain data.
  2. Jupiter Caching: I cached Jupiter routes in memory to avoid unnecessary API calls.
  3. Prepared Transactions: I pre-signed transactions to reduce submission time.

Lessons Learned

  1. Latency Matters: Even a 100ms delay can make the difference between success and failure. Use low-latency RPCs like Helius.
  2. Atomicity is Crucial: MEV bundles ensure atomic execution, preventing partial trades.
  3. Monitor Gas Fees: High gas fees can outpace your snipe. Monitor gas prices and adjust your strategy accordingly.

The Result: 400ms Snipe

With this stack, I successfully sniped a new token within 400ms of its liquidity pool going live. The entire process, from detection to execution, was seamless thanks to the combination of Jito MEV bundles, Jupiter routing, and Helius RPC.


Conclusion

Sniping tokens on Solana requires precision, speed, and the right tools. By leveraging Jito MEV bundles, Jupiter’s swap API, and Helius RPC, I was able to achieve a 400ms snipe. This stack is not just theoretical — it’s battle-tested and effective. If you’re looking to snipe tokens yourself, I encourage you to experiment with these tools and optimize based on your specific needs.

Happy sniping!


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