All Resources
RaydiumTypeScript8 min read

How to Stream and Parse Raydium AMM Transactions Using Solana gRPC

Learn how to stream real-time Raydium AMM swap transactions on Solana using Yellowstone gRPC and parse the transaction data in TypeScript.

raydiumgrpctypescripttransaction-parsingamm

Introduction

Raydium is one of the most active automated market makers (AMMs) on Solana, processing thousands of swaps every minute. For developers building trading bots, analytics dashboards, or monitoring tools, the ability to stream and parse these transactions in real-time is essential.

In this guide, you'll learn how to use Yellowstone gRPC to subscribe to Raydium AMM transactions and decode the swap data — including token amounts, pool addresses, and trade direction.

What is Yellowstone gRPC?

Yellowstone gRPC (also known as Geyser gRPC) is a high-performance streaming interface for Solana. Unlike polling RPC endpoints, gRPC pushes data to your application the moment it's confirmed on-chain. This means:

  • Sub-second latency — you see transactions as they land
  • No rate limits from polling
  • Filtered streams — subscribe only to the programs and accounts you care about

Setting Up the Stream

First, you'll need a gRPC endpoint. Solana Tracker provides Yellowstone gRPC access through its infrastructure plans.

import { Client } from '@triton-one/yellowstone-grpc';

const client = new Client(
  'your-grpc-endpoint',
  'your-auth-token'
);

// Subscribe to Raydium AMM program transactions
const stream = await client.subscribe();

await stream.write({
  transactions: {
    raydium: {
      accountInclude: ['675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8'],
      accountExclude: [],
      accountRequired: [],
    },
  },
  commitment: 'confirmed',
});

Parsing Transaction Data

Raydium AMM transactions contain the swap instruction data encoded in the transaction's inner instructions. The key fields to extract are:

  • Pool address — identifies which token pair was traded
  • Amount in / Amount out — the swap amounts
  • Token mints — which tokens were swapped
  • User wallet — who performed the swap
function parseRaydiumSwap(tx: TransactionMessage) {
  const instructions = tx.transaction?.transaction?.message?.instructions || [];
  
  for (const ix of instructions) {
    // Check if this is a Raydium AMM instruction
    if (ix.programId === 'RAYDIUM_AMM_PROGRAM_ID') {
      const data = Buffer.from(ix.data);
      const discriminator = data.readUInt8(0);
      
      // Discriminator 9 = Swap instruction
      if (discriminator === 9) {
        const amountIn = data.readBigUInt64LE(1);
        const minAmountOut = data.readBigUInt64LE(9);
        
        return {
          type: 'swap',
          amountIn: amountIn.toString(),
          minAmountOut: minAmountOut.toString(),
          pool: ix.accounts[1],
          user: ix.accounts[16],
        };
      }
    }
  }
  return null;
}

Detecting Buy vs Sell Events

To determine whether a swap is a buy or sell, you need to check the direction of the swap relative to the base token (usually SOL or USDC):

function classifyTrade(swap: ParsedSwap, pool: PoolInfo) {
  const isBaseToQuote = swap.sourceToken === pool.baseMint;
  return isBaseToQuote ? 'sell' : 'buy';
}

Common Pitfalls

  1. IDL version mismatches — Raydium has multiple program versions (AMM v4, CLMM, CPMM). Make sure you're parsing against the correct IDL.
  2. Inner instruction parsing — Some swap data is in inner instructions, not top-level. Always check both.
  3. Connection handling — gRPC streams can disconnect. Implement automatic reconnection with exponential backoff.

Next Steps

With real-time Raydium transaction data flowing into your application, you can:

  • Build a trading bot that reacts to large swaps
  • Create a price feed by aggregating swap ratios
  • Monitor new pool creation events for early token discovery
  • Track whale wallets making large trades

Infrastructure

Solana Tracker's Yellowstone gRPC endpoints are optimized for low-latency DeFi streaming. Check out the Data API for pre-parsed token data, or get a Dedicated Node for maximum performance.

View the full source code on GitHub.