Skip to main content

parse_cfm_margin_balances

Function parse_cfm_margin_balances 

Source
pub fn parse_cfm_margin_balances(
    summary: &CfmBalanceSummary,
) -> Result<Vec<MarginBalance>>
Expand description

Parses a CFM balance summary into a single consolidated [MarginBalance].

Coinbase reports two windows (intraday and overnight) with identical currency, but MarginAccount::split_event_margins keys account-level margins by currency only, so emitting both would have one overwrite the other. Selecting per-field maxima could synthesize a pair that matches neither window, so we pick the whole window with the larger initial_margin (ties broken by maintenance_margin) and emit its pair verbatim; the stricter capital requirement governs risk.

ยงErrors

Returns an error when any balance cannot be built as [Money].