carbon_pump_swap_decoder/
lib.rs

1use solana_pubkey::Pubkey;
2
3pub struct PumpSwapDecoder;
4pub mod accounts;
5pub mod instructions;
6pub mod types;
7
8pub const PROGRAM_ID: Pubkey =
9    Pubkey::from_str_const("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA");
10
11#[cfg(test)]
12mod tests {
13
14    use crate::instructions::PumpSwapInstruction;
15
16    use super::PumpSwapDecoder;
17    use carbon_core::instruction::InstructionDecoder;
18
19    #[test]
20    fn test_buy_deserialization_without_track_volume() {
21        let decoder = PumpSwapDecoder;
22        let ix =
23            carbon_test_utils::read_instruction("tests/fixtures/buy_with_track_volume_false.json")
24                .expect("read fixture");
25
26        let maybe_decoded = decoder.decode_instruction(&ix);
27        let decoded = maybe_decoded.expect("Invalid instruction");
28        match decoded.data {
29            PumpSwapInstruction::Buy(buy) => {
30                assert!(!buy.track_volume.0);
31            }
32            other => {
33                panic!("Expected Buy, got {:?}", other);
34            }
35        }
36    }
37
38    #[test]
39    fn test_buy_deserialization_with_track_volume() {
40        let decoder = PumpSwapDecoder;
41        let ix =
42            carbon_test_utils::read_instruction("tests/fixtures/buy_with_track_volume_true.json")
43                .expect("read fixture");
44
45        let decoded = decoder
46            .decode_instruction(&ix)
47            .expect("Invalid instruction");
48        match decoded.data {
49            PumpSwapInstruction::Buy(buy) => {
50                assert!(buy.track_volume.0);
51            }
52            other => {
53                panic!("Expected Buy, got {:?}", other);
54            }
55        }
56    }
57}