//! This code was AUTOGENERATED using the Codama library.
use solana_pubkey::Pubkey;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct PoolCreatedEventEvent {
    /// The first token of the pool by address sort order
    pub token_mint0: Pubkey,
    /// The second token of the pool by address sort order
    pub token_mint1: Pubkey,
    /// The minimum number of ticks between initialized ticks
    pub tick_spacing: u16,
    /// The address of the created pool
    pub pool_state: Pubkey,
    /// The initial sqrt price of the pool, as a Q64.64
    pub sqrt_price_x64: u128,
    /// The initial tick of the pool, i.e. log base 1.0001 of the starting price
    /// of the pool
    pub tick: i32,
    /// Vault of token_0
    pub token_vault0: Pubkey,
    /// Vault of token_1
    pub token_vault1: Pubkey,
}

impl PoolCreatedEventEvent {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [25, 94, 75, 47, 112, 99, 53, 63] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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