carbon-meteora-vault-decoder 1.0.0

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

/// Strategy struct
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct Strategy {
    /// Lending pool address, that the strategy will deposit/withdraw balance
    pub reserve: Pubkey,
    /// The token account, that holds the collateral token
    pub collateral_vault: Pubkey,
    /// Specify type of strategy
    pub strategy_type: StrategyType,
    /// The liquidity in strategy at the time vault deposit/withdraw from a
    /// lending protocol
    pub current_liquidity: u64,
    /// Hold some bumps, in case the strategy needs to use other seeds to sign a
    /// CPI call.
    pub bumps: [u8; 10],
    /// Vault address, that the strategy belongs
    pub vault: Pubkey,
    /// If we remove strategy by remove_strategy2 endpoint, this account will be
    /// never added again
    pub is_disable: u8,
}

impl Strategy {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [174, 110, 39, 119, 82, 106, 169, 102] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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