Shyft
Start BuildingSupportWebsite
  • Welcome
    • πŸ‘‹Introducing Shyft
    • πŸ—οΈStart Building
  • Solana Infrastructure
    • 🚁Shyft RPCs
  • Yellowstone gRPC Network
    • Decoding gRPC Latency
    • ⚑gRPC Docs
      • Introduction
      • Authentication
      • Subscribe Requests
      • FAQ
      • Getting Started
        • Initializing the Yellowstone Client
        • Making a gRPC connection
        • Adding a Reconnection Mechanism
        • πŸ”₯Replaying Slots with Solana yellowstone gRPCs
        • Modifying your Subscribe Request
        • Closing a gRPC Connection
      • Subscribing to Transactions
        • All Transactions of an address
        • Subscribing to all transactions of a Liquidity Pool
        • Subscribing to all transactions of multiple addresses
        • Subscribing to all transactions of a Token
      • Subscribing to Accounts
        • Account Updates for a Program
        • Account Updates for an Address
        • Account updates using memcmp
      • Streaming Blocks & BlocksMeta
        • Streaming Block Updates
        • Subscribing to BlocksMeta
      • Modifying & Unsubscribing
  • Solana defi data
    • DeFI APIs
      • Get Pool By Address
      • Get Pools By Token Pair
      • Get All Pools for a Token
      • Get Liquidity Details of a Pool
  • Callbacks
    • ☎️What are Callbacks?
      • Transaction Callbacks
      • Account Callbacks
    • πŸ“”Callback APIs
      • Response Structure
      • List Callbacks
      • Register callback
      • Remove callback
      • πŸ”₯Pause a callback
      • πŸ”₯Resume a callback
      • Update Callbacks
      • Add Addresses
      • Remove addresses
  • Solana Super Indexers
    • 🌩️GraphQL APIs
      • Getting Started
      • Building Queries
      • Paginating Response
      • Applying Filters
      • Ordering and Sorting Data
    • πŸ“€Case Studies
      • Tensor
        • Get Active Listings of a Wallet
        • Get Active Bids of a Wallet
        • Get Active Listings of a Collection
        • Get all Bids of a Collection
        • Get all Pools of a Margin Account
        • Get all Pools by Owner
      • Raydium
        • Get Pool By Address
        • Get Pools By Token Address
        • Get Pools Created Between Time
        • Get Pool Burn Percentage
        • Get Liquidity Details of a Pool
        • Get Pool and OpenBook Market Info
        • Get Token Supply Percentage In Pool
      • Orca Whirlpool
        • Get Pool by Address
        • Get Pool by Token Address
        • Get Positions for a Pool
        • Get Positions for a Wallet
        • Get Liquidity Details of a Pool
      • Kamino
        • Get Borrow Details of a Wallet
        • Get Deposit Details of a Wallet
        • Get Reserve Details
      • Cross Marketplace Queries
        • Get active listings across marketplaces for a wallet
        • Get listings for a collection across marketplaces
        • Get floor price of a collection
      • Cross Defi Queries
        • Fetch Liquidity Pools for Token
      • Native Staking
        • Get Stakes for a Wallet
        • Get Stakes For Validator
      • Governance/Realms
        • Get DAO Token Owners
        • Get Proposals For Governing Mint
        • Get All Proposals For DAO
        • Get DAO Treasury Info
        • Get All Active Proposals For Wallet
      • Meteora
        • Get All LB Position Pairs
        • Get Position of a User Wallet
        • Get Pool by Token Addresses
        • Get All Deposits for a User
        • Get All Withdraws for a User
        • Get All Fees Claimed by a User
        • Get All User Positions and Deposits for a Pool
        • Get All User Positions and Withdrawals for a Pool
      • Fluxbeam
        • Get Pool by Address
        • Get Pool by Token Addresses
      • Drift
        • Get User account for Delegate
        • Get User accounts based on authority
        • Get User details based on Referrer
        • Get Borrow/Deposit Amount for an User
        • Get PrepPositions for an User Account
        • Getting OrderId and userOrderId
        • Get OpenOrders for a User Account
      • πŸ”₯Pumpswap
        • πŸ”₯Get Pool by Address
        • πŸ”₯Get Pool by Creator Address
        • πŸ”₯Get Pools by Token Addresses
      • Raydium Launchpad
        • Get Bonding Curve Details by Pool Address
        • Get All Pools for a Creator
        • Get Pools by Token Addresses
        • Get Migration details of a Pool
  • Solana APIs
    • API Reference
    • Transactions
      • Parsed Transaction Structure
      • Transaction APIs
        • History
        • Parse Signature
        • Parse Multiple Signatures
        • Send
        • Send Multiple
    • NFT
      • πŸ”₯Create Gasless
      • Create
      • Read All
      • Burn
      • πŸ”₯Burn Multiple NFTs V2
      • Update
      • πŸ”₯Create NFT from Metadata
      • πŸ”₯Read Wallet Nfts
      • πŸ”₯Read Selected NFTs
      • πŸ”₯Get NFT Owners
      • πŸ”₯Update NFT Metadata Uri
      • πŸ”₯Update V2
      • Search
      • Transfer
      • Transfer Multiple NFTs
      • Mint
      • Read
    • Wallet
      • Get Balance
      • Get Token Balance
      • Get All Tokens Balance
      • Get Portfolio
      • Resolve Address
      • Get All Domains
      • Get Stake Accounts
    • Fungible Tokens
      • Create
      • Mint
      • Burn
      • πŸ”₯Update
      • Get Token Info
      • Transfer
      • Airdrop
  • πŸ“˜Dev Guides
    • πŸ“€gRPC Case Studies
      • Pumpfun
        • Streaming and Parsing Pump.fun Transactions
        • Streaming and Parsing Pump.fun Accounts
        • Detecting new Token launches on Pump.fun
        • Detecting Buy/Sell Transactions on Pump.fun
        • Detecting tokens migrating from Pump.fun to Pump Swap AMM
      • PumpSwap AMM
        • Streaming and Parsing Pump Swap Transactions
        • Streaming and Parsing Pump Swap AMM Accounts
        • Detecting Buy/Sell Transactions on Pump Swap AMM
        • Detecting tokens migrating from Pump.fun to Pump Swap AMM
      • Raydium AMM
        • Streaming and Parsing Raydium AMM Transactions
        • Streaming and Parsing Raydium AMM Accounts
        • Detecting Buy/Sell Transactions on Raydium AMM
        • Detecting new Pools on Raydium AMM
      • Raydium CLMM
        • Streaming and Parsing Raydium CLMM Transactions
        • Streaming and Parsing Raydium CLMM Accounts
Powered by GitBook
On this page
  • Step-by-Step Breakdown
  • Streaming Transactions Using gRPC
  • Handling the incoming data
  • Important Links

Was this helpful?

  1. Dev Guides
  2. gRPC Case Studies
  3. Raydium AMM

Detecting new Pools on Raydium AMM

Monitoring New Raydium AMM Pools Using Yellowstone gRPC

PreviousDetecting Buy/Sell Transactions on Raydium AMMNextRaydium CLMM

Last updated 1 day ago

Was this helpful?

In the fast-moving world of decentralized finance, being among the first to identify new liquidity pools can offer significant advantages. Raydium AMM frequently sees the creation of new pools, and quickly detecting these allows traders and analysts to capitalize on early opportunities. In this document, we will illustrate how we can detect new Pools on Raydium AMM

The complete source code for this project is available on GitHub.

Please feel free to clone the repository and try it out. Additionally, you will find other relevant and useful code examples related to gRPC and streaming .

Step-by-Step Breakdown

This project consists of two key components:

  1. Create a Yellowstone gRPC SubscribeRequest with Raydium AMM Filters

  2. Parse the Incoming Account Data

Streaming Transactions Using gRPC

The first step involves initializing the Solana Yellowstone Client. You can get Solana Yellowstone gRPC access from the Shyft Dashboard. Please check out our for more details.

Initializing the Client

Once you have the authentication details, you can initialize the client in the following manner,

import Client from "@triton-one/yellowstone-grpc";

const client = new Client(
  "YOUR-GRPC-ENDPOINT", //yellowstone grpc url
  "GRPC-ACCESS-TOKEN", //authentication token
  undefined
);
use yellowstone_grpc_client::{GeyserGrpcClient, Interceptor}

async fn connect(&self) -> anyhow::Result<GeyserGrpcClient<impl Interceptor>> {
     GeyserGrpcClient::build_from_shared(self.endpoint.clone())? //grpc url
            .x_token(Some(self.x_token.clone()))? //grpc auth token
            .connect_timeout(Duration::from_secs(10))
            .timeout(Duration::from_secs(10))
            .tls_config(ClientTlsConfig::new().with_native_roots())?
            .max_decoding_message_size(1024 * 1024 * 1024)
            .connect()
            .await
            .map_err(Into::into)
}

You can use any Yellowstone gRPC endpoint with this client. An access token is optional, as some gRPC services don't require authentication.

The Rust client supports several additional options, as demonstrated in the example above. Most of these options are also available for the TS client, where they are passed as the third argument to the Client constructor.

Specifying what data to stream from gRPC

We first construct a SubscribeRequest targeting the Raydium AMM program (675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8) with specific account-level memcmp filters:

  • Filter 1: Matches liquidity pools where the quoteMint is SOL (So1111...), identifying pools paired with SOL.

  • Filter 2: Verifies that the marketProgramId is set to Raydium Serum Market (srmqPvym...).

  • Filters 3 & 4: Ensure both swapQuoteInAmount and swapBaseOutAmount are initially zeroβ€”indicating the pool has just been created and no swaps have occurred yet.

This setup streams only newly initialized Raydium AMM liquidity pool accounts that meet these conditions.

const request: SubscribeRequest = {
  "slots": {},
  "accounts": {
    "raydium": {
      "account": [],
      "filters": [
        {
          "memcmp": {
            "offset": LIQUIDITY_STATE_LAYOUT_V4.offsetOf('quoteMint').toString(), // Filter for only tokens paired with SOL
            "base58": "So11111111111111111111111111111111111111112"
          }
        },
        {
          "memcmp": {
            "offset": LIQUIDITY_STATE_LAYOUT_V4.offsetOf('marketProgramId').toString(), 
            "base58": "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"
          }
        },
        {
          "memcmp": {
            "offset": LIQUIDITY_STATE_LAYOUT_V4.offsetOf('swapQuoteInAmount').toString(), 
            "bytes": Uint8Array.from([0])
          }
         },
        {
          "memcmp": {
            "offset": LIQUIDITY_STATE_LAYOUT_V4.offsetOf('swapBaseOutAmount').toString(), 
            "bytes": Uint8Array.from([0])
          }
        }
      ],
      "owner": ["675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"] 
    }
  },
  "transactions": {},
  "blocks": {},
  "blocksMeta": {
    "block": []
  },
  "accountsDataSlice": [],
  "commitment": CommitmentLevel.PROCESSED, // Subscribe to processed blocks for the fastest updates
  entry: {},
  transactionsStatus: {}
}

Handling the incoming data

Once the subscription is active, your gRPC client starts receiving account updates in real-time. You check for the presence of an account field in the stream. The tOutPut() function decodes and extracts critical on-chain metadata about the Raydium pool:

export function tOutPut(data){
    const dataTx = data?.account?.account;
    const signature = decodeTransact(dataTx?.txnSignature); // Transaction signature
    const pubKey = decodeTransact(dataTx?.pubkey);          // Account public key
    const owner = decodeTransact(dataTx?.owner);            // Program owner
    const poolstate = LIQUIDITY_STATE_LAYOUT_V4.decode(dataTx.data); // Pool state decoded using Raydium SDK
    const slot = data?.account.slot;                        // Slot number of update

    return {
        signature,
        pubKey,
        owner,
        poolstate,
        slot
    }
}

This function extracts:

  • signature: The transaction signature associated with the account creation.

  • pubKey: The public key of the new Raydium pool account.

  • owner: Should match the Raydium AMM program ID.

  • poolstate: Decoded struct holding all AMM pool configuration details (mints, reserves, fee structure, etc.).

  • slot: Solana slot number when the update occurred.

Important Links

To specify what on-chain data, we send a SubscribeRequest over the existing Solana Yellowstone gRPC client. These Request allows you to filter for specific accounts, transactions, slots, or other Solana on-chain events, giving you full control over the data you receive. You can find out more about here.

Once established, the stream will begin sending data directly to your application. You have the flexibility to on the fly, allowing you to change the data specifications you receive without stopping your stream. For more details on , or , you can find additional information in our .

– In-depth technical docs for implementing real-time streaming with Yellowstone gRPC and Geyser plugin on Solana.

– Guides, use cases, and performance benchmarks for building low-latency Solana applications using gRPC-based infrastructure.

– Ready-to-use code snippets and integrations for common DeFi protocols, transaction parsers, and real-time Solana data streaming use cases.

πŸ“˜
πŸ“€
modify your subscription
reconnecting and re-starting the stream from a specific slot
closing your gRPC connection
documentation
Solana gRPC Documentation
Blogs on Solana gRPC Streaming
Solana DeFi Code Snippets & Examples
TypeScript
here
gRPC Authentication Docs
Subscribe Requests