hypercall_db/traits/
settlements.rs1use anyhow::Result;
8use hypercall_types::{MarginMode, WalletAddress};
9use rust_decimal::Decimal;
10use std::collections::HashSet;
11
12use crate::SettlementResult;
13
14pub trait SettlementReader: Send + Sync {
16 fn is_settlement_ledger_applied_sync(
18 &self,
19 wallet: &WalletAddress,
20 symbol: &str,
21 ) -> Result<bool>;
22
23 fn get_applied_settlement_symbols_sync(
25 &self,
26 wallet: &WalletAddress,
27 symbols: &[String],
28 ) -> Result<HashSet<String>>;
29
30 fn get_total_fill_volume_sync(&self) -> Result<(i64, Decimal)>;
32}
33
34pub trait SettlementWriter: SettlementReader {
36 fn try_apply_settlement_sync(
39 &self,
40 wallet: &WalletAddress,
41 symbol: &str,
42 position_size: Decimal,
43 settlement_price: Decimal,
44 settlement_value: Decimal,
45 margin_mode: MarginMode,
46 event_ts_ms: i64,
47 settlement_entry_price: Option<Decimal>,
48 cost_basis: Option<Decimal>,
49 net_pnl: Option<Decimal>,
50 ) -> Result<SettlementResult>;
51
52 fn observe_applied_settlement_sync(
57 &self,
58 wallet: &WalletAddress,
59 symbol: &str,
60 position_size: Decimal,
61 settlement_price: Decimal,
62 settlement_value: Decimal,
63 margin_mode: MarginMode,
64 settlement_entry_price: Option<Decimal>,
65 cost_basis: Option<Decimal>,
66 net_pnl: Option<Decimal>,
67 ) -> Result<SettlementResult>;
68}