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
99
100
101
102
103
104
//! This code was AUTOGENERATED using the Codama library.
use {
crate::types::{FeeStateCache, GroupRateLimiter, PanicStateCache, WithdrawWindowCache},
solana_pubkey::Pubkey,
};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct MarginfiGroup {
/// Broadly able to modify anything, and can set/remove other admins at
/// will.
pub admin: Pubkey,
/// Bitmask for group settings flags.
/// * Bit 0 (1): `PROGRAM_FEES_ENABLED` — If set, program-level fees are
/// enabled.
/// * Bits 1-63: Reserved for future use.
pub group_flags: u64,
/// Caches information from the global `FeeState` so the FeeState can be
/// omitted on certain ixes
pub fee_state_cache: FeeStateCache,
/// For groups initialized in versions 0.1.2 or greater, this is an
/// authoritative count of the number of banks under this group. For
/// groups initialized prior to 0.1.2, a non-authoritative count of the
/// number of banks initiated after 0.1.2 went live.
pub banks: u16,
pub pad0: [u8; 6],
/// This admin can configure collateral ratios above (but not below) the
/// collateral ratio of certain banks, e.g. allow SOL to count as 90%
/// collateral when borrowing an LST instead of the default rate.
pub emode_admin: Pubkey,
/// Can modify the fields in `config.interest_rate_config` but nothing else,
/// for every bank under this group
pub delegate_curve_admin: Pubkey,
/// Can modify the `deposit_limit`, `borrow_limit`,
/// `total_asset_value_init_limit` but nothing else, for every bank
/// under this group
pub delegate_limit_admin: Pubkey,
/// Can modify the emissions `flags`, `emissions_rate` and `emissions_mint`,
/// but nothing else, for every bank under this group
pub delegate_emissions_admin: Pubkey,
/// When program keeper temporarily puts the program into panic mode,
/// information about the duration of the lockup will be available here.
pub panic_state_cache: PanicStateCache,
/// Keeps track of the liquidity withdrawn from the group over the day as a
/// result of deleverages. Used as a protection mechanism against too
/// big (and unwanted) withdrawals (e.g. when the risk admin is
/// compromised).
pub deleverage_withdraw_window_cache: WithdrawWindowCache,
/// Can run bankruptcy and forced deleverage ixes to e.g. sunset
/// risky/illiquid assets
pub risk_admin: Pubkey,
/// Can modify a Bank's metadata, and nothing else.
pub metadata_admin: Pubkey,
/// Maximum leverage allowed for emode positions (initial margin), stored as
/// u32 basis. Use `u32_to_basis` to convert to I80F48. Range: 1-100.
pub emode_max_init_leverage: u32,
/// Maximum leverage allowed for emode positions (maintenance margin),
/// stored as u32 basis. Must be > emode_max_init_leverage. Range:
/// 1-100.
pub emode_max_maint_leverage: u32,
/// Reserved for future use
pub padding: [u8; 8],
/// Rate limiter for controlling aggregate withdraw/borrow outflow across
/// all banks. Tracks net outflow in USD.
pub rate_limiter: GroupRateLimiter,
/// Last slot covered by an admin group rate limiter aggregation update.
pub rate_limiter_last_admin_update_slot: u64,
/// Monotonic sequence number for admin group rate limiter updates.
/// This is used to enforce strict ordering and prevent duplicate/replayed
/// batches when slot ranges overlap or multiple updates happen in the
/// same slot.
pub rate_limiter_last_admin_update_seq: u64,
/// Last slot covered by an admin deleverage withdraw-limit aggregation
/// update.
pub deleverage_withdraw_last_admin_update_slot: u64,
/// Monotonic sequence number for admin deleverage withdraw-limit updates.
pub deleverage_withdraw_last_admin_update_seq: u64,
/// Can modify flow-control status for the group, i.e. update the withdraw
/// caches with flow information from banks. Typically this is a hot
/// wallet that lives in e.g. some cron job. If compromised, flow
/// control can be effectively disabled until the admin is restored, which
/// does not itself compromise any funds, and is merely annoying.
pub delegate_flow_admin: Pubkey,
pub padding0: [[u64; 2]; 2],
pub padding1: [[u64; 2]; 32],
}
impl MarginfiGroup {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [182, 23, 173, 240, 151, 206, 182, 67] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}