Created
May 16, 2024 23:26
-
-
Save DutchKevv/bf86abd296fff1825777c55353741297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { MAINNET_PROGRAM_ID, LIQUIDITY_STATE_LAYOUT_V4, Token } = require("@raydium-io/raydium-sdk") | |
const { Connection } = require("@solana/web3.js") | |
const bs58 = require('bs58') | |
const connection = new Connection('RPC URL') | |
let timeoutRef | |
const raydiumSubscriptionId = connection.onProgramAccountChange( | |
MAINNET_PROGRAM_ID.AmmV4, | |
async updatedAccountInfo => { | |
clearTimeout(timeoutRef) | |
timeoutRef = setTimeout(() => { | |
console.log('STREAM DEAD - HASN`T RECEIVED ANYTHING LAST 30 SECONDS') | |
}, 30_000) | |
}, | |
'confirmed', | |
// 'processed', | |
// 'finalized', | |
// commitment, | |
[ | |
{ dataSize: LIQUIDITY_STATE_LAYOUT_V4.span }, | |
{ | |
memcmp: { | |
offset: LIQUIDITY_STATE_LAYOUT_V4.offsetOf('quoteMint'), | |
bytes: Token.WSOL.mint.toBase58(), | |
}, | |
}, | |
{ | |
memcmp: { | |
offset: LIQUIDITY_STATE_LAYOUT_V4.offsetOf('marketProgramId'), | |
bytes: MAINNET_PROGRAM_ID.OPENBOOK_MARKET.toBase58(), | |
}, | |
}, | |
{ | |
memcmp: { | |
offset: LIQUIDITY_STATE_LAYOUT_V4.offsetOf('status'), | |
bytes: bs58.encode([6, 0, 0, 0, 0, 0, 0, 0]), | |
}, | |
}, | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment