1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! This code was AUTOGENERATED using the Codama library.
use {
crate::types::{HealthCache, LendingAccount},
solana_pubkey::Pubkey,
};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct MarginfiAccount {
pub group: Pubkey,
pub authority: Pubkey,
pub lending_account: LendingAccount,
/// The flags that indicate the state of the account. This is u64 bitfield,
/// where each bit represents a flag.
/// Flags:MarginfiAccount
/// - 1: `ACCOUNT_DISABLED` - Indicates that the account is disabled and no
/// further actions can
///
/// be taken on it.
/// - 2: `ACCOUNT_IN_FLASHLOAN` - Only set when an account is within a flash
/// loan, e.g. when
///
/// start_flashloan is called, then unset when the flashloan ends.
/// - 4: `ACCOUNT_FLAG_DEPRECATED` - Deprecated, available for future use
/// - 8: `ACCOUNT_TRANSFER_AUTHORITY_DEPRECATED` - the admin has flagged
/// with account to be
///
/// moved, original owner can now call `set_account_transfer_authority`
/// - 16: `ACCOUNT_IN_RECEIVERSHIP` - the account is eligible to be
/// liquidated and has entered
///
/// receivership, a liquidator is able to control borrows and withdraws
/// until the end of the tx. This flag will only appear within a tx.
/// - 32: `ACCOUNT_IN_DELEVERAGE - the account is being deleveraged by the
/// risk admin
/// - 64: `ACCOUNT_FROZEN` - the admin has frozen the account; only the
/// group admin may perform
///
/// actions until unfrozen.
pub account_flags: u64,
/// Wallet whose canonical ATA receives off-chain emissions distributions.
pub emissions_destination_account: Pubkey,
pub health_cache: HealthCache,
/// If this account was migrated from another one, store the original
/// account key
pub migrated_from: Pubkey,
/// If this account has been migrated to another one, store the destination
/// account key
pub migrated_to: Pubkey,
/// Unix timestamp (u64) of the last account interaction. Note:
/// Bank.last_update uses i64.
pub last_update: u64,
/// If a PDA-based account, the account index, a seed used to derive the PDA
/// that can be chosen arbitrarily (0.1.5 or later). Otherwise, does
/// nothing.
pub account_index: u16,
/// If a PDA-based account (0.1.5 or later), a "vendor specific" id. Values
/// < PDA_FREE_THRESHOLD can be used by anyone with no restrictions.
/// Values >= PDA_FREE_THRESHOLD can only be used by a particular
/// program via CPI. These values require being added to a list, contact us
/// for more details. For legacy non-pda accounts, does nothing.
/// Note: use a unique seed to tag accounts related to some particular
/// program or campaign so you can easily fetch them all later.
pub third_party_index: u16,
/// This account's bump, if a PDA-based account (0.1.5 or later). Otherwise,
/// does nothing.
pub bump: u8,
pub pad0: [u8; 3],
/// Stores information related to liquidations made against this account. A
/// pda of this account's key, and "liq_record"
/// * Typically pubkey default if this account has never been liquidated or
/// close to liquidation
/// * Opening this account is permissionless. Typically the liquidator pays,
/// but e.g. we may
///
/// also charge the user if they are opening a risky position on the front
/// end.
pub liquidation_record: Pubkey,
pub padding0: [u64; 7],
}
impl MarginfiAccount {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [67, 178, 130, 109, 126, 114, 28, 42] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}