reserve for ALTs (#152)
* reserve for ALTs Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * add explicit padding Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * fix from review Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * fix from review Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
d8340ba594
commit
d594286266
|
@ -137,7 +137,7 @@ pub fn token_register(
|
||||||
bump: *ctx.bumps.get("bank").ok_or(MangoError::SomeError)?,
|
bump: *ctx.bumps.get("bank").ok_or(MangoError::SomeError)?,
|
||||||
mint_decimals: ctx.accounts.mint.decimals,
|
mint_decimals: ctx.accounts.mint.decimals,
|
||||||
bank_num: 0,
|
bank_num: 0,
|
||||||
reserved: [0; 256],
|
reserved: [0; 2560],
|
||||||
};
|
};
|
||||||
require_gt!(bank.max_rate, MINIMUM_MAX_RATE);
|
require_gt!(bank.max_rate, MINIMUM_MAX_RATE);
|
||||||
|
|
||||||
|
@ -145,14 +145,14 @@ pub fn token_register(
|
||||||
*mint_info = MintInfo {
|
*mint_info = MintInfo {
|
||||||
group: ctx.accounts.group.key(),
|
group: ctx.accounts.group.key(),
|
||||||
token_index,
|
token_index,
|
||||||
|
group_insurance_fund: 1,
|
||||||
padding1: Default::default(),
|
padding1: Default::default(),
|
||||||
mint: ctx.accounts.mint.key(),
|
mint: ctx.accounts.mint.key(),
|
||||||
banks: Default::default(),
|
banks: Default::default(),
|
||||||
vaults: Default::default(),
|
vaults: Default::default(),
|
||||||
oracle: ctx.accounts.oracle.key(),
|
oracle: ctx.accounts.oracle.key(),
|
||||||
registration_time: Clock::get()?.unix_timestamp,
|
registration_time: Clock::get()?.unix_timestamp,
|
||||||
group_insurance_fund: 1,
|
reserved: [0; 2560],
|
||||||
reserved: [0; 255],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mint_info.banks[0] = ctx.accounts.bank.key();
|
mint_info.banks[0] = ctx.accounts.bank.key();
|
||||||
|
|
|
@ -110,7 +110,7 @@ pub fn token_register_trustless(
|
||||||
bump: *ctx.bumps.get("bank").ok_or(MangoError::SomeError)?,
|
bump: *ctx.bumps.get("bank").ok_or(MangoError::SomeError)?,
|
||||||
mint_decimals: ctx.accounts.mint.decimals,
|
mint_decimals: ctx.accounts.mint.decimals,
|
||||||
bank_num: 0,
|
bank_num: 0,
|
||||||
reserved: [0; 256],
|
reserved: [0; 2560],
|
||||||
};
|
};
|
||||||
require_gt!(bank.max_rate, MINIMUM_MAX_RATE);
|
require_gt!(bank.max_rate, MINIMUM_MAX_RATE);
|
||||||
|
|
||||||
|
@ -118,14 +118,14 @@ pub fn token_register_trustless(
|
||||||
*mint_info = MintInfo {
|
*mint_info = MintInfo {
|
||||||
group: ctx.accounts.group.key(),
|
group: ctx.accounts.group.key(),
|
||||||
token_index,
|
token_index,
|
||||||
|
group_insurance_fund: 0,
|
||||||
padding1: Default::default(),
|
padding1: Default::default(),
|
||||||
mint: ctx.accounts.mint.key(),
|
mint: ctx.accounts.mint.key(),
|
||||||
banks: Default::default(),
|
banks: Default::default(),
|
||||||
vaults: Default::default(),
|
vaults: Default::default(),
|
||||||
oracle: ctx.accounts.oracle.key(),
|
oracle: ctx.accounts.oracle.key(),
|
||||||
registration_time: Clock::get()?.unix_timestamp,
|
registration_time: Clock::get()?.unix_timestamp,
|
||||||
group_insurance_fund: 0,
|
reserved: [0; 2560],
|
||||||
reserved: [0; 255],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mint_info.banks[0] = ctx.accounts.bank.key();
|
mint_info.banks[0] = ctx.accounts.bank.key();
|
||||||
|
|
|
@ -94,11 +94,11 @@ pub struct Bank {
|
||||||
|
|
||||||
pub bank_num: u32,
|
pub bank_num: u32,
|
||||||
|
|
||||||
pub reserved: [u8; 256],
|
pub reserved: [u8; 2560],
|
||||||
}
|
}
|
||||||
const_assert_eq!(
|
const_assert_eq!(
|
||||||
size_of::<Bank>(),
|
size_of::<Bank>(),
|
||||||
32 + 16 + 32 * 3 + 16 + 16 * 6 + 8 * 2 + 16 * 16 + 8 * 2 + 2 + 1 + 1 + 4 + 256
|
32 + 16 + 32 * 3 + 16 + 16 * 6 + 8 * 2 + 16 * 16 + 8 * 2 + 2 + 1 + 1 + 4 + 2560
|
||||||
);
|
);
|
||||||
const_assert_eq!(size_of::<Bank>() % 8, 0);
|
const_assert_eq!(size_of::<Bank>() % 8, 0);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ impl Bank {
|
||||||
token_index: existing_bank.token_index,
|
token_index: existing_bank.token_index,
|
||||||
bump: existing_bank.bump,
|
bump: existing_bank.bump,
|
||||||
mint_decimals: existing_bank.mint_decimals,
|
mint_decimals: existing_bank.mint_decimals,
|
||||||
reserved: [0; 256],
|
reserved: [0; 2560],
|
||||||
bank_num,
|
bank_num,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ pub struct Group {
|
||||||
|
|
||||||
pub padding2: [u8; 5],
|
pub padding2: [u8; 5],
|
||||||
|
|
||||||
pub reserved: [u8; 256],
|
pub reserved: [u8; 2560],
|
||||||
}
|
}
|
||||||
const_assert_eq!(size_of::<Group>(), 32 * 5 + 4 + 4 + 1 + 1 + 6 + 256);
|
const_assert_eq!(size_of::<Group>(), 32 * 5 + 4 + 4 + 1 + 1 + 6 + 2560);
|
||||||
const_assert_eq!(size_of::<Group>() % 8, 0);
|
const_assert_eq!(size_of::<Group>() % 8, 0);
|
||||||
|
|
||||||
impl Group {
|
impl Group {
|
||||||
|
|
|
@ -21,20 +21,20 @@ pub struct MintInfo {
|
||||||
// ABI: Clients rely on this being at offset 40
|
// ABI: Clients rely on this being at offset 40
|
||||||
pub token_index: TokenIndex,
|
pub token_index: TokenIndex,
|
||||||
|
|
||||||
pub padding1: [u8; 6],
|
pub group_insurance_fund: u8,
|
||||||
|
pub padding1: [u8; 5],
|
||||||
pub mint: Pubkey,
|
pub mint: Pubkey,
|
||||||
pub banks: [Pubkey; MAX_BANKS],
|
pub banks: [Pubkey; MAX_BANKS],
|
||||||
pub vaults: [Pubkey; MAX_BANKS],
|
pub vaults: [Pubkey; MAX_BANKS],
|
||||||
pub oracle: Pubkey,
|
pub oracle: Pubkey,
|
||||||
|
|
||||||
pub registration_time: i64,
|
pub registration_time: i64,
|
||||||
pub group_insurance_fund: u8,
|
|
||||||
|
|
||||||
pub reserved: [u8; 255],
|
pub reserved: [u8; 2560],
|
||||||
}
|
}
|
||||||
const_assert_eq!(
|
const_assert_eq!(
|
||||||
size_of::<MintInfo>(),
|
size_of::<MintInfo>(),
|
||||||
MAX_BANKS * 2 * 32 + 3 * 32 + 2 + 8 + 6 + 1 + 255
|
MAX_BANKS * 2 * 32 + 3 * 32 + 2 + 8 + 6 + 2560
|
||||||
);
|
);
|
||||||
const_assert_eq!(size_of::<MintInfo>() % 8, 0);
|
const_assert_eq!(size_of::<MintInfo>() % 8, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue