Using rust I have a versionedTransaction, I am able to check if it interfaces with raydium by running a check on the account_keys:
fn is_raydium(tx: &VersionedTransaction) -> bool {
let raydium_program_ids: Vec<Pubkey> = RAYDIUM_PROGRAM_IDS
.iter()
.map(|id| Pubkey::from_str(id).unwrap())
.collect();
match &tx.message {
VersionedMessage::V0(message) | VersionedMessage::Legacy(message) => {
for instruction in &message.instructions {
if instruction.program_id_index as usize >= message.account_keys.len() {
continue;
}
let program_id = &message.account_keys[instruction.program_id_index as usize];
if raydium_program_ids.contains(program_id) {
info!("Found Raydium Program ID in instruction: {:?}", instruction);
return true;
}
}
}
}
false
}
So I know that my transaction I'm interested in is involved in a raydium transaction. However - now I want to see if the transaction involved sending solana to raydium, and how much.
How do I achieve this programmatically and purely from getting it from VersionedTransaction without resorting to the RPC call?