From de98c5f70685a334792293b1783f0cae94994a00 Mon Sep 17 00:00:00 2001 From: nym21 Date: Sun, 7 Sep 2025 21:55:39 +0200 Subject: [PATCH] global: fixes --- crates/brk_computer/src/lib.rs | 2 - crates/brk_computer/src/stateful/common.rs | 24 ++--- crates/brk_interface/src/ids.rs | 6 +- crates/brk_structs/src/structs/stored_f64.rs | 14 +++ websites/bitview/scripts/options.js | 99 +++++++------------- 5 files changed, 63 insertions(+), 82 deletions(-) diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index 6d1b180d6..51518afff 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -151,8 +151,6 @@ impl Computer { .compute(indexer, &self.indexes, price, &starting_indexes, exit)?; } - // let _ = generate_allocation_files(&self.pools); - chain.join().unwrap()?; Ok(()) })?; diff --git a/crates/brk_computer/src/stateful/common.rs b/crates/brk_computer/src/stateful/common.rs index 5b9132041..5b4b45fea 100644 --- a/crates/brk_computer/src/stateful/common.rs +++ b/crates/brk_computer/src/stateful/common.rs @@ -50,12 +50,12 @@ pub struct Vecs { pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight, pub indexes_to_coindays_destroyed: ComputedVecsFromHeight, - pub dateindex_to_sopr: Option>, - pub dateindex_to_sopr_7d_ema: Option>, - pub dateindex_to_sopr_30d_ema: Option>, - pub dateindex_to_adjusted_sopr: Option>, - pub dateindex_to_adjusted_sopr_7d_ema: Option>, - pub dateindex_to_adjusted_sopr_30d_ema: Option>, + pub dateindex_to_sopr: Option>, + pub dateindex_to_sopr_7d_ema: Option>, + pub dateindex_to_sopr_30d_ema: Option>, + pub dateindex_to_adjusted_sopr: Option>, + pub dateindex_to_adjusted_sopr_7d_ema: Option>, + pub dateindex_to_adjusted_sopr_30d_ema: Option>, pub indexes_to_realized_cap_30d_delta: Option>, pub dateindex_to_sell_side_risk_ratio: Option>, pub dateindex_to_sell_side_risk_ratio_7d_ema: Option>, @@ -720,7 +720,7 @@ impl Vecs { EagerVec::forced_import( db, &suffix("sopr"), - version + VERSION + Version::ZERO, + version + VERSION + Version::ONE, format, ) .unwrap() @@ -729,7 +729,7 @@ impl Vecs { EagerVec::forced_import( db, &suffix("sopr_7d_ema"), - version + VERSION + Version::ZERO, + version + VERSION + Version::ONE, format, ) .unwrap() @@ -738,7 +738,7 @@ impl Vecs { EagerVec::forced_import( db, &suffix("sopr_30d_ema"), - version + VERSION + Version::ZERO, + version + VERSION + Version::ONE, format, ) .unwrap() @@ -747,7 +747,7 @@ impl Vecs { EagerVec::forced_import( db, &suffix("adjusted_sopr"), - version + VERSION + Version::ZERO, + version + VERSION + Version::ONE, format, ) .unwrap() @@ -756,7 +756,7 @@ impl Vecs { EagerVec::forced_import( db, &suffix("adjusted_sopr_7d_ema"), - version + VERSION + Version::ZERO, + version + VERSION + Version::ONE, format, ) .unwrap() @@ -765,7 +765,7 @@ impl Vecs { EagerVec::forced_import( db, &suffix("adjusted_sopr_30d_ema"), - version + VERSION + Version::ZERO, + version + VERSION + Version::ONE, format, ) .unwrap() diff --git a/crates/brk_interface/src/ids.rs b/crates/brk_interface/src/ids.rs index a751fb366..253b9dacd 100644 --- a/crates/brk_interface/src/ids.rs +++ b/crates/brk_interface/src/ids.rs @@ -7,8 +7,8 @@ use serde::Deserialize; #[derive(Debug, Deref, JsonSchema)] pub struct MaybeIds(Vec); -const MAX_STRING_SIZE: usize = 10_000; -const MAX_VECS: usize = 64; +const MAX_VECS: usize = 32; +const MAX_STRING_SIZE: usize = 64 * MAX_VECS; impl From for MaybeIds { fn from(value: String) -> Self { @@ -34,7 +34,6 @@ impl<'de> Deserialize<'de> for MaybeIds { str.split(",").map(|s| s.to_string()), ))) } else { - dbg!(str.len(), MAX_STRING_SIZE); Err(serde::de::Error::custom("Given parameter is too long")) } } @@ -44,7 +43,6 @@ impl<'de> Deserialize<'de> for MaybeIds { vec.into_iter().map(|s| s.as_str().unwrap().to_string()), ))) } else { - dbg!(vec.len(), MAX_VECS); Err(serde::de::Error::custom("Given parameter is too long")) } } diff --git a/crates/brk_structs/src/structs/stored_f64.rs b/crates/brk_structs/src/structs/stored_f64.rs index b4c5ec2ea..044013949 100644 --- a/crates/brk_structs/src/structs/stored_f64.rs +++ b/crates/brk_structs/src/structs/stored_f64.rs @@ -1,6 +1,7 @@ use std::{ cmp::Ordering, f64, + iter::Sum, ops::{Add, AddAssign, Div, Mul}, }; @@ -77,6 +78,13 @@ impl Div for StoredF64 { } } +impl Div for StoredF64 { + type Output = Self; + fn div(self, rhs: Dollars) -> Self::Output { + Self::from(self.0 / *rhs) + } +} + impl Add for StoredF64 { type Output = Self; fn add(self, rhs: Self) -> Self::Output { @@ -161,3 +169,9 @@ impl Printable for StoredF64 { &["f64"] } } + +impl Sum for StoredF64 { + fn sum>(iter: I) -> Self { + Self(iter.map(|v| v.0).sum::()) + } +} diff --git a/websites/bitview/scripts/options.js b/websites/bitview/scripts/options.js index c09ca5c3f..8bb8ce906 100644 --- a/websites/bitview/scripts/options.js +++ b/websites/bitview/scripts/options.js @@ -3740,15 +3740,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes, pools }) { return { name, tree: [ - // indexes_to_dominance: ComputedVecsFromDateIndex, - // indexes_to_1d_dominance: ComputedVecsFromDateIndex, - // indexes_to_1w_dominance: ComputedVecsFromDateIndex, - // indexes_to_1m_dominance: ComputedVecsFromDateIndex, - // indexes_to_1y_dominance: ComputedVecsFromDateIndex, - // indexes_to_days_since_block: ComputedVecsFromDateIndex, { name: "Dominance", - title: `Dominance of ${name}`, + title: `Mining Dominance of ${name}`, bottom: [ createBaseSeries({ key: `${key}_1d_dominance`, @@ -3815,68 +3809,45 @@ function createPartialOptions({ env, colors, vecIdToIndexes, pools }) { }, { name: "Rewards", - tree: [ + title: `Rewards collected by ${name}`, + bottom: [ { - name: "coinbase", - title: `coinbase collected by ${name}`, - bottom: [ - ...createSumCumulativeSeries({ - concat: `${key}_coinbase`, - common: "coinbase", - // cumulativeColor: colors. - }), - ...createSumCumulativeSeries({ - concat: `${key}_coinbase_in_btc`, - common: "coinbase", - // cumulativeColor: colors. - }), - ...createSumCumulativeSeries({ - concat: `${key}_coinbase_in_usd`, - common: "coinbase", - }), - ], + keyAddon: "coinbase", + cumulativeColor: colors.red, + sumColor: colors.orange, }, { - name: "subsidy", - title: `subsidy collected by ${name}`, - bottom: [ - ...createSumCumulativeSeries({ - concat: `${key}_subsidy`, - common: "subsidy", - // cumulativeColor: colors. - }), - ...createSumCumulativeSeries({ - concat: `${key}_subsidy_in_btc`, - common: "subsidy", - // cumulativeColor: colors. - }), - ...createSumCumulativeSeries({ - concat: `${key}_subsidy_in_usd`, - common: "subsidy", - }), - ], + keyAddon: "subsidy", + cumulativeColor: colors.emerald, + sumColor: colors.lime, }, { - name: "fees", - title: `fees collected by ${name}`, - bottom: [ - ...createSumCumulativeSeries({ - concat: `${key}_fee`, - common: "fee", - // cumulativeColor: colors. - }), - ...createSumCumulativeSeries({ - concat: `${key}_fee_in_btc`, - common: "fee", - // cumulativeColor: colors. - }), - ...createSumCumulativeSeries({ - concat: `${key}_fee_in_usd`, - common: "fee", - }), - ], + keyAddon: "fee", + cumulativeColor: colors.indigo, + sumColor: colors.cyan, }, - ], + ].flatMap( + ({ keyAddon, sumColor, cumulativeColor }) => [ + ...createSumCumulativeSeries({ + concat: `${key}_${keyAddon}`, + common: keyAddon, + sumColor, + cumulativeColor, + }), + ...createSumCumulativeSeries({ + concat: `${key}_${keyAddon}_in_btc`, + common: keyAddon, + sumColor, + cumulativeColor, + }), + ...createSumCumulativeSeries({ + concat: `${key}_${keyAddon}_in_usd`, + common: keyAddon, + sumColor, + cumulativeColor, + }), + ], + ), }, { name: "Days since block", @@ -3884,7 +3855,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes, pools }) { bottom: [ createBaseSeries({ key: `${key}_days_since_block`, - name: "Raw", + name: "Since block", }), ], },