global: replace most bps with ppm

This commit is contained in:
nym21
2026-07-20 18:28:12 +02:00
parent 3af673132a
commit 00984112d8
110 changed files with 3320 additions and 3220 deletions
@@ -1,12 +1,12 @@
use brk_error::Result;
use brk_indexer::Indexer;
use brk_types::{Dollars, Height, Sats, StoredF32, StoredF64};
use brk_types::{Dollars, Height, PartsPerMillionSigned64, Sats, StoredF32, StoredF64};
use vecdb::{Exit, ReadableVec};
use super::Vecs;
use crate::{
blocks::{self, ONE_TERA_HASH, TARGET_BLOCKS_PER_DAY_F64},
internal::RatioDiffF32Bps32,
internal::RatioDiffF32,
};
impl Vecs {
@@ -103,7 +103,7 @@ impl Vecs {
self.price
.rebound
.compute_binary::<StoredF32, StoredF32, RatioDiffF32Bps32>(
.compute_binary::<StoredF32, StoredF32, RatioDiffF32<PartsPerMillionSigned64>>(
starting_height,
&self.price.phs.height,
&self.price.phs_min.height,
@@ -112,7 +112,7 @@ impl Vecs {
self.value
.rebound
.compute_binary::<StoredF32, StoredF32, RatioDiffF32Bps32>(
.compute_binary::<StoredF32, StoredF32, RatioDiffF32<PartsPerMillionSigned64>>(
starting_height,
&self.value.phs.height,
&self.value.phs_min.height,
@@ -77,7 +77,7 @@ impl Vecs {
rebound: PercentPerBlock::forced_import(
db,
"hash_price_rebound",
version + v4,
version + v5,
indexes,
)?,
},
@@ -89,7 +89,7 @@ impl Vecs {
rebound: PercentPerBlock::forced_import(
db,
"hash_value_rebound",
version + v4,
version + v5,
indexes,
)?,
},
@@ -1,5 +1,5 @@
use brk_traversable::Traversable;
use brk_types::{BasisPointsSigned16, BasisPointsSigned32, StoredF32, StoredF64};
use brk_types::{PartsPerMillionSigned32, PartsPerMillionSigned64, StoredF32, StoredF64};
use vecdb::{Rw, StorageMode};
use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock};
@@ -18,7 +18,7 @@ pub struct HashPriceValueVecs<M: StorageMode = Rw> {
pub ths_min: PerBlock<StoredF32, M>,
pub phs: LazyPerBlock<StoredF32>,
pub phs_min: LazyPerBlock<StoredF32>,
pub rebound: PercentPerBlock<BasisPointsSigned32, M>,
pub rebound: PercentPerBlock<PartsPerMillionSigned64, M>,
}
#[derive(Traversable)]
@@ -26,7 +26,7 @@ pub struct RateVecs<M: StorageMode = Rw> {
pub base: PerBlock<StoredF64, M>,
pub sma: HashRateSmaVecs<M>,
pub ath: PerBlock<StoredF64, M>,
pub drawdown: PercentPerBlock<BasisPointsSigned16, M>,
pub drawdown: PercentPerBlock<PartsPerMillionSigned32, M>,
}
#[derive(Traversable)]
@@ -1,12 +1,14 @@
use brk_error::Result;
use brk_indexer::Indexer;
use brk_types::{CheckedSub, Dollars, Halving, Sats};
use brk_types::{
CheckedSub, Dollars, Halving, PartsPerMillion32, PartsPerMillion64, Sats,
};
use vecdb::{Exit, ReadableVec, VecIndex};
use super::Vecs;
use crate::{
blocks, indexes,
internal::{RatioDollarsBp32, RatioSatsBp16},
internal::{RatioDollars, RatioSats},
price, transactions,
};
@@ -109,7 +111,7 @@ impl Vecs {
self.unclaimed.compute(prices, starting_height, exit)?;
self.fee_dominance
.compute_binary::<Sats, Sats, RatioSatsBp16, _, _, _, _>(
.compute_binary::<Sats, Sats, RatioSats<PartsPerMillion32>, _, _, _, _>(
starting_height,
&self.fees.cumulative.sats.height,
&self.coinbase.cumulative.sats.height,
@@ -119,7 +121,7 @@ impl Vecs {
)?;
self.fee_to_subsidy_ratio
.compute_binary::<Dollars, Dollars, RatioDollarsBp32, _, _>(
.compute_binary::<Dollars, Dollars, RatioDollars<PartsPerMillion64>, _, _>(
starting_height,
self.coinbase.sum.as_array().map(|w| &w.usd.height),
self.fees.sum.as_array().map(|w| &w.usd.height),
@@ -6,7 +6,7 @@ use super::Vecs;
use crate::{
indexes,
internal::{
LazyPercentCumulativeRolling, OneMinusBp16, PercentCumulativeRolling, RatioRollingWindows,
LazyPercentCumulativeRolling, OneMinusPpm, PercentCumulativeRolling, RatioRollingWindows,
ValuePerBlockCumulative, ValuePerBlockCumulativeRolling, ValuePerBlockFull, WindowStartVec,
Windows,
},
@@ -22,7 +22,7 @@ impl Vecs {
let fee_dominance =
PercentCumulativeRolling::forced_import(db, "fee_dominance", version, indexes)?;
let subsidy_dominance = LazyPercentCumulativeRolling::from_source::<OneMinusBp16>(
let subsidy_dominance = LazyPercentCumulativeRolling::from_source::<OneMinusPpm>(
"subsidy_dominance",
version,
&fee_dominance,
@@ -1,5 +1,5 @@
use brk_traversable::Traversable;
use brk_types::{BasisPoints16, BasisPoints32, Height, Sats};
use brk_types::{Height, PartsPerMillion32, PartsPerMillion64, Sats};
use vecdb::{EagerVec, PcoVec, Rw, StorageMode};
use crate::internal::{
@@ -15,9 +15,9 @@ pub struct Vecs<M: StorageMode = Rw> {
pub output_volume: M::Stored<EagerVec<PcoVec<Height, Sats>>>,
pub unclaimed: ValuePerBlockCumulative<M>,
#[traversable(wrap = "fees", rename = "dominance")]
pub fee_dominance: PercentCumulativeRolling<BasisPoints16, M>,
pub fee_dominance: PercentCumulativeRolling<PartsPerMillion32, M>,
#[traversable(wrap = "subsidy", rename = "dominance")]
pub subsidy_dominance: LazyPercentCumulativeRolling<BasisPoints16>,
pub subsidy_dominance: LazyPercentCumulativeRolling<PartsPerMillion32>,
#[traversable(wrap = "fees", rename = "to_subsidy_ratio")]
pub fee_to_subsidy_ratio: RatioRollingWindows<BasisPoints32, M>,
pub fee_to_subsidy_ratio: RatioRollingWindows<PartsPerMillion64, M>,
}