use crate::{BoopDecoder, PROGRAM_ID};
#[cfg(feature = "postgres")]
pub mod postgres;
#[cfg(feature = "graphql")]
pub mod graphql;
pub mod amm_config;
pub mod bonding_curve;
pub mod config;
pub mod locked_cp_liquidity_state;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum BoopAccount {
AmmConfig(Box<amm_config::AmmConfig>),
BondingCurve(Box<bonding_curve::BondingCurve>),
Config(Box<config::Config>),
LockedCpLiquidityState(Box<locked_cp_liquidity_state::LockedCpLiquidityState>),
}
impl<'a> carbon_core::account::AccountDecoder<'a> for BoopDecoder {
type AccountType = BoopAccount;
fn decode_account(
&self,
account: &'a solana_account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if account.owner != PROGRAM_ID {
return None;
}
let data = account.data.as_slice();
{
if let Some(decoded) = amm_config::AmmConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: BoopAccount::AmmConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = bonding_curve::BondingCurve::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: BoopAccount::BondingCurve(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = config::Config::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: BoopAccount::Config(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = locked_cp_liquidity_state::LockedCpLiquidityState::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: BoopAccount::LockedCpLiquidityState(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
None
}
}