gmsol_store/events/
glv.rs1use anchor_lang::prelude::*;
2use borsh::BorshSerialize;
3
4use gmsol_utils::InitSpace;
5
6use crate::states::common::action::ActionState;
7
8use super::Event;
9
10#[event]
12#[cfg_attr(feature = "debug", derive(Debug))]
13#[derive(Clone, InitSpace)]
14pub struct GlvDepositRemoved {
15 pub id: u64,
17 pub ts: i64,
19 pub slot: u64,
21 pub store: Pubkey,
23 pub glv_deposit: Pubkey,
25 pub market_token: Pubkey,
27 pub glv_token: Pubkey,
29 pub owner: Pubkey,
31 pub state: ActionState,
33 #[max_len(32)]
35 pub reason: String,
36}
37
38impl GlvDepositRemoved {
39 pub(crate) fn new(
40 id: u64,
41 store: Pubkey,
42 glv_deposit: Pubkey,
43 market_token: Pubkey,
44 glv_token: Pubkey,
45 owner: Pubkey,
46 state: ActionState,
47 reason: impl ToString,
48 ) -> Result<Self> {
49 let clock = Clock::get()?;
50 Ok(Self {
51 id,
52 ts: clock.unix_timestamp,
53 slot: clock.slot,
54 store,
55 glv_deposit,
56 glv_token,
57 market_token,
58 owner,
59 state,
60 reason: reason.to_string(),
61 })
62 }
63}
64
65impl InitSpace for GlvDepositRemoved {
66 const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
67}
68
69impl Event for GlvDepositRemoved {}
70
71#[event]
73#[cfg_attr(feature = "debug", derive(Debug))]
74#[derive(Clone, InitSpace)]
75pub struct GlvWithdrawalRemoved {
76 pub id: u64,
78 pub ts: i64,
80 pub slot: u64,
82 pub store: Pubkey,
84 pub glv_withdrawal: Pubkey,
86 pub market_token: Pubkey,
88 pub glv_token: Pubkey,
90 pub owner: Pubkey,
92 pub state: ActionState,
94 #[max_len(32)]
96 pub reason: String,
97}
98
99impl GlvWithdrawalRemoved {
100 pub(crate) fn new(
101 id: u64,
102 store: Pubkey,
103 glv_withdrawal: Pubkey,
104 market_token: Pubkey,
105 glv_token: Pubkey,
106 owner: Pubkey,
107 state: ActionState,
108 reason: impl ToString,
109 ) -> Result<Self> {
110 let clock = Clock::get()?;
111 Ok(Self {
112 id,
113 ts: clock.unix_timestamp,
114 slot: clock.slot,
115 store,
116 glv_withdrawal,
117 glv_token,
118 market_token,
119 owner,
120 state,
121 reason: reason.to_string(),
122 })
123 }
124}
125
126impl InitSpace for GlvWithdrawalRemoved {
127 const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
128}
129
130impl Event for GlvWithdrawalRemoved {}
131
132#[event]
134#[cfg_attr(feature = "debug", derive(Debug))]
135#[derive(Clone, InitSpace)]
136pub struct GlvPricing {
137 pub glv_token: Pubkey,
139 pub market_token: Pubkey,
141 pub supply: u64,
143 pub value_maximized: bool,
145 pub value: u128,
147 pub input_amount: u64,
151 pub input_value: u128,
153 pub output_amount: u64,
157 pub kind: GlvPricingKind,
159}
160
161impl InitSpace for GlvPricing {
162 const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
163}
164
165impl Event for GlvPricing {}
166
167#[cfg_attr(feature = "debug", derive(Debug))]
169#[derive(Clone, InitSpace, AnchorSerialize, AnchorDeserialize)]
170#[non_exhaustive]
171pub enum GlvPricingKind {
172 Deposit,
174 Withdrawal,
176}