2022-02-10 01:04:47 -08:00
|
|
|
use anchor_lang::prelude::*;
|
2022-03-31 05:37:05 -07:00
|
|
|
use static_assertions::const_assert_eq;
|
|
|
|
use std::mem::size_of;
|
2022-02-10 01:04:47 -08:00
|
|
|
|
2022-02-22 00:32:21 -08:00
|
|
|
// TODO: Assuming we allow up to 65536 different tokens
|
|
|
|
pub type TokenIndex = u16;
|
2022-07-04 04:13:11 -07:00
|
|
|
pub const QUOTE_TOKEN_INDEX: TokenIndex = 0;
|
2022-02-22 00:32:21 -08:00
|
|
|
|
|
|
|
#[account(zero_copy)]
|
2022-07-05 10:31:47 -07:00
|
|
|
#[derive(Debug)]
|
2022-03-07 07:16:34 -08:00
|
|
|
pub struct Group {
|
2022-07-06 00:56:14 -07:00
|
|
|
// ABI: Clients rely on this being at offset 8
|
2022-02-23 01:19:54 -08:00
|
|
|
pub admin: Pubkey,
|
2022-02-22 00:32:21 -08:00
|
|
|
|
2022-07-06 00:56:14 -07:00
|
|
|
// ABI: Clients rely on this being at offset 40
|
|
|
|
pub group_num: u32,
|
|
|
|
|
|
|
|
pub padding: [u8; 4],
|
|
|
|
|
2022-07-04 04:13:11 -07:00
|
|
|
pub insurance_vault: Pubkey,
|
|
|
|
pub insurance_mint: Pubkey,
|
|
|
|
|
2022-02-25 06:14:15 -08:00
|
|
|
pub bump: u8,
|
2022-06-09 09:27:31 -07:00
|
|
|
// Only support closing/deregistering groups, stub oracles, tokens, and markets
|
|
|
|
// if testing == 1
|
|
|
|
pub testing: u8,
|
2022-07-06 00:56:14 -07:00
|
|
|
pub padding2: [u8; 6],
|
2022-05-27 00:23:17 -07:00
|
|
|
pub reserved: [u8; 8],
|
2022-02-10 00:07:34 -08:00
|
|
|
}
|
2022-07-06 00:56:14 -07:00
|
|
|
const_assert_eq!(size_of::<Group>(), 32 * 3 + 4 + 4 + 1 * 2 + 6 + 8);
|
2022-03-31 05:37:05 -07:00
|
|
|
const_assert_eq!(size_of::<Group>() % 8, 0);
|
2022-02-25 06:14:15 -08:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! group_seeds {
|
|
|
|
( $group:expr ) => {
|
2022-05-27 00:23:17 -07:00
|
|
|
&[
|
|
|
|
b"Group".as_ref(),
|
|
|
|
$group.admin.as_ref(),
|
|
|
|
&$group.group_num.to_le_bytes(),
|
|
|
|
&[$group.bump],
|
|
|
|
]
|
2022-02-25 06:14:15 -08:00
|
|
|
};
|
|
|
|
}
|
2022-02-28 02:18:35 -08:00
|
|
|
|
|
|
|
pub use group_seeds;
|