mango-v4/programs/mango-v4/src/state/group.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

use anchor_lang::prelude::*;
use static_assertions::const_assert_eq;
use std::mem::size_of;
// 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;
#[account(zero_copy)]
#[derive(Debug)]
2022-03-07 07:16:34 -08:00
pub struct Group {
// ABI: Clients rely on this being at offset 8
pub creator: Pubkey,
// ABI: Clients rely on this being at offset 40
pub group_num: u32,
pub admin: Pubkey,
// TODO: unused, use case - listing shit tokens with conservative parameters (mostly defaults)
pub fast_listing_admin: Pubkey,
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,
// Only support closing/deregistering groups, stub oracles, tokens, and markets
// if testing == 1
pub testing: u8,
pub padding2: [u8; 6],
pub reserved: [u8; 8],
}
const_assert_eq!(size_of::<Group>(), 32 * 5 + 4 + 4 + 1 * 2 + 6 + 8);
const_assert_eq!(size_of::<Group>() % 8, 0);
2022-02-25 06:14:15 -08:00
// note: using creator instead of admin, since admin can be changed
2022-02-25 06:14:15 -08:00
#[macro_export]
macro_rules! group_seeds {
( $group:expr ) => {
&[
b"Group".as_ref(),
$group.creator.as_ref(),
&$group.group_num.to_le_bytes(),
&[$group.bump],
]
2022-02-25 06:14:15 -08:00
};
}
pub use group_seeds;