carbon-zeta-decoder 1.0.0

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

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct Greeks {
    pub nonce: u8,
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub mark_prices: [u64; 46],
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub mark_prices_padding: [u64; 91],
    pub perp_mark_price: u64,
    pub product_greeks: [ProductGreeks; 22],
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub product_greeks_padding: [ProductGreeks; 44],
    pub update_timestamp: [u64; 2],
    pub update_timestamp_padding: [u64; 4],
    pub retreat_expiration_timestamp: [u64; 2],
    pub retreat_expiration_timestamp_padding: [u64; 4],
    pub interest_rate: [i64; 2],
    pub interest_rate_padding: [i64; 4],
    pub nodes: [u64; 5],
    pub volatility: [u64; 10],
    pub volatility_padding: [u64; 20],
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub node_keys: [Pubkey; 138],
    pub halt_force_pricing: [bool; 6],
    pub perp_update_timestamp: u64,
    pub perp_funding_delta: AnchorDecimal,
    pub perp_latest_funding_rate: AnchorDecimal,
    pub perp_latest_midpoint: u64,
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub padding: [u8; 1593],
}

impl Greeks {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [247, 213, 170, 154, 43, 243, 146, 254] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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