mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -14,30 +14,27 @@ impl Vecs {
|
||||
activity: &activity::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.cointime_adj_inflation_rate
|
||||
.bps
|
||||
.height
|
||||
.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&activity.liveliness.height,
|
||||
&supply.inflation_rate.bps.height,
|
||||
|(h, liveliness, inflation, ..)| {
|
||||
(
|
||||
h,
|
||||
BasisPointsSigned32::from(f64::from(liveliness) * f64::from(inflation)),
|
||||
)
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
self.adj_inflation_rate.bps.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&activity.liveliness.height,
|
||||
&supply.inflation_rate.bps.height,
|
||||
|(h, liveliness, inflation, ..)| {
|
||||
(
|
||||
h,
|
||||
BasisPointsSigned32::from(f64::from(liveliness) * f64::from(inflation)),
|
||||
)
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_velocity_btc.height.compute_multiply(
|
||||
self.adj_tx_velocity_btc.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&supply.velocity.btc.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_velocity_usd.height.compute_multiply(
|
||||
self.adj_tx_velocity_usd.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&supply.velocity.usd.height,
|
||||
|
||||
@@ -15,19 +15,19 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_adj_inflation_rate: PercentPerBlock::forced_import(
|
||||
adj_inflation_rate: PercentPerBlock::forced_import(
|
||||
db,
|
||||
"cointime_adj_inflation_rate",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_velocity_btc: ComputedPerBlock::forced_import(
|
||||
adj_tx_velocity_btc: ComputedPerBlock::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_velocity_btc",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_velocity_usd: ComputedPerBlock::forced_import(
|
||||
adj_tx_velocity_usd: ComputedPerBlock::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_velocity_usd",
|
||||
version,
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::internal::{ComputedPerBlock, PercentPerBlock};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub cointime_adj_inflation_rate: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub cointime_adj_tx_velocity_btc: ComputedPerBlock<StoredF64, M>,
|
||||
pub cointime_adj_tx_velocity_usd: ComputedPerBlock<StoredF64, M>,
|
||||
pub adj_inflation_rate: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub adj_tx_velocity_btc: ComputedPerBlock<StoredF64, M>,
|
||||
pub adj_tx_velocity_usd: ComputedPerBlock<StoredF64, M>,
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Vecs {
|
||||
// cointime_cap = (cointime_value_destroyed_cumulative * circulating_supply) / coinblocks_stored_cumulative
|
||||
self.cointime_cap.cents.height.compute_transform3(
|
||||
starting_indexes.height,
|
||||
&value.cointime_value_destroyed.cumulative.height,
|
||||
&value.value_destroyed.cumulative.height,
|
||||
circulating_supply,
|
||||
&activity.coinblocks_stored.cumulative.height,
|
||||
|(i, destroyed, supply, stored, ..)| {
|
||||
|
||||
@@ -23,11 +23,8 @@ impl Vecs {
|
||||
let coindays_destroyed = &all_metrics.activity.coindays_destroyed;
|
||||
let circulating_supply = &all_metrics.supply.total.btc.height;
|
||||
|
||||
self.cointime_value_destroyed.compute(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
exit,
|
||||
|vec| {
|
||||
self.value_destroyed
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&prices.price.usd.height,
|
||||
@@ -35,14 +32,10 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
})?;
|
||||
|
||||
self.cointime_value_created.compute(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
exit,
|
||||
|vec| {
|
||||
self.value_created
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&prices.price.usd.height,
|
||||
@@ -50,14 +43,10 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
})?;
|
||||
|
||||
self.cointime_value_stored.compute(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
exit,
|
||||
|vec| {
|
||||
self.value_stored
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&prices.price.usd.height,
|
||||
@@ -65,8 +54,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
})?;
|
||||
|
||||
// VOCDD: Value of Coin Days Destroyed = price × (CDD / circulating_supply)
|
||||
// Supply-adjusted to account for growing supply over time
|
||||
|
||||
@@ -12,19 +12,19 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_value_destroyed: ComputedPerBlockCumulativeSum::forced_import(
|
||||
value_destroyed: ComputedPerBlockCumulativeSum::forced_import(
|
||||
db,
|
||||
"cointime_value_destroyed",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_value_created: ComputedPerBlockCumulativeSum::forced_import(
|
||||
value_created: ComputedPerBlockCumulativeSum::forced_import(
|
||||
db,
|
||||
"cointime_value_created",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_value_stored: ComputedPerBlockCumulativeSum::forced_import(
|
||||
value_stored: ComputedPerBlockCumulativeSum::forced_import(
|
||||
db,
|
||||
"cointime_value_stored",
|
||||
version,
|
||||
|
||||
@@ -6,8 +6,8 @@ use crate::internal::ComputedPerBlockCumulativeSum;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub cointime_value_destroyed: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub cointime_value_created: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub cointime_value_stored: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub value_destroyed: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub value_created: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub value_stored: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub vocdd: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ pub struct RealizedFull<M: StorageMode = Rw> {
|
||||
pub sell_side_risk_ratio: PercentRollingWindows<BasisPoints32, M>,
|
||||
|
||||
pub peak_regret: ComputedPerBlockCumulative<Cents, M>,
|
||||
pub peak_regret_rel_to_realized_cap: PercentPerBlock<BasisPoints32, M>,
|
||||
pub peak_regret_rel_to_rcap: PercentPerBlock<BasisPoints32, M>,
|
||||
|
||||
pub cap_rel_to_own_mcap: PercentPerBlock<BasisPoints32, M>,
|
||||
|
||||
@@ -207,7 +207,7 @@ impl RealizedFull {
|
||||
investor_cap_raw,
|
||||
sell_side_risk_ratio,
|
||||
peak_regret,
|
||||
peak_regret_rel_to_realized_cap,
|
||||
peak_regret_rel_to_rcap: peak_regret_rel_to_realized_cap,
|
||||
cap_rel_to_own_mcap: cfg.import("realized_cap_rel_to_own_market_cap", v1)?,
|
||||
profit_sum_extended: cfg.import("realized_profit", v1)?,
|
||||
loss_sum_extended: cfg.import("realized_loss", v1)?,
|
||||
@@ -535,7 +535,7 @@ impl RealizedFull {
|
||||
)?;
|
||||
|
||||
// Peak regret
|
||||
self.peak_regret_rel_to_realized_cap
|
||||
self.peak_regret_rel_to_rcap
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.peak_regret.height,
|
||||
|
||||
@@ -2,13 +2,9 @@ use brk_traversable::Traversable;
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Windows<A> {
|
||||
#[traversable(rename = "24h")]
|
||||
pub _24h: A,
|
||||
#[traversable(rename = "1w")]
|
||||
pub _1w: A,
|
||||
#[traversable(rename = "1m")]
|
||||
pub _1m: A,
|
||||
#[traversable(rename = "1y")]
|
||||
pub _1y: A,
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ pub struct RollingWindow24h<T, M: StorageMode = Rw>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd + JsonSchema,
|
||||
{
|
||||
#[traversable(rename = "24h")]
|
||||
pub _24h: ComputedPerBlock<T, M>,
|
||||
}
|
||||
|
||||
@@ -114,11 +113,8 @@ pub struct RollingWindowsFrom1w<T, M: StorageMode = Rw>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd + JsonSchema,
|
||||
{
|
||||
#[traversable(rename = "1w")]
|
||||
pub _1w: ComputedPerBlock<T, M>,
|
||||
#[traversable(rename = "1m")]
|
||||
pub _1m: ComputedPerBlock<T, M>,
|
||||
#[traversable(rename = "1y")]
|
||||
pub _1y: ComputedPerBlock<T, M>,
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ pub struct BlockRollingDistribution<T, M: StorageMode = Rw>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd + JsonSchema,
|
||||
{
|
||||
#[traversable(rename = "6b")]
|
||||
pub _6b: Distribution<Height, T, M>,
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub fees: AmountPerBlockFull<M>,
|
||||
pub unclaimed_rewards: AmountPerBlockCumulativeSum<M>,
|
||||
pub fee_dominance: PercentPerBlock<BasisPoints16, M>,
|
||||
#[traversable(rename = "fee_dominance")]
|
||||
pub fee_dominance_rolling: PercentRollingWindows<BasisPoints16, M>,
|
||||
pub subsidy_dominance: PercentPerBlock<BasisPoints16, M>,
|
||||
#[traversable(rename = "subsidy_dominance")]
|
||||
pub subsidy_dominance_rolling: PercentRollingWindows<BasisPoints16, M>,
|
||||
pub subsidy_sma_1y: FiatPerBlock<Cents, M>,
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ use crate::{
|
||||
use super::minor;
|
||||
|
||||
#[derive(Deref, DerefMut, Traversable)]
|
||||
#[traversable(merge)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
@@ -26,6 +25,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
#[traversable(wrap = "blocks_mined", rename = "sum")]
|
||||
pub blocks_mined_sum: RollingWindows<StoredU32, M>,
|
||||
pub rewards: AmountPerBlockCumulativeSum<M>,
|
||||
#[traversable(rename = "dominance")]
|
||||
pub dominance_rolling: PercentRollingWindows<BasisPoints16, M>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user