Find pool initialisation transaction timestamp
CVB91 opened this issue · 1 comments
I want to get the timestamp for when a raydium pool initialisation transaction occurred. Is the a simple way to do this from the pool id?
I have managed to get the pool init transaction by going through the lp mint and then getting largest token accounts for the lp mint, which is the lp token account and then getting the signatures by address for this account and parsing it. However, this needs to be done immediately because as soon as the lp tokens get burned or the liqudity gets removed this token account gets closed. There must be a simpler way right?
export async function test (id: PublicKey) {
const info = await connection.getTokenLargestAccounts(id)
const tokenAccount = info.value[0].address
const tokenSignatures = await connection.getSignaturesForAddress(tokenAccount)
console.log(tokenSignatures)
console.log(tokenSignatures[0].blockTime)
}
Currently this works but needs to be done immediately. I want to find the transaction details after some time has passed so this is not a feasible technique for my implementation.
You can get this information from the pool account info.
Having poolIdMint
:
import {
LIQUIDITY_STATE_LAYOUT_V4
} from '@raydium-io/raydium-sdk'
const data = await connection
.getAccountInfo(new PublicKey(poolIdMint))
.then((info) => LIQUIDITY_STATE_LAYOUT_V4.decode(info.data))
console.log(new Date(Number(data.poolOpenTime.toString() * 1000)))