carbon-boop-decoder 1.0.0

Boop program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {crate::types::BondingCurveStatus, solana_pubkey::Pubkey};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct BondingCurve {
    pub creator: Pubkey,
    pub mint: Pubkey,
    pub virtual_sol_reserves: u64,
    /// virtual token reserves is deprecated, we now use the xyk formula instead
    /// and it only requires virtual sol reserves
    /// to maintain backwards compatibility, if damping term is 30, we use the
    /// old formula and we still need virtual_token_reserves to be set
    /// correctly
    pub virtual_token_reserves: u64,
    pub graduation_target: u64,
    pub graduation_fee: u64,
    pub sol_reserves: u64,
    pub token_reserves: u64,
    /// In reality, this is now more like a bonding_curve_selector
    pub damping_term: u8,
    pub swap_fee_basis_points: u8,
    pub token_for_stakers_basis_points: u16,
    pub status: BondingCurveStatus,
}

impl BondingCurve {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [23, 183, 248, 55, 96, 216, 172, 96] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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