insurance fund for trustless vs not trustful

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-08-03 10:37:35 +02:00 committed by microwavedcola1
parent e31ad9ce34
commit 59dd3aa66e
4 changed files with 12 additions and 4 deletions

View File

@ -31,6 +31,7 @@ pub struct LiqTokenBankruptcy<'info> {
#[account(
has_one = group,
constraint = liab_mint_info.load()?.token_index == liab_token_index,
constraint = liab_mint_info.load()?.elligible_for_group_insurance_fund()
)]
pub liab_mint_info: AccountLoader<'info, MintInfo>,

View File

@ -153,7 +153,8 @@ pub fn token_register(
vaults: Default::default(),
oracle: ctx.accounts.oracle.key(),
registration_time: Clock::get()?.unix_timestamp,
reserved: [0; 256],
group_insurance_fund: 1,
reserved: [0; 255],
};
mint_info.banks[0] = ctx.accounts.bank.key();

View File

@ -123,7 +123,8 @@ pub fn token_register_trustless(
vaults: Default::default(),
oracle: ctx.accounts.oracle.key(),
registration_time: Clock::get()?.unix_timestamp,
reserved: [0; 256],
group_insurance_fund: 0,
reserved: [0; 255],
};
mint_info.banks[0] = ctx.accounts.bank.key();

View File

@ -28,12 +28,13 @@ pub struct MintInfo {
pub oracle: Pubkey,
pub registration_time: i64,
pub group_insurance_fund: u8,
pub reserved: [u8; 256],
pub reserved: [u8; 255],
}
const_assert_eq!(
size_of::<MintInfo>(),
MAX_BANKS * 2 * 32 + 3 * 32 + 2 + 8 + 6 + 256
MAX_BANKS * 2 * 32 + 3 * 32 + 2 + 8 + 6 + 1 + 255
);
const_assert_eq!(size_of::<MintInfo>() % 8, 0);
@ -67,4 +68,8 @@ impl MintInfo {
);
Ok(())
}
pub fn elligible_for_group_insurance_fund(&self) -> bool {
self.group_insurance_fund == 1
}
}