Skip to main content

hypercall_db/types/
settlements.rs

1//! Settlement types for option expiry processing.
2//!
3//! Covers settlement results, payout records, and the idempotent
4//! settlement claim pattern (CALL-500).
5
6use chrono::{DateTime, Utc};
7use hypercall_types::WalletAddress;
8use rust_decimal::Decimal;
9use serde::{Deserialize, Serialize};
10
11/// Result of an idempotent settlement attempt.
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct SettlementResult {
14    /// True if this call created the settlement row; false if it already existed.
15    pub newly_persisted: bool,
16}
17
18/// A completed settlement payout for a single wallet+symbol.
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct SettlementPayoutRecord {
21    pub id: i64,
22    pub wallet: WalletAddress,
23    pub symbol: String,
24    /// Expiry as Unix timestamp in seconds.
25    pub expiry_ts: i64,
26    pub position_size: Decimal,
27    pub settlement_price: Decimal,
28    pub payout_amount: Decimal,
29    /// Whether the settlement audit event has been applied.
30    pub ledger_applied: bool,
31    pub created_at: Option<DateTime<Utc>>,
32    pub settlement_entry_price: Option<Decimal>,
33    pub cost_basis: Option<Decimal>,
34    pub net_pnl: Option<Decimal>,
35}