gmsol_store/events/
swap.rs

1use anchor_lang::prelude::*;
2use borsh::BorshSerialize;
3
4use gmsol_model::action::{decrease_position::DecreasePositionSwapType, swap::SwapReport};
5
6use super::Event;
7
8/// Swap executed Event.
9#[event]
10#[cfg_attr(feature = "debug", derive(Debug))]
11pub struct SwapExecuted {
12    /// Revision.
13    pub rev: u64,
14    /// Market token.
15    pub market_token: Pubkey,
16    /// Report.
17    pub report: SwapReport<u128, i128>,
18    /// Type.
19    pub ty: Option<DecreasePositionSwapType>,
20}
21
22impl gmsol_utils::InitSpace for SwapExecuted {
23    const INIT_SPACE: usize =
24        8 + 32 + SwapReport::<u128, i128>::INIT_SPACE + 1 + DecreasePositionSwapType::INIT_SPACE;
25}
26
27impl Event for SwapExecuted {}
28
29impl SwapExecuted {
30    /// Create.
31    pub fn new(
32        rev: u64,
33        market_token: Pubkey,
34        report: SwapReport<u128, i128>,
35        ty: Option<DecreasePositionSwapType>,
36    ) -> Self {
37        Self {
38            rev,
39            market_token,
40            report,
41            ty,
42        }
43    }
44}