carbon-pump-fees-decoder 2.0.0

PumpFees Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{PumpFeesDecoder, PROGRAM_ID};

#[cfg(feature = "postgres")]
pub mod postgres;

#[cfg(feature = "graphql")]
pub mod graphql;

pub mod bonding_curve;
pub mod fee_config;
pub mod fee_program_global;
pub mod global;
pub mod pool;
pub mod sharing_config;
pub mod social_fee_pda;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum PumpFeesAccount {
    BondingCurve(Box<bonding_curve::BondingCurve>),
    FeeConfig(Box<fee_config::FeeConfig>),
    FeeProgramGlobal(Box<fee_program_global::FeeProgramGlobal>),
    Global(Box<global::Global>),
    Pool(Box<pool::Pool>),
    SharingConfig(Box<sharing_config::SharingConfig>),
    SocialFeePda(Box<social_fee_pda::SocialFeePda>),
}

impl<'a> carbon_core::account::AccountDecoder<'a> for PumpFeesDecoder {
    type AccountType = PumpFeesAccount;

    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) = bonding_curve::BondingCurve::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::BondingCurve(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = fee_config::FeeConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::FeeConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = fee_program_global::FeeProgramGlobal::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::FeeProgramGlobal(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = global::Global::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::Global(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = pool::Pool::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::Pool(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = sharing_config::SharingConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::SharingConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = social_fee_pda::SocialFeePda::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: PumpFeesAccount::SocialFeePda(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }

        None
    }
}