carbon-zeta-decoder 2.0.0

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

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

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

pub mod cross_margin_account;
pub mod cross_margin_account_manager;
pub mod cross_open_orders_map;
pub mod greeks;
pub mod insurance_deposit_account;
pub mod margin_account;
pub mod market_indexes;
pub mod market_node;
pub mod open_orders_map;
pub mod perp_sync_queue;
pub mod pricing;
pub mod referral_account;
pub mod referrer_account;
pub mod referrer_alias;
pub mod settlement_account;
pub mod socialized_loss_account;
pub mod spread_account;
pub mod state;
pub mod underlying;
pub mod whitelist_deposit_account;
pub mod whitelist_insurance_account;
pub mod whitelist_trading_fees_account;
pub mod zeta_group;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum ZetaAccount {
    CrossMarginAccount(Box<cross_margin_account::CrossMarginAccount>),
    CrossMarginAccountManager(Box<cross_margin_account_manager::CrossMarginAccountManager>),
    CrossOpenOrdersMap(Box<cross_open_orders_map::CrossOpenOrdersMap>),
    Greeks(Box<greeks::Greeks>),
    InsuranceDepositAccount(Box<insurance_deposit_account::InsuranceDepositAccount>),
    MarginAccount(Box<margin_account::MarginAccount>),
    MarketIndexes(Box<market_indexes::MarketIndexes>),
    MarketNode(Box<market_node::MarketNode>),
    OpenOrdersMap(Box<open_orders_map::OpenOrdersMap>),
    PerpSyncQueue(Box<perp_sync_queue::PerpSyncQueue>),
    Pricing(Box<pricing::Pricing>),
    ReferralAccount(Box<referral_account::ReferralAccount>),
    ReferrerAccount(Box<referrer_account::ReferrerAccount>),
    ReferrerAlias(Box<referrer_alias::ReferrerAlias>),
    SettlementAccount(Box<settlement_account::SettlementAccount>),
    SocializedLossAccount(Box<socialized_loss_account::SocializedLossAccount>),
    SpreadAccount(Box<spread_account::SpreadAccount>),
    State(Box<state::State>),
    Underlying(Box<underlying::Underlying>),
    WhitelistDepositAccount(Box<whitelist_deposit_account::WhitelistDepositAccount>),
    WhitelistInsuranceAccount(Box<whitelist_insurance_account::WhitelistInsuranceAccount>),
    WhitelistTradingFeesAccount(Box<whitelist_trading_fees_account::WhitelistTradingFeesAccount>),
    ZetaGroup(Box<zeta_group::ZetaGroup>),
}

impl<'a> carbon_core::account::AccountDecoder<'a> for ZetaDecoder {
    type AccountType = ZetaAccount;

    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) = pricing::Pricing::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::Pricing(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = greeks::Greeks::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::Greeks(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = market_indexes::MarketIndexes::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::MarketIndexes(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = open_orders_map::OpenOrdersMap::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::OpenOrdersMap(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = cross_open_orders_map::CrossOpenOrdersMap::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::CrossOpenOrdersMap(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = state::State::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::State(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = underlying::Underlying::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::Underlying(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = settlement_account::SettlementAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::SettlementAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = perp_sync_queue::PerpSyncQueue::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::PerpSyncQueue(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = zeta_group::ZetaGroup::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::ZetaGroup(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = market_node::MarketNode::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::MarketNode(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = spread_account::SpreadAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::SpreadAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) =
                cross_margin_account_manager::CrossMarginAccountManager::decode(data)
            {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::CrossMarginAccountManager(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = cross_margin_account::CrossMarginAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::CrossMarginAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = margin_account::MarginAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::MarginAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = socialized_loss_account::SocializedLossAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::SocializedLossAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = whitelist_deposit_account::WhitelistDepositAccount::decode(data)
            {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::WhitelistDepositAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) =
                whitelist_insurance_account::WhitelistInsuranceAccount::decode(data)
            {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::WhitelistInsuranceAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = insurance_deposit_account::InsuranceDepositAccount::decode(data)
            {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::InsuranceDepositAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) =
                whitelist_trading_fees_account::WhitelistTradingFeesAccount::decode(data)
            {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::WhitelistTradingFeesAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = referrer_account::ReferrerAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::ReferrerAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = referral_account::ReferralAccount::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::ReferralAccount(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = referrer_alias::ReferrerAlias::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: ZetaAccount::ReferrerAlias(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }

        None
    }
}