mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-31 20:53:06 -07:00
website: snapshot
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use vecdb::Exit;
|
||||
use brk_types::{Bitcoin, Close, Dollars, StoredF64};
|
||||
use vecdb::{Exit, TypedVecIterator};
|
||||
|
||||
use super::super::activity;
|
||||
use super::Vecs;
|
||||
@@ -29,6 +30,15 @@ impl Vecs {
|
||||
.activity
|
||||
.coindays_destroyed;
|
||||
|
||||
let circulating_supply = &distribution
|
||||
.utxo_cohorts
|
||||
.all
|
||||
.metrics
|
||||
.supply
|
||||
.total
|
||||
.bitcoin
|
||||
.height;
|
||||
|
||||
self.cointime_value_destroyed
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
@@ -62,14 +72,27 @@ impl Vecs {
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
// VOCDD: Value-weighted Coin Days Destroyed = CDD × price
|
||||
// This is a key input for Reserve Risk calculation
|
||||
// VOCDD: Value of Coin Days Destroyed = price × (CDD / circulating_supply)
|
||||
// Supply-adjusted to account for growing supply over time
|
||||
// This is a key input for Reserve Risk / HODL Bank calculation
|
||||
self.vocdd
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
let mut supply_iter = circulating_supply.into_iter();
|
||||
vec.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&price.usd.split.close.height,
|
||||
&coindays_destroyed.height,
|
||||
|(i, price, cdd, _): (_, Close<Dollars>, StoredF64, _)| {
|
||||
let supply: Bitcoin = supply_iter.get_unwrap(i);
|
||||
let supply_f64 = f64::from(supply);
|
||||
if supply_f64 == 0.0 {
|
||||
(i, StoredF64::from(0.0))
|
||||
} else {
|
||||
// VOCDD = price × (CDD / supply)
|
||||
let vocdd = f64::from(price) * f64::from(cdd) / supply_f64;
|
||||
(i, StoredF64::from(vocdd))
|
||||
}
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
|
||||
@@ -29,7 +29,7 @@ impl Vecs {
|
||||
vocdd: ComputedFromHeightSumCum::forced_import(
|
||||
db,
|
||||
"vocdd",
|
||||
version,
|
||||
version + Version::ONE,
|
||||
indexes,
|
||||
)?,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user