npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

raydium-pool-keys

v1.0.3

Published

A TypeScript utility for fetching Raydium pool keys or Market pair for a given token address on the Solana blockchain.

Downloads

17

Readme

Raydium Pool Keys Fetcher

npm version npm downloads license

A TypeScript utility for fetching Raydium pool keys for a given token address on the Solana blockchain. This package allows you to get market IDs and liquidity pool keys using the Raydium SDK and Solana web3.js. Important: You need an RPC that has the RPC call "getProgramAccounts" enabled. This will not work with the public mainnet-beta rpc, but will work fine free tier RPC's from Helius for example.

Installation

npm install raydium-pool-keys

Usage

Importing the Package

import { Connection, PublicKey } from '@solana/web3.js';
import { getMarketIdForTokenAddress, getPoolKeysForTokenAddress } from 'raydium-pool-keys';

Fetching Market ID for a Token Address

const connection = new Connection('https://api.mainnet-beta.solana.com');
const tokenAddress = 'YourTokenAddressHere';

getMarketIdForTokenAddress(connection, tokenAddress)
  .then((marketId) => {
    if (marketId) {
      console.log('Market ID:', marketId.toString());
    } else {
      console.log('Market ID not found for the provided token address.');
    }
  })
  .catch((error) => {
    console.error('Error fetching Market ID:', error);
  });

Fetching Pool Keys for a Token Address

getPoolKeysForTokenAddress(connection, tokenAddress)
  .then((poolKeys) => {
    if (poolKeys) {
      console.log('Pool Keys:', poolKeys);
    } else {
      console.log('Pool Keys not found for the provided token address.');
    }
  })
  .catch((error) => {
    console.error('Error fetching Pool Keys:', error);
  });

API

getMarketIdForTokenAddress(connection: Connection, tokenaddress: string): Promise<PublicKey | null>

Fetches the market ID for a given token address.

  • connection: An instance of Connection from @solana/web3.js.
  • tokenaddress: The token address for which to fetch the market ID.

Returns a Promise that resolves to a PublicKey if found, otherwise null.

getPoolKeysForTokenAddress(connection: Connection, tokenaddress: string): Promise<LiquidityPoolKeys | null>

Fetches the liquidity pool keys for a given token address.

  • connection: An instance of Connection from @solana/web3.js.
  • tokenaddress: The token address for which to fetch the pool keys.

Returns a Promise that resolves to LiquidityPoolKeys if found, otherwise null.

Constants

You can define constants in a separate file (e.g., constants.ts) and import them as needed. Here's an example of what your constants.ts might look like:

export const RAYDIUM_LIQUIDITY_POOL_V4_ADDRESS = 'YourRaydiumLiquidityPoolV4AddressHere';
export const WSOL_ADDRESS = 'YourWrappedSOLAddressHere';

Example constants.ts

export const RAYDIUM_LIQUIDITY_POOL_V4_ADDRESS = 'RAYDIUM_LIQUIDITY_POOL_V4_ADDRESS_HERE';
export const WSOL_ADDRESS = 'So11111111111111111111111111111111111111112';

Contributing

Contributions are welcome! Please open an issue or submit a pull request with any improvements or bug fixes.

License

This project is licensed under the MIT License.


This README provides a clear guide on how to install, use, and understand your package. Adjust the example addresses and constants as needed to match your actual configuration and data.