Skip to main content

carbon_boop_decoder/accounts/
mod.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::{BoopDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod amm_config;
11pub mod bonding_curve;
12pub mod config;
13pub mod locked_cp_liquidity_state;
14
15#[derive(Debug, Clone, PartialEq)]
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
18pub enum BoopAccount {
19    AmmConfig(Box<amm_config::AmmConfig>),
20    BondingCurve(Box<bonding_curve::BondingCurve>),
21    Config(Box<config::Config>),
22    LockedCpLiquidityState(Box<locked_cp_liquidity_state::LockedCpLiquidityState>),
23}
24
25impl<'a> carbon_core::account::AccountDecoder<'a> for BoopDecoder {
26    type AccountType = BoopAccount;
27
28    fn decode_account(
29        &self,
30        account: &'a solana_account::Account,
31    ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
32        if account.owner != PROGRAM_ID {
33            return None;
34        }
35
36        let data = account.data.as_slice();
37
38        {
39            if let Some(decoded) = amm_config::AmmConfig::decode(data) {
40                return Some(carbon_core::account::DecodedAccount {
41                    lamports: account.lamports,
42                    data: BoopAccount::AmmConfig(Box::new(decoded)),
43                    owner: account.owner,
44                    executable: account.executable,
45                    rent_epoch: account.rent_epoch,
46                });
47            }
48        }
49        {
50            if let Some(decoded) = bonding_curve::BondingCurve::decode(data) {
51                return Some(carbon_core::account::DecodedAccount {
52                    lamports: account.lamports,
53                    data: BoopAccount::BondingCurve(Box::new(decoded)),
54                    owner: account.owner,
55                    executable: account.executable,
56                    rent_epoch: account.rent_epoch,
57                });
58            }
59        }
60        {
61            if let Some(decoded) = config::Config::decode(data) {
62                return Some(carbon_core::account::DecodedAccount {
63                    lamports: account.lamports,
64                    data: BoopAccount::Config(Box::new(decoded)),
65                    owner: account.owner,
66                    executable: account.executable,
67                    rent_epoch: account.rent_epoch,
68                });
69            }
70        }
71        {
72            if let Some(decoded) = locked_cp_liquidity_state::LockedCpLiquidityState::decode(data) {
73                return Some(carbon_core::account::DecodedAccount {
74                    lamports: account.lamports,
75                    data: BoopAccount::LockedCpLiquidityState(Box::new(decoded)),
76                    owner: account.owner,
77                    executable: account.executable,
78                    rent_epoch: account.rent_epoch,
79                });
80            }
81        }
82
83        None
84    }
85}