use {
crate::types::{
Asset, ExpirySeries, HaltState, MarginParameters, PerpParameters, PricingParameters,
Product,
},
solana_pubkey::Pubkey,
};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct ZetaGroup {
pub nonce: u8,
pub nonce_padding: [u8; 2],
pub front_expiry_index: u8,
pub halt_state: HaltState,
pub underlying_mint: Pubkey,
pub oracle: Pubkey,
pub greeks: Pubkey,
pub pricing_parameters: PricingParameters,
pub margin_parameters: MarginParameters,
#[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
pub margin_parameters_padding: [u8; 104],
#[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
pub products: [Product; 46],
#[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
pub products_padding: [Product; 91],
pub perp: Product,
pub expiry_series: [ExpirySeries; 2],
pub expiry_series_padding: [ExpirySeries; 4],
pub deprecated_padding: [u8; 8],
pub asset: Asset,
pub expiry_interval_seconds: u32,
pub new_expiry_threshold_seconds: u32,
pub perp_parameters: PerpParameters,
pub perp_sync_queue: Pubkey,
pub oracle_backup_feed: Pubkey,
pub perps_only: bool,
pub flex_underlying: bool,
#[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
pub padding: [u8; 964],
}
impl ZetaGroup {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [121, 17, 210, 107, 109, 235, 14, 12] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}