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 fee_config;
9pub mod global;
10pub mod global_volume_accumulator;
11pub mod user_volume_accumulator;
12
13pub enum PumpfunAccount {
14 BondingCurve(bonding_curve::BondingCurve),
15 FeeConfig(fee_config::FeeConfig),
16 Global(global::Global),
17 GlobalVolumeAccumulator(global_volume_accumulator::GlobalVolumeAccumulator),
18 UserVolumeAccumulator(user_volume_accumulator::UserVolumeAccumulator),
19}
20
21impl AccountDecoder<'_> for PumpfunDecoder {
22 type AccountType = PumpfunAccount;
23 fn decode_account(
24 &self,
25 account: &solana_account::Account,
26 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
27 if !account.owner.eq(&PROGRAM_ID) {
28 return None;
29 }
30
31 if let Some(decoded_account) =
32 bonding_curve::BondingCurve::deserialize(account.data.as_slice())
33 {
34 return Some(carbon_core::account::DecodedAccount {
35 lamports: account.lamports,
36 data: PumpfunAccount::BondingCurve(decoded_account),
37 owner: account.owner,
38 executable: account.executable,
39 rent_epoch: account.rent_epoch,
40 });
41 }
42
43 if let Some(decoded_account) = fee_config::FeeConfig::deserialize(account.data.as_slice()) {
44 return Some(carbon_core::account::DecodedAccount {
45 lamports: account.lamports,
46 data: PumpfunAccount::FeeConfig(decoded_account),
47 owner: account.owner,
48 executable: account.executable,
49 rent_epoch: account.rent_epoch,
50 });
51 }
52
53 if let Some(decoded_account) = global::Global::deserialize(account.data.as_slice()) {
54 return Some(carbon_core::account::DecodedAccount {
55 lamports: account.lamports,
56 data: PumpfunAccount::Global(decoded_account),
57 owner: account.owner,
58 executable: account.executable,
59 rent_epoch: account.rent_epoch,
60 });
61 }
62
63 if let Some(decoded_account) =
64 global_volume_accumulator::GlobalVolumeAccumulator::deserialize(account.data.as_slice())
65 {
66 return Some(carbon_core::account::DecodedAccount {
67 lamports: account.lamports,
68 data: PumpfunAccount::GlobalVolumeAccumulator(decoded_account),
69 owner: account.owner,
70 executable: account.executable,
71 rent_epoch: account.rent_epoch,
72 });
73 }
74
75 if let Some(decoded_account) =
76 user_volume_accumulator::UserVolumeAccumulator::deserialize(account.data.as_slice())
77 {
78 return Some(carbon_core::account::DecodedAccount {
79 lamports: account.lamports,
80 data: PumpfunAccount::UserVolumeAccumulator(decoded_account),
81 owner: account.owner,
82 executable: account.executable,
83 rent_epoch: account.rent_epoch,
84 });
85 }
86
87 None
88 }
89}