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