mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -130,30 +130,20 @@ impl Vecs {
|
||||
)?;
|
||||
|
||||
// Rolling fee dominance = sum(fees) / sum(coinbase) * 100
|
||||
self.fee_dominance_24h.height.compute_percentage(
|
||||
starting_indexes.height,
|
||||
&self.fees.rolling._24h.sum.sats.height,
|
||||
&self.coinbase.rolling._24h.sum.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
self.fee_dominance_7d.height.compute_percentage(
|
||||
starting_indexes.height,
|
||||
&self.fees.rolling._7d.sum.sats.height,
|
||||
&self.coinbase.rolling._7d.sum.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
self.fee_dominance_30d.height.compute_percentage(
|
||||
starting_indexes.height,
|
||||
&self.fees.rolling._30d.sum.sats.height,
|
||||
&self.coinbase.rolling._30d.sum.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
self.fee_dominance_1y.height.compute_percentage(
|
||||
starting_indexes.height,
|
||||
&self.fees.rolling._1y.sum.sats.height,
|
||||
&self.coinbase.rolling._1y.sum.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
for ((fee_dom, fees_w), coinbase_w) in self
|
||||
.fee_dominance_rolling
|
||||
.as_mut_array()
|
||||
.into_iter()
|
||||
.zip(self.fees.rolling.as_array())
|
||||
.zip(self.coinbase.rolling.as_array())
|
||||
{
|
||||
fee_dom.height.compute_percentage(
|
||||
starting_indexes.height,
|
||||
&fees_w.sum.sats.height,
|
||||
&coinbase_w.sum.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
}
|
||||
|
||||
// All-time cumulative subsidy dominance
|
||||
self.subsidy_dominance.height.compute_percentage(
|
||||
@@ -165,30 +155,19 @@ impl Vecs {
|
||||
|
||||
// Rolling subsidy dominance = 100 - fee_dominance
|
||||
let hundred = StoredF32::from(100u8);
|
||||
self.subsidy_dominance_24h.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.fee_dominance_24h.height,
|
||||
|(height, fee_dom, _)| (height, hundred - fee_dom),
|
||||
exit,
|
||||
)?;
|
||||
self.subsidy_dominance_7d.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.fee_dominance_7d.height,
|
||||
|(height, fee_dom, _)| (height, hundred - fee_dom),
|
||||
exit,
|
||||
)?;
|
||||
self.subsidy_dominance_30d.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.fee_dominance_30d.height,
|
||||
|(height, fee_dom, _)| (height, hundred - fee_dom),
|
||||
exit,
|
||||
)?;
|
||||
self.subsidy_dominance_1y.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.fee_dominance_1y.height,
|
||||
|(height, fee_dom, _)| (height, hundred - fee_dom),
|
||||
exit,
|
||||
)?;
|
||||
for (sub_dom, fee_dom) in self
|
||||
.subsidy_dominance_rolling
|
||||
.as_mut_array()
|
||||
.into_iter()
|
||||
.zip(self.fee_dominance_rolling.as_array())
|
||||
{
|
||||
sub_dom.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&fee_dom.height,
|
||||
|(height, fee_dom, _)| (height, hundred - fee_dom),
|
||||
exit,
|
||||
)?;
|
||||
}
|
||||
|
||||
self.subsidy_usd_1y_sma.cents.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{
|
||||
ComputedFromHeight, FiatFromHeight, ValueFromHeightFull,
|
||||
ComputedFromHeight, FiatFromHeight, RollingWindows, ValueFromHeightFull,
|
||||
ValueFromHeightCumulativeSum,
|
||||
},
|
||||
};
|
||||
@@ -33,27 +33,9 @@ impl Vecs {
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_24h: ComputedFromHeight::forced_import(
|
||||
fee_dominance_rolling: RollingWindows::forced_import(
|
||||
db,
|
||||
"fee_dominance_24h",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_7d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_7d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_30d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_30d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_1y: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_1y",
|
||||
"fee_dominance",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
@@ -63,27 +45,9 @@ impl Vecs {
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_24h: ComputedFromHeight::forced_import(
|
||||
subsidy_dominance_rolling: RollingWindows::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_24h",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_7d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_7d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_30d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_30d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_1y: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_1y",
|
||||
"subsidy_dominance",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
|
||||
@@ -3,7 +3,7 @@ use brk_types::{Cents, StoredF32};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{
|
||||
ComputedFromHeight, FiatFromHeight, ValueFromHeightFull,
|
||||
ComputedFromHeight, FiatFromHeight, RollingWindows, ValueFromHeightFull,
|
||||
ValueFromHeightCumulativeSum,
|
||||
};
|
||||
|
||||
@@ -15,14 +15,8 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub fees: ValueFromHeightFull<M>,
|
||||
pub unclaimed_rewards: ValueFromHeightCumulativeSum<M>,
|
||||
pub fee_dominance: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_24h: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_7d: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_30d: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_1y: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_rolling: RollingWindows<StoredF32, M>,
|
||||
pub subsidy_dominance: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_24h: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_7d: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_30d: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_1y: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_rolling: RollingWindows<StoredF32, M>,
|
||||
pub subsidy_usd_1y_sma: FiatFromHeight<Cents, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user