I'm trying to read user staked validator information using @solana/web3.js. I was able to read the stake accounts for the given wallet address but having trouble with reading staked validator information(name, APY, etc...). Here's the code that I've used to read stake accounts.
cosnt stakeAccounts = await connection.getParsedProgramAccounts(
StakeProgram.programId,
{
filters: [
{
memcmp: {
offset: 12, // number of bytes
bytes: wallet.publicKey.toBase58(), // base58 encoded string
},
},
],
},
);
I've tried to read the stake account information like below, but it returns an empty array.
const stakeAccountInfo = await connection.getParsedProgramAccounts(
new PublicKey("Config1111111111111111111111111111111111111"),
{
filters: [
{ memcmp: { offset: 124, bytes: accountData instanceof Buffer ? account?.pubkey?.toString() : accountData?.parsed?.info?.stake?.delegation?.voter } },
{ dataSize: 200 } // Stake account data length
]
}
);