How to Build a Solana Copy Trading Bot with gRPC (Step-by-Step)

Copy trading is one of the most popular strategies on Solana — follow smart money wallets, mirror their trades, profit from their alpha. But building a reliable copy trading bot requires fast data. If you see the whale's trade 500ms late, you're buying at 2x their price. This tutorial shows you how to build one using Subglow's filtered gRPC.
Architecture Overview
A copy trading bot has four components:
- Event stream — real-time feed of all relevant trades (gRPC)
- Wallet filter — match incoming events against your watchlist
- Trade executor — fire mirror transactions via Jupiter or direct AMM
- Risk manager — position sizing, stop losses, max exposure
Most bots fail at step 1. They use RPC polling (slow) or raw WebSockets (unreliable). gRPC gives you push-based, guaranteed delivery with sub-5ms latency.
Step 1: Connect to Filtered gRPC
const client = new Subglow({
url: "grpc.subglow.io:443",
apiKey: process.env.SUBGLOW_KEY,
filter: ["pump_fun", "jupiter", "raydium"],
});
client.subscribe((event) => {
checkWatchlist(event);
});
This single connection gives you every Pump.fun launch, Jupiter swap, and Raydium event — pre-parsed. No Borsh, no filtering millions of irrelevant transactions.
Step 2: Build Your Watchlist
const WATCHLIST = new Set([
"7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", // whale #1
"HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", // alpha caller
]);
Where do you find wallets worth tracking? Look at:
- Pump.fun leaderboard — top buyers who consistently hit migrations
- Birdeye/Solscan — wallets with highest PnL on new token launches
- Telegram alpha groups — callers often share or leak their wallets
- On-chain analysis — wallets that consistently buy before major price moves
Step 3: Match and Execute
function checkWatchlist(event) {
const signer = event.parsed?.signer || event.parsed?.user;
if (!signer || !WATCHLIST.has(signer)) return;
// Whale detected — mirror the trade
const { token, sol_amount } = event.parsed;
console.log(`Whale ${signer.slice(0,8)}... bought ${token} for ${sol_amount} SOL`);
// Execute with your own position sizing
const mySize = Math.min(sol_amount * POSITION_RATIO, MAX_SOL_PER_TRADE);
executeBuy(token, mySize);
}
Step 4: Risk Management
Copy trading without risk management is just gambling with extra steps. Key rules:
- Max position size: Never mirror more than X SOL per trade regardless of whale size
- Max daily exposure: Cap total capital deployed per day
- Token filters: Skip tokens with <$1K liquidity or <10 holders
- Timing check: If the whale bought >2 slots ago, the price may have already moved — skip or reduce size
- Auto-exit: When the tracked wallet sells, consider exiting too
Why gRPC Matters for Copy Trading
Let's say a whale buys a Pump.fun token at 5% bonding curve for 1 SOL. In the next 3 seconds, the curve moves to 15%. If your copy bot uses:
- RPC polling (1s interval): You buy at ~12% curve. Price already 2.4x the whale's entry.
- WebSocket (~200ms): You buy at ~7% curve. Still a 40% markup.
- Filtered gRPC (<5ms): You buy at ~5.1% curve. Nearly identical entry to the whale.
That's the difference between a profitable copy trade and a bad entry.
Next Steps
This tutorial covers the core architecture. For production, you'll want to add: persistent watchlist storage, trade logging, PnL tracking, and a Telegram notification system. All of these build on the same gRPC event stream — the data layer is the foundation everything else sits on.
Ready to try it?
Get your API key and start receiving filtered data in under 5 minutes. Free tier available.
Get started →