use {
crate::types::{DepositDirection, DepositExplanation},
solana_pubkey::Pubkey,
};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct DepositRecordEvent {
pub ts: i64,
pub user_authority: Pubkey,
pub user: Pubkey,
pub direction: DepositDirection,
pub deposit_record_id: u64,
pub amount: u64,
pub market_index: u16,
pub oracle_price: i64,
pub market_deposit_balance: u128,
pub market_withdraw_balance: u128,
pub market_cumulative_deposit_interest: u128,
pub market_cumulative_borrow_interest: u128,
pub total_deposits_after: u64,
pub total_withdraws_after: u64,
pub explanation: DepositExplanation,
pub transfer_user: Option<Pubkey>,
pub signer: Option<Pubkey>,
pub user_token_amount_after: i128,
}
impl DepositRecordEvent {
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, 180, 241, 218, 207, 102, 135, 44, 134,
]
{
return None;
}
let mut data_slice = data;
data_slice = &data_slice[16..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}