From 60c73f56354af5b8b4356056bbfe8f4ee5810561 Mon Sep 17 00:00:00 2001 From: nym21 Date: Wed, 3 Dec 2025 00:00:50 +0100 Subject: [PATCH] computer: fix LTH p2a increment --- .../brk_computer/src/stateful/utxo_cohorts.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/brk_computer/src/stateful/utxo_cohorts.rs b/crates/brk_computer/src/stateful/utxo_cohorts.rs index 664179f65..78519a55a 100644 --- a/crates/brk_computer/src/stateful/utxo_cohorts.rs +++ b/crates/brk_computer/src/stateful/utxo_cohorts.rs @@ -1458,11 +1458,15 @@ impl Vecs { let prev_timestamp = chain_state.last().unwrap().timestamp; let mut vecs = self + .0 .age_range .iter_mut() .map(|v| (v.filter().clone(), &mut v.state)) .collect::>(); + let mut sth_p2a = self.0.term.short.price_to_amount.as_mut(); + let mut lth_p2a = self.0.term.long.price_to_amount.as_mut(); + let _ = chain_state .iter() .try_for_each(|block_state| -> ControlFlow<()> { @@ -1491,6 +1495,21 @@ impl Vecs { } }); + // Handle STH -> LTH transitions for price_to_amount + let prev_was_sth = prev_days_old < Term::THRESHOLD_DAYS; + let now_is_sth = days_old < Term::THRESHOLD_DAYS; + + if prev_was_sth && !now_is_sth { + if let Some(price) = block_state.price { + if let Some(p2a) = sth_p2a.as_mut() { + p2a.decrement(price, &block_state.supply); + } + if let Some(p2a) = lth_p2a.as_mut() { + p2a.increment(price, &block_state.supply); + } + } + } + ControlFlow::Continue(()) }); }