global: snapshot

This commit is contained in:
nym21
2026-03-10 14:25:11 +01:00
parent 9aed86cbf2
commit ed0c9ade1a
26 changed files with 599 additions and 674 deletions
+76 -1
View File
@@ -1,5 +1,5 @@
use brk_error::Result;
use brk_types::{Dollars, Indexes};
use brk_types::{Bitcoin, Dollars, Indexes, StoredF32};
use vecdb::Exit;
use super::{gini, Vecs};
@@ -71,6 +71,81 @@ impl Vecs {
exit,
)?;
// Thermocap Multiple: market_cap / thermo_cap
// thermo_cap = cumulative subsidy in USD
self.thermocap_multiple
.bps
.compute_binary::<Dollars, Dollars, RatioDollarsBp32>(
starting_indexes.height,
market_cap,
&mining.rewards.subsidy.cumulative.usd.height,
exit,
)?;
let all_activity = &distribution.utxo_cohorts.all.metrics.activity;
let supply_total_sats = &distribution
.utxo_cohorts
.all
.metrics
.supply
.total
.sats
.height;
// Supply-Adjusted CDD = sum_24h(CDD) / circulating_supply_btc
self.coindays_destroyed_supply_adjusted
.height
.compute_transform2(
starting_indexes.height,
&all_activity.coindays_destroyed.sum._24h.height,
supply_total_sats,
|(i, cdd_24h, supply_sats, ..)| {
let supply = f64::from(Bitcoin::from(supply_sats));
if supply == 0.0 {
(i, StoredF32::from(0.0f32))
} else {
(i, StoredF32::from((f64::from(cdd_24h) / supply) as f32))
}
},
exit,
)?;
// Supply-Adjusted CYD = CYD / circulating_supply_btc (CYD = 1y rolling sum of CDD)
self.coinyears_destroyed_supply_adjusted
.height
.compute_transform2(
starting_indexes.height,
&all_activity.coinyears_destroyed.height,
supply_total_sats,
|(i, cyd, supply_sats, ..)| {
let supply = f64::from(Bitcoin::from(supply_sats));
if supply == 0.0 {
(i, StoredF32::from(0.0f32))
} else {
(i, StoredF32::from((f64::from(cyd) / supply) as f32))
}
},
exit,
)?;
// Supply-Adjusted Dormancy = dormancy / circulating_supply_btc
self.dormancy_supply_adjusted
.height
.compute_transform2(
starting_indexes.height,
&all_activity.dormancy.height,
supply_total_sats,
|(i, dormancy, supply_sats, ..)| {
let supply = f64::from(Bitcoin::from(supply_sats));
if supply == 0.0 {
(i, StoredF32::from(0.0f32))
} else {
(i, StoredF32::from((f64::from(dormancy) / supply) as f32))
}
},
exit,
)?;
let _lock = exit.lock();
self.db.compact()?;
Ok(())