Skip to main content

hypercall_types/
settlement_events.rs

1use crate::{MarginMode, WalletAddress};
2use rust_decimal::Decimal;
3use serde::{Deserialize, Serialize};
4
5/// Optional economics fields that must be all present or all absent.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub struct SettlementEconomics {
8    pub settlement_entry_price: Decimal,
9    pub cost_basis: Decimal,
10    pub net_pnl: Decimal,
11}
12
13/// Canonical position-expired event payload.
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct PositionExpiredMessage {
16    /// Wallet address that held the position.
17    pub wallet_address: WalletAddress,
18    /// Margin regime used to determine the settlement ledger delta.
19    pub margin_mode: MarginMode,
20    pub symbol: String,
21    /// Signed to indicate long or short.
22    pub position_size: Decimal,
23    /// Intrinsic value per contract.
24    pub settlement_price: Decimal,
25    /// Total settlement amount.
26    pub settlement_value: Decimal,
27    /// Per-contract entry price used to derive settlement economics.
28    #[serde(default)]
29    pub settlement_entry_price: Option<Decimal>,
30    /// Position cost basis at settlement.
31    #[serde(default)]
32    pub cost_basis: Option<Decimal>,
33    /// Net PnL at settlement.
34    #[serde(default)]
35    pub net_pnl: Option<Decimal>,
36    pub timestamp: u64,
37}