carbon_pumpfun_decoder/accounts/
mod.rs1
2use carbon_core::account::AccountDecoder;
3use carbon_core::deserialize::CarbonDeserialize;
4
5
6use super::PumpfunDecoder;
7pub mod global;
8pub mod last_withdraw;
9pub mod bonding_curve;
10
11pub enum PumpfunAccount {
12 Global(global::Global),
13 LastWithdraw(last_withdraw::LastWithdraw),
14 BondingCurve(bonding_curve::BondingCurve),
15}
16
17
18impl<'a> AccountDecoder<'a> for PumpfunDecoder {
19 type AccountType = PumpfunAccount;
20 fn decode_account( &self, account: &solana_sdk::account::Account, ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
21
22 if let Some(decoded_account) = global::Global::deserialize(account.data.as_slice()) {
23 return Some(carbon_core::account::DecodedAccount {
24 lamports: account.lamports,
25 data: PumpfunAccount::Global(decoded_account),
26 owner: account.owner,
27 executable: account.executable,
28 rent_epoch: account.rent_epoch,
29 });
30 }
31
32 if let Some(decoded_account) = last_withdraw::LastWithdraw::deserialize(account.data.as_slice()) {
33 return Some(carbon_core::account::DecodedAccount {
34 lamports: account.lamports,
35 data: PumpfunAccount::LastWithdraw(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) = bonding_curve::BondingCurve::deserialize(account.data.as_slice()) {
43 return Some(carbon_core::account::DecodedAccount {
44 lamports: account.lamports,
45 data: PumpfunAccount::BondingCurve(decoded_account),
46 owner: account.owner,
47 executable: account.executable,
48 rent_epoch: account.rent_epoch,
49 });
50 }
51
52 None
53 }
54}