carbon-zeta-decoder 2.0.0

Zeta Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::{AnchorDecimal, MarginParameters, PerpParameters, Product},
    solana_pubkey::Pubkey,
};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct Pricing {
    pub nonce: u8,
    pub mark_prices: [u64; 5],
    pub mark_prices_padding: [u64; 20],
    pub update_timestamps: [u64; 5],
    pub update_timestamps_padding: [u64; 20],
    pub funding_deltas: [AnchorDecimal; 5],
    pub funding_deltas_padding: [AnchorDecimal; 20],
    pub latest_funding_rates: [AnchorDecimal; 5],
    pub latest_funding_rates_padding: [AnchorDecimal; 20],
    pub latest_midpoints: [u64; 5],
    pub latest_midpoints_padding: [u64; 20],
    pub oracles: [Pubkey; 5],
    pub oracles_padding: [Pubkey; 20],
    pub oracle_backup_feeds: [Pubkey; 5],
    pub oracle_backup_feeds_padding: [Pubkey; 20],
    pub markets: [Pubkey; 5],
    pub markets_padding: [Pubkey; 20],
    pub perp_sync_queues: [Pubkey; 5],
    pub perp_sync_queues_padding: [Pubkey; 20],
    pub perp_parameters: [PerpParameters; 5],
    pub perp_parameters_padding: [PerpParameters; 20],
    pub margin_parameters: [MarginParameters; 5],
    pub margin_parameters_padding: [MarginParameters; 20],
    pub products: [Product; 5],
    pub products_padding: [Product; 20],
    pub zeta_group_keys: [Pubkey; 5],
    pub zeta_group_keys_padding: [Pubkey; 20],
    pub total_insurance_vault_deposits: u64,
    pub last_withdraw_timestamp: u64,
    pub net_outflow_sum: i64,
    pub halt_force_pricing: [bool; 5],
    pub halt_force_pricing_padding: [bool; 20],
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub padding: [u8; 2707],
}

impl Pricing {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [190, 123, 210, 182, 143, 11, 152, 136] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}