Skip to main content

SettlementWriter

Trait SettlementWriter 

Source
pub trait SettlementWriter: SettlementReader {
    // Required methods
    fn try_apply_settlement_sync(
        &self,
        wallet: &WalletAddress,
        symbol: &str,
        position_size: Decimal,
        settlement_price: Decimal,
        settlement_value: Decimal,
        margin_mode: MarginMode,
        event_ts_ms: i64,
        settlement_entry_price: Option<Decimal>,
        cost_basis: Option<Decimal>,
        net_pnl: Option<Decimal>,
    ) -> Result<SettlementResult>;
    fn observe_applied_settlement_sync(
        &self,
        wallet: &WalletAddress,
        symbol: &str,
        position_size: Decimal,
        settlement_price: Decimal,
        settlement_value: Decimal,
        margin_mode: MarginMode,
        settlement_entry_price: Option<Decimal>,
        cost_basis: Option<Decimal>,
        net_pnl: Option<Decimal>,
    ) -> Result<SettlementResult>;
}
Expand description

Settlement mutations. Atomic and idempotent.

Required Methods§

Source

fn try_apply_settlement_sync( &self, wallet: &WalletAddress, symbol: &str, position_size: Decimal, settlement_price: Decimal, settlement_value: Decimal, margin_mode: MarginMode, event_ts_ms: i64, settlement_entry_price: Option<Decimal>, cost_basis: Option<Decimal>, net_pnl: Option<Decimal>, ) -> Result<SettlementResult>

Idempotent settlement audit: expiration row, payout row, and ledger event. Returns whether this was a new settlement or a duplicate replay.

Source

fn observe_applied_settlement_sync( &self, wallet: &WalletAddress, symbol: &str, position_size: Decimal, settlement_price: Decimal, settlement_value: Decimal, margin_mode: MarginMode, settlement_entry_price: Option<Decimal>, cost_basis: Option<Decimal>, net_pnl: Option<Decimal>, ) -> Result<SettlementResult>

Read and validate an already-applied settlement without writing.

Standby replay uses this after primary NATS publication, which happens only after the primary durable settlement effect succeeds.

Implementors§