Using Solana gRPC for Trading Bots
TL;DR
- - gRPC provides lowest-latency structured data for trading bots
- - Use processed commitment for speed, confirmed for safety
- - Separate data ingestion from trade execution
- - Combine gRPC monitoring with Jito bundles for execution
Yellowstone gRPC is the standard data feed for Solana trading bots. It provides real-time transaction and account data with lower latency than WebSocket or HTTP polling.
Architecture
A trading bot using gRPC has three layers:
- Data ingestion — gRPC stream receives market data
- Signal processing — logic determines when to trade
- Execution — submits transactions via RPC or Jito bundles
Keep these layers separate. The gRPC stream should write to an in-memory queue that the signal processor reads from. This prevents slow processing from causing backpressure on the stream.
Subscription patterns
Price monitoring. Subscribe to account updates for liquidity pool accounts. Parse the pool state to calculate token prices.
{
"accounts": {
"pools": {
"account": ["POOL_ADDRESS_1", "POOL_ADDRESS_2"],
"owner": [],
"filters": []
}
},
"commitment": 0
}
Copy trading. Subscribe to transactions for target wallets and replicate their swaps.
{
"transactions": {
"target_wallet": {
"vote": false,
"failed": false,
"accountInclude": ["TARGET_WALLET"],
"accountExclude": []
}
},
"commitment": 0
}
New token sniping. Watch for new liquidity pool creation events. See track new token launches.
Commitment level for trading
Use processed commitment for data ingestion. The ~400ms latency advantage over confirmed matters for competitive trading. Accept the small rollback risk — if a processed block is rolled back, your signal was based on stale data, but this is rare.
For trade confirmation, check at confirmed commitment. Do not assume a trade succeeded based on processed status alone.
Execution strategies
Standard RPC. sendTransaction via a provider with staked connections for SWQoS priority. Simple but no ordering guarantees.
Jito bundles. Submit a bundle of up to 5 transactions with a tip. Guarantees atomic execution in sequence. Preferred for MEV-sensitive trades.
Multiple submission. Send the same transaction to multiple RPC providers simultaneously to maximize landing probability.
Latency optimization
- Co-locate with your gRPC provider. Network latency between your bot and the gRPC endpoint matters
- Pre-build transactions. Prepare transaction templates with all accounts resolved. Fill in amounts when the signal fires
- Maintain fresh blockhash. Keep a recent blockhash ready from slot subscriptions rather than fetching one per trade
- Use processed commitment for data, confirmed for validation
FAQ
Is gRPC fast enough for MEV? gRPC delivers structured data faster than WebSocket or HTTP. For sub-slot latency, ShredStream is faster but requires parsing raw shreds.
How do I handle gRPC disconnections? Implement automatic reconnection with exponential backoff. During reconnection, your bot cannot see market data — consider pausing execution until the stream recovers.
Can I copy-trade with gRPC alone? You need gRPC for monitoring and standard RPC (or Jito) for execution. gRPC is a data feed, not a transaction submission channel.
Updated: