Skip to main content

klend_interface/state/
withdraw_ticket.rs

1use bytemuck::{Pod, Zeroable};
2use solana_pubkey::Pubkey;
3use spl_discriminator::SplDiscriminate;
4
5/// A ticket representing a depositor's place in a reserve's withdraw queue.
6#[derive(Debug, Clone, Copy, Zeroable, Pod, SplDiscriminate)]
7#[discriminator_hash_input("account:WithdrawTicket")]
8#[repr(C)]
9pub struct WithdrawTicket {
10    pub sequence_number: u64,
11    pub owner: Pubkey,
12    pub reserve: Pubkey,
13    pub user_destination_liquidity_ta: Pubkey,
14    pub queued_collateral_amount: u64,
15    pub created_at_timestamp: u64,
16    /// 0 = valid, 1 = invalid.
17    pub invalid: u8,
18    /// `ProgressCallbackType` representation.
19    pub progress_callback_type: u8,
20    pub alignment_padding: [u8; 6],
21    pub progress_callback_custom_accounts: [Pubkey; 2],
22    pub end_padding: [u64; 40],
23}
24
25const _: () = assert!(core::mem::size_of::<WithdrawTicket>() == 512);
26
27impl WithdrawTicket {
28    /// Whether this ticket is valid (eligible for withdrawal).
29    pub fn is_valid(&self) -> bool {
30        self.invalid == 0
31    }
32
33    /// Whether this ticket has been fully cancelled (tombstoned).
34    pub fn is_fully_cancelled(&self) -> bool {
35        self.queued_collateral_amount == 0
36    }
37}