solana_tx_decoding/instruction/pumpfun/
is_pumpfun_event_instruction.rs

1use solana_central::constants::PUMP_CONSTANTS;
2use solana_central::Instruction;
3
4/// Determine if a Solana instruction is a Pumpfun bonding curve event instruction. Checks data
5/// length, discriminator, program ID, and event authority account to identify Pumpfun event
6/// instructions that contain swap data.
7pub fn is_pumpfun_event_instruction(instruction: &Instruction) -> bool {
8  // Smallest data length is 137, we'll give a bit tolerance
9  if instruction.data.len() < 100 {
10    return false;
11  }
12  // check data discriminator
13  for i in 0..PUMP_CONSTANTS.bonding_curve_event_discriminator.len() {
14    if instruction.data[i] != PUMP_CONSTANTS.bonding_curve_event_discriminator[i] {
15      return false;
16    }
17  }
18  // check program id matches
19  if instruction.tx_account_keys[instruction.program_id_index as usize] != PUMP_CONSTANTS.bonding_curve_program {
20    return false;
21  }
22  // The only account that should be interacted with here is the event authority
23  if instruction.accounts.len() < 1
24    || instruction.tx_account_keys[instruction.accounts[0] as usize] != PUMP_CONSTANTS.bonding_curve_event_authority
25  {
26    return false;
27  }
28  // All checks for bonding curve event passed
29  true
30}