hypercall_settlement/
api.rs1use rust_decimal::Decimal;
2
3use crate::SettlementError;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct SettlementPayoutView {
8 pub id: i64,
9 pub wallet: String,
10 pub symbol: String,
11 pub expiry_ts: i64,
12 pub position_size: Decimal,
13 pub settlement_price: Decimal,
14 pub settlement_value: Decimal,
15 pub settlement_entry_price: Option<Decimal>,
16 pub cost_basis: Option<Decimal>,
17 pub net_pnl: Option<Decimal>,
18 pub ledger_applied: bool,
19 pub is_seen: bool,
20 pub created_at: Option<i64>,
21}
22
23pub fn normalize_payout_ids(ids: &[i64]) -> Result<Vec<i64>, SettlementError> {
25 if ids.is_empty() {
26 return Err(SettlementError::new("ids cannot be empty"));
27 }
28
29 if ids.iter().any(|id| *id <= 0) {
30 return Err(SettlementError::new(
31 "ids must contain only positive payout IDs",
32 ));
33 }
34
35 Ok(ids.to_vec())
36}