pub fn account_balance_from_lighter_asset(
asset: &LighterAsset,
) -> Result<AccountBalance>Expand description
Builds the per-asset [AccountBalance] for one Lighter wallet entry.
Lighter is a unified-margin venue: spot-side balance and perp-side
margin_balance are both deployable equity. The split shows where the
money currently sits, not whether it’s usable. The only true lock on
the trading side is locked_balance (resting spot orders); perp
margin currently in use is tracked separately via [MarginBalance],
not via AccountBalance.locked.
We map:
total = balance + margin_balance: every unit of that currency the account owns at the venuelocked = locked_balance: only spot-order reservationsfree = total - locked(derived byfrom_total_and_locked): all deployable equity, whether currently sitting on spot or perp
Perp-side margin currently allocated to positions is not folded
into locked. It lives on [MarginBalance] and the portfolio’s
risk engine consumes it from there. See
margin_balance_from_user_stats.
§Errors
Returns an error if AccountBalance::from_total_and_locked rejects
the computed values.