levana_perpswap_cosmos/contracts/market/
delta_neutrality_fee.rs1use crate::prelude::*;
3use cosmwasm_std::Event;
4
5#[derive(Clone)]
7pub struct DeltaNeutralityFeeEvent {
8 pub amount: Signed<Collateral>,
10 pub total_funds_before: Collateral,
12 pub total_funds_after: Collateral,
14 pub reason: DeltaNeutralityFeeReason,
16 pub protocol_amount: Collateral,
18}
19
20impl From<DeltaNeutralityFeeEvent> for Event {
21 fn from(src: DeltaNeutralityFeeEvent) -> Self {
22 Event::new("delta-neutrality-fee").add_attributes(vec![
23 ("amount", src.amount.to_string()),
24 ("total-funds-before", src.total_funds_before.to_string()),
25 ("total-funds-after", src.total_funds_after.to_string()),
26 ("reason", src.reason.as_str().to_string()),
27 ])
28 }
29}
30
31#[derive(Clone, Copy, Debug, Eq, PartialEq)]
33pub enum DeltaNeutralityFeeReason {
34 PositionOpen,
36 PositionUpdate,
38 PositionClose,
40}
41
42impl DeltaNeutralityFeeReason {
43 pub const fn as_str(&self) -> &'static str {
45 match self {
46 Self::PositionOpen => "open",
47 Self::PositionUpdate => "update",
48 Self::PositionClose => "close",
49 }
50 }
51}