https://www.quicknode.com/guides/solana-development/3rd-party-integrations/track-raydium-…
- User
https://www.quicknode.com/guides/solana-development/3rd-party-integrations/track-raydium-lps import { Connection, PublicKey } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
const RAYDIUM_PUBLIC_KEY = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"; const HTTP_URL = "YOUR_QUICKNODE_HTTP_ENDPOINT"; const WSS_URL = "YOUR_QUICKNODE_WSS_ENDPOINT"; const RAYDIUM = new PublicKey(RAYDIUM_PUBLIC_KEY); const INSTRUCTION_NAME = "initialize2";
const connection = new Connection(HTTP_URL, { wsEndpoint: WSS_URL });
async function startConnection(connection: Connection, programAddress: PublicKey, searchInstruction: string): Promise { console.log("Monitoring logs for program:", programAddress.toString());
connection.onLogs( programAddress, ({ logs, err, signature }) => { if (err) return; if (logs && logs.some(log => log.includes(searchInstruction))) { console.log("Signature for 'initialize2':", `https://explorer.solana.com/tx/${signature}`); fetchRaydiumMints(signature, connection); } }, "finalized" );}
async function fetchRaydiumMints(txId: string, connection: Connection) { try { const tx = await connection.getParsedTransaction( txId, { maxSupportedTransactionVersion: 0, commitment: 'confirmed' } );
//@ts-ignore const accounts = (tx?.transaction.message.instructions).find(ix => ix.programId.toBase58() === RAYDIUM_PUBLIC_KEY).accounts as PublicKey[]; if (!accounts) { console.log("No accounts found in the transaction."); return; } const tokenAIndex = 8; const tokenBIndex = 9; const tokenAAccount = accounts[tokenAIndex]; const tokenBAccount = accounts[tokenBIndex]; console.log("New LP Found"); await displayTokenMetadata(tokenAAccount, connection, "A"); await displayTokenMetadata(tokenBAccount, connection, "B"); } catch (error) { console.log("Error fetching transaction:", txId, error); return; }}
async function getTokenMetadata(tokenAccount: PublicKey, connection: Connection): Promise { const accountInfo = await connection.getAccountInfo(tokenAccount);
if (!accountInfo) { console.error(`Token account not found: ${tokenAccount.toBase58()}`); return null; } const tokenInfo = await connection.getTokenAccountBalance(tokenAccount); const mint = tokenInfo.value.mint; const mintAccountInfo = await connection.getAccountInfo(new PublicKey(mint)); if (!mintAccountInfo) { console.error(`Mint account not found: ${mint}`); return null; } const tokenMetadata = await connection.getParsedAccountInfo(new PublicKey(mint), 'confirmed'); return tokenMetadata?.value?.data?.parsed?.info;}
Assistant
- User
Build final script version using all above. From begin to end. Provide me also how to install and usage.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.