carbon-jupiter-dca-decoder 2.0.0

Jupiter DCA Decoder
Documentation
//! 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 ClosedEvent {
    pub user_key: Pubkey,
    pub dca_key: Pubkey,
    pub in_deposited: u64,
    pub input_mint: Pubkey,
    pub output_mint: Pubkey,
    pub cycle_frequency: i64,
    pub in_amount_per_cycle: u64,
    pub created_at: i64,
    pub total_in_withdrawn: u64,
    pub total_out_withdrawn: u64,
    pub unfilled_amount: u64,
    pub user_closed: bool,
}

impl ClosedEvent {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 16 {
            return None;
        }
        let discriminator = &data[0..16];
        if discriminator
            != [
                228, 69, 165, 46, 81, 203, 154, 29, 50, 31, 87, 155, 135, 220, 195, 239,
            ]
        {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[16..];

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