//! 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 LiquidityChangeEventEvent {
    /// The pool for swap
    pub pool_state: Pubkey,
    /// The tick of the pool
    pub tick: i32,
    /// The tick lower of position
    pub tick_lower: i32,
    /// The tick lower of position
    pub tick_upper: i32,
    /// The liquidity of the pool before liquidity change
    pub liquidity_before: u128,
    /// The liquidity of the pool after liquidity change
    pub liquidity_after: u128,
}

impl LiquidityChangeEventEvent {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [126, 240, 175, 206, 158, 88, 153, 107] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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