use {
crate::types::WrappedI80F48,
carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
solana_pubkey::Pubkey,
};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct MarginfiGroupConfigure {
pub new_admin: Option<Pubkey>,
pub new_emode_admin: Option<Pubkey>,
pub new_curve_admin: Option<Pubkey>,
pub new_limit_admin: Option<Pubkey>,
pub new_flow_admin: Option<Pubkey>,
pub new_emissions_admin: Option<Pubkey>,
pub new_metadata_admin: Option<Pubkey>,
pub new_risk_admin: Option<Pubkey>,
pub emode_max_init_leverage: Option<WrappedI80F48>,
pub emode_max_maint_leverage: Option<WrappedI80F48>,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MarginfiGroupConfigureInstructionAccounts {
pub marginfi_group: solana_pubkey::Pubkey,
pub admin: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}
impl MarginfiGroupConfigure {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [62, 199, 81, 78, 33, 13, 236, 61] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}
impl ArrangeAccounts for MarginfiGroupConfigure {
type ArrangedAccounts = MarginfiGroupConfigureInstructionAccounts;
fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let marginfi_group = next_account(&mut iter)?;
let admin = next_account(&mut iter)?;
let remaining = iter.as_slice();
Some(MarginfiGroupConfigureInstructionAccounts {
marginfi_group,
admin,
remaining: remaining.to_vec(),
})
}
}