carbon-raydium-launchpad-decoder 2.0.0

Raydium Launchpad Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::{AmmCreatorFeeOn, VestingSchedule},
    solana_pubkey::Pubkey,
};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct PoolState {
    /// Account update epoch
    pub epoch: u64,
    /// Bump seed used for PDA address derivation
    pub auth_bump: u8,
    /// Current status of the pool
    /// * 0: Pool is funding
    /// * 1: Pool funding is end, waiting for migration
    /// * 2: Pool migration is done
    pub status: u8,
    /// Decimals of the pool base token
    pub base_decimals: u8,
    /// Decimals of the pool quote token
    pub quote_decimals: u8,
    /// Migrate to AMM or CpSwap, 0: amm, 1: cpswap
    pub migrate_type: u8,
    /// Supply of the pool base token
    pub supply: u64,
    /// Total sell amount of the base token
    pub total_base_sell: u64,
    /// For different curves, virtual_base and virtual_quote have different
    /// meanings For constant product curve, virtual_base and virtual_quote
    /// are virtual liquidity, virtual_quote/virtual_base is the initial price
    /// For linear price curve, virtual_base is the price slope parameter a,
    /// virtual_quote has no effect For fixed price curve,
    /// virtual_quote/virtual_base is the initial price
    pub virtual_base: u64,
    pub virtual_quote: u64,
    /// Actual base token amount in the pool
    /// Represents the real tokens available for trading
    pub real_base: u64,
    /// Actual quote token amount in the pool
    /// Represents the real tokens available for trading
    pub real_quote: u64,
    /// The total quote fund raising of the pool
    pub total_quote_fund_raising: u64,
    /// Accumulated trading fees in quote tokens
    /// Can be collected by the protocol fee owner
    pub quote_protocol_fee: u64,
    /// Accumulated platform fees in quote tokens
    /// Can be collected by the platform wallet stored in platform config
    pub platform_fee: u64,
    /// The fee of migrate to amm
    pub migrate_fee: u64,
    /// Vesting schedule for the base token
    pub vesting_schedule: VestingSchedule,
    /// Public key of the global configuration account
    /// Contains protocol-wide settings this pool adheres to
    pub global_config: Pubkey,
    /// Public key of the platform configuration account
    /// Contains platform-wide settings this pool adheres to
    pub platform_config: Pubkey,
    /// Public key of the base mint address
    pub base_mint: Pubkey,
    /// Public key of the quote mint address
    pub quote_mint: Pubkey,
    /// Public key of the base token vault
    /// Holds the actual base tokens owned by the pool
    pub base_vault: Pubkey,
    /// Public key of the quote token vault
    /// Holds the actual quote tokens owned by the pool
    pub quote_vault: Pubkey,
    /// The creator of base token
    pub creator: Pubkey,
    /// token program bits
    /// bit0: base token program flag
    /// 0: spl_token_program
    /// 1: token_program_2022
    /// bit1: quote token program flag
    /// 0: spl_token_program
    /// 1: token_program_2022
    pub token_program_flag: u8,
    /// migrate to cpmm, creator fee on quote token or both token
    pub amm_creator_fee_on: AmmCreatorFeeOn,
    /// platform vesting token amount
    pub platform_vesting_share: u64,
    /// padding for future updates
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub padding: [u8; 54],
}

impl PoolState {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [247, 237, 227, 245, 215, 195, 222, 70] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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