carbon-orca-whirlpool-decoder 1.0.0

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

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

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

pub mod adaptive_fee_tier;
pub mod dynamic_tick_array;
pub mod fee_tier;
pub mod lock_config;
pub mod oracle;
pub mod position;
pub mod position_bundle;
pub mod tick_array;
pub mod token_badge;
pub mod whirlpool;
pub mod whirlpools_config;
pub mod whirlpools_config_extension;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum OrcaWhirlpoolAccount {
    AdaptiveFeeTier(Box<adaptive_fee_tier::AdaptiveFeeTier>),
    DynamicTickArray(Box<dynamic_tick_array::DynamicTickArray>),
    FeeTier(Box<fee_tier::FeeTier>),
    LockConfig(Box<lock_config::LockConfig>),
    Oracle(Box<oracle::Oracle>),
    Position(Box<position::Position>),
    PositionBundle(Box<position_bundle::PositionBundle>),
    TickArray(Box<tick_array::TickArray>),
    TokenBadge(Box<token_badge::TokenBadge>),
    Whirlpool(Box<whirlpool::Whirlpool>),
    WhirlpoolsConfig(Box<whirlpools_config::WhirlpoolsConfig>),
    WhirlpoolsConfigExtension(Box<whirlpools_config_extension::WhirlpoolsConfigExtension>),
}

impl<'a> carbon_core::account::AccountDecoder<'a> for OrcaWhirlpoolDecoder {
    type AccountType = OrcaWhirlpoolAccount;

    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) = adaptive_fee_tier::AdaptiveFeeTier::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::AdaptiveFeeTier(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = dynamic_tick_array::DynamicTickArray::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::DynamicTickArray(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = fee_tier::FeeTier::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::FeeTier(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = lock_config::LockConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::LockConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = oracle::Oracle::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::Oracle(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = position::Position::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::Position(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = position_bundle::PositionBundle::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::PositionBundle(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = tick_array::TickArray::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::TickArray(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = token_badge::TokenBadge::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::TokenBadge(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = whirlpool::Whirlpool::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::Whirlpool(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = whirlpools_config::WhirlpoolsConfig::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::WhirlpoolsConfig(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) =
                whirlpools_config_extension::WhirlpoolsConfigExtension::decode(data)
            {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: OrcaWhirlpoolAccount::WhirlpoolsConfigExtension(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }

        None
    }
}