How to Stream and Parse Pump AMM Transactions on Solana Using gRPC

Learn how to stream and parse real-time PumpSwap AMM transactions on
Solana using Shyft's Yellowstone gRPC. Includes TypeScript code for
filtering by program ID and parsing buy/sell events.

A step-by-step guide to streaming real-time Pump AMM transactions on Solana using Shyft’s Yellowstone gRPC — with full TypeScript parsing examples

Streaming Pumpfun transaction on Solana Cover

PumpSwap is Pump.fun‘s native AMM — tokens that graduate from the bonding curve now migrate to PumpSwap instead of Raydium. If you’re building a trading bot, sniper, or analytics tool, you need to stream and parse PumpSwap transactions in real time.

In this guide, you’ll learn how to:

  • Subscribe to PumpSwap AMM transactions using Shyft’s Yellowstone gRPC
  • Filter by the PumpSwap program ID (pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA)
  • Parse buy, sell, and liquidity events from the raw transaction stream

All examples use TypeScript with the @triton-one/yellowstone-grpc client.

Before Getting Started

To get started, we will need a few things.

Authentication: gRPC endpoint and gRPC token

Shyft’s Yellowstone gRPC nodes are available in various locations all across EU and the US region. To access, we would require a region-specific gRPC endpoint and an access token, which is available to purchase on your Shyft Dashboard.

A server-side backend (like NodeJS) to receive gRPC data

As gRPC services are unsupported in web-browsers, you would need a backend application such as C#, Go, Java, Python etc. to receive gRPC data.

The PumpSwap Program ID

The core address for PumpSwap (Pump AMM) is:

6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P

Here is a full guide on fetching PumpSwap AMM pool data on Solana using Shyft DeFi APIs.

Introduction

Shyft’s gRPC, utilizing the Geyser framework, provides a live stream of on-chain Solana data, including account updates, transactions, blocks, and slot changes. Our approach involves connecting to Shyft’s gRPC service to create a real-time stream of transactions specifically for PumpSwap AMM.

This will allow us to receive transaction data instantly as it’s processed on the blockchain. Our backend will then parse and display this parsed information, which can be used for further processing.

The entire code for this article is available here on GitHub, feel free to clone and follow along.

How to Initialize the Yellowstone Client?

For streaming Pumpfun AMM transactions using gRPC, we need two things: The gRPC endpoint, which is your region-specific endpoint, and a gRPC access token. Both of these are available in your Shyft dashboard. Once you have them, you can initialize the yellowstone client and begin streaming Pumpfun AMM data.

const client = new Client('Your Region specific Shyft gRPC URL','Shyft gRPC Access Token', undefined);

Now we can proceed to obtain our data from the blockchain.

How to Subscribe to PumpSwap Transactions Using Shyft gRPC?

Specifying what data to receive — Subscribe Request

Once the Yellowstone client is set up, the next step is to define exactly what information we want to receive. Shyft’s gRPC interface provides various types of real-time updates, such as account changes, transactions, new blocks, and slot updates. To focus only on the data we need, we have to use “subscribe requests.” Subscribe requests define what data will be streamed. In our case the subscribe request will look something like this.

const req: SubscribeRequest = {
  accounts: {},
  slots: {},
  transactions: { //for streaming transactions
    pumpFun: {
      vote: false,
      failed: false,
      signature: undefined,
      accountInclude: [PUMPSWAP_AMM.toBase58()], //pumpswap program id
      accountExclude: [],
      accountRequired: [],
    },
  },
  transactionsStatus: {},
  entry: {},
  blocks: {},
  blocksMeta: {},
  accountsDataSlice: [],
  ping: undefined,
  commitment: CommitmentLevel.PROCESSED, //commitment level, can be confirmed
  //or finalized too
};

The two main aspects of establishing a successful stream are as follows:

  • client: This is the yellowstone client which is used to connect to the Solana blockchain and subscribe to real-time on-chain events.
  • arg: This parameter specifies the exact data we want to retrieve from the blockchain by the means of Subscribe Requests.

To ensure your bot never misses a PumpSwap transaction during a network hiccup, implement a reconnect and slot replay strategy for your gRPC stream.

Handling the received data stream

The handle stream function is responsible for receiving raw transactions from the stream and sending the subscribe request.

async function handleStream(client: Client, args: SubscribeRequest) {
// Subscribe for events
const stream = await client.subscribe();
// Create `error` / `end` handler
const streamClosed = new Promise<void>((resolve, reject) => {
stream.on("error", (error) => {
console.log("ERROR", error);
reject(error);
stream.end();
});
stream.on("end", () => {
resolve();
});
stream.on("close", () => {
resolve();
});
});
// Handle updates
stream.on("data", async (data) => {
try{
console.log(data);
}catch(error){
if(error){
console.log(error)
}
}
});
// Send subscribe request
await new Promise<void>((resolve, reject) => {
stream.write(args, (err: any) => {
if (err === null || err === undefined) {
resolve();
} else {
reject(err);
}
});
}).catch((reason) => {
console.error(reason);
throw reason;
});
await streamClosed;
}

How to Parse the PumpSwap Transactions Received – Buy & Sell

gRPC streams provide transaction data like standard RPC, plus extra fields like isVote, message headers (signature, signer), isVersioned, and block/ping/entry info. Shyft offers a utility function to convert these gRPC transactions to a traditional RPC format.

import { TransactionFormatter } from "./utils/transaction-formatter";
const TXN_FORMATTER = new TransactionFormatter();

//formatting raw gRPC data to RPC like transactions
const txn = TXN_FORMATTER.formTransactionFromJson(
data.transaction,
Date.now(),
);

The next step involves decoding the transaction, so that the raw data is human readable. That’s where the parsing comes in. We can define our own transaction parser, or simply use Shyft’s Solana transaction parser.

npm i @shyft-to/solana-transaction-parser

This parser just takes in the program IDL, understands how the transaction data is structured, then produces the parsed transaction which can be easily read and understood. In our case, we’ve used Shyft’s parser, which can be initialized in the following manner.

//initialization
const TXN_FORMATTER = new TransactionFormatter();
const PUMP_FUN_AMM_PROGRAM_ID = new PublicKey(
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
);
const PUMP_FUN_IX_PARSER = new SolanaParser([]);
PUMP_FUN_IX_PARSER.addParserFromIdl(
PUMP_FUN_AMM_PROGRAM_ID.toBase58(),
pumpFunAmmIdl as Idl
);

//decoding data
const paredIxs = PUMP_FUN_IX_PARSER.parseTransactionData(
tx.transaction.message,
tx.meta.loadedAddresses
);

Conclusion

In summary, establishing a real-time transaction stream for Pump AMM using gRPC, coupled with efficient parsing via Shyft’s transaction parser, provides developers with immediate and understandable insights into the platform’s activity. This is crucial for building responsive applications and gaining a timely understanding of the evolving Pump.fun ecosystem.

If you also need to track tokens before they graduate to PumpSwap, check out our guide on streaming Bonding Curve transactions on PumpFun.

In case you missed out, the entire code for this article is available here on GitHub, feel free to clone and follow along.

You can explore our other related articles: Streaming Real-Time Data on SolanaReal-Time Data Streaming with gRPC: Accounts, Transactions, BlocksHow to Stream Real-Time Pump.fun Updates on Solana, and Tracking New Pools on Raydium.

Resources