← Back to guides
April 1, 2026·10 min read

How to Build a Solana Sniper Bot with Filtered gRPC

How to Build a Solana Sniper Bot with Filtered gRPC
Sniper BotgRPCTradingPump.funRaydium

A sniper bot detects new token listings and executes a buy within the first seconds — before the crowd arrives. In this guide, we'll build one step-by-step using Subglow filtered gRPC for detection and Solana web3.js for execution.

Architecture Overview

A production sniper bot has four stages:

  1. Detection: Receive new pool or token events via filtered gRPC
  2. Validation: Check if the token passes safety filters (liquidity, creator history, honeypot detection)
  3. Execution: Build and send a swap transaction targeting the new pool
  4. Management: Set take-profit/stop-loss and monitor position

Subglow handles stage 1 — delivering the detection event ~4ms after the slot. Your bot logic handles stages 2-4.

Step 1: Detection via Filtered gRPC

Subscribe to both Pump.fun and Raydium filters to catch tokens at two stages: initial bonding curve launch and Raydium pool migration.

const client = new Subglow({
  url: "grpc.subglow.io:443",
  apiKey: process.env.SUBGLOW_KEY,
  filter: ["pump_fun", "raydium_v5"],
});

client.subscribe((tx) => {
  if (tx.type === "pool_create") {
    handleNewPool(tx.parsed);
  }
  if (tx.type === "migrate") {
    handleMigration(tx.parsed);
  }
});

Step 2: Safety Checks

Never buy blindly. Run these checks before executing:

async function isSafe(token) {
  // 1. Minimum liquidity check
  if (token.initial_liquidity < 5_000) return false;

  // 2. Creator reputation (optional — query Helius or Birdeye)
  const creatorHistory = await checkCreator(token.creator);
  if (creatorHistory.rugs > 0) return false;

  // 3. Mint authority check
  const mintInfo = await getMintInfo(token.base_mint);
  if (mintInfo.mintAuthority !== null) return false; // Can still mint = danger

  // 4. Freeze authority check
  if (mintInfo.freezeAuthority !== null) return false;

  return true;
}

Step 3: Execution

Build a swap transaction using Jupiter or Raydium SDK. Key optimization: use priority fees to land your transaction faster.

async function executeBuy(poolAddress, solAmount) {
  const tx = new Transaction();

  // Add priority fee for faster inclusion
  tx.add(ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: 50_000, // Adjust based on network congestion
  }));

  // Add swap instruction (via Jupiter or Raydium SDK)
  tx.add(await buildSwapInstruction(poolAddress, solAmount));

  // Send with preflight disabled for speed
  const sig = await connection.sendTransaction(tx, [wallet], {
    skipPreflight: true,
    maxRetries: 2,
  });

  return sig;
}

Step 4: Position Management

After buying, monitor the token price and implement exit logic:

  • Take profit: Sell 50% at 2x, remaining at 5x
  • Stop loss: Sell everything if price drops 30% from entry
  • Time-based exit: Sell after 30 minutes regardless (most pumps are short-lived)

Risk Management

Sniping is inherently risky. Follow these rules:

  • Never risk more than 1-2% of your portfolio per snipe
  • Use a dedicated wallet with limited funds
  • Monitor your win rate — adjust filters if it drops below 30%
  • Keep a kill switch to stop the bot instantly if something goes wrong

Why Filtered gRPC for Sniping

The ~4ms latency from Subglow filtered gRPC gives you a head start over bots using WebSocket (~120ms) or webhook-based detection (~100ms). When thousands of bots are competing for the same token launch, that 100ms advantage determines who gets in at the bottom.

Ready to try it?

Get your API key and start receiving filtered data in under 5 minutes. Free tier available.

Get started