use crate::*;
#[account]
#[derive(Copy, Default, Debug)]
pub struct Rewarder {
pub base: Pubkey,
pub bump: u8,
pub authority: Pubkey,
pub pending_authority: Pubkey,
pub num_quarries: u16,
pub annual_rewards_rate: u64,
pub total_rewards_shares: u64,
pub mint_wrapper: Pubkey,
pub rewards_token_mint: Pubkey,
pub claim_fee_token_account: Pubkey,
pub max_claim_fee_millibps: u64,
pub pause_authority: Pubkey,
pub is_paused: bool,
}
impl Rewarder {
pub const LEN: usize = 32 + 1 + 32 + 32 + 2 + 8 + 8 + 32 + 32 + 32 + 8 + 32 + 1;
pub fn assert_not_paused(&self) -> Result<()> {
invariant!(!self.is_paused, Paused);
Ok(())
}
}
#[account]
#[derive(Copy, Default)]
pub struct Quarry {
pub rewarder: Pubkey,
pub token_mint_key: Pubkey,
pub bump: u8,
pub index: u16,
pub token_mint_decimals: u8, pub famine_ts: i64,
pub last_update_ts: i64,
pub rewards_per_token_stored: u128,
pub annual_rewards_rate: u64,
pub rewards_share: u64,
pub total_tokens_deposited: u64,
pub num_miners: u64,
}
impl Quarry {
pub const LEN: usize = 32 + 32 + 1 + 2 + 1 + 8 + 8 + 16 + 8 + 8 + 8 + 8;
}
#[account]
#[derive(Copy, Default, Debug)]
pub struct Miner {
pub quarry: Pubkey,
pub authority: Pubkey,
pub bump: u8,
pub token_vault_key: Pubkey,
pub rewards_earned: u64,
pub rewards_per_token_paid: u128,
pub balance: u64,
pub index: u64,
}
impl Miner {
pub const LEN: usize = 32 + 32 + 1 + 32 + 8 + 16 + 8 + 8;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_rewarder_len() {
assert_eq!(
Rewarder::default().try_to_vec().unwrap().len(),
Rewarder::LEN
);
}
#[test]
fn test_quarry_len() {
assert_eq!(Quarry::default().try_to_vec().unwrap().len(), Quarry::LEN);
}
#[test]
fn test_miner_len() {
assert_eq!(Miner::default().try_to_vec().unwrap().len(), Miner::LEN);
}
}