Skip to main content

parse_combined_account_balances_and_margins

Function parse_combined_account_balances_and_margins 

Source
pub fn parse_combined_account_balances_and_margins(
    perp_state: &ClearinghouseState,
    spot_state: &SpotClearinghouseState,
) -> Result<(Vec<AccountBalance>, Vec<MarginBalance>)>
Expand description

Merges perp clearinghouse balances with spot balances into a unified set.

The perp parser already reflects combined USDC (its withdrawable may include spot buckets). To avoid double-counting, this helper appends only non-USDC spot tokens onto the perp-derived balances. If the perp state has no margin summary, the full spot balance set is used verbatim.

ยงErrors

Returns an error if any balance conversion fails.