2

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?

1 Answer 1

1

If anyone comes looking... the answer was to do a simulation on the transaction and read the before and after tokens and figure out direction by which transaction changed value on which side. Jito-ts has the simulateBalance capability which returns both instead of jist the simulate from vanilla solana

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.