use crate::account::SpotState;
use crate::live::Funding;
use crate::markets::perps::UserFunding;
pub(crate) fn spot_state(sent: &crate::live::SpotState, held: Option<&SpotState>) -> SpotState {
let mut spot = sent.state.clone();
spot.portfolio_margin_enabled =
spot.portfolio_margin_enabled.or_else(|| held.and_then(|held| held.portfolio_margin_enabled));
spot.portfolio_margin_ratio =
spot.portfolio_margin_ratio.or_else(|| held.and_then(|held| held.portfolio_margin_ratio));
spot
}
pub(crate) fn funding(read: &UserFunding) -> Funding {
Funding {
time: read.time,
coin: read.delta.coin.clone(),
usdc: read.delta.usdc,
szi: read.delta.szi,
funding_rate: read.delta.funding_rate,
n_samples: read.delta.n_samples.map(u64::from),
}
}