use anchor_lang::prelude::*;
use borsh::BorshSerialize;
use gmsol_utils::InitSpace;
use crate::states::common::action::ActionState;
use super::Event;
#[event]
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(Clone, InitSpace)]
pub struct GlvDepositRemoved {
pub id: u64,
pub ts: i64,
pub slot: u64,
pub store: Pubkey,
pub glv_deposit: Pubkey,
pub market_token: Pubkey,
pub glv_token: Pubkey,
pub owner: Pubkey,
pub state: ActionState,
#[max_len(32)]
pub reason: String,
}
impl GlvDepositRemoved {
pub(crate) fn new(
id: u64,
store: Pubkey,
glv_deposit: Pubkey,
market_token: Pubkey,
glv_token: Pubkey,
owner: Pubkey,
state: ActionState,
reason: impl ToString,
) -> Result<Self> {
let clock = Clock::get()?;
Ok(Self {
id,
ts: clock.unix_timestamp,
slot: clock.slot,
store,
glv_deposit,
glv_token,
market_token,
owner,
state,
reason: reason.to_string(),
})
}
}
impl InitSpace for GlvDepositRemoved {
const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
}
impl Event for GlvDepositRemoved {}
#[event]
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(Clone, InitSpace)]
pub struct GlvWithdrawalRemoved {
pub id: u64,
pub ts: i64,
pub slot: u64,
pub store: Pubkey,
pub glv_withdrawal: Pubkey,
pub market_token: Pubkey,
pub glv_token: Pubkey,
pub owner: Pubkey,
pub state: ActionState,
#[max_len(32)]
pub reason: String,
}
impl GlvWithdrawalRemoved {
pub(crate) fn new(
id: u64,
store: Pubkey,
glv_withdrawal: Pubkey,
market_token: Pubkey,
glv_token: Pubkey,
owner: Pubkey,
state: ActionState,
reason: impl ToString,
) -> Result<Self> {
let clock = Clock::get()?;
Ok(Self {
id,
ts: clock.unix_timestamp,
slot: clock.slot,
store,
glv_withdrawal,
glv_token,
market_token,
owner,
state,
reason: reason.to_string(),
})
}
}
impl InitSpace for GlvWithdrawalRemoved {
const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
}
impl Event for GlvWithdrawalRemoved {}
#[event]
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(Clone, InitSpace)]
pub struct GlvPricing {
pub glv_token: Pubkey,
pub market_token: Pubkey,
pub supply: u64,
pub value_maximized: bool,
pub value: u128,
pub input_amount: u64,
pub input_value: u128,
pub output_amount: u64,
pub kind: GlvPricingKind,
}
impl InitSpace for GlvPricing {
const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
}
impl Event for GlvPricing {}
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(Clone, InitSpace, AnchorSerialize, AnchorDeserialize)]
#[non_exhaustive]
pub enum GlvPricingKind {
Deposit,
Withdrawal,
}