carbon_pumpfun_decoder/accounts/
mod.rs1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use crate::PROGRAM_ID;
5
6use super::PumpfunDecoder;
7pub mod bonding_curve;
8pub mod global;
9pub mod global_volume_accumulator;
10pub mod user_volume_accumulator;
11
12#[allow(clippy::large_enum_variant)]
13pub enum PumpfunAccount {
14 BondingCurve(bonding_curve::BondingCurve),
15 Global(global::Global),
16 GlobalVolumeAccumulator(global_volume_accumulator::GlobalVolumeAccumulator),
17 UserVolumeAccumulator(user_volume_accumulator::UserVolumeAccumulator),
18}
19
20impl AccountDecoder<'_> for PumpfunDecoder {
21 type AccountType = PumpfunAccount;
22 fn decode_account(
23 &self,
24 account: &solana_account::Account,
25 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
26 if !account.owner.eq(&PROGRAM_ID) {
27 return None;
28 }
29
30 if let Some(decoded_account) =
31 bonding_curve::BondingCurve::deserialize(account.data.as_slice())
32 {
33 return Some(carbon_core::account::DecodedAccount {
34 lamports: account.lamports,
35 data: PumpfunAccount::BondingCurve(decoded_account),
36 owner: account.owner,
37 executable: account.executable,
38 rent_epoch: account.rent_epoch,
39 });
40 }
41
42 if let Some(decoded_account) = global::Global::deserialize(account.data.as_slice()) {
43 return Some(carbon_core::account::DecodedAccount {
44 lamports: account.lamports,
45 data: PumpfunAccount::Global(decoded_account),
46 owner: account.owner,
47 executable: account.executable,
48 rent_epoch: account.rent_epoch,
49 });
50 }
51
52 if let Some(decoded_account) =
53 global_volume_accumulator::GlobalVolumeAccumulator::deserialize(account.data.as_slice())
54 {
55 return Some(carbon_core::account::DecodedAccount {
56 lamports: account.lamports,
57 data: PumpfunAccount::GlobalVolumeAccumulator(decoded_account),
58 owner: account.owner,
59 executable: account.executable,
60 rent_epoch: account.rent_epoch,
61 });
62 }
63
64 if let Some(decoded_account) =
65 user_volume_accumulator::UserVolumeAccumulator::deserialize(account.data.as_slice())
66 {
67 return Some(carbon_core::account::DecodedAccount {
68 lamports: account.lamports,
69 data: PumpfunAccount::UserVolumeAccumulator(decoded_account),
70 owner: account.owner,
71 executable: account.executable,
72 rent_epoch: account.rent_epoch,
73 });
74 }
75
76 None
77 }
78}