carbon-jupiter-lend-decoder 2.0.0

Jupiter Lend Liquidity Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{JupiterLendDecoder, PROGRAM_ID};

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

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

pub mod authorization_list;
pub mod liquidity;
pub mod rate_model;
pub mod token_reserve;
pub mod user_borrow_position;
pub mod user_claim;
pub mod user_supply_position;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum JupiterLendAccount {
    AuthorizationList(Box<authorization_list::AuthorizationList>),
    Liquidity(Box<liquidity::Liquidity>),
    RateModel(Box<rate_model::RateModel>),
    TokenReserve(Box<token_reserve::TokenReserve>),
    UserBorrowPosition(Box<user_borrow_position::UserBorrowPosition>),
    UserClaim(Box<user_claim::UserClaim>),
    UserSupplyPosition(Box<user_supply_position::UserSupplyPosition>),
}

impl<'a> carbon_core::account::AccountDecoder<'a> for JupiterLendDecoder {
    type AccountType = JupiterLendAccount;

    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) = authorization_list::AuthorizationList::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::AuthorizationList(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = liquidity::Liquidity::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::Liquidity(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = rate_model::RateModel::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::RateModel(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = token_reserve::TokenReserve::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::TokenReserve(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = user_borrow_position::UserBorrowPosition::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::UserBorrowPosition(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = user_claim::UserClaim::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::UserClaim(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }
        {
            if let Some(decoded) = user_supply_position::UserSupplyPosition::decode(data) {
                return Some(carbon_core::account::DecodedAccount {
                    lamports: account.lamports,
                    data: JupiterLendAccount::UserSupplyPosition(Box::new(decoded)),
                    owner: account.owner,
                    executable: account.executable,
                    rent_epoch: account.rent_epoch,
                });
            }
        }

        None
    }
}