From 24d2b7b142e627e274692ceb8dec68b59ac909d6 Mon Sep 17 00:00:00 2001 From: nym21 Date: Sat, 28 Mar 2026 11:56:51 +0100 Subject: [PATCH] global: fmt --- crates/brk_bindgen/src/analysis/positions.rs | 359 +- crates/brk_bindgen/src/generate/constants.rs | 11 +- crates/brk_bindgen/src/generate/fields.rs | 8 +- crates/brk_bindgen/src/generate/tree.rs | 4 +- .../src/generators/javascript/client.rs | 7 +- .../brk_bindgen/src/generators/python/api.rs | 6 +- .../src/generators/python/client.rs | 1 - crates/brk_client/src/lib.rs | 5850 ++++++++++++++--- crates/brk_cohort/src/addr.rs | 5 +- crates/brk_cohort/src/age_range.rs | 24 +- crates/brk_cohort/src/amount_range.rs | 6 +- crates/brk_cohort/src/lib.rs | 4 +- crates/brk_cohort/src/over_amount.rs | 24 +- crates/brk_cohort/src/profit.rs | 24 +- crates/brk_cohort/src/profitability_range.rs | 150 +- crates/brk_cohort/src/utxo.rs | 4 +- crates/brk_computer/src/blocks/compute.rs | 3 +- .../brk_computer/src/blocks/count/import.rs | 28 +- crates/brk_computer/src/blocks/count/vecs.rs | 2 +- .../src/blocks/difficulty/import.rs | 8 +- .../src/blocks/difficulty/vecs.rs | 2 +- .../brk_computer/src/blocks/halving/import.rs | 5 +- crates/brk_computer/src/blocks/import.rs | 3 +- .../src/blocks/interval/compute.rs | 41 +- .../src/blocks/interval/import.rs | 5 +- crates/brk_computer/src/blocks/lookback.rs | 115 +- .../src/cointime/activity/import.rs | 12 +- .../src/cointime/prices/compute.rs | 40 +- .../src/cointime/prices/import.rs | 5 +- .../src/cointime/supply/compute.rs | 3 +- .../src/cointime/supply/import.rs | 7 +- .../src/cointime/value/compute.rs | 79 +- .../src/distribution/addr/activity.rs | 32 +- .../src/distribution/addr/addr_count.rs | 54 +- .../src/distribution/addr/data.rs | 4 +- .../src/distribution/addr/delta.rs | 5 +- .../src/distribution/addr/indexes/any.rs | 4 +- .../src/distribution/addr/new_addr_count.rs | 5 +- .../src/distribution/addr/total_addr_count.rs | 17 +- .../src/distribution/block/cache/addr.rs | 4 +- .../src/distribution/block/cache/lookup.rs | 5 +- .../distribution/block/cohort/addr_updates.rs | 4 +- .../src/distribution/block/cohort/received.rs | 6 +- .../distribution/block/cohort/tx_counts.rs | 5 +- .../src/distribution/block/utxo/inputs.rs | 11 +- .../src/distribution/block/utxo/outputs.rs | 15 +- .../src/distribution/cohorts/addr/groups.rs | 4 +- .../src/distribution/cohorts/addr/vecs.rs | 4 +- .../src/distribution/cohorts/utxo/receive.rs | 12 +- .../src/distribution/cohorts/utxo/send.rs | 10 +- .../distribution/cohorts/utxo/tick_tock.rs | 7 +- .../distribution/cohorts/utxo/vecs/core.rs | 13 +- .../distribution/cohorts/utxo/vecs/type.rs | 12 +- .../src/distribution/compute/block_loop.rs | 104 +- .../src/distribution/compute/readers.rs | 21 +- .../src/distribution/compute/recover.rs | 5 +- .../src/distribution/metrics/activity/core.rs | 22 +- .../src/distribution/metrics/activity/full.rs | 15 +- .../distribution/metrics/activity/minimal.rs | 14 +- .../src/distribution/metrics/activity/mod.rs | 57 +- .../src/distribution/metrics/cohort/all.rs | 18 +- .../src/distribution/metrics/cohort/basic.rs | 12 +- .../src/distribution/metrics/cohort/core.rs | 22 +- .../distribution/metrics/cohort/minimal.rs | 6 +- .../src/distribution/metrics/cohort/type.rs | 6 +- .../distribution/metrics/cost_basis/mod.rs | 32 +- .../src/distribution/metrics/mod.rs | 22 +- .../src/distribution/metrics/profitability.rs | 24 +- .../src/distribution/metrics/realized/core.rs | 18 +- .../src/distribution/metrics/realized/full.rs | 8 +- .../distribution/metrics/realized/minimal.rs | 47 +- .../src/distribution/metrics/realized/mod.rs | 42 +- .../relative/extended_own_market_cap.rs | 3 +- .../metrics/relative/extended_own_pnl.rs | 4 +- .../distribution/metrics/relative/for_all.rs | 13 +- .../src/distribution/metrics/relative/full.rs | 9 +- .../distribution/metrics/relative/to_all.rs | 3 +- .../metrics/relative/with_extended.rs | 27 +- .../src/distribution/metrics/supply/base.rs | 9 +- .../src/distribution/metrics/supply/mod.rs | 2 +- .../distribution/metrics/unrealized/basic.rs | 10 +- .../distribution/metrics/unrealized/core.rs | 11 +- .../distribution/metrics/unrealized/mod.rs | 8 +- .../src/distribution/state/cohort/base.rs | 25 +- .../src/distribution/state/cost_basis/data.rs | 10 +- .../src/distribution/state/cost_basis/mod.rs | 2 +- .../state/cost_basis/unrealized.rs | 32 +- crates/brk_computer/src/indexes/addr.rs | 34 +- crates/brk_computer/src/indexes/height.rs | 4 +- crates/brk_computer/src/indexes/mod.rs | 18 +- crates/brk_computer/src/indicators/compute.rs | 78 +- crates/brk_computer/src/indicators/import.rs | 8 +- .../src/indicators/realized_envelope.rs | 135 +- crates/brk_computer/src/inputs/compute.rs | 3 +- .../brk_computer/src/inputs/count/import.rs | 5 +- crates/brk_computer/src/inputs/count/vecs.rs | 4 +- crates/brk_computer/src/inputs/import.rs | 5 +- .../internal/algo/expanding_percentiles.rs | 1 - .../src/internal/algo/sliding_distribution.rs | 11 +- .../src/internal/containers/constant.rs | 4 +- .../internal/containers/distribution_stats.rs | 5 +- .../src/internal/containers/mod.rs | 4 +- .../src/internal/indexes/eager.rs | 4 +- .../brk_computer/src/internal/indexes/lazy.rs | 4 +- crates/brk_computer/src/internal/mod.rs | 4 +- .../src/internal/per_block/amount/base.rs | 12 +- .../src/internal/per_block/amount/block.rs | 19 +- .../src/internal/per_block/amount/full.rs | 3 +- .../src/internal/per_block/amount/lazy.rs | 4 +- .../src/internal/per_block/computed/base.rs | 10 +- .../per_block/computed/distribution.rs | 6 +- .../per_block/computed/lazy_distribution.rs | 2 +- .../per_block/computed/lazy_rolling.rs | 4 +- .../internal/per_block/computed/rolling.rs | 2 +- .../per_block/computed/with_deltas.rs | 4 +- .../src/internal/per_block/fiat/base.rs | 6 +- .../src/internal/per_block/fiat/block.rs | 11 +- .../internal/per_block/fiat/cumulative_sum.rs | 18 +- .../fiat/cumulative_sum_with_deltas.rs | 9 +- .../src/internal/per_block/fiat/lazy.rs | 8 +- .../per_block/lazy/derived_resolutions.rs | 8 +- .../src/internal/per_block/percent/lazy.rs | 7 +- .../src/internal/per_block/ratio/base.rs | 2 +- .../internal/per_block/ratio/percentiles.rs | 3 +- .../per_block/ratio/price_extended.rs | 5 +- .../internal/per_block/ratio/std_dev_bands.rs | 9 +- .../src/internal/per_block/ratio/windows.rs | 8 +- .../internal/per_block/rolling/complete.rs | 2 +- .../per_block/rolling/lazy_complete.rs | 4 +- .../src/internal/per_block/rolling/mod.rs | 4 +- .../src/internal/per_block/rolling/windows.rs | 15 +- .../src/internal/per_block/stddev/base.rs | 13 +- .../src/internal/per_block/stddev/extended.rs | 3 +- .../src/internal/per_tx/distribution.rs | 7 +- crates/brk_computer/src/internal/traits.rs | 4 +- .../src/internal/transform/arithmetic.rs | 6 +- .../src/internal/transform/mod.rs | 4 +- .../src/internal/transform/ratio.rs | 4 +- crates/brk_computer/src/lib.rs | 52 +- crates/brk_computer/src/market/ath/import.rs | 3 +- crates/brk_computer/src/market/compute.rs | 5 +- crates/brk_computer/src/market/import.rs | 4 +- crates/brk_computer/src/market/mod.rs | 4 +- .../src/market/moving_average/import.rs | 2 +- .../brk_computer/src/market/range/compute.rs | 41 +- .../brk_computer/src/market/range/import.rs | 9 +- .../src/market/returns/compute.rs | 4 +- .../brk_computer/src/market/returns/import.rs | 8 +- .../src/market/technical/compute.rs | 20 +- .../src/market/technical/import.rs | 26 +- .../src/market/volatility/import.rs | 7 +- .../src/mining/hashrate/import.rs | 49 +- crates/brk_computer/src/mining/import.rs | 5 +- .../src/mining/rewards/compute.rs | 31 +- .../brk_computer/src/mining/rewards/import.rs | 24 +- .../brk_computer/src/outputs/count/import.rs | 7 +- crates/brk_computer/src/outputs/import.rs | 5 +- .../brk_computer/src/outputs/spent/compute.rs | 7 +- crates/brk_computer/src/pools/major.rs | 14 +- crates/brk_computer/src/pools/minor.rs | 11 +- crates/brk_computer/src/pools/mod.rs | 29 +- crates/brk_computer/src/positions.rs | 6 +- crates/brk_computer/src/prices/by_unit.rs | 4 +- crates/brk_computer/src/prices/mod.rs | 5 +- crates/brk_computer/src/prices/ohlcs.rs | 7 +- .../brk_computer/src/scripts/count/import.rs | 81 +- .../brk_computer/src/scripts/value/compute.rs | 30 +- .../brk_computer/src/supply/burned/compute.rs | 16 +- crates/brk_computer/src/supply/compute.rs | 9 +- crates/brk_computer/src/supply/import.rs | 19 +- crates/brk_computer/src/supply/vecs.rs | 4 +- .../src/transactions/count/import.rs | 13 +- .../src/transactions/fees/compute.rs | 18 +- .../src/transactions/fees/import.rs | 6 +- .../brk_computer/src/transactions/import.rs | 5 +- .../src/transactions/size/import.rs | 14 +- .../src/transactions/versions/compute.rs | 6 +- .../src/transactions/versions/import.rs | 24 +- crates/brk_fetcher/src/binance.rs | 17 +- crates/brk_indexer/src/indexes.rs | 36 +- crates/brk_indexer/src/processor/tx.rs | 3 +- crates/brk_indexer/src/processor/txout.rs | 20 +- crates/brk_indexer/src/processor/types.rs | 4 +- crates/brk_indexer/src/readers.rs | 7 +- crates/brk_indexer/src/stores.rs | 5 +- crates/brk_indexer/src/vecs/addrs.rs | 129 +- crates/brk_indexer/src/vecs/blocks.rs | 3 +- crates/brk_indexer/src/vecs/mod.rs | 1 - crates/brk_indexer/src/vecs/outputs.rs | 7 +- crates/brk_indexer/src/vecs/scripts.rs | 49 +- .../src/impl/mining/block_rewards.rs | 15 +- crates/brk_query/src/impl/mining/hashrate.rs | 3 +- crates/brk_query/src/impl/series.rs | 21 +- crates/brk_query/src/impl/tx.rs | 13 +- crates/brk_query/src/vecs.rs | 2 +- .../brk_server/src/api/metrics_legacy/mod.rs | 4 +- crates/brk_server/src/api/mod.rs | 6 +- crates/brk_server/src/lib.rs | 2 +- crates/brk_types/src/addr_index_outpoint.rs | 2 +- crates/brk_types/src/basis_points_16.rs | 2 +- crates/brk_types/src/basis_points_32.rs | 2 +- .../brk_types/src/basis_points_signed_16.rs | 2 +- .../brk_types/src/basis_points_signed_32.rs | 2 +- .../brk_types/src/cost_basis_distribution.rs | 3 +- crates/brk_types/src/index.rs | 14 +- crates/brk_types/src/indexes.rs | 3 +- crates/brk_types/src/pagination.rs | 4 +- crates/brk_types/src/series_selection.rs | 2 +- crates/brk_types/src/stored_bool.rs | 13 +- crates/brk_types/src/stored_u16.rs | 4 +- crates/brk_types/src/stored_u32.rs | 4 +- crates/brk_types/src/stored_u64.rs | 4 +- crates/brk_types/src/tree_node.rs | 75 +- 213 files changed, 6888 insertions(+), 2527 deletions(-) diff --git a/crates/brk_bindgen/src/analysis/positions.rs b/crates/brk_bindgen/src/analysis/positions.rs index f74edde0f..aacf370dd 100644 --- a/crates/brk_bindgen/src/analysis/positions.rs +++ b/crates/brk_bindgen/src/analysis/positions.rs @@ -108,7 +108,13 @@ fn fill_mixed_empty_field_parts( // Recurse first (bottom-up) for (field_name, child_node) in children { let child_path = build_child_path(path, field_name); - fill_mixed_empty_field_parts(child_node, &child_path, pattern_lookup, patterns, node_bases); + fill_mixed_empty_field_parts( + child_node, + &child_path, + pattern_lookup, + patterns, + node_bases, + ); } // Check if this node has mixed empty/non-empty field_parts @@ -351,16 +357,18 @@ fn try_embedded_disc( } /// Strategy 2: suffix discriminator (e.g., all field_parts differ by `_4y` suffix) -fn try_suffix_disc( - majority: &[&InstanceAnalysis], - fields: &[PatternField], -) -> Option { +fn try_suffix_disc(majority: &[&InstanceAnalysis], fields: &[PatternField]) -> Option { let first = &majority[0]; // Use a non-empty field to detect the suffix let ref_field = fields .iter() - .find(|f| first.field_parts.get(&f.name).is_some_and(|v| !v.is_empty())) + .find(|f| { + first + .field_parts + .get(&f.name) + .is_some_and(|v| !v.is_empty()) + }) .map(|f| &f.name)?; let ref_first = first.field_parts.get(ref_field)?; @@ -763,19 +771,51 @@ mod tests { fn test_embedded_disc_percentile_bands() { use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "bps".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "price".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "ratio".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "bps".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "price".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "ratio".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; let pct99 = InstanceAnalysis { base: "realized_price".into(), - field_parts: [("bps".into(), "ratio_pct99_bps".into()), ("price".into(), "pct99".into()), ("ratio".into(), "ratio_pct99".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("bps".into(), "ratio_pct99_bps".into()), + ("price".into(), "pct99".into()), + ("ratio".into(), "ratio_pct99".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let pct1 = InstanceAnalysis { base: "realized_price".into(), - field_parts: [("bps".into(), "ratio_pct1_bps".into()), ("price".into(), "pct1".into()), ("ratio".into(), "ratio_pct1".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("bps".into(), "ratio_pct1_bps".into()), + ("price".into(), "pct1".into()), + ("ratio".into(), "ratio_pct1".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let mode = determine_pattern_mode(&[pct99, pct1], &fields); assert!(mode.is_some()); @@ -793,19 +833,51 @@ mod tests { fn test_suffix_disc_period_windows() { use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "p1sd".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "sd".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "zscore".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "p1sd".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "sd".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "zscore".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; let all_time = InstanceAnalysis { base: "realized_price".into(), - field_parts: [("p1sd".into(), "p1sd".into()), ("sd".into(), "ratio_sd".into()), ("zscore".into(), "ratio_zscore".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("p1sd".into(), "p1sd".into()), + ("sd".into(), "ratio_sd".into()), + ("zscore".into(), "ratio_zscore".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let four_year = InstanceAnalysis { base: "realized_price".into(), - field_parts: [("p1sd".into(), "p1sd_4y".into()), ("sd".into(), "ratio_sd_4y".into()), ("zscore".into(), "ratio_zscore_4y".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("p1sd".into(), "p1sd_4y".into()), + ("sd".into(), "ratio_sd_4y".into()), + ("zscore".into(), "ratio_zscore_4y".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let mode = determine_pattern_mode(&[all_time, four_year], &fields); assert!(mode.is_some()); @@ -823,18 +895,39 @@ mod tests { fn test_suffix_disc_with_empty_fields() { use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "band".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "sd".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "band".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "sd".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; let all_time = InstanceAnalysis { base: "price".into(), - field_parts: [("band".into(), "".into()), ("sd".into(), "ratio_sd".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [("band".into(), "".into()), ("sd".into(), "ratio_sd".into())] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let four_year = InstanceAnalysis { base: "price".into(), - field_parts: [("band".into(), "".into()), ("sd".into(), "ratio_sd_4y".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("band".into(), "".into()), + ("sd".into(), "ratio_sd_4y".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let mode = determine_pattern_mode(&[all_time, four_year], &fields); assert!(mode.is_some()); @@ -851,18 +944,39 @@ mod tests { fn test_suffix_disc_empty_to_nonempty() { use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "all".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "sth".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "all".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "sth".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; let regular = InstanceAnalysis { base: "supply".into(), - field_parts: [("all".into(), "".into()), ("sth".into(), "sth_".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [("all".into(), "".into()), ("sth".into(), "sth_".into())] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let profitability = InstanceAnalysis { base: "utxos_in_profit".into(), - field_parts: [("all".into(), "supply".into()), ("sth".into(), "sth_supply".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("all".into(), "supply".into()), + ("sth".into(), "sth_supply".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let mode = determine_pattern_mode(&[regular, profitability], &fields); assert!(mode.is_some()); @@ -879,43 +993,91 @@ mod tests { fn test_outlier_rejects_pattern() { use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "ratio".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "value".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "ratio".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "value".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; // SOPR case: one instance has outlier naming (no common prefix) let normal = InstanceAnalysis { base: "series".into(), - field_parts: [("ratio".into(), "ratio".into()), ("value".into(), "value".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [ + ("ratio".into(), "ratio".into()), + ("value".into(), "value".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let outlier = InstanceAnalysis { base: "".into(), - field_parts: [("ratio".into(), "asopr".into()), ("value".into(), "adj_value".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: true, + field_parts: [ + ("ratio".into(), "asopr".into()), + ("value".into(), "adj_value".into()), + ] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: true, }; let mode = determine_pattern_mode(&[normal, outlier], &fields); - assert!(mode.is_some(), "Outlier should be filtered out, leaving a valid pattern from non-outlier instances"); + assert!( + mode.is_some(), + "Outlier should be filtered out, leaving a valid pattern from non-outlier instances" + ); } #[test] fn test_unanimity_rejects_disagreeing_instances() { use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "a".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "b".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "a".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "b".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; let inst1 = InstanceAnalysis { base: "x".into(), - field_parts: [("a".into(), "foo".into()), ("b".into(), "bar".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [("a".into(), "foo".into()), ("b".into(), "bar".into())] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let inst2 = InstanceAnalysis { base: "y".into(), - field_parts: [("a".into(), "baz".into()), ("b".into(), "qux".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [("a".into(), "baz".into()), ("b".into(), "qux".into())] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let mode = determine_pattern_mode(&[inst1, inst2], &fields); - assert!(mode.is_none(), "Should be non-parameterizable when no pattern detected"); + assert!( + mode.is_none(), + "Should be non-parameterizable when no pattern detected" + ); } #[test] @@ -925,20 +1087,43 @@ mod tests { // Should keep identity (empty parts) so both children receive acc unchanged. use std::collections::BTreeSet; let fields = vec![ - PatternField { name: "absolute".into(), rust_type: "TypeA".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "rate".into(), rust_type: "TypeB".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "absolute".into(), + rust_type: "TypeA".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "rate".into(), + rust_type: "TypeB".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ]; let inst = InstanceAnalysis { base: "supply_delta".into(), - field_parts: [("absolute".into(), "".into()), ("rate".into(), "".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: false, + field_parts: [("absolute".into(), "".into()), ("rate".into(), "".into())] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: false, }; let mode = determine_pattern_mode(&[inst], &fields); assert!(mode.is_some()); match mode.unwrap() { PatternMode::Suffix { relatives } => { - assert_eq!(relatives.get("absolute"), Some(&"".to_string()), "absolute should be identity"); - assert_eq!(relatives.get("rate"), Some(&"".to_string()), "rate should be identity"); + assert_eq!( + relatives.get("absolute"), + Some(&"".to_string()), + "absolute should be identity" + ); + assert_eq!( + relatives.get("rate"), + Some(&"".to_string()), + "rate should be identity" + ); } other => panic!("Expected Suffix with identity, got {:?}", other), } @@ -975,16 +1160,26 @@ mod tests { // Parent patterns containing non-parameterizable children should also // be detected via metadata.is_parameterizable (recursive check). use std::collections::BTreeSet; - let fields = vec![ - PatternField { name: "a".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - ]; + let fields = vec![PatternField { + name: "a".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }]; let inst = InstanceAnalysis { base: "".into(), - field_parts: [("a".into(), "standalone_name".into())].into_iter().collect(), - is_suffix_mode: true, has_outlier: true, + field_parts: [("a".into(), "standalone_name".into())] + .into_iter() + .collect(), + is_suffix_mode: true, + has_outlier: true, }; let mode = determine_pattern_mode(&[inst], &fields); - assert!(mode.is_none(), "Pattern with outlier should be non-parameterizable"); + assert!( + mode.is_none(), + "Pattern with outlier should be non-parameterizable" + ); } #[test] @@ -998,9 +1193,27 @@ mod tests { let pattern = StructuralPattern { name: "TestPattern".into(), fields: vec![ - PatternField { name: "_0sd".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "p1sd".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, - PatternField { name: "sd".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), type_param: None }, + PatternField { + name: "_0sd".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "p1sd".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, + PatternField { + name: "sd".into(), + rust_type: "T".into(), + json_type: "n".into(), + indexes: BTreeSet::new(), + type_param: None, + }, ], mode: Some(PatternMode::Templated { templates: [ @@ -1059,9 +1272,15 @@ mod tests { assert_eq!(analysis.field_parts.get("loss"), Some(&"".to_string())); assert_eq!(analysis.field_parts.get("supply"), Some(&"".to_string())); // others should be non-empty - assert_eq!(analysis.field_parts.get("cap"), Some(&"realized_cap".to_string())); + assert_eq!( + analysis.field_parts.get("cap"), + Some(&"realized_cap".to_string()) + ); assert_eq!(analysis.field_parts.get("mvrv"), Some(&"mvrv".to_string())); - assert_eq!(analysis.field_parts.get("price"), Some(&"realized_price".to_string())); + assert_eq!( + analysis.field_parts.get("price"), + Some(&"realized_price".to_string()) + ); } #[test] @@ -1111,12 +1330,20 @@ mod tests { &mut path_to_pattern, ); - let result = node_bases.get("test").expect("should have node_bases entry"); + let result = node_bases + .get("test") + .expect("should have node_bases entry"); assert_eq!(result.base, "utxos"); assert!(!result.has_outlier); - assert_eq!(result.field_parts.get("cap"), Some(&"realized_cap".to_string())); + assert_eq!( + result.field_parts.get("cap"), + Some(&"realized_cap".to_string()) + ); assert_eq!(result.field_parts.get("mvrv"), Some(&"mvrv".to_string())); // loss branch returns base "utxos_realized_loss" which yields field_part "realized_loss" - assert_eq!(result.field_parts.get("loss"), Some(&"realized_loss".to_string())); + assert_eq!( + result.field_parts.get("loss"), + Some(&"realized_loss".to_string()) + ); } } diff --git a/crates/brk_bindgen/src/generate/constants.rs b/crates/brk_bindgen/src/generate/constants.rs index d9f40d26f..f00953efb 100644 --- a/crates/brk_bindgen/src/generate/constants.rs +++ b/crates/brk_bindgen/src/generate/constants.rs @@ -6,9 +6,9 @@ use std::collections::BTreeMap; use brk_cohort::{ - AGE_RANGE_NAMES, AMOUNT_RANGE_NAMES, CLASS_NAMES, EPOCH_NAMES, LOSS_NAMES, - OVER_AGE_NAMES, OVER_AMOUNT_NAMES, PROFITABILITY_RANGE_NAMES, PROFIT_NAMES, - SPENDABLE_TYPE_NAMES, TERM_NAMES, UNDER_AGE_NAMES, UNDER_AMOUNT_NAMES, + AGE_RANGE_NAMES, AMOUNT_RANGE_NAMES, CLASS_NAMES, EPOCH_NAMES, LOSS_NAMES, OVER_AGE_NAMES, + OVER_AMOUNT_NAMES, PROFIT_NAMES, PROFITABILITY_RANGE_NAMES, SPENDABLE_TYPE_NAMES, TERM_NAMES, + UNDER_AGE_NAMES, UNDER_AMOUNT_NAMES, }; use brk_types::{Index, PoolSlug, pools}; use serde::Serialize; @@ -64,7 +64,10 @@ impl CohortConstants { ("AMOUNT_RANGE_NAMES", to_value(&AMOUNT_RANGE_NAMES)), ("OVER_AMOUNT_NAMES", to_value(&OVER_AMOUNT_NAMES)), ("UNDER_AMOUNT_NAMES", to_value(&UNDER_AMOUNT_NAMES)), - ("PROFITABILITY_RANGE_NAMES", to_value(&PROFITABILITY_RANGE_NAMES)), + ( + "PROFITABILITY_RANGE_NAMES", + to_value(&PROFITABILITY_RANGE_NAMES), + ), ("PROFIT_NAMES", to_value(&PROFIT_NAMES)), ("LOSS_NAMES", to_value(&LOSS_NAMES)), ] diff --git a/crates/brk_bindgen/src/generate/fields.rs b/crates/brk_bindgen/src/generate/fields.rs index 7a9509d3a..297c20078 100644 --- a/crates/brk_bindgen/src/generate/fields.rs +++ b/crates/brk_bindgen/src/generate/fields.rs @@ -8,7 +8,9 @@ use std::fmt::Write; use brk_types::SeriesLeafWithSchema; -use crate::{ClientMetadata, LanguageSyntax, PatternBaseResult, PatternField, PatternMode, StructuralPattern}; +use crate::{ + ClientMetadata, LanguageSyntax, PatternBaseResult, PatternField, PatternMode, StructuralPattern, +}; /// Create a path suffix from a name. fn path_suffix(name: &str) -> String { @@ -33,9 +35,7 @@ fn compute_parameterized_value( if let Some(child_pattern) = metadata.find_pattern(&field.rust_type) && child_pattern.is_templated() { - let disc_template = pattern - .get_field_part(&field.name) - .unwrap_or(&field.name); + let disc_template = pattern.get_field_part(&field.name).unwrap_or(&field.name); let disc_arg = syntax.disc_arg_expr(disc_template); let acc_arg = syntax.owned_expr("acc"); return syntax.constructor(&field.rust_type, &format!("{acc_arg}, {disc_arg}")); diff --git a/crates/brk_bindgen/src/generate/tree.rs b/crates/brk_bindgen/src/generate/tree.rs index ad8706293..f325cbee8 100644 --- a/crates/brk_bindgen/src/generate/tree.rs +++ b/crates/brk_bindgen/src/generate/tree.rs @@ -125,8 +125,8 @@ pub fn prepare_tree_node<'a>( p.is_suffix_mode() == base_result.is_suffix_mode && p.field_parts_match(&base_result.field_parts) }); - let is_parameterizable = matching_pattern - .is_none_or(|p| metadata.is_parameterizable(&p.name)); + let is_parameterizable = + matching_pattern.is_none_or(|p| metadata.is_parameterizable(&p.name)); // should_inline determines if we generate an inline struct type let should_inline = !is_leaf diff --git a/crates/brk_bindgen/src/generators/javascript/client.rs b/crates/brk_bindgen/src/generators/javascript/client.rs index fadf4bcb4..ba8f285a4 100644 --- a/crates/brk_bindgen/src/generators/javascript/client.rs +++ b/crates/brk_bindgen/src/generators/javascript/client.rs @@ -726,7 +726,12 @@ pub fn generate_structural_patterns( writeln!(output, " */").unwrap(); if pattern.is_templated() { - writeln!(output, "function create{}(client, acc, disc) {{", pattern.name).unwrap(); + writeln!( + output, + "function create{}(client, acc, disc) {{", + pattern.name + ) + .unwrap(); } else { writeln!(output, "function create{}(client, acc) {{", pattern.name).unwrap(); } diff --git a/crates/brk_bindgen/src/generators/python/api.rs b/crates/brk_bindgen/src/generators/python/api.rs index db0137c62..b4e45c4ce 100644 --- a/crates/brk_bindgen/src/generators/python/api.rs +++ b/crates/brk_bindgen/src/generators/python/api.rs @@ -56,11 +56,7 @@ pub fn generate_main_client(output: &mut String, endpoints: &[Endpoint]) { ) .unwrap(); writeln!(output, " \"\"\"").unwrap(); - writeln!( - output, - " return SeriesEndpoint(self, series, index)" - ) - .unwrap(); + writeln!(output, " return SeriesEndpoint(self, series, index)").unwrap(); writeln!(output).unwrap(); // Generate helper methods diff --git a/crates/brk_bindgen/src/generators/python/client.rs b/crates/brk_bindgen/src/generators/python/client.rs index 3721aa9e3..4a2294619 100644 --- a/crates/brk_bindgen/src/generators/python/client.rs +++ b/crates/brk_bindgen/src/generators/python/client.rs @@ -684,7 +684,6 @@ pub fn generate_structural_patterns( writeln!(output, "# Reusable structural pattern classes\n").unwrap(); for pattern in patterns { - // Generate class if pattern.is_generic { writeln!(output, "class {}(Generic[T]):", pattern.name).unwrap(); diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 91a0197c1..d0962e57f 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -7,12 +7,11 @@ #![allow(clippy::useless_format)] #![allow(clippy::unnecessary_to_owned)] -use std::sync::Arc; -use std::ops::{Bound, RangeBounds}; -use serde::de::DeserializeOwned; pub use brk_cohort::*; pub use brk_types::*; - +use serde::de::DeserializeOwned; +use std::ops::{Bound, RangeBounds}; +use std::sync::Arc; /// Error type for BRK client operations. #[derive(Debug)] @@ -57,7 +56,10 @@ pub struct BrkClientBase { impl BrkClientBase { /// Create a new client with the given base URL. pub fn new(base_url: impl Into) -> Self { - Self::with_options(BrkClientOptions { base_url: base_url.into(), ..Default::default() }) + Self::with_options(BrkClientOptions { + base_url: base_url.into(), + ..Default::default() + }) } /// Create a new client with options. @@ -78,36 +80,49 @@ impl BrkClientBase { /// Make a GET request and deserialize JSON response. pub fn get_json(&self, path: &str) -> Result { - self.agent.get(&self.url(path)) + self.agent + .get(&self.url(path)) .call() .and_then(|mut r| r.body_mut().read_json()) - .map_err(|e| BrkError { message: e.to_string() }) + .map_err(|e| BrkError { + message: e.to_string(), + }) } /// Make a GET request and return raw text response. pub fn get_text(&self, path: &str) -> Result { - self.agent.get(&self.url(path)) + self.agent + .get(&self.url(path)) .call() .and_then(|mut r| r.body_mut().read_to_string()) - .map_err(|e| BrkError { message: e.to_string() }) + .map_err(|e| BrkError { + message: e.to_string(), + }) } } /// Build series name with suffix. #[inline] fn _m(acc: &str, s: &str) -> String { - if s.is_empty() { acc.to_string() } - else if acc.is_empty() { s.to_string() } - else { format!("{acc}_{s}") } + if s.is_empty() { + acc.to_string() + } else if acc.is_empty() { + s.to_string() + } else { + format!("{acc}_{s}") + } } /// Build series name with prefix. #[inline] fn _p(prefix: &str, acc: &str) -> String { - if acc.is_empty() { prefix.to_string() } else { format!("{prefix}_{acc}") } + if acc.is_empty() { + prefix.to_string() + } else { + format!("{prefix}_{acc}") + } } - /// Non-generic trait for series patterns (usable in collections). pub trait AnySeriesPattern { /// Get the series name. @@ -123,7 +138,6 @@ pub trait SeriesPattern: AnySeriesPattern { fn get(&self, index: Index) -> Option>; } - /// Shared endpoint configuration. #[derive(Clone)] struct EndpointConfig { @@ -136,7 +150,13 @@ struct EndpointConfig { impl EndpointConfig { fn new(client: Arc, name: Arc, index: Index) -> Self { - Self { client, name, index, start: None, end: None } + Self { + client, + name, + index, + start: None, + end: None, + } } fn path(&self) -> String { @@ -145,11 +165,21 @@ impl EndpointConfig { fn build_path(&self, format: Option<&str>) -> String { let mut params = Vec::new(); - if let Some(s) = self.start { params.push(format!("start={}", s)); } - if let Some(e) = self.end { params.push(format!("end={}", e)); } - if let Some(fmt) = format { params.push(format!("format={}", fmt)); } + if let Some(s) = self.start { + params.push(format!("start={}", s)); + } + if let Some(e) = self.end { + params.push(format!("end={}", e)); + } + if let Some(fmt) = format { + params.push(format!("format={}", fmt)); + } let p = self.path(); - if params.is_empty() { p } else { format!("{}?{}", p, params.join("&")) } + if params.is_empty() { + p + } else { + format!("{}?{}", p, params.join("&")) + } } fn get_json(&self, format: Option<&str>) -> Result { @@ -189,14 +219,20 @@ pub type DateSeriesEndpoint = SeriesEndpoint>; impl SeriesEndpoint { pub fn new(client: Arc, name: Arc, index: Index) -> Self { - Self { config: EndpointConfig::new(client, name, index), _marker: std::marker::PhantomData } + Self { + config: EndpointConfig::new(client, name, index), + _marker: std::marker::PhantomData, + } } /// Select a specific index position. pub fn get(mut self, index: usize) -> SingleItemBuilder { self.config.start = Some(index as i64); self.config.end = Some(index as i64 + 1); - SingleItemBuilder { config: self.config, _marker: std::marker::PhantomData } + SingleItemBuilder { + config: self.config, + _marker: std::marker::PhantomData, + } } /// Select a range using Rust range syntax. @@ -218,7 +254,10 @@ impl SeriesEndpoint { Bound::Excluded(&n) => Some(n as i64), Bound::Unbounded => None, }; - RangeBuilder { config: self.config, _marker: std::marker::PhantomData } + RangeBuilder { + config: self.config, + _marker: std::marker::PhantomData, + } } /// Take the first n items. @@ -233,13 +272,19 @@ impl SeriesEndpoint { } else { self.config.start = Some(-(n as i64)); } - RangeBuilder { config: self.config, _marker: std::marker::PhantomData } + RangeBuilder { + config: self.config, + _marker: std::marker::PhantomData, + } } /// Skip the first n items. Chain with `take(n)` to get a range. pub fn skip(mut self, n: usize) -> SkippedBuilder { self.config.start = Some(n as i64); - SkippedBuilder { config: self.config, _marker: std::marker::PhantomData } + SkippedBuilder { + config: self.config, + _marker: std::marker::PhantomData, + } } /// Fetch all data as parsed JSON. @@ -280,7 +325,11 @@ impl SeriesEndpoint> { } /// Select a timestamp range (works for all date-based indexes including sub-daily). - pub fn timestamp_range(self, start: Timestamp, end: Timestamp) -> RangeBuilder> { + pub fn timestamp_range( + self, + start: Timestamp, + end: Timestamp, + ) -> RangeBuilder> { let s = self.config.index.timestamp_to_index(start).unwrap_or(0); let e = self.config.index.timestamp_to_index(end).unwrap_or(0); self.range(s..e) @@ -322,7 +371,10 @@ impl SkippedBuilder { pub fn take(mut self, n: usize) -> RangeBuilder { let start = self.config.start.unwrap_or(0); self.config.end = Some(start + n as i64); - RangeBuilder { config: self.config, _marker: std::marker::PhantomData } + RangeBuilder { + config: self.config, + _marker: std::marker::PhantomData, + } } /// Fetch from the skipped position to the end. @@ -357,10 +409,42 @@ impl RangeBuilder { } } - // Static index arrays -const _I1: &[Index] = &[Index::Minute10, Index::Minute30, Index::Hour1, Index::Hour4, Index::Hour12, Index::Day1, Index::Day3, Index::Week1, Index::Month1, Index::Month3, Index::Month6, Index::Year1, Index::Year10, Index::Halving, Index::Epoch, Index::Height]; -const _I2: &[Index] = &[Index::Minute10, Index::Minute30, Index::Hour1, Index::Hour4, Index::Hour12, Index::Day1, Index::Day3, Index::Week1, Index::Month1, Index::Month3, Index::Month6, Index::Year1, Index::Year10, Index::Halving, Index::Epoch]; +const _I1: &[Index] = &[ + Index::Minute10, + Index::Minute30, + Index::Hour1, + Index::Hour4, + Index::Hour12, + Index::Day1, + Index::Day3, + Index::Week1, + Index::Month1, + Index::Month3, + Index::Month6, + Index::Year1, + Index::Year10, + Index::Halving, + Index::Epoch, + Index::Height, +]; +const _I2: &[Index] = &[ + Index::Minute10, + Index::Minute30, + Index::Hour1, + Index::Hour4, + Index::Hour12, + Index::Day1, + Index::Day3, + Index::Week1, + Index::Month1, + Index::Month3, + Index::Month6, + Index::Year1, + Index::Year10, + Index::Halving, + Index::Epoch, +]; const _I3: &[Index] = &[Index::Minute10]; const _I4: &[Index] = &[Index::Minute30]; const _I5: &[Index] = &[Index::Hour1]; @@ -401,535 +485,1753 @@ fn _ep(c: &Arc, n: &Arc, i: Index) -> S } #[inline] -fn _dep(c: &Arc, n: &Arc, i: Index) -> DateSeriesEndpoint { +fn _dep( + c: &Arc, + n: &Arc, + i: Index, +) -> DateSeriesEndpoint { DateSeriesEndpoint::new(c.clone(), n.clone(), i) } // Index accessor structs -pub struct SeriesPattern1By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern1By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern1By { - pub fn minute10(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Minute10) } - pub fn minute30(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Minute30) } - pub fn hour1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour1) } - pub fn hour4(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour4) } - pub fn hour12(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour12) } - pub fn day1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Day1) } - pub fn day3(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Day3) } - pub fn week1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Week1) } - pub fn month1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month1) } - pub fn month3(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month3) } - pub fn month6(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month6) } - pub fn year1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Year1) } - pub fn year10(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Year10) } - pub fn halving(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Halving) } - pub fn epoch(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Epoch) } - pub fn height(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Height) } + pub fn minute10(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Minute10) + } + pub fn minute30(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Minute30) + } + pub fn hour1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour1) + } + pub fn hour4(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour4) + } + pub fn hour12(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour12) + } + pub fn day1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Day1) + } + pub fn day3(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Day3) + } + pub fn week1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Week1) + } + pub fn month1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month1) + } + pub fn month3(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month3) + } + pub fn month6(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month6) + } + pub fn year1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Year1) + } + pub fn year10(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Year10) + } + pub fn halving(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Halving) + } + pub fn epoch(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Epoch) + } + pub fn height(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Height) + } } -pub struct SeriesPattern1 { name: Arc, pub by: SeriesPattern1By } +pub struct SeriesPattern1 { + name: Arc, + pub by: SeriesPattern1By, +} impl SeriesPattern1 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern1By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern1By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern1 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I1 } } -impl SeriesPattern for SeriesPattern1 { fn get(&self, index: Index) -> Option> { _I1.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern1 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I1 + } +} +impl SeriesPattern for SeriesPattern1 { + fn get(&self, index: Index) -> Option> { + _I1.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern2By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern2By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern2By { - pub fn minute10(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Minute10) } - pub fn minute30(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Minute30) } - pub fn hour1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour1) } - pub fn hour4(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour4) } - pub fn hour12(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour12) } - pub fn day1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Day1) } - pub fn day3(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Day3) } - pub fn week1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Week1) } - pub fn month1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month1) } - pub fn month3(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month3) } - pub fn month6(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month6) } - pub fn year1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Year1) } - pub fn year10(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Year10) } - pub fn halving(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Halving) } - pub fn epoch(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Epoch) } + pub fn minute10(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Minute10) + } + pub fn minute30(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Minute30) + } + pub fn hour1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour1) + } + pub fn hour4(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour4) + } + pub fn hour12(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour12) + } + pub fn day1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Day1) + } + pub fn day3(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Day3) + } + pub fn week1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Week1) + } + pub fn month1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month1) + } + pub fn month3(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month3) + } + pub fn month6(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month6) + } + pub fn year1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Year1) + } + pub fn year10(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Year10) + } + pub fn halving(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Halving) + } + pub fn epoch(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Epoch) + } } -pub struct SeriesPattern2 { name: Arc, pub by: SeriesPattern2By } +pub struct SeriesPattern2 { + name: Arc, + pub by: SeriesPattern2By, +} impl SeriesPattern2 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern2By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern2By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern2 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I2 } } -impl SeriesPattern for SeriesPattern2 { fn get(&self, index: Index) -> Option> { _I2.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern2 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I2 + } +} +impl SeriesPattern for SeriesPattern2 { + fn get(&self, index: Index) -> Option> { + _I2.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern3By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern3By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern3By { - pub fn minute10(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Minute10) } + pub fn minute10(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Minute10) + } } -pub struct SeriesPattern3 { name: Arc, pub by: SeriesPattern3By } +pub struct SeriesPattern3 { + name: Arc, + pub by: SeriesPattern3By, +} impl SeriesPattern3 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern3By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern3By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern3 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I3 } } -impl SeriesPattern for SeriesPattern3 { fn get(&self, index: Index) -> Option> { _I3.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern3 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I3 + } +} +impl SeriesPattern for SeriesPattern3 { + fn get(&self, index: Index) -> Option> { + _I3.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern4By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern4By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern4By { - pub fn minute30(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Minute30) } + pub fn minute30(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Minute30) + } } -pub struct SeriesPattern4 { name: Arc, pub by: SeriesPattern4By } +pub struct SeriesPattern4 { + name: Arc, + pub by: SeriesPattern4By, +} impl SeriesPattern4 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern4By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern4By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern4 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I4 } } -impl SeriesPattern for SeriesPattern4 { fn get(&self, index: Index) -> Option> { _I4.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern4 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I4 + } +} +impl SeriesPattern for SeriesPattern4 { + fn get(&self, index: Index) -> Option> { + _I4.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern5By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern5By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern5By { - pub fn hour1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour1) } + pub fn hour1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour1) + } } -pub struct SeriesPattern5 { name: Arc, pub by: SeriesPattern5By } +pub struct SeriesPattern5 { + name: Arc, + pub by: SeriesPattern5By, +} impl SeriesPattern5 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern5By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern5By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern5 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I5 } } -impl SeriesPattern for SeriesPattern5 { fn get(&self, index: Index) -> Option> { _I5.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern5 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I5 + } +} +impl SeriesPattern for SeriesPattern5 { + fn get(&self, index: Index) -> Option> { + _I5.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern6By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern6By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern6By { - pub fn hour4(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour4) } + pub fn hour4(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour4) + } } -pub struct SeriesPattern6 { name: Arc, pub by: SeriesPattern6By } +pub struct SeriesPattern6 { + name: Arc, + pub by: SeriesPattern6By, +} impl SeriesPattern6 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern6By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern6By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern6 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I6 } } -impl SeriesPattern for SeriesPattern6 { fn get(&self, index: Index) -> Option> { _I6.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern6 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I6 + } +} +impl SeriesPattern for SeriesPattern6 { + fn get(&self, index: Index) -> Option> { + _I6.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern7By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern7By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern7By { - pub fn hour12(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Hour12) } + pub fn hour12(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Hour12) + } } -pub struct SeriesPattern7 { name: Arc, pub by: SeriesPattern7By } +pub struct SeriesPattern7 { + name: Arc, + pub by: SeriesPattern7By, +} impl SeriesPattern7 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern7By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern7By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern7 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I7 } } -impl SeriesPattern for SeriesPattern7 { fn get(&self, index: Index) -> Option> { _I7.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern7 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I7 + } +} +impl SeriesPattern for SeriesPattern7 { + fn get(&self, index: Index) -> Option> { + _I7.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern8By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern8By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern8By { - pub fn day1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Day1) } + pub fn day1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Day1) + } } -pub struct SeriesPattern8 { name: Arc, pub by: SeriesPattern8By } +pub struct SeriesPattern8 { + name: Arc, + pub by: SeriesPattern8By, +} impl SeriesPattern8 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern8By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern8By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern8 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I8 } } -impl SeriesPattern for SeriesPattern8 { fn get(&self, index: Index) -> Option> { _I8.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern8 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I8 + } +} +impl SeriesPattern for SeriesPattern8 { + fn get(&self, index: Index) -> Option> { + _I8.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern9By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern9By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern9By { - pub fn day3(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Day3) } + pub fn day3(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Day3) + } } -pub struct SeriesPattern9 { name: Arc, pub by: SeriesPattern9By } +pub struct SeriesPattern9 { + name: Arc, + pub by: SeriesPattern9By, +} impl SeriesPattern9 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern9By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern9By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern9 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I9 } } -impl SeriesPattern for SeriesPattern9 { fn get(&self, index: Index) -> Option> { _I9.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern9 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I9 + } +} +impl SeriesPattern for SeriesPattern9 { + fn get(&self, index: Index) -> Option> { + _I9.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern10By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern10By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern10By { - pub fn week1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Week1) } + pub fn week1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Week1) + } } -pub struct SeriesPattern10 { name: Arc, pub by: SeriesPattern10By } +pub struct SeriesPattern10 { + name: Arc, + pub by: SeriesPattern10By, +} impl SeriesPattern10 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern10By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern10By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern10 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I10 } } -impl SeriesPattern for SeriesPattern10 { fn get(&self, index: Index) -> Option> { _I10.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern10 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I10 + } +} +impl SeriesPattern for SeriesPattern10 { + fn get(&self, index: Index) -> Option> { + _I10.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern11By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern11By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern11By { - pub fn month1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month1) } + pub fn month1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month1) + } } -pub struct SeriesPattern11 { name: Arc, pub by: SeriesPattern11By } +pub struct SeriesPattern11 { + name: Arc, + pub by: SeriesPattern11By, +} impl SeriesPattern11 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern11By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern11By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern11 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I11 } } -impl SeriesPattern for SeriesPattern11 { fn get(&self, index: Index) -> Option> { _I11.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern11 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I11 + } +} +impl SeriesPattern for SeriesPattern11 { + fn get(&self, index: Index) -> Option> { + _I11.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern12By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern12By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern12By { - pub fn month3(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month3) } + pub fn month3(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month3) + } } -pub struct SeriesPattern12 { name: Arc, pub by: SeriesPattern12By } +pub struct SeriesPattern12 { + name: Arc, + pub by: SeriesPattern12By, +} impl SeriesPattern12 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern12By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern12By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern12 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I12 } } -impl SeriesPattern for SeriesPattern12 { fn get(&self, index: Index) -> Option> { _I12.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern12 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I12 + } +} +impl SeriesPattern for SeriesPattern12 { + fn get(&self, index: Index) -> Option> { + _I12.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern13By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern13By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern13By { - pub fn month6(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Month6) } + pub fn month6(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Month6) + } } -pub struct SeriesPattern13 { name: Arc, pub by: SeriesPattern13By } +pub struct SeriesPattern13 { + name: Arc, + pub by: SeriesPattern13By, +} impl SeriesPattern13 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern13By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern13By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern13 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I13 } } -impl SeriesPattern for SeriesPattern13 { fn get(&self, index: Index) -> Option> { _I13.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern13 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I13 + } +} +impl SeriesPattern for SeriesPattern13 { + fn get(&self, index: Index) -> Option> { + _I13.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern14By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern14By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern14By { - pub fn year1(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Year1) } + pub fn year1(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Year1) + } } -pub struct SeriesPattern14 { name: Arc, pub by: SeriesPattern14By } +pub struct SeriesPattern14 { + name: Arc, + pub by: SeriesPattern14By, +} impl SeriesPattern14 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern14By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern14By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern14 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I14 } } -impl SeriesPattern for SeriesPattern14 { fn get(&self, index: Index) -> Option> { _I14.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern14 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I14 + } +} +impl SeriesPattern for SeriesPattern14 { + fn get(&self, index: Index) -> Option> { + _I14.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern15By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern15By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern15By { - pub fn year10(&self) -> DateSeriesEndpoint { _dep(&self.client, &self.name, Index::Year10) } + pub fn year10(&self) -> DateSeriesEndpoint { + _dep(&self.client, &self.name, Index::Year10) + } } -pub struct SeriesPattern15 { name: Arc, pub by: SeriesPattern15By } +pub struct SeriesPattern15 { + name: Arc, + pub by: SeriesPattern15By, +} impl SeriesPattern15 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern15By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern15By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern15 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I15 } } -impl SeriesPattern for SeriesPattern15 { fn get(&self, index: Index) -> Option> { _I15.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern15 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I15 + } +} +impl SeriesPattern for SeriesPattern15 { + fn get(&self, index: Index) -> Option> { + _I15.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern16By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern16By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern16By { - pub fn halving(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Halving) } + pub fn halving(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Halving) + } } -pub struct SeriesPattern16 { name: Arc, pub by: SeriesPattern16By } +pub struct SeriesPattern16 { + name: Arc, + pub by: SeriesPattern16By, +} impl SeriesPattern16 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern16By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern16By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern16 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I16 } } -impl SeriesPattern for SeriesPattern16 { fn get(&self, index: Index) -> Option> { _I16.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern16 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I16 + } +} +impl SeriesPattern for SeriesPattern16 { + fn get(&self, index: Index) -> Option> { + _I16.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern17By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern17By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern17By { - pub fn epoch(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Epoch) } + pub fn epoch(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Epoch) + } } -pub struct SeriesPattern17 { name: Arc, pub by: SeriesPattern17By } +pub struct SeriesPattern17 { + name: Arc, + pub by: SeriesPattern17By, +} impl SeriesPattern17 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern17By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern17By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern17 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I17 } } -impl SeriesPattern for SeriesPattern17 { fn get(&self, index: Index) -> Option> { _I17.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern17 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I17 + } +} +impl SeriesPattern for SeriesPattern17 { + fn get(&self, index: Index) -> Option> { + _I17.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern18By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern18By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern18By { - pub fn height(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::Height) } + pub fn height(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::Height) + } } -pub struct SeriesPattern18 { name: Arc, pub by: SeriesPattern18By } +pub struct SeriesPattern18 { + name: Arc, + pub by: SeriesPattern18By, +} impl SeriesPattern18 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern18By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern18By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern18 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I18 } } -impl SeriesPattern for SeriesPattern18 { fn get(&self, index: Index) -> Option> { _I18.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern18 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I18 + } +} +impl SeriesPattern for SeriesPattern18 { + fn get(&self, index: Index) -> Option> { + _I18.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern19By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern19By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern19By { - pub fn tx_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::TxIndex) } + pub fn tx_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::TxIndex) + } } -pub struct SeriesPattern19 { name: Arc, pub by: SeriesPattern19By } +pub struct SeriesPattern19 { + name: Arc, + pub by: SeriesPattern19By, +} impl SeriesPattern19 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern19By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern19By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern19 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I19 } } -impl SeriesPattern for SeriesPattern19 { fn get(&self, index: Index) -> Option> { _I19.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern19 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I19 + } +} +impl SeriesPattern for SeriesPattern19 { + fn get(&self, index: Index) -> Option> { + _I19.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern20By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern20By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern20By { - pub fn txin_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::TxInIndex) } + pub fn txin_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::TxInIndex) + } } -pub struct SeriesPattern20 { name: Arc, pub by: SeriesPattern20By } +pub struct SeriesPattern20 { + name: Arc, + pub by: SeriesPattern20By, +} impl SeriesPattern20 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern20By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern20By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern20 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I20 } } -impl SeriesPattern for SeriesPattern20 { fn get(&self, index: Index) -> Option> { _I20.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern20 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I20 + } +} +impl SeriesPattern for SeriesPattern20 { + fn get(&self, index: Index) -> Option> { + _I20.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern21By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern21By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern21By { - pub fn txout_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::TxOutIndex) } + pub fn txout_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::TxOutIndex) + } } -pub struct SeriesPattern21 { name: Arc, pub by: SeriesPattern21By } +pub struct SeriesPattern21 { + name: Arc, + pub by: SeriesPattern21By, +} impl SeriesPattern21 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern21By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern21By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern21 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I21 } } -impl SeriesPattern for SeriesPattern21 { fn get(&self, index: Index) -> Option> { _I21.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern21 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I21 + } +} +impl SeriesPattern for SeriesPattern21 { + fn get(&self, index: Index) -> Option> { + _I21.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern22By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern22By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern22By { - pub fn empty_output_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::EmptyOutputIndex) } + pub fn empty_output_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::EmptyOutputIndex) + } } -pub struct SeriesPattern22 { name: Arc, pub by: SeriesPattern22By } +pub struct SeriesPattern22 { + name: Arc, + pub by: SeriesPattern22By, +} impl SeriesPattern22 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern22By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern22By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern22 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I22 } } -impl SeriesPattern for SeriesPattern22 { fn get(&self, index: Index) -> Option> { _I22.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern22 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I22 + } +} +impl SeriesPattern for SeriesPattern22 { + fn get(&self, index: Index) -> Option> { + _I22.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern23By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern23By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern23By { - pub fn op_return_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::OpReturnIndex) } + pub fn op_return_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::OpReturnIndex) + } } -pub struct SeriesPattern23 { name: Arc, pub by: SeriesPattern23By } +pub struct SeriesPattern23 { + name: Arc, + pub by: SeriesPattern23By, +} impl SeriesPattern23 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern23By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern23By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern23 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I23 } } -impl SeriesPattern for SeriesPattern23 { fn get(&self, index: Index) -> Option> { _I23.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern23 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I23 + } +} +impl SeriesPattern for SeriesPattern23 { + fn get(&self, index: Index) -> Option> { + _I23.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern24By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern24By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern24By { - pub fn p2a_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2AAddrIndex) } + pub fn p2a_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2AAddrIndex) + } } -pub struct SeriesPattern24 { name: Arc, pub by: SeriesPattern24By } +pub struct SeriesPattern24 { + name: Arc, + pub by: SeriesPattern24By, +} impl SeriesPattern24 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern24By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern24By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern24 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I24 } } -impl SeriesPattern for SeriesPattern24 { fn get(&self, index: Index) -> Option> { _I24.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern24 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I24 + } +} +impl SeriesPattern for SeriesPattern24 { + fn get(&self, index: Index) -> Option> { + _I24.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern25By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern25By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern25By { - pub fn p2ms_output_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2MSOutputIndex) } + pub fn p2ms_output_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2MSOutputIndex) + } } -pub struct SeriesPattern25 { name: Arc, pub by: SeriesPattern25By } +pub struct SeriesPattern25 { + name: Arc, + pub by: SeriesPattern25By, +} impl SeriesPattern25 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern25By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern25By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern25 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I25 } } -impl SeriesPattern for SeriesPattern25 { fn get(&self, index: Index) -> Option> { _I25.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern25 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I25 + } +} +impl SeriesPattern for SeriesPattern25 { + fn get(&self, index: Index) -> Option> { + _I25.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern26By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern26By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern26By { - pub fn p2pk33_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PK33AddrIndex) } + pub fn p2pk33_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2PK33AddrIndex) + } } -pub struct SeriesPattern26 { name: Arc, pub by: SeriesPattern26By } +pub struct SeriesPattern26 { + name: Arc, + pub by: SeriesPattern26By, +} impl SeriesPattern26 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern26By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern26By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern26 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I26 } } -impl SeriesPattern for SeriesPattern26 { fn get(&self, index: Index) -> Option> { _I26.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern26 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I26 + } +} +impl SeriesPattern for SeriesPattern26 { + fn get(&self, index: Index) -> Option> { + _I26.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern27By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern27By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern27By { - pub fn p2pk65_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PK65AddrIndex) } + pub fn p2pk65_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2PK65AddrIndex) + } } -pub struct SeriesPattern27 { name: Arc, pub by: SeriesPattern27By } +pub struct SeriesPattern27 { + name: Arc, + pub by: SeriesPattern27By, +} impl SeriesPattern27 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern27By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern27By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern27 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I27 } } -impl SeriesPattern for SeriesPattern27 { fn get(&self, index: Index) -> Option> { _I27.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern27 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I27 + } +} +impl SeriesPattern for SeriesPattern27 { + fn get(&self, index: Index) -> Option> { + _I27.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern28By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern28By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern28By { - pub fn p2pkh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PKHAddrIndex) } + pub fn p2pkh_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2PKHAddrIndex) + } } -pub struct SeriesPattern28 { name: Arc, pub by: SeriesPattern28By } +pub struct SeriesPattern28 { + name: Arc, + pub by: SeriesPattern28By, +} impl SeriesPattern28 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern28By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern28By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern28 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I28 } } -impl SeriesPattern for SeriesPattern28 { fn get(&self, index: Index) -> Option> { _I28.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern28 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I28 + } +} +impl SeriesPattern for SeriesPattern28 { + fn get(&self, index: Index) -> Option> { + _I28.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern29By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern29By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern29By { - pub fn p2sh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2SHAddrIndex) } + pub fn p2sh_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2SHAddrIndex) + } } -pub struct SeriesPattern29 { name: Arc, pub by: SeriesPattern29By } +pub struct SeriesPattern29 { + name: Arc, + pub by: SeriesPattern29By, +} impl SeriesPattern29 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern29By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern29By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern29 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I29 } } -impl SeriesPattern for SeriesPattern29 { fn get(&self, index: Index) -> Option> { _I29.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern29 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I29 + } +} +impl SeriesPattern for SeriesPattern29 { + fn get(&self, index: Index) -> Option> { + _I29.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern30By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern30By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern30By { - pub fn p2tr_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2TRAddrIndex) } + pub fn p2tr_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2TRAddrIndex) + } } -pub struct SeriesPattern30 { name: Arc, pub by: SeriesPattern30By } +pub struct SeriesPattern30 { + name: Arc, + pub by: SeriesPattern30By, +} impl SeriesPattern30 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern30By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern30By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern30 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I30 } } -impl SeriesPattern for SeriesPattern30 { fn get(&self, index: Index) -> Option> { _I30.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern30 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I30 + } +} +impl SeriesPattern for SeriesPattern30 { + fn get(&self, index: Index) -> Option> { + _I30.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern31By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern31By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern31By { - pub fn p2wpkh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2WPKHAddrIndex) } + pub fn p2wpkh_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2WPKHAddrIndex) + } } -pub struct SeriesPattern31 { name: Arc, pub by: SeriesPattern31By } +pub struct SeriesPattern31 { + name: Arc, + pub by: SeriesPattern31By, +} impl SeriesPattern31 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern31By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern31By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern31 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I31 } } -impl SeriesPattern for SeriesPattern31 { fn get(&self, index: Index) -> Option> { _I31.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern31 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I31 + } +} +impl SeriesPattern for SeriesPattern31 { + fn get(&self, index: Index) -> Option> { + _I31.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern32By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern32By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern32By { - pub fn p2wsh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2WSHAddrIndex) } + pub fn p2wsh_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::P2WSHAddrIndex) + } } -pub struct SeriesPattern32 { name: Arc, pub by: SeriesPattern32By } +pub struct SeriesPattern32 { + name: Arc, + pub by: SeriesPattern32By, +} impl SeriesPattern32 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern32By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern32By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern32 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I32 } } -impl SeriesPattern for SeriesPattern32 { fn get(&self, index: Index) -> Option> { _I32.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern32 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I32 + } +} +impl SeriesPattern for SeriesPattern32 { + fn get(&self, index: Index) -> Option> { + _I32.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern33By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern33By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern33By { - pub fn unknown_output_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::UnknownOutputIndex) } + pub fn unknown_output_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::UnknownOutputIndex) + } } -pub struct SeriesPattern33 { name: Arc, pub by: SeriesPattern33By } +pub struct SeriesPattern33 { + name: Arc, + pub by: SeriesPattern33By, +} impl SeriesPattern33 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern33By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern33By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern33 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I33 } } -impl SeriesPattern for SeriesPattern33 { fn get(&self, index: Index) -> Option> { _I33.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern33 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I33 + } +} +impl SeriesPattern for SeriesPattern33 { + fn get(&self, index: Index) -> Option> { + _I33.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern34By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern34By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern34By { - pub fn funded_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::FundedAddrIndex) } + pub fn funded_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::FundedAddrIndex) + } } -pub struct SeriesPattern34 { name: Arc, pub by: SeriesPattern34By } +pub struct SeriesPattern34 { + name: Arc, + pub by: SeriesPattern34By, +} impl SeriesPattern34 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern34By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern34By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern34 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I34 } } -impl SeriesPattern for SeriesPattern34 { fn get(&self, index: Index) -> Option> { _I34.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern34 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I34 + } +} +impl SeriesPattern for SeriesPattern34 { + fn get(&self, index: Index) -> Option> { + _I34.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} -pub struct SeriesPattern35By { client: Arc, name: Arc, _marker: std::marker::PhantomData } +pub struct SeriesPattern35By { + client: Arc, + name: Arc, + _marker: std::marker::PhantomData, +} impl SeriesPattern35By { - pub fn empty_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::EmptyAddrIndex) } + pub fn empty_addr_index(&self) -> SeriesEndpoint { + _ep(&self.client, &self.name, Index::EmptyAddrIndex) + } } -pub struct SeriesPattern35 { name: Arc, pub by: SeriesPattern35By } +pub struct SeriesPattern35 { + name: Arc, + pub by: SeriesPattern35By, +} impl SeriesPattern35 { - pub fn new(client: Arc, name: String) -> Self { let name: Arc = name.into(); Self { name: name.clone(), by: SeriesPattern35By { client, name, _marker: std::marker::PhantomData } } } - pub fn name(&self) -> &str { &self.name } + pub fn new(client: Arc, name: String) -> Self { + let name: Arc = name.into(); + Self { + name: name.clone(), + by: SeriesPattern35By { + client, + name, + _marker: std::marker::PhantomData, + }, + } + } + pub fn name(&self) -> &str { + &self.name + } } -impl AnySeriesPattern for SeriesPattern35 { fn name(&self) -> &str { &self.name } fn indexes(&self) -> &'static [Index] { _I35 } } -impl SeriesPattern for SeriesPattern35 { fn get(&self, index: Index) -> Option> { _I35.contains(&index).then(|| _ep(&self.by.client, &self.by.name, index)) } } +impl AnySeriesPattern for SeriesPattern35 { + fn name(&self) -> &str { + &self.name + } + fn indexes(&self) -> &'static [Index] { + _I35 + } +} +impl SeriesPattern for SeriesPattern35 { + fn get(&self, index: Index) -> Option> { + _I35.contains(&index) + .then(|| _ep(&self.by.client, &self.by.name, index)) + } +} // Reusable pattern structs /// Pattern struct for repeated tree structure. -pub struct Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern { +pub struct Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern +{ pub pct05: CentsSatsUsdPattern, pub pct10: CentsSatsUsdPattern, pub pct15: CentsSatsUsdPattern, @@ -1232,8 +2534,14 @@ impl GrossInvestedInvestorLossNetNuplProfitSentimentPattern2 { Self { gross_pnl: CentsUsdPattern3::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), invested_capital: InPattern::new(client.clone(), _m(&acc, "invested_capital_in")), - investor_cap_in_loss_raw: SeriesPattern18::new(client.clone(), _m(&acc, "investor_cap_in_loss_raw")), - investor_cap_in_profit_raw: SeriesPattern18::new(client.clone(), _m(&acc, "investor_cap_in_profit_raw")), + investor_cap_in_loss_raw: SeriesPattern18::new( + client.clone(), + _m(&acc, "investor_cap_in_loss_raw"), + ), + investor_cap_in_profit_raw: SeriesPattern18::new( + client.clone(), + _m(&acc, "investor_cap_in_profit_raw"), + ), loss: CentsNegativeToUsdPattern2::new(client.clone(), _m(&acc, "unrealized_loss")), net_pnl: CentsToUsdPattern3::new(client.clone(), _m(&acc, "net_unrealized_pnl")), nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), @@ -1353,7 +2661,10 @@ impl CapLossMvrvNetPriceProfitSoprPattern { cap: CentsDeltaUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), loss: BlockCumulativeNegativeSumPattern::new(client.clone(), _m(&acc, "realized_loss")), mvrv: SeriesPattern1::new(client.clone(), _m(&acc, "mvrv")), - net_pnl: BlockCumulativeDeltaSumPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), + net_pnl: BlockCumulativeDeltaSumPattern::new( + client.clone(), + _m(&acc, "net_realized_pnl"), + ), price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), profit: BlockCumulativeSumPattern::new(client.clone(), _m(&acc, "realized_profit")), sopr: RatioValuePattern::new(client.clone(), acc.clone()), @@ -1505,7 +2816,10 @@ impl AverageBlockCumulativeInSumPattern { block: BtcCentsSatsUsdPattern2::new(client.clone(), acc.clone()), cumulative: BtcCentsSatsUsdPattern3::new(client.clone(), _m(&acc, "cumulative")), in_loss: AverageBlockCumulativeSumPattern3::new(client.clone(), _m(&acc, "in_loss")), - in_profit: AverageBlockCumulativeSumPattern3::new(client.clone(), _m(&acc, "in_profit")), + in_profit: AverageBlockCumulativeSumPattern3::new( + client.clone(), + _m(&acc, "in_profit"), + ), sum: _1m1w1y24hPattern4::new(client.clone(), _m(&acc, "sum")), } } @@ -1552,7 +2866,10 @@ impl BtcCentsSatsToUsdPattern3 { btc: SeriesPattern1::new(client.clone(), acc.clone()), cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), - to_circulating: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_circulating")), + to_circulating: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, "to_circulating"), + ), to_own: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_own")), usd: SeriesPattern1::new(client.clone(), _m(&acc, "usd")), } @@ -1576,7 +2893,10 @@ impl CentsNegativeToUsdPattern2 { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), negative: SeriesPattern1::new(client.clone(), _m(&acc, "neg")), to_mcap: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_mcap")), - to_own_gross_pnl: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_own_gross_pnl")), + to_own_gross_pnl: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, "to_own_gross_pnl"), + ), to_own_mcap: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "to_own_mcap")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } @@ -1601,7 +2921,10 @@ impl DeltaHalfInToTotalPattern { half: BtcCentsSatsUsdPattern3::new(client.clone(), _m(&acc, "half")), in_loss: BtcCentsSatsToUsdPattern::new(client.clone(), _m(&acc, "in_loss")), in_profit: BtcCentsSatsToUsdPattern::new(client.clone(), _m(&acc, "in_profit")), - to_circulating: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_circulating")), + to_circulating: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, "to_circulating"), + ), total: BtcCentsSatsUsdPattern3::new(client.clone(), acc.clone()), } } @@ -1625,7 +2948,10 @@ impl DeltaHalfInToTotalPattern2 { half: BtcCentsSatsUsdPattern3::new(client.clone(), _m(&acc, "half")), in_loss: BtcCentsSatsToUsdPattern3::new(client.clone(), _m(&acc, "in_loss")), in_profit: BtcCentsSatsToUsdPattern3::new(client.clone(), _m(&acc, "in_profit")), - to_circulating: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_circulating")), + to_circulating: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, "to_circulating"), + ), total: BtcCentsSatsUsdPattern3::new(client.clone(), acc.clone()), } } @@ -1801,7 +3127,10 @@ impl BtcCentsSatsToUsdPattern { btc: SeriesPattern1::new(client.clone(), acc.clone()), cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), - to_circulating: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_circulating")), + to_circulating: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, "to_circulating"), + ), usd: SeriesPattern1::new(client.clone(), _m(&acc, "usd")), } } @@ -1866,7 +3195,10 @@ impl CentsToUsdPattern4 { Self { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), to_mcap: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_mcap")), - to_own_gross_pnl: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_own_gross_pnl")), + to_own_gross_pnl: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, "to_own_gross_pnl"), + ), to_own_mcap: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "to_own_mcap")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } @@ -2267,7 +3599,10 @@ impl CentsToUsdPattern3 { pub fn new(client: Arc, acc: String) -> Self { Self { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), - to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "to_own_gross_pnl")), + to_own_gross_pnl: BpsPercentRatioPattern::new( + client.clone(), + _m(&acc, "to_own_gross_pnl"), + ), to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "to_own_mcap")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } @@ -2286,10 +3621,19 @@ impl CoindaysCoinyearsDormancyTransferPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - coindays_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - coinyears_destroyed: SeriesPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), + coindays_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + _m(&acc, "coindays_destroyed"), + ), + coinyears_destroyed: SeriesPattern1::new( + client.clone(), + _m(&acc, "coinyears_destroyed"), + ), dormancy: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "dormancy")), - transfer_volume: AverageBlockCumulativeInSumPattern::new(client.clone(), _m(&acc, "transfer_volume")), + transfer_volume: AverageBlockCumulativeInSumPattern::new( + client.clone(), + _m(&acc, "transfer_volume"), + ), } } } @@ -2327,9 +3671,17 @@ impl NuplRealizedSupplyUnrealizedPattern { pub fn new(client: Arc, acc: String) -> Self { Self { nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), - realized_cap: AllSthPattern::new(client.clone(), acc.clone(), "realized_cap".to_string()), + realized_cap: AllSthPattern::new( + client.clone(), + acc.clone(), + "realized_cap".to_string(), + ), supply: AllSthPattern2::new(client.clone(), acc.clone()), - unrealized_pnl: AllSthPattern::new(client.clone(), acc.clone(), "unrealized_pnl".to_string()), + unrealized_pnl: AllSthPattern::new( + client.clone(), + acc.clone(), + "unrealized_pnl".to_string(), + ), } } } @@ -2387,7 +3739,10 @@ impl AdjustedRatioValuePattern { Self { adjusted: RatioTransferValuePattern::new(client.clone(), acc.clone()), ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), - value_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), + value_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + _m(&acc, "value_destroyed"), + ), } } } @@ -2421,7 +3776,10 @@ impl BlocksDominanceRewardsPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - blocks_mined: AverageBlockCumulativeSumPattern2::new(client.clone(), _m(&acc, "blocks_mined")), + blocks_mined: AverageBlockCumulativeSumPattern2::new( + client.clone(), + _m(&acc, "blocks_mined"), + ), dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance")), rewards: AverageBlockCumulativeSumPattern3::new(client.clone(), _m(&acc, "rewards")), } @@ -2475,9 +3833,15 @@ impl BpsPriceRatioPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String, disc: String) -> Self { Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}_bps", disc=disc))), + bps: SeriesPattern1::new( + client.clone(), + _m(&acc, &format!("ratio_{disc}_bps", disc = disc)), + ), price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, &disc)), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}", disc=disc))), + ratio: SeriesPattern1::new( + client.clone(), + _m(&acc, &format!("ratio_{disc}", disc = disc)), + ), } } } @@ -2602,7 +3966,10 @@ impl CumulativeRollingSumPattern { pub fn new(client: Arc, acc: String) -> Self { Self { cumulative: SeriesPattern1::new(client.clone(), _m(&acc, "cumulative")), - rolling: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), acc.clone()), + rolling: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new( + client.clone(), + acc.clone(), + ), sum: SeriesPattern18::new(client.clone(), _m(&acc, "sum")), } } @@ -2656,8 +4023,14 @@ impl RatioTransferValuePattern { pub fn new(client: Arc, acc: String) -> Self { Self { ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "asopr")), - transfer_volume: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "adj_value_created")), - value_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "adj_value_destroyed")), + transfer_volume: AverageBlockCumulativeSumPattern::new( + client.clone(), + _m(&acc, "adj_value_created"), + ), + value_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + _m(&acc, "adj_value_destroyed"), + ), } } } @@ -2674,8 +4047,14 @@ impl RsiStochPattern { pub fn new(client: Arc, acc: String, disc: String) -> Self { Self { rsi: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, &disc)), - stoch_rsi_d: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, &format!("stoch_d_{disc}", disc=disc))), - stoch_rsi_k: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, &format!("stoch_k_{disc}", disc=disc))), + stoch_rsi_d: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, &format!("stoch_d_{disc}", disc = disc)), + ), + stoch_rsi_k: BpsPercentRatioPattern3::new( + client.clone(), + _m(&acc, &format!("stoch_k_{disc}", disc = disc)), + ), } } } @@ -2692,7 +4071,10 @@ impl SpendingSpentUnspentPattern { pub fn new(client: Arc, acc: String) -> Self { Self { spending_rate: SeriesPattern1::new(client.clone(), _m(&acc, "spending_rate")), - spent_count: AverageBlockCumulativeSumPattern2::new(client.clone(), _m(&acc, "spent_utxo_count")), + spent_count: AverageBlockCumulativeSumPattern2::new( + client.clone(), + _m(&acc, "spent_utxo_count"), + ), unspent_count: BaseDeltaPattern::new(client.clone(), _m(&acc, "utxo_count")), } } @@ -2775,7 +4157,10 @@ impl AllSthPattern { pub fn new(client: Arc, acc: String, disc: String) -> Self { Self { all: SeriesPattern1::new(client.clone(), _m(&acc, &disc)), - sth: SeriesPattern1::new(client.clone(), _m(&acc, &format!("sth_{disc}", disc=disc))), + sth: SeriesPattern1::new( + client.clone(), + _m(&acc, &format!("sth_{disc}", disc = disc)), + ), } } } @@ -2838,7 +4223,10 @@ impl BlocksDominancePattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - blocks_mined: AverageBlockCumulativeSumPattern2::new(client.clone(), _m(&acc, "blocks_mined")), + blocks_mined: AverageBlockCumulativeSumPattern2::new( + client.clone(), + _m(&acc, "blocks_mined"), + ), dominance: BpsPercentRatioPattern3::new(client.clone(), _m(&acc, "dominance")), } } @@ -2950,8 +4338,14 @@ impl CoindaysTransferPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - coindays_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - transfer_volume: AverageBlockCumulativeInSumPattern::new(client.clone(), _m(&acc, "transfer_volume")), + coindays_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + _m(&acc, "coindays_destroyed"), + ), + transfer_volume: AverageBlockCumulativeInSumPattern::new( + client.clone(), + _m(&acc, "transfer_volume"), + ), } } } @@ -3015,7 +4409,10 @@ impl PriceRatioPattern { pub fn new(client: Arc, acc: String, disc: String) -> Self { Self { price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, &disc)), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}", disc=disc))), + ratio: SeriesPattern1::new( + client.clone(), + _m(&acc, &format!("ratio_{disc}", disc = disc)), + ), } } } @@ -3031,7 +4428,10 @@ impl RatioValuePattern { pub fn new(client: Arc, acc: String) -> Self { Self { ratio: _24hPattern::new(client.clone(), _m(&acc, "sopr_24h")), - value_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), + value_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + _m(&acc, "value_destroyed"), + ), } } } @@ -3142,7 +4542,10 @@ impl SeriesTree { pub fn new(client: Arc, base_path: String) -> Self { Self { blocks: SeriesTree_Blocks::new(client.clone(), format!("{base_path}_blocks")), - transactions: SeriesTree_Transactions::new(client.clone(), format!("{base_path}_transactions")), + transactions: SeriesTree_Transactions::new( + client.clone(), + format!("{base_path}_transactions"), + ), inputs: SeriesTree_Inputs::new(client.clone(), format!("{base_path}_inputs")), outputs: SeriesTree_Outputs::new(client.clone(), format!("{base_path}_outputs")), addrs: SeriesTree_Addrs::new(client.clone(), format!("{base_path}_addrs")), @@ -3152,7 +4555,10 @@ impl SeriesTree { cointime: SeriesTree_Cointime::new(client.clone(), format!("{base_path}_cointime")), constants: SeriesTree_Constants::new(client.clone(), format!("{base_path}_constants")), indexes: SeriesTree_Indexes::new(client.clone(), format!("{base_path}_indexes")), - indicators: SeriesTree_Indicators::new(client.clone(), format!("{base_path}_indicators")), + indicators: SeriesTree_Indicators::new( + client.clone(), + format!("{base_path}_indicators"), + ), investing: SeriesTree_Investing::new(client.clone(), format!("{base_path}_investing")), market: SeriesTree_Market::new(client.clone(), format!("{base_path}_market")), pools: SeriesTree_Pools::new(client.clone(), format!("{base_path}_pools")), @@ -3182,15 +4588,33 @@ impl SeriesTree_Blocks { pub fn new(client: Arc, base_path: String) -> Self { Self { blockhash: SeriesPattern18::new(client.clone(), "blockhash".to_string()), - difficulty: SeriesTree_Blocks_Difficulty::new(client.clone(), format!("{base_path}_difficulty")), + difficulty: SeriesTree_Blocks_Difficulty::new( + client.clone(), + format!("{base_path}_difficulty"), + ), time: SeriesTree_Blocks_Time::new(client.clone(), format!("{base_path}_time")), size: SeriesTree_Blocks_Size::new(client.clone(), format!("{base_path}_size")), - weight: AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), "block_weight".to_string()), + weight: AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new( + client.clone(), + "block_weight".to_string(), + ), count: SeriesTree_Blocks_Count::new(client.clone(), format!("{base_path}_count")), - lookback: SeriesTree_Blocks_Lookback::new(client.clone(), format!("{base_path}_lookback")), - interval: SeriesTree_Blocks_Interval::new(client.clone(), format!("{base_path}_interval")), - vbytes: AverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), "block_vbytes".to_string()), - fullness: SeriesTree_Blocks_Fullness::new(client.clone(), format!("{base_path}_fullness")), + lookback: SeriesTree_Blocks_Lookback::new( + client.clone(), + format!("{base_path}_lookback"), + ), + interval: SeriesTree_Blocks_Interval::new( + client.clone(), + format!("{base_path}_interval"), + ), + vbytes: AverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new( + client.clone(), + "block_vbytes".to_string(), + ), + fullness: SeriesTree_Blocks_Fullness::new( + client.clone(), + format!("{base_path}_fullness"), + ), halving: SeriesTree_Blocks_Halving::new(client.clone(), format!("{base_path}_halving")), } } @@ -3211,9 +4635,15 @@ impl SeriesTree_Blocks_Difficulty { Self { value: SeriesPattern1::new(client.clone(), "difficulty".to_string()), hashrate: SeriesPattern1::new(client.clone(), "difficulty_hashrate".to_string()), - adjustment: BpsPercentRatioPattern::new(client.clone(), "difficulty_adjustment".to_string()), + adjustment: BpsPercentRatioPattern::new( + client.clone(), + "difficulty_adjustment".to_string(), + ), epoch: SeriesPattern1::new(client.clone(), "difficulty_epoch".to_string()), - blocks_to_retarget: SeriesPattern1::new(client.clone(), "blocks_to_retarget".to_string()), + blocks_to_retarget: SeriesPattern1::new( + client.clone(), + "blocks_to_retarget".to_string(), + ), days_to_retarget: SeriesPattern1::new(client.clone(), "days_to_retarget".to_string()), } } @@ -3275,7 +4705,10 @@ impl SeriesTree_Blocks_Count { pub fn new(client: Arc, base_path: String) -> Self { Self { target: _1m1w1y24hPattern::new(client.clone(), "block_count_target".to_string()), - total: AverageBlockCumulativeSumPattern2::new(client.clone(), "block_count".to_string()), + total: AverageBlockCumulativeSumPattern2::new( + client.clone(), + "block_count".to_string(), + ), } } } @@ -3449,8 +4882,14 @@ impl SeriesTree_Transactions { count: SeriesTree_Transactions_Count::new(client.clone(), format!("{base_path}_count")), size: SeriesTree_Transactions_Size::new(client.clone(), format!("{base_path}_size")), fees: SeriesTree_Transactions_Fees::new(client.clone(), format!("{base_path}_fees")), - versions: SeriesTree_Transactions_Versions::new(client.clone(), format!("{base_path}_versions")), - volume: SeriesTree_Transactions_Volume::new(client.clone(), format!("{base_path}_volume")), + versions: SeriesTree_Transactions_Versions::new( + client.clone(), + format!("{base_path}_versions"), + ), + volume: SeriesTree_Transactions_Volume::new( + client.clone(), + format!("{base_path}_volume"), + ), } } } @@ -3479,9 +4918,15 @@ impl SeriesTree_Transactions_Raw { raw_locktime: SeriesPattern19::new(client.clone(), "raw_locktime".to_string()), base_size: SeriesPattern19::new(client.clone(), "base_size".to_string()), total_size: SeriesPattern19::new(client.clone(), "total_size".to_string()), - is_explicitly_rbf: SeriesPattern19::new(client.clone(), "is_explicitly_rbf".to_string()), + is_explicitly_rbf: SeriesPattern19::new( + client.clone(), + "is_explicitly_rbf".to_string(), + ), first_txin_index: SeriesPattern19::new(client.clone(), "first_txin_index".to_string()), - first_txout_index: SeriesPattern19::new(client.clone(), "first_txout_index".to_string()), + first_txout_index: SeriesPattern19::new( + client.clone(), + "first_txout_index".to_string(), + ), } } } @@ -3495,7 +4940,10 @@ pub struct SeriesTree_Transactions_Count { impl SeriesTree_Transactions_Count { pub fn new(client: Arc, base_path: String) -> Self { Self { - total: AverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), "tx_count".to_string()), + total: AverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new( + client.clone(), + "tx_count".to_string(), + ), is_coinbase: SeriesPattern19::new(client.clone(), "is_coinbase".to_string()), } } @@ -3511,7 +4959,10 @@ impl SeriesTree_Transactions_Size { pub fn new(client: Arc, base_path: String) -> Self { Self { vsize: _6bBlockTxPattern::new(client.clone(), "tx_vsize".to_string()), - weight: SeriesTree_Transactions_Size_Weight::new(client.clone(), format!("{base_path}_weight")), + weight: SeriesTree_Transactions_Size_Weight::new( + client.clone(), + format!("{base_path}_weight"), + ), } } } @@ -3527,8 +4978,14 @@ impl SeriesTree_Transactions_Size_Weight { pub fn new(client: Arc, base_path: String) -> Self { Self { tx_index: SeriesPattern19::new(client.clone(), "tx_weight".to_string()), - block: MaxMedianMinPct10Pct25Pct75Pct90Pattern2::new(client.clone(), "tx_weight".to_string()), - _6b: MaxMedianMinPct10Pct25Pct75Pct90Pattern2::new(client.clone(), "tx_weight_6b".to_string()), + block: MaxMedianMinPct10Pct25Pct75Pct90Pattern2::new( + client.clone(), + "tx_weight".to_string(), + ), + _6b: MaxMedianMinPct10Pct25Pct75Pct90Pattern2::new( + client.clone(), + "tx_weight_6b".to_string(), + ), } } } @@ -3580,7 +5037,10 @@ pub struct SeriesTree_Transactions_Volume { impl SeriesTree_Transactions_Volume { pub fn new(client: Arc, base_path: String) -> Self { Self { - transfer_volume: AverageBlockCumulativeSumPattern3::new(client.clone(), "transfer_volume_bis".to_string()), + transfer_volume: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "transfer_volume_bis".to_string(), + ), tx_per_sec: _1m1w1y24hPattern::new(client.clone(), "tx_per_sec".to_string()), outputs_per_sec: _1m1w1y24hPattern::new(client.clone(), "outputs_per_sec".to_string()), inputs_per_sec: _1m1w1y24hPattern::new(client.clone(), "inputs_per_sec".to_string()), @@ -3670,7 +5130,10 @@ pub struct SeriesTree_Outputs_Raw { impl SeriesTree_Outputs_Raw { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_txout_index: SeriesPattern18::new(client.clone(), "first_txout_index".to_string()), + first_txout_index: SeriesPattern18::new( + client.clone(), + "first_txout_index".to_string(), + ), value: SeriesPattern21::new(client.clone(), "value".to_string()), output_type: SeriesPattern21::new(client.clone(), "output_type".to_string()), type_index: SeriesPattern21::new(client.clone(), "type_index".to_string()), @@ -3726,10 +5189,22 @@ impl SeriesTree_Addrs { raw: SeriesTree_Addrs_Raw::new(client.clone(), format!("{base_path}_raw")), indexes: SeriesTree_Addrs_Indexes::new(client.clone(), format!("{base_path}_indexes")), data: SeriesTree_Addrs_Data::new(client.clone(), format!("{base_path}_data")), - funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "addr_count".to_string()), - empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "empty_addr_count".to_string()), - activity: SeriesTree_Addrs_Activity::new(client.clone(), format!("{base_path}_activity")), - total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "total_addr_count".to_string()), + funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new( + client.clone(), + "addr_count".to_string(), + ), + empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new( + client.clone(), + "empty_addr_count".to_string(), + ), + activity: SeriesTree_Addrs_Activity::new( + client.clone(), + format!("{base_path}_activity"), + ), + total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new( + client.clone(), + "total_addr_count".to_string(), + ), new: SeriesTree_Addrs_New::new(client.clone(), format!("{base_path}_new")), delta: SeriesTree_Addrs_Delta::new(client.clone(), format!("{base_path}_delta")), } @@ -3772,7 +5247,10 @@ pub struct SeriesTree_Addrs_Raw_P2pk65 { impl SeriesTree_Addrs_Raw_P2pk65 { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2pk65_addr_index".to_string()), + first_index: SeriesPattern18::new( + client.clone(), + "first_p2pk65_addr_index".to_string(), + ), bytes: SeriesPattern27::new(client.clone(), "p2pk65_bytes".to_string()), } } @@ -3787,7 +5265,10 @@ pub struct SeriesTree_Addrs_Raw_P2pk33 { impl SeriesTree_Addrs_Raw_P2pk33 { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2pk33_addr_index".to_string()), + first_index: SeriesPattern18::new( + client.clone(), + "first_p2pk33_addr_index".to_string(), + ), bytes: SeriesPattern26::new(client.clone(), "p2pk33_bytes".to_string()), } } @@ -3832,7 +5313,10 @@ pub struct SeriesTree_Addrs_Raw_P2wpkh { impl SeriesTree_Addrs_Raw_P2wpkh { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2wpkh_addr_index".to_string()), + first_index: SeriesPattern18::new( + client.clone(), + "first_p2wpkh_addr_index".to_string(), + ), bytes: SeriesPattern31::new(client.clone(), "p2wpkh_bytes".to_string()), } } @@ -3945,15 +5429,42 @@ pub struct SeriesTree_Addrs_Activity { impl SeriesTree_Addrs_Activity { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: BothReactivatedReceivingSendingPattern::new(client.clone(), "addr_activity".to_string()), - p2pk65: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_addr_activity".to_string()), - p2pk33: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_addr_activity".to_string()), - p2pkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_addr_activity".to_string()), - p2sh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_addr_activity".to_string()), - p2wpkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_addr_activity".to_string()), - p2wsh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_addr_activity".to_string()), - p2tr: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_addr_activity".to_string()), - p2a: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_addr_activity".to_string()), + all: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "addr_activity".to_string(), + ), + p2pk65: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2pk65_addr_activity".to_string(), + ), + p2pk33: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2pk33_addr_activity".to_string(), + ), + p2pkh: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2pkh_addr_activity".to_string(), + ), + p2sh: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2sh_addr_activity".to_string(), + ), + p2wpkh: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2wpkh_addr_activity".to_string(), + ), + p2wsh: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2wsh_addr_activity".to_string(), + ), + p2tr: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2tr_addr_activity".to_string(), + ), + p2a: BothReactivatedReceivingSendingPattern::new( + client.clone(), + "p2a_addr_activity".to_string(), + ), } } } @@ -3974,15 +5485,42 @@ pub struct SeriesTree_Addrs_New { impl SeriesTree_Addrs_New { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: AverageBlockCumulativeSumPattern::new(client.clone(), "new_addr_count".to_string()), - p2pk65: AverageBlockCumulativeSumPattern::new(client.clone(), "p2pk65_new_addr_count".to_string()), - p2pk33: AverageBlockCumulativeSumPattern::new(client.clone(), "p2pk33_new_addr_count".to_string()), - p2pkh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2pkh_new_addr_count".to_string()), - p2sh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2sh_new_addr_count".to_string()), - p2wpkh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2wpkh_new_addr_count".to_string()), - p2wsh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2wsh_new_addr_count".to_string()), - p2tr: AverageBlockCumulativeSumPattern::new(client.clone(), "p2tr_new_addr_count".to_string()), - p2a: AverageBlockCumulativeSumPattern::new(client.clone(), "p2a_new_addr_count".to_string()), + all: AverageBlockCumulativeSumPattern::new( + client.clone(), + "new_addr_count".to_string(), + ), + p2pk65: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2pk65_new_addr_count".to_string(), + ), + p2pk33: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2pk33_new_addr_count".to_string(), + ), + p2pkh: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2pkh_new_addr_count".to_string(), + ), + p2sh: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2sh_new_addr_count".to_string(), + ), + p2wpkh: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2wpkh_new_addr_count".to_string(), + ), + p2wsh: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2wsh_new_addr_count".to_string(), + ), + p2tr: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2tr_new_addr_count".to_string(), + ), + p2a: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2a_new_addr_count".to_string(), + ), } } } @@ -4045,9 +5583,15 @@ impl SeriesTree_Scripts_Raw { pub fn new(client: Arc, base_path: String) -> Self { Self { empty: SeriesTree_Scripts_Raw_Empty::new(client.clone(), format!("{base_path}_empty")), - op_return: SeriesTree_Scripts_Raw_OpReturn::new(client.clone(), format!("{base_path}_op_return")), + op_return: SeriesTree_Scripts_Raw_OpReturn::new( + client.clone(), + format!("{base_path}_op_return"), + ), p2ms: SeriesTree_Scripts_Raw_P2ms::new(client.clone(), format!("{base_path}_p2ms")), - unknown: SeriesTree_Scripts_Raw_Unknown::new(client.clone(), format!("{base_path}_unknown")), + unknown: SeriesTree_Scripts_Raw_Unknown::new( + client.clone(), + format!("{base_path}_unknown"), + ), } } } @@ -4061,7 +5605,10 @@ pub struct SeriesTree_Scripts_Raw_Empty { impl SeriesTree_Scripts_Raw_Empty { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_empty_output_index".to_string()), + first_index: SeriesPattern18::new( + client.clone(), + "first_empty_output_index".to_string(), + ), to_tx_index: SeriesPattern22::new(client.clone(), "tx_index".to_string()), } } @@ -4091,7 +5638,10 @@ pub struct SeriesTree_Scripts_Raw_P2ms { impl SeriesTree_Scripts_Raw_P2ms { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2ms_output_index".to_string()), + first_index: SeriesPattern18::new( + client.clone(), + "first_p2ms_output_index".to_string(), + ), to_tx_index: SeriesPattern25::new(client.clone(), "tx_index".to_string()), } } @@ -4106,7 +5656,10 @@ pub struct SeriesTree_Scripts_Raw_Unknown { impl SeriesTree_Scripts_Raw_Unknown { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_unknown_output_index".to_string()), + first_index: SeriesPattern18::new( + client.clone(), + "first_unknown_output_index".to_string(), + ), to_tx_index: SeriesPattern33::new(client.clone(), "tx_index".to_string()), } } @@ -4133,16 +5686,34 @@ impl SeriesTree_Scripts_Count { Self { p2a: AverageBlockCumulativeSumPattern::new(client.clone(), "p2a_count".to_string()), p2ms: AverageBlockCumulativeSumPattern::new(client.clone(), "p2ms_count".to_string()), - p2pk33: AverageBlockCumulativeSumPattern::new(client.clone(), "p2pk33_count".to_string()), - p2pk65: AverageBlockCumulativeSumPattern::new(client.clone(), "p2pk65_count".to_string()), + p2pk33: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2pk33_count".to_string(), + ), + p2pk65: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2pk65_count".to_string(), + ), p2pkh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2pkh_count".to_string()), p2sh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2sh_count".to_string()), p2tr: AverageBlockCumulativeSumPattern::new(client.clone(), "p2tr_count".to_string()), - p2wpkh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2wpkh_count".to_string()), + p2wpkh: AverageBlockCumulativeSumPattern::new( + client.clone(), + "p2wpkh_count".to_string(), + ), p2wsh: AverageBlockCumulativeSumPattern::new(client.clone(), "p2wsh_count".to_string()), - op_return: AverageBlockCumulativeSumPattern::new(client.clone(), "op_return_count".to_string()), - empty_output: AverageBlockCumulativeSumPattern::new(client.clone(), "empty_output_count".to_string()), - unknown_output: AverageBlockCumulativeSumPattern::new(client.clone(), "unknown_output_count".to_string()), + op_return: AverageBlockCumulativeSumPattern::new( + client.clone(), + "op_return_count".to_string(), + ), + empty_output: AverageBlockCumulativeSumPattern::new( + client.clone(), + "empty_output_count".to_string(), + ), + unknown_output: AverageBlockCumulativeSumPattern::new( + client.clone(), + "unknown_output_count".to_string(), + ), } } } @@ -4170,7 +5741,10 @@ impl SeriesTree_Mining { pub fn new(client: Arc, base_path: String) -> Self { Self { rewards: SeriesTree_Mining_Rewards::new(client.clone(), format!("{base_path}_rewards")), - hashrate: SeriesTree_Mining_Hashrate::new(client.clone(), format!("{base_path}_hashrate")), + hashrate: SeriesTree_Mining_Hashrate::new( + client.clone(), + format!("{base_path}_hashrate"), + ), } } } @@ -4186,8 +5760,14 @@ pub struct SeriesTree_Mining_Rewards { impl SeriesTree_Mining_Rewards { pub fn new(client: Arc, base_path: String) -> Self { Self { - coinbase: AverageBlockCumulativeSumPattern3::new(client.clone(), "coinbase".to_string()), - subsidy: SeriesTree_Mining_Rewards_Subsidy::new(client.clone(), format!("{base_path}_subsidy")), + coinbase: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "coinbase".to_string(), + ), + subsidy: SeriesTree_Mining_Rewards_Subsidy::new( + client.clone(), + format!("{base_path}_subsidy"), + ), fees: SeriesTree_Mining_Rewards_Fees::new(client.clone(), format!("{base_path}_fees")), unclaimed: BlockCumulativePattern::new(client.clone(), "unclaimed_rewards".to_string()), } @@ -4207,10 +5787,16 @@ impl SeriesTree_Mining_Rewards_Subsidy { pub fn new(client: Arc, base_path: String) -> Self { Self { block: BtcCentsSatsUsdPattern2::new(client.clone(), "subsidy".to_string()), - cumulative: BtcCentsSatsUsdPattern3::new(client.clone(), "subsidy_cumulative".to_string()), + cumulative: BtcCentsSatsUsdPattern3::new( + client.clone(), + "subsidy_cumulative".to_string(), + ), sum: _1m1w1y24hPattern4::new(client.clone(), "subsidy_sum".to_string()), average: _1m1w1y24hPattern3::new(client.clone(), "subsidy_average".to_string()), - dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "subsidy_dominance".to_string()), + dominance: _1m1w1y24hBpsPercentRatioPattern::new( + client.clone(), + "subsidy_dominance".to_string(), + ), } } } @@ -4246,8 +5832,14 @@ impl SeriesTree_Mining_Rewards_Fees { median: _1m1w1y24hPattern4::new(client.clone(), "fees_median".to_string()), pct75: _1m1w1y24hPattern4::new(client.clone(), "fees_pct75".to_string()), pct90: _1m1w1y24hPattern4::new(client.clone(), "fees_pct90".to_string()), - dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "fee_dominance".to_string()), - to_subsidy_ratio: SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio::new(client.clone(), format!("{base_path}_to_subsidy_ratio")), + dominance: _1m1w1y24hBpsPercentRatioPattern::new( + client.clone(), + "fee_dominance".to_string(), + ), + to_subsidy_ratio: SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio::new( + client.clone(), + format!("{base_path}_to_subsidy_ratio"), + ), } } } @@ -4300,9 +5892,15 @@ impl SeriesTree_Mining_Hashrate_Rate { pub fn new(client: Arc, base_path: String) -> Self { Self { base: SeriesPattern1::new(client.clone(), "hash_rate".to_string()), - sma: SeriesTree_Mining_Hashrate_Rate_Sma::new(client.clone(), format!("{base_path}_sma")), + sma: SeriesTree_Mining_Hashrate_Rate_Sma::new( + client.clone(), + format!("{base_path}_sma"), + ), ath: SeriesPattern1::new(client.clone(), "hash_rate_ath".to_string()), - drawdown: BpsPercentRatioPattern5::new(client.clone(), "hash_rate_drawdown".to_string()), + drawdown: BpsPercentRatioPattern5::new( + client.clone(), + "hash_rate_drawdown".to_string(), + ), } } } @@ -4327,13 +5925,11 @@ impl SeriesTree_Mining_Hashrate_Rate_Sma { } /// Series tree node. -pub struct SeriesTree_Positions { -} +pub struct SeriesTree_Positions {} impl SeriesTree_Positions { pub fn new(client: Arc, base_path: String) -> Self { - Self { - } + Self {} } } @@ -4351,13 +5947,22 @@ pub struct SeriesTree_Cointime { impl SeriesTree_Cointime { pub fn new(client: Arc, base_path: String) -> Self { Self { - activity: SeriesTree_Cointime_Activity::new(client.clone(), format!("{base_path}_activity")), + activity: SeriesTree_Cointime_Activity::new( + client.clone(), + format!("{base_path}_activity"), + ), supply: SeriesTree_Cointime_Supply::new(client.clone(), format!("{base_path}_supply")), value: SeriesTree_Cointime_Value::new(client.clone(), format!("{base_path}_value")), cap: SeriesTree_Cointime_Cap::new(client.clone(), format!("{base_path}_cap")), prices: SeriesTree_Cointime_Prices::new(client.clone(), format!("{base_path}_prices")), - adjusted: SeriesTree_Cointime_Adjusted::new(client.clone(), format!("{base_path}_adjusted")), - reserve_risk: SeriesTree_Cointime_ReserveRisk::new(client.clone(), format!("{base_path}_reserve_risk")), + adjusted: SeriesTree_Cointime_Adjusted::new( + client.clone(), + format!("{base_path}_adjusted"), + ), + reserve_risk: SeriesTree_Cointime_ReserveRisk::new( + client.clone(), + format!("{base_path}_reserve_risk"), + ), } } } @@ -4375,12 +5980,21 @@ pub struct SeriesTree_Cointime_Activity { impl SeriesTree_Cointime_Activity { pub fn new(client: Arc, base_path: String) -> Self { Self { - coinblocks_created: AverageBlockCumulativeSumPattern::new(client.clone(), "coinblocks_created".to_string()), - coinblocks_stored: AverageBlockCumulativeSumPattern::new(client.clone(), "coinblocks_stored".to_string()), + coinblocks_created: AverageBlockCumulativeSumPattern::new( + client.clone(), + "coinblocks_created".to_string(), + ), + coinblocks_stored: AverageBlockCumulativeSumPattern::new( + client.clone(), + "coinblocks_stored".to_string(), + ), liveliness: SeriesPattern1::new(client.clone(), "liveliness".to_string()), vaultedness: SeriesPattern1::new(client.clone(), "vaultedness".to_string()), ratio: SeriesPattern1::new(client.clone(), "activity_to_vaultedness".to_string()), - coinblocks_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), "coinblocks_destroyed".to_string()), + coinblocks_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + "coinblocks_destroyed".to_string(), + ), } } } @@ -4411,9 +6025,18 @@ pub struct SeriesTree_Cointime_Value { impl SeriesTree_Cointime_Value { pub fn new(client: Arc, base_path: String) -> Self { Self { - destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), "cointime_value_destroyed".to_string()), - created: AverageBlockCumulativeSumPattern::new(client.clone(), "cointime_value_created".to_string()), - stored: AverageBlockCumulativeSumPattern::new(client.clone(), "cointime_value_stored".to_string()), + destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + "cointime_value_destroyed".to_string(), + ), + created: AverageBlockCumulativeSumPattern::new( + client.clone(), + "cointime_value_created".to_string(), + ), + stored: AverageBlockCumulativeSumPattern::new( + client.clone(), + "cointime_value_stored".to_string(), + ), vocdd: AverageBlockCumulativeSumPattern::new(client.clone(), "vocdd".to_string()), } } @@ -4453,10 +6076,22 @@ pub struct SeriesTree_Cointime_Prices { impl SeriesTree_Cointime_Prices { pub fn new(client: Arc, base_path: String) -> Self { Self { - vaulted: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "vaulted_price".to_string()), - active: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "active_price".to_string()), - true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "true_market_mean".to_string()), - cointime: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "cointime_price".to_string()), + vaulted: BpsCentsPercentilesRatioSatsUsdPattern::new( + client.clone(), + "vaulted_price".to_string(), + ), + active: BpsCentsPercentilesRatioSatsUsdPattern::new( + client.clone(), + "active_price".to_string(), + ), + true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern::new( + client.clone(), + "true_market_mean".to_string(), + ), + cointime: BpsCentsPercentilesRatioSatsUsdPattern::new( + client.clone(), + "cointime_price".to_string(), + ), } } } @@ -4471,9 +6106,18 @@ pub struct SeriesTree_Cointime_Adjusted { impl SeriesTree_Cointime_Adjusted { pub fn new(client: Arc, base_path: String) -> Self { Self { - inflation_rate: BpsPercentRatioPattern::new(client.clone(), "cointime_adj_inflation_rate".to_string()), - tx_velocity_native: SeriesPattern1::new(client.clone(), "cointime_adj_tx_velocity_btc".to_string()), - tx_velocity_fiat: SeriesPattern1::new(client.clone(), "cointime_adj_tx_velocity_usd".to_string()), + inflation_rate: BpsPercentRatioPattern::new( + client.clone(), + "cointime_adj_inflation_rate".to_string(), + ), + tx_velocity_native: SeriesPattern1::new( + client.clone(), + "cointime_adj_tx_velocity_btc".to_string(), + ), + tx_velocity_fiat: SeriesPattern1::new( + client.clone(), + "cointime_adj_tx_velocity_usd".to_string(), + ), } } } @@ -4573,9 +6217,18 @@ impl SeriesTree_Indexes { addr: SeriesTree_Indexes_Addr::new(client.clone(), format!("{base_path}_addr")), height: SeriesTree_Indexes_Height::new(client.clone(), format!("{base_path}_height")), epoch: SeriesTree_Indexes_Epoch::new(client.clone(), format!("{base_path}_epoch")), - halving: SeriesTree_Indexes_Halving::new(client.clone(), format!("{base_path}_halving")), - minute10: SeriesTree_Indexes_Minute10::new(client.clone(), format!("{base_path}_minute10")), - minute30: SeriesTree_Indexes_Minute30::new(client.clone(), format!("{base_path}_minute30")), + halving: SeriesTree_Indexes_Halving::new( + client.clone(), + format!("{base_path}_halving"), + ), + minute10: SeriesTree_Indexes_Minute10::new( + client.clone(), + format!("{base_path}_minute10"), + ), + minute30: SeriesTree_Indexes_Minute30::new( + client.clone(), + format!("{base_path}_minute30"), + ), hour1: SeriesTree_Indexes_Hour1::new(client.clone(), format!("{base_path}_hour1")), hour4: SeriesTree_Indexes_Hour4::new(client.clone(), format!("{base_path}_hour4")), hour12: SeriesTree_Indexes_Hour12::new(client.clone(), format!("{base_path}_hour12")), @@ -4587,10 +6240,22 @@ impl SeriesTree_Indexes { month6: SeriesTree_Indexes_Month6::new(client.clone(), format!("{base_path}_month6")), year1: SeriesTree_Indexes_Year1::new(client.clone(), format!("{base_path}_year1")), year10: SeriesTree_Indexes_Year10::new(client.clone(), format!("{base_path}_year10")), - tx_index: SeriesTree_Indexes_TxIndex::new(client.clone(), format!("{base_path}_tx_index")), - txin_index: SeriesTree_Indexes_TxinIndex::new(client.clone(), format!("{base_path}_txin_index")), - txout_index: SeriesTree_Indexes_TxoutIndex::new(client.clone(), format!("{base_path}_txout_index")), - timestamp: SeriesTree_Indexes_Timestamp::new(client.clone(), format!("{base_path}_timestamp")), + tx_index: SeriesTree_Indexes_TxIndex::new( + client.clone(), + format!("{base_path}_tx_index"), + ), + txin_index: SeriesTree_Indexes_TxinIndex::new( + client.clone(), + format!("{base_path}_txin_index"), + ), + txout_index: SeriesTree_Indexes_TxoutIndex::new( + client.clone(), + format!("{base_path}_txout_index"), + ), + timestamp: SeriesTree_Indexes_Timestamp::new( + client.clone(), + format!("{base_path}_timestamp"), + ), } } } @@ -4614,18 +6279,33 @@ pub struct SeriesTree_Indexes_Addr { impl SeriesTree_Indexes_Addr { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk33: SeriesTree_Indexes_Addr_P2pk33::new(client.clone(), format!("{base_path}_p2pk33")), - p2pk65: SeriesTree_Indexes_Addr_P2pk65::new(client.clone(), format!("{base_path}_p2pk65")), + p2pk33: SeriesTree_Indexes_Addr_P2pk33::new( + client.clone(), + format!("{base_path}_p2pk33"), + ), + p2pk65: SeriesTree_Indexes_Addr_P2pk65::new( + client.clone(), + format!("{base_path}_p2pk65"), + ), p2pkh: SeriesTree_Indexes_Addr_P2pkh::new(client.clone(), format!("{base_path}_p2pkh")), p2sh: SeriesTree_Indexes_Addr_P2sh::new(client.clone(), format!("{base_path}_p2sh")), p2tr: SeriesTree_Indexes_Addr_P2tr::new(client.clone(), format!("{base_path}_p2tr")), - p2wpkh: SeriesTree_Indexes_Addr_P2wpkh::new(client.clone(), format!("{base_path}_p2wpkh")), + p2wpkh: SeriesTree_Indexes_Addr_P2wpkh::new( + client.clone(), + format!("{base_path}_p2wpkh"), + ), p2wsh: SeriesTree_Indexes_Addr_P2wsh::new(client.clone(), format!("{base_path}_p2wsh")), p2a: SeriesTree_Indexes_Addr_P2a::new(client.clone(), format!("{base_path}_p2a")), p2ms: SeriesTree_Indexes_Addr_P2ms::new(client.clone(), format!("{base_path}_p2ms")), empty: SeriesTree_Indexes_Addr_Empty::new(client.clone(), format!("{base_path}_empty")), - unknown: SeriesTree_Indexes_Addr_Unknown::new(client.clone(), format!("{base_path}_unknown")), - op_return: SeriesTree_Indexes_Addr_OpReturn::new(client.clone(), format!("{base_path}_op_return")), + unknown: SeriesTree_Indexes_Addr_Unknown::new( + client.clone(), + format!("{base_path}_unknown"), + ), + op_return: SeriesTree_Indexes_Addr_OpReturn::new( + client.clone(), + format!("{base_path}_op_return"), + ), } } } @@ -5170,13 +6850,28 @@ impl SeriesTree_Indicators { nvt: BpsRatioPattern2::new(client.clone(), "nvt".to_string()), gini: BpsPercentRatioPattern3::new(client.clone(), "gini".to_string()), rhodl_ratio: BpsRatioPattern2::new(client.clone(), "rhodl_ratio".to_string()), - thermo_cap_multiple: BpsRatioPattern2::new(client.clone(), "thermo_cap_multiple".to_string()), - coindays_destroyed_supply_adjusted: SeriesPattern1::new(client.clone(), "coindays_destroyed_supply_adjusted".to_string()), - coinyears_destroyed_supply_adjusted: SeriesPattern1::new(client.clone(), "coinyears_destroyed_supply_adjusted".to_string()), - dormancy: SeriesTree_Indicators_Dormancy::new(client.clone(), format!("{base_path}_dormancy")), + thermo_cap_multiple: BpsRatioPattern2::new( + client.clone(), + "thermo_cap_multiple".to_string(), + ), + coindays_destroyed_supply_adjusted: SeriesPattern1::new( + client.clone(), + "coindays_destroyed_supply_adjusted".to_string(), + ), + coinyears_destroyed_supply_adjusted: SeriesPattern1::new( + client.clone(), + "coinyears_destroyed_supply_adjusted".to_string(), + ), + dormancy: SeriesTree_Indicators_Dormancy::new( + client.clone(), + format!("{base_path}_dormancy"), + ), stock_to_flow: SeriesPattern1::new(client.clone(), "stock_to_flow".to_string()), seller_exhaustion: SeriesPattern1::new(client.clone(), "seller_exhaustion".to_string()), - realized_envelope: SeriesTree_Indicators_RealizedEnvelope::new(client.clone(), format!("{base_path}_realized_envelope")), + realized_envelope: SeriesTree_Indicators_RealizedEnvelope::new( + client.clone(), + format!("{base_path}_realized_envelope"), + ), } } } @@ -5190,7 +6885,10 @@ pub struct SeriesTree_Indicators_Dormancy { impl SeriesTree_Indicators_Dormancy { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply_adjusted: SeriesPattern1::new(client.clone(), "dormancy_supply_adjusted".to_string()), + supply_adjusted: SeriesPattern1::new( + client.clone(), + "dormancy_supply_adjusted".to_string(), + ), flow: SeriesPattern1::new(client.clone(), "dormancy_flow".to_string()), } } @@ -5213,14 +6911,20 @@ pub struct SeriesTree_Indicators_RealizedEnvelope { impl SeriesTree_Indicators_RealizedEnvelope { pub fn new(client: Arc, base_path: String) -> Self { Self { - pct0_5: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct0_5".to_string()), + pct0_5: CentsSatsUsdPattern::new( + client.clone(), + "realized_envelope_pct0_5".to_string(), + ), pct1: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct01".to_string()), pct2: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct02".to_string()), pct5: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct05".to_string()), pct95: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct95".to_string()), pct98: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct98".to_string()), pct99: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct99".to_string()), - pct99_5: CentsSatsUsdPattern::new(client.clone(), "realized_envelope_pct99_5".to_string()), + pct99_5: CentsSatsUsdPattern::new( + client.clone(), + "realized_envelope_pct99_5".to_string(), + ), index: SeriesPattern1::new(client.clone(), "realized_envelope_index".to_string()), score: SeriesPattern1::new(client.clone(), "realized_envelope_score".to_string()), } @@ -5257,12 +6961,27 @@ pub struct SeriesTree_Investing_Period { impl SeriesTree_Investing_Period { pub fn new(client: Arc, base_path: String) -> Self { Self { - dca_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "dca_stack".to_string()), - dca_cost_basis: SeriesTree_Investing_Period_DcaCostBasis::new(client.clone(), format!("{base_path}_dca_cost_basis")), - dca_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "dca_return".to_string()), + dca_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new( + client.clone(), + "dca_stack".to_string(), + ), + dca_cost_basis: SeriesTree_Investing_Period_DcaCostBasis::new( + client.clone(), + format!("{base_path}_dca_cost_basis"), + ), + dca_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new( + client.clone(), + "dca_return".to_string(), + ), dca_cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "dca_cagr".to_string()), - lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "lump_sum_stack".to_string()), - lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "lump_sum_return".to_string()), + lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new( + client.clone(), + "lump_sum_stack".to_string(), + ), + lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new( + client.clone(), + "lump_sum_return".to_string(), + ), } } } @@ -5312,9 +7031,18 @@ pub struct SeriesTree_Investing_Class { impl SeriesTree_Investing_Class { pub fn new(client: Arc, base_path: String) -> Self { Self { - dca_stack: SeriesTree_Investing_Class_DcaStack::new(client.clone(), format!("{base_path}_dca_stack")), - dca_cost_basis: SeriesTree_Investing_Class_DcaCostBasis::new(client.clone(), format!("{base_path}_dca_cost_basis")), - dca_return: SeriesTree_Investing_Class_DcaReturn::new(client.clone(), format!("{base_path}_dca_return")), + dca_stack: SeriesTree_Investing_Class_DcaStack::new( + client.clone(), + format!("{base_path}_dca_stack"), + ), + dca_cost_basis: SeriesTree_Investing_Class_DcaCostBasis::new( + client.clone(), + format!("{base_path}_dca_cost_basis"), + ), + dca_return: SeriesTree_Investing_Class_DcaReturn::new( + client.clone(), + format!("{base_path}_dca_return"), + ), } } } @@ -5338,18 +7066,54 @@ pub struct SeriesTree_Investing_Class_DcaStack { impl SeriesTree_Investing_Class_DcaStack { pub fn new(client: Arc, base_path: String) -> Self { Self { - from_2015: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2015".to_string()), - from_2016: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2016".to_string()), - from_2017: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2017".to_string()), - from_2018: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2018".to_string()), - from_2019: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2019".to_string()), - from_2020: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2020".to_string()), - from_2021: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2021".to_string()), - from_2022: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2022".to_string()), - from_2023: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2023".to_string()), - from_2024: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2024".to_string()), - from_2025: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2025".to_string()), - from_2026: BtcCentsSatsUsdPattern3::new(client.clone(), "dca_stack_from_2026".to_string()), + from_2015: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2015".to_string(), + ), + from_2016: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2016".to_string(), + ), + from_2017: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2017".to_string(), + ), + from_2018: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2018".to_string(), + ), + from_2019: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2019".to_string(), + ), + from_2020: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2020".to_string(), + ), + from_2021: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2021".to_string(), + ), + from_2022: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2022".to_string(), + ), + from_2023: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2023".to_string(), + ), + from_2024: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2024".to_string(), + ), + from_2025: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2025".to_string(), + ), + from_2026: BtcCentsSatsUsdPattern3::new( + client.clone(), + "dca_stack_from_2026".to_string(), + ), } } } @@ -5373,18 +7137,54 @@ pub struct SeriesTree_Investing_Class_DcaCostBasis { impl SeriesTree_Investing_Class_DcaCostBasis { pub fn new(client: Arc, base_path: String) -> Self { Self { - from_2015: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2015".to_string()), - from_2016: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2016".to_string()), - from_2017: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2017".to_string()), - from_2018: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2018".to_string()), - from_2019: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2019".to_string()), - from_2020: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2020".to_string()), - from_2021: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2021".to_string()), - from_2022: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2022".to_string()), - from_2023: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2023".to_string()), - from_2024: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2024".to_string()), - from_2025: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2025".to_string()), - from_2026: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2026".to_string()), + from_2015: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2015".to_string(), + ), + from_2016: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2016".to_string(), + ), + from_2017: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2017".to_string(), + ), + from_2018: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2018".to_string(), + ), + from_2019: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2019".to_string(), + ), + from_2020: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2020".to_string(), + ), + from_2021: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2021".to_string(), + ), + from_2022: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2022".to_string(), + ), + from_2023: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2023".to_string(), + ), + from_2024: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2024".to_string(), + ), + from_2025: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2025".to_string(), + ), + from_2026: CentsSatsUsdPattern::new( + client.clone(), + "dca_cost_basis_from_2026".to_string(), + ), } } } @@ -5408,18 +7208,54 @@ pub struct SeriesTree_Investing_Class_DcaReturn { impl SeriesTree_Investing_Class_DcaReturn { pub fn new(client: Arc, base_path: String) -> Self { Self { - from_2015: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2015".to_string()), - from_2016: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2016".to_string()), - from_2017: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2017".to_string()), - from_2018: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2018".to_string()), - from_2019: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2019".to_string()), - from_2020: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2020".to_string()), - from_2021: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2021".to_string()), - from_2022: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2022".to_string()), - from_2023: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2023".to_string()), - from_2024: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2024".to_string()), - from_2025: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2025".to_string()), - from_2026: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2026".to_string()), + from_2015: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2015".to_string(), + ), + from_2016: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2016".to_string(), + ), + from_2017: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2017".to_string(), + ), + from_2018: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2018".to_string(), + ), + from_2019: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2019".to_string(), + ), + from_2020: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2020".to_string(), + ), + from_2021: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2021".to_string(), + ), + from_2022: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2022".to_string(), + ), + from_2023: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2023".to_string(), + ), + from_2024: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2024".to_string(), + ), + from_2025: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2025".to_string(), + ), + from_2026: BpsPercentRatioPattern::new( + client.clone(), + "dca_return_from_2026".to_string(), + ), } } } @@ -5439,12 +7275,21 @@ impl SeriesTree_Market { pub fn new(client: Arc, base_path: String) -> Self { Self { ath: SeriesTree_Market_Ath::new(client.clone(), format!("{base_path}_ath")), - lookback: SeriesTree_Market_Lookback::new(client.clone(), format!("{base_path}_lookback")), + lookback: SeriesTree_Market_Lookback::new( + client.clone(), + format!("{base_path}_lookback"), + ), returns: SeriesTree_Market_Returns::new(client.clone(), format!("{base_path}_returns")), volatility: _1m1w1y24hPattern::new(client.clone(), "price_volatility".to_string()), range: SeriesTree_Market_Range::new(client.clone(), format!("{base_path}_range")), - moving_average: SeriesTree_Market_MovingAverage::new(client.clone(), format!("{base_path}_moving_average")), - technical: SeriesTree_Market_Technical::new(client.clone(), format!("{base_path}_technical")), + moving_average: SeriesTree_Market_MovingAverage::new( + client.clone(), + format!("{base_path}_moving_average"), + ), + technical: SeriesTree_Market_Technical::new( + client.clone(), + format!("{base_path}_technical"), + ), } } } @@ -5466,8 +7311,14 @@ impl SeriesTree_Market_Ath { drawdown: BpsPercentRatioPattern5::new(client.clone(), "price_drawdown".to_string()), days_since: SeriesPattern1::new(client.clone(), "days_since_price_ath".to_string()), years_since: SeriesPattern1::new(client.clone(), "years_since_price_ath".to_string()), - max_days_between: SeriesPattern1::new(client.clone(), "max_days_between_price_ath".to_string()), - max_years_between: SeriesPattern1::new(client.clone(), "max_years_between_price_ath".to_string()), + max_days_between: SeriesPattern1::new( + client.clone(), + "max_days_between_price_ath".to_string(), + ), + max_years_between: SeriesPattern1::new( + client.clone(), + "max_years_between_price_ath".to_string(), + ), } } } @@ -5519,9 +7370,15 @@ pub struct SeriesTree_Market_Returns { impl SeriesTree_Market_Returns { pub fn new(client: Arc, base_path: String) -> Self { Self { - periods: SeriesTree_Market_Returns_Periods::new(client.clone(), format!("{base_path}_periods")), + periods: SeriesTree_Market_Returns_Periods::new( + client.clone(), + format!("{base_path}_periods"), + ), cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "price_cagr".to_string()), - sd_24h: SeriesTree_Market_Returns_Sd24h::new(client.clone(), format!("{base_path}_sd_24h")), + sd_24h: SeriesTree_Market_Returns_Sd24h::new( + client.clone(), + format!("{base_path}_sd_24h"), + ), } } } @@ -5574,7 +7431,10 @@ pub struct SeriesTree_Market_Returns_Sd24h { impl SeriesTree_Market_Returns_Sd24h { pub fn new(client: Arc, base_path: String) -> Self { Self { - _24h: SeriesTree_Market_Returns_Sd24h_24h::new(client.clone(), format!("{base_path}_24h")), + _24h: SeriesTree_Market_Returns_Sd24h_24h::new( + client.clone(), + format!("{base_path}_24h"), + ), _1w: SeriesTree_Market_Returns_Sd24h_1w::new(client.clone(), format!("{base_path}_1w")), _1m: SeriesTree_Market_Returns_Sd24h_1m::new(client.clone(), format!("{base_path}_1m")), _1y: SeriesTree_Market_Returns_Sd24h_1y::new(client.clone(), format!("{base_path}_1y")), @@ -5657,8 +7517,14 @@ impl SeriesTree_Market_Range { min: _1m1w1y2wPattern::new(client.clone(), "price_min".to_string()), max: _1m1w1y2wPattern::new(client.clone(), "price_max".to_string()), true_range: SeriesPattern1::new(client.clone(), "price_true_range".to_string()), - true_range_sum_2w: SeriesPattern1::new(client.clone(), "price_true_range_sum_2w".to_string()), - choppiness_index_2w: BpsPercentRatioPattern3::new(client.clone(), "price_choppiness_index_2w".to_string()), + true_range_sum_2w: SeriesPattern1::new( + client.clone(), + "price_true_range_sum_2w".to_string(), + ), + choppiness_index_2w: BpsPercentRatioPattern3::new( + client.clone(), + "price_choppiness_index_2w".to_string(), + ), } } } @@ -5672,8 +7538,14 @@ pub struct SeriesTree_Market_MovingAverage { impl SeriesTree_Market_MovingAverage { pub fn new(client: Arc, base_path: String) -> Self { Self { - sma: SeriesTree_Market_MovingAverage_Sma::new(client.clone(), format!("{base_path}_sma")), - ema: SeriesTree_Market_MovingAverage_Ema::new(client.clone(), format!("{base_path}_ema")), + sma: SeriesTree_Market_MovingAverage_Sma::new( + client.clone(), + format!("{base_path}_sma"), + ), + ema: SeriesTree_Market_MovingAverage_Ema::new( + client.clone(), + format!("{base_path}_ema"), + ), } } } @@ -5711,8 +7583,14 @@ impl SeriesTree_Market_MovingAverage_Sma { _89d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_89d".to_string()), _111d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_111d".to_string()), _144d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_144d".to_string()), - _200d: SeriesTree_Market_MovingAverage_Sma_200d::new(client.clone(), format!("{base_path}_200d")), - _350d: SeriesTree_Market_MovingAverage_Sma_350d::new(client.clone(), format!("{base_path}_350d")), + _200d: SeriesTree_Market_MovingAverage_Sma_200d::new( + client.clone(), + format!("{base_path}_200d"), + ), + _350d: SeriesTree_Market_MovingAverage_Sma_350d::new( + client.clone(), + format!("{base_path}_350d"), + ), _1y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_1y".to_string()), _2y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_2y".to_string()), _200w: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_200w".to_string()), @@ -5824,7 +7702,10 @@ impl SeriesTree_Market_Technical { Self { rsi: SeriesTree_Market_Technical_Rsi::new(client.clone(), format!("{base_path}_rsi")), pi_cycle: BpsRatioPattern2::new(client.clone(), "pi_cycle".to_string()), - macd: SeriesTree_Market_Technical_Macd::new(client.clone(), format!("{base_path}_macd")), + macd: SeriesTree_Market_Technical_Macd::new( + client.clone(), + format!("{base_path}_macd"), + ), } } } @@ -5856,9 +7737,18 @@ pub struct SeriesTree_Market_Technical_Macd { impl SeriesTree_Market_Technical_Macd { pub fn new(client: Arc, base_path: String) -> Self { Self { - _24h: SeriesTree_Market_Technical_Macd_24h::new(client.clone(), format!("{base_path}_24h")), - _1w: SeriesTree_Market_Technical_Macd_1w::new(client.clone(), format!("{base_path}_1w")), - _1m: SeriesTree_Market_Technical_Macd_1m::new(client.clone(), format!("{base_path}_1m")), + _24h: SeriesTree_Market_Technical_Macd_24h::new( + client.clone(), + format!("{base_path}_24h"), + ), + _1w: SeriesTree_Market_Technical_Macd_1w::new( + client.clone(), + format!("{base_path}_1w"), + ), + _1m: SeriesTree_Market_Technical_Macd_1m::new( + client.clone(), + format!("{base_path}_1m"), + ), } } } @@ -5979,16 +7869,28 @@ impl SeriesTree_Pools_Major { btcguild: BlocksDominanceRewardsPattern::new(client.clone(), "btcguild".to_string()), eligius: BlocksDominanceRewardsPattern::new(client.clone(), "eligius".to_string()), f2pool: BlocksDominanceRewardsPattern::new(client.clone(), "f2pool".to_string()), - braiinspool: BlocksDominanceRewardsPattern::new(client.clone(), "braiinspool".to_string()), + braiinspool: BlocksDominanceRewardsPattern::new( + client.clone(), + "braiinspool".to_string(), + ), antpool: BlocksDominanceRewardsPattern::new(client.clone(), "antpool".to_string()), btcc: BlocksDominanceRewardsPattern::new(client.clone(), "btcc".to_string()), bwpool: BlocksDominanceRewardsPattern::new(client.clone(), "bwpool".to_string()), bitfury: BlocksDominanceRewardsPattern::new(client.clone(), "bitfury".to_string()), viabtc: BlocksDominanceRewardsPattern::new(client.clone(), "viabtc".to_string()), poolin: BlocksDominanceRewardsPattern::new(client.clone(), "poolin".to_string()), - spiderpool: BlocksDominanceRewardsPattern::new(client.clone(), "spiderpool".to_string()), - binancepool: BlocksDominanceRewardsPattern::new(client.clone(), "binancepool".to_string()), - foundryusa: BlocksDominanceRewardsPattern::new(client.clone(), "foundryusa".to_string()), + spiderpool: BlocksDominanceRewardsPattern::new( + client.clone(), + "spiderpool".to_string(), + ), + binancepool: BlocksDominanceRewardsPattern::new( + client.clone(), + "binancepool".to_string(), + ), + foundryusa: BlocksDominanceRewardsPattern::new( + client.clone(), + "foundryusa".to_string(), + ), sbicrypto: BlocksDominanceRewardsPattern::new(client.clone(), "sbicrypto".to_string()), marapool: BlocksDominanceRewardsPattern::new(client.clone(), "marapool".to_string()), secpool: BlocksDominanceRewardsPattern::new(client.clone(), "secpool".to_string()), @@ -6189,7 +8091,10 @@ impl SeriesTree_Pools_Minor { ckpool: BlocksDominancePattern::new(client.clone(), "ckpool".to_string()), nicehash: BlocksDominancePattern::new(client.clone(), "nicehash".to_string()), bitclub: BlocksDominancePattern::new(client.clone(), "bitclub".to_string()), - bitcoinaffiliatenetwork: BlocksDominancePattern::new(client.clone(), "bitcoinaffiliatenetwork".to_string()), + bitcoinaffiliatenetwork: BlocksDominancePattern::new( + client.clone(), + "bitcoinaffiliatenetwork".to_string(), + ), exxbw: BlocksDominancePattern::new(client.clone(), "exxbw".to_string()), bitsolo: BlocksDominancePattern::new(client.clone(), "bitsolo".to_string()), twentyoneinc: BlocksDominancePattern::new(client.clone(), "twentyoneinc".to_string()), @@ -6212,7 +8117,10 @@ impl SeriesTree_Pools_Minor { dcexploration: BlocksDominancePattern::new(client.clone(), "dcexploration".to_string()), dcex: BlocksDominancePattern::new(client.clone(), "dcex".to_string()), btpool: BlocksDominancePattern::new(client.clone(), "btpool".to_string()), - fiftyeightcoin: BlocksDominancePattern::new(client.clone(), "fiftyeightcoin".to_string()), + fiftyeightcoin: BlocksDominancePattern::new( + client.clone(), + "fiftyeightcoin".to_string(), + ), bitcoinindia: BlocksDominancePattern::new(client.clone(), "bitcoinindia".to_string()), shawnp0wers: BlocksDominancePattern::new(client.clone(), "shawnp0wers".to_string()), phashio: BlocksDominancePattern::new(client.clone(), "phashio".to_string()), @@ -6225,8 +8133,14 @@ impl SeriesTree_Pools_Minor { rawpool: BlocksDominancePattern::new(client.clone(), "rawpool".to_string()), haominer: BlocksDominancePattern::new(client.clone(), "haominer".to_string()), helix: BlocksDominancePattern::new(client.clone(), "helix".to_string()), - bitcoinukraine: BlocksDominancePattern::new(client.clone(), "bitcoinukraine".to_string()), - secretsuperstar: BlocksDominancePattern::new(client.clone(), "secretsuperstar".to_string()), + bitcoinukraine: BlocksDominancePattern::new( + client.clone(), + "bitcoinukraine".to_string(), + ), + secretsuperstar: BlocksDominancePattern::new( + client.clone(), + "secretsuperstar".to_string(), + ), tigerpoolnet: BlocksDominancePattern::new(client.clone(), "tigerpoolnet".to_string()), sigmapoolcom: BlocksDominancePattern::new(client.clone(), "sigmapoolcom".to_string()), okpooltop: BlocksDominancePattern::new(client.clone(), "okpooltop".to_string()), @@ -6243,25 +8157,40 @@ impl SeriesTree_Pools_Minor { arkpool: BlocksDominancePattern::new(client.clone(), "arkpool".to_string()), purebtccom: BlocksDominancePattern::new(client.clone(), "purebtccom".to_string()), kucoinpool: BlocksDominancePattern::new(client.clone(), "kucoinpool".to_string()), - entrustcharitypool: BlocksDominancePattern::new(client.clone(), "entrustcharitypool".to_string()), + entrustcharitypool: BlocksDominancePattern::new( + client.clone(), + "entrustcharitypool".to_string(), + ), okminer: BlocksDominancePattern::new(client.clone(), "okminer".to_string()), titan: BlocksDominancePattern::new(client.clone(), "titan".to_string()), pegapool: BlocksDominancePattern::new(client.clone(), "pegapool".to_string()), btcnuggets: BlocksDominancePattern::new(client.clone(), "btcnuggets".to_string()), cloudhashing: BlocksDominancePattern::new(client.clone(), "cloudhashing".to_string()), - digitalxmintsy: BlocksDominancePattern::new(client.clone(), "digitalxmintsy".to_string()), + digitalxmintsy: BlocksDominancePattern::new( + client.clone(), + "digitalxmintsy".to_string(), + ), telco214: BlocksDominancePattern::new(client.clone(), "telco214".to_string()), btcpoolparty: BlocksDominancePattern::new(client.clone(), "btcpoolparty".to_string()), multipool: BlocksDominancePattern::new(client.clone(), "multipool".to_string()), - transactioncoinmining: BlocksDominancePattern::new(client.clone(), "transactioncoinmining".to_string()), + transactioncoinmining: BlocksDominancePattern::new( + client.clone(), + "transactioncoinmining".to_string(), + ), btcdig: BlocksDominancePattern::new(client.clone(), "btcdig".to_string()), - trickysbtcpool: BlocksDominancePattern::new(client.clone(), "trickysbtcpool".to_string()), + trickysbtcpool: BlocksDominancePattern::new( + client.clone(), + "trickysbtcpool".to_string(), + ), btcmp: BlocksDominancePattern::new(client.clone(), "btcmp".to_string()), eobot: BlocksDominancePattern::new(client.clone(), "eobot".to_string()), unomp: BlocksDominancePattern::new(client.clone(), "unomp".to_string()), patels: BlocksDominancePattern::new(client.clone(), "patels".to_string()), gogreenlight: BlocksDominancePattern::new(client.clone(), "gogreenlight".to_string()), - bitcoinindiapool: BlocksDominancePattern::new(client.clone(), "bitcoinindiapool".to_string()), + bitcoinindiapool: BlocksDominancePattern::new( + client.clone(), + "bitcoinindiapool".to_string(), + ), ekanembtc: BlocksDominancePattern::new(client.clone(), "ekanembtc".to_string()), canoe: BlocksDominancePattern::new(client.clone(), "canoe".to_string()), tiger: BlocksDominancePattern::new(client.clone(), "tiger".to_string()), @@ -6269,8 +8198,14 @@ impl SeriesTree_Pools_Minor { zulupool: BlocksDominancePattern::new(client.clone(), "zulupool".to_string()), wiz: BlocksDominancePattern::new(client.clone(), "wiz".to_string()), wk057: BlocksDominancePattern::new(client.clone(), "wk057".to_string()), - futurebitapollosolo: BlocksDominancePattern::new(client.clone(), "futurebitapollosolo".to_string()), - carbonnegative: BlocksDominancePattern::new(client.clone(), "carbonnegative".to_string()), + futurebitapollosolo: BlocksDominancePattern::new( + client.clone(), + "futurebitapollosolo".to_string(), + ), + carbonnegative: BlocksDominancePattern::new( + client.clone(), + "carbonnegative".to_string(), + ), portlandhodl: BlocksDominancePattern::new(client.clone(), "portlandhodl".to_string()), phoenix: BlocksDominancePattern::new(client.clone(), "phoenix".to_string()), neopool: BlocksDominancePattern::new(client.clone(), "neopool".to_string()), @@ -6375,13 +8310,28 @@ impl SeriesTree_Supply { pub fn new(client: Arc, base_path: String) -> Self { Self { state: SeriesPattern18::new(client.clone(), "supply_state".to_string()), - circulating: BtcCentsSatsUsdPattern3::new(client.clone(), "circulating_supply".to_string()), + circulating: BtcCentsSatsUsdPattern3::new( + client.clone(), + "circulating_supply".to_string(), + ), burned: BlockCumulativePattern::new(client.clone(), "unspendable_supply".to_string()), - inflation_rate: BpsPercentRatioPattern::new(client.clone(), "inflation_rate".to_string()), - velocity: SeriesTree_Supply_Velocity::new(client.clone(), format!("{base_path}_velocity")), + inflation_rate: BpsPercentRatioPattern::new( + client.clone(), + "inflation_rate".to_string(), + ), + velocity: SeriesTree_Supply_Velocity::new( + client.clone(), + format!("{base_path}_velocity"), + ), market_cap: CentsDeltaUsdPattern::new(client.clone(), "market_cap".to_string()), - market_minus_realized_cap_growth_rate: _1m1w1y24hPattern::new(client.clone(), "market_minus_realized_cap_growth_rate".to_string()), - hodled_or_lost: BtcCentsSatsUsdPattern3::new(client.clone(), "hodled_or_lost_supply".to_string()), + market_minus_realized_cap_growth_rate: _1m1w1y24hPattern::new( + client.clone(), + "market_minus_realized_cap_growth_rate".to_string(), + ), + hodled_or_lost: BtcCentsSatsUsdPattern3::new( + client.clone(), + "hodled_or_lost_supply".to_string(), + ), } } } @@ -6440,17 +8390,41 @@ impl SeriesTree_Cohorts_Utxo { all: SeriesTree_Cohorts_Utxo_All::new(client.clone(), format!("{base_path}_all")), sth: SeriesTree_Cohorts_Utxo_Sth::new(client.clone(), format!("{base_path}_sth")), lth: SeriesTree_Cohorts_Utxo_Lth::new(client.clone(), format!("{base_path}_lth")), - age_range: SeriesTree_Cohorts_Utxo_AgeRange::new(client.clone(), format!("{base_path}_age_range")), - under_age: SeriesTree_Cohorts_Utxo_UnderAge::new(client.clone(), format!("{base_path}_under_age")), - over_age: SeriesTree_Cohorts_Utxo_OverAge::new(client.clone(), format!("{base_path}_over_age")), + age_range: SeriesTree_Cohorts_Utxo_AgeRange::new( + client.clone(), + format!("{base_path}_age_range"), + ), + under_age: SeriesTree_Cohorts_Utxo_UnderAge::new( + client.clone(), + format!("{base_path}_under_age"), + ), + over_age: SeriesTree_Cohorts_Utxo_OverAge::new( + client.clone(), + format!("{base_path}_over_age"), + ), epoch: SeriesTree_Cohorts_Utxo_Epoch::new(client.clone(), format!("{base_path}_epoch")), class: SeriesTree_Cohorts_Utxo_Class::new(client.clone(), format!("{base_path}_class")), - over_amount: SeriesTree_Cohorts_Utxo_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), - amount_range: SeriesTree_Cohorts_Utxo_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), - under_amount: SeriesTree_Cohorts_Utxo_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), + over_amount: SeriesTree_Cohorts_Utxo_OverAmount::new( + client.clone(), + format!("{base_path}_over_amount"), + ), + amount_range: SeriesTree_Cohorts_Utxo_AmountRange::new( + client.clone(), + format!("{base_path}_amount_range"), + ), + under_amount: SeriesTree_Cohorts_Utxo_UnderAmount::new( + client.clone(), + format!("{base_path}_under_amount"), + ), type_: SeriesTree_Cohorts_Utxo_Type::new(client.clone(), format!("{base_path}_type")), - profitability: SeriesTree_Cohorts_Utxo_Profitability::new(client.clone(), format!("{base_path}_profitability")), - matured: SeriesTree_Cohorts_Utxo_Matured::new(client.clone(), format!("{base_path}_matured")), + profitability: SeriesTree_Cohorts_Utxo_Profitability::new( + client.clone(), + format!("{base_path}_profitability"), + ), + matured: SeriesTree_Cohorts_Utxo_Matured::new( + client.clone(), + format!("{base_path}_matured"), + ), } } } @@ -6468,12 +8442,30 @@ pub struct SeriesTree_Cohorts_Utxo_All { impl SeriesTree_Cohorts_Utxo_All { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply: SeriesTree_Cohorts_Utxo_All_Supply::new(client.clone(), format!("{base_path}_supply")), - outputs: SeriesTree_Cohorts_Utxo_All_Outputs::new(client.clone(), format!("{base_path}_outputs")), - activity: SeriesTree_Cohorts_Utxo_All_Activity::new(client.clone(), format!("{base_path}_activity")), - realized: SeriesTree_Cohorts_Utxo_All_Realized::new(client.clone(), format!("{base_path}_realized")), - cost_basis: SeriesTree_Cohorts_Utxo_All_CostBasis::new(client.clone(), format!("{base_path}_cost_basis")), - unrealized: SeriesTree_Cohorts_Utxo_All_Unrealized::new(client.clone(), format!("{base_path}_unrealized")), + supply: SeriesTree_Cohorts_Utxo_All_Supply::new( + client.clone(), + format!("{base_path}_supply"), + ), + outputs: SeriesTree_Cohorts_Utxo_All_Outputs::new( + client.clone(), + format!("{base_path}_outputs"), + ), + activity: SeriesTree_Cohorts_Utxo_All_Activity::new( + client.clone(), + format!("{base_path}_activity"), + ), + realized: SeriesTree_Cohorts_Utxo_All_Realized::new( + client.clone(), + format!("{base_path}_realized"), + ), + cost_basis: SeriesTree_Cohorts_Utxo_All_CostBasis::new( + client.clone(), + format!("{base_path}_cost_basis"), + ), + unrealized: SeriesTree_Cohorts_Utxo_All_Unrealized::new( + client.clone(), + format!("{base_path}_unrealized"), + ), } } } @@ -6493,7 +8485,10 @@ impl SeriesTree_Cohorts_Utxo_All_Supply { total: BtcCentsSatsUsdPattern3::new(client.clone(), "supply".to_string()), delta: AbsoluteRatePattern::new(client.clone(), "supply_delta".to_string()), half: BtcCentsSatsUsdPattern3::new(client.clone(), "supply_half".to_string()), - in_profit: BtcCentsSatsToUsdPattern2::new(client.clone(), "supply_in_profit".to_string()), + in_profit: BtcCentsSatsToUsdPattern2::new( + client.clone(), + "supply_in_profit".to_string(), + ), in_loss: BtcCentsSatsToUsdPattern2::new(client.clone(), "supply_in_loss".to_string()), } } @@ -6510,7 +8505,10 @@ impl SeriesTree_Cohorts_Utxo_All_Outputs { pub fn new(client: Arc, base_path: String) -> Self { Self { unspent_count: BaseDeltaPattern::new(client.clone(), "utxo_count".to_string()), - spent_count: AverageBlockCumulativeSumPattern2::new(client.clone(), "spent_utxo_count".to_string()), + spent_count: AverageBlockCumulativeSumPattern2::new( + client.clone(), + "spent_utxo_count".to_string(), + ), spending_rate: SeriesPattern1::new(client.clone(), "spending_rate".to_string()), } } @@ -6527,9 +8525,18 @@ pub struct SeriesTree_Cohorts_Utxo_All_Activity { impl SeriesTree_Cohorts_Utxo_All_Activity { pub fn new(client: Arc, base_path: String) -> Self { Self { - transfer_volume: AverageBlockCumulativeInSumPattern::new(client.clone(), "transfer_volume".to_string()), - coindays_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), "coindays_destroyed".to_string()), - coinyears_destroyed: SeriesPattern1::new(client.clone(), "coinyears_destroyed".to_string()), + transfer_volume: AverageBlockCumulativeInSumPattern::new( + client.clone(), + "transfer_volume".to_string(), + ), + coindays_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + "coindays_destroyed".to_string(), + ), + coinyears_destroyed: SeriesPattern1::new( + client.clone(), + "coinyears_destroyed".to_string(), + ), dormancy: _1m1w1y24hPattern::new(client.clone(), "dormancy".to_string()), } } @@ -6556,16 +8563,37 @@ impl SeriesTree_Cohorts_Utxo_All_Realized { Self { cap: CentsDeltaToUsdPattern::new(client.clone(), "realized_cap".to_string()), profit: BlockCumulativeSumPattern::new(client.clone(), "realized_profit".to_string()), - loss: BlockCumulativeNegativeSumPattern::new(client.clone(), "realized_loss".to_string()), - price: SeriesTree_Cohorts_Utxo_All_Realized_Price::new(client.clone(), format!("{base_path}_price")), + loss: BlockCumulativeNegativeSumPattern::new( + client.clone(), + "realized_loss".to_string(), + ), + price: SeriesTree_Cohorts_Utxo_All_Realized_Price::new( + client.clone(), + format!("{base_path}_price"), + ), mvrv: SeriesPattern1::new(client.clone(), "mvrv".to_string()), net_pnl: BlockChangeCumulativeDeltaSumPattern::new(client.clone(), "net".to_string()), - sopr: SeriesTree_Cohorts_Utxo_All_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), - gross_pnl: BlockCumulativeSumPattern::new(client.clone(), "realized_gross_pnl".to_string()), - sell_side_risk_ratio: _1m1w1y24hPattern7::new(client.clone(), "sell_side_risk_ratio".to_string()), - peak_regret: BlockCumulativeSumPattern::new(client.clone(), "realized_peak_regret".to_string()), + sopr: SeriesTree_Cohorts_Utxo_All_Realized_Sopr::new( + client.clone(), + format!("{base_path}_sopr"), + ), + gross_pnl: BlockCumulativeSumPattern::new( + client.clone(), + "realized_gross_pnl".to_string(), + ), + sell_side_risk_ratio: _1m1w1y24hPattern7::new( + client.clone(), + "sell_side_risk_ratio".to_string(), + ), + peak_regret: BlockCumulativeSumPattern::new( + client.clone(), + "realized_peak_regret".to_string(), + ), investor: PricePattern::new(client.clone(), "investor_price".to_string()), - profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "realized_profit_to_loss_ratio".to_string()), + profit_to_loss_ratio: _1m1w1y24hPattern::new( + client.clone(), + "realized_profit_to_loss_ratio".to_string(), + ), } } } @@ -6590,9 +8618,15 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Price { sats: SeriesPattern1::new(client.clone(), "realized_price_sats".to_string()), bps: SeriesPattern1::new(client.clone(), "realized_price_ratio_bps".to_string()), ratio: SeriesPattern1::new(client.clone(), "realized_price_ratio".to_string()), - percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "realized_price".to_string()), + percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new( + client.clone(), + "realized_price".to_string(), + ), sma: _1m1w1y2y4yAllPattern::new(client.clone(), "realized_price_ratio_sma".to_string()), - std_dev: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev::new(client.clone(), format!("{base_path}_std_dev")), + std_dev: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev::new( + client.clone(), + format!("{base_path}_std_dev"), + ), } } } @@ -6608,10 +8642,22 @@ pub struct SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev { impl SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_All::new(client.clone(), format!("{base_path}_all")), - _4y: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_4y::new(client.clone(), format!("{base_path}_4y")), - _2y: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_2y::new(client.clone(), format!("{base_path}_2y")), - _1y: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_1y::new(client.clone(), format!("{base_path}_1y")), + all: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_All::new( + client.clone(), + format!("{base_path}_all"), + ), + _4y: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_4y::new( + client.clone(), + format!("{base_path}_4y"), + ), + _2y: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_2y::new( + client.clone(), + format!("{base_path}_2y"), + ), + _1y: SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_1y::new( + client.clone(), + format!("{base_path}_1y"), + ), } } } @@ -6641,18 +8687,66 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_All { sd: SeriesPattern1::new(client.clone(), "realized_price_ratio_sd".to_string()), zscore: SeriesPattern1::new(client.clone(), "realized_price_ratio_zscore".to_string()), _0sd: CentsSatsUsdPattern::new(client.clone(), "realized_price_0sd".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p0_5sd".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1sd".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1_5sd".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2sd".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2_5sd".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p3sd".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m0_5sd".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1sd".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1_5sd".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2sd".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2_5sd".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m3sd".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p0_5sd".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1sd".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1_5sd".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2sd".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2_5sd".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p3sd".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m0_5sd".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1sd".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1_5sd".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2sd".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2_5sd".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m3sd".to_string(), + ), } } } @@ -6680,20 +8774,71 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_4y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "realized_price_ratio_sd_4y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "realized_price_ratio_zscore_4y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "realized_price_ratio_zscore_4y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "realized_price_0sd_4y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p0_5sd_4y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1sd_4y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1_5sd_4y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2sd_4y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2_5sd_4y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p3sd_4y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m0_5sd_4y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1sd_4y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1_5sd_4y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2sd_4y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2_5sd_4y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m3sd_4y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p0_5sd_4y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1sd_4y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1_5sd_4y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2sd_4y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2_5sd_4y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p3sd_4y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m0_5sd_4y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1sd_4y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1_5sd_4y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2sd_4y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2_5sd_4y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m3sd_4y".to_string(), + ), } } } @@ -6721,20 +8866,71 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_2y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "realized_price_ratio_sd_2y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "realized_price_ratio_zscore_2y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "realized_price_ratio_zscore_2y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "realized_price_0sd_2y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p0_5sd_2y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1sd_2y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1_5sd_2y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2sd_2y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2_5sd_2y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p3sd_2y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m0_5sd_2y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1sd_2y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1_5sd_2y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2sd_2y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2_5sd_2y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m3sd_2y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p0_5sd_2y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1sd_2y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1_5sd_2y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2sd_2y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2_5sd_2y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p3sd_2y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m0_5sd_2y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1sd_2y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1_5sd_2y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2sd_2y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2_5sd_2y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m3sd_2y".to_string(), + ), } } } @@ -6762,20 +8958,71 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Price_StdDev_1y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "realized_price_ratio_sd_1y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "realized_price_ratio_zscore_1y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "realized_price_ratio_zscore_1y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "realized_price_0sd_1y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p0_5sd_1y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1sd_1y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p1_5sd_1y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2sd_1y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p2_5sd_1y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "p3sd_1y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m0_5sd_1y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1sd_1y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m1_5sd_1y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2sd_1y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m2_5sd_1y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "realized_price".to_string(), "m3sd_1y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p0_5sd_1y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1sd_1y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p1_5sd_1y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2sd_1y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p2_5sd_1y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "p3sd_1y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m0_5sd_1y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1sd_1y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m1_5sd_1y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2sd_1y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m2_5sd_1y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "realized_price".to_string(), + "m3sd_1y".to_string(), + ), } } } @@ -6790,9 +9037,15 @@ pub struct SeriesTree_Cohorts_Utxo_All_Realized_Sopr { impl SeriesTree_Cohorts_Utxo_All_Realized_Sopr { pub fn new(client: Arc, base_path: String) -> Self { Self { - value_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), "value_destroyed".to_string()), + value_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + "value_destroyed".to_string(), + ), ratio: _1m1w1y24hPattern::new(client.clone(), "sopr".to_string()), - adjusted: SeriesTree_Cohorts_Utxo_All_Realized_Sopr_Adjusted::new(client.clone(), format!("{base_path}_adjusted")), + adjusted: SeriesTree_Cohorts_Utxo_All_Realized_Sopr_Adjusted::new( + client.clone(), + format!("{base_path}_adjusted"), + ), } } } @@ -6808,8 +9061,14 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Sopr_Adjusted { pub fn new(client: Arc, base_path: String) -> Self { Self { ratio: _1m1w1y24hPattern::new(client.clone(), "asopr".to_string()), - transfer_volume: AverageBlockCumulativeSumPattern::new(client.clone(), "adj_value_created".to_string()), - value_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), "adj_value_destroyed".to_string()), + transfer_volume: AverageBlockCumulativeSumPattern::new( + client.clone(), + "adj_value_created".to_string(), + ), + value_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + "adj_value_destroyed".to_string(), + ), } } } @@ -6856,14 +9115,32 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized { pub fn new(client: Arc, base_path: String) -> Self { Self { nupl: BpsRatioPattern::new(client.clone(), "nupl".to_string()), - profit: SeriesTree_Cohorts_Utxo_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), - loss: SeriesTree_Cohorts_Utxo_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), - net_pnl: SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), + profit: SeriesTree_Cohorts_Utxo_All_Unrealized_Profit::new( + client.clone(), + format!("{base_path}_profit"), + ), + loss: SeriesTree_Cohorts_Utxo_All_Unrealized_Loss::new( + client.clone(), + format!("{base_path}_loss"), + ), + net_pnl: SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl::new( + client.clone(), + format!("{base_path}_net_pnl"), + ), gross_pnl: CentsUsdPattern3::new(client.clone(), "unrealized_gross_pnl".to_string()), invested_capital: InPattern::new(client.clone(), "invested_capital_in".to_string()), - investor_cap_in_profit_raw: SeriesPattern18::new(client.clone(), "investor_cap_in_profit_raw".to_string()), - investor_cap_in_loss_raw: SeriesPattern18::new(client.clone(), "investor_cap_in_loss_raw".to_string()), - sentiment: SeriesTree_Cohorts_Utxo_All_Unrealized_Sentiment::new(client.clone(), format!("{base_path}_sentiment")), + investor_cap_in_profit_raw: SeriesPattern18::new( + client.clone(), + "investor_cap_in_profit_raw".to_string(), + ), + investor_cap_in_loss_raw: SeriesPattern18::new( + client.clone(), + "investor_cap_in_loss_raw".to_string(), + ), + sentiment: SeriesTree_Cohorts_Utxo_All_Unrealized_Sentiment::new( + client.clone(), + format!("{base_path}_sentiment"), + ), } } } @@ -6881,8 +9158,14 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_Profit { Self { usd: SeriesPattern1::new(client.clone(), "unrealized_profit".to_string()), cents: SeriesPattern1::new(client.clone(), "unrealized_profit_cents".to_string()), - to_mcap: BpsPercentRatioPattern3::new(client.clone(), "unrealized_profit_to_mcap".to_string()), - to_own_gross_pnl: BpsPercentRatioPattern3::new(client.clone(), "unrealized_profit_to_own_gross_pnl".to_string()), + to_mcap: BpsPercentRatioPattern3::new( + client.clone(), + "unrealized_profit_to_mcap".to_string(), + ), + to_own_gross_pnl: BpsPercentRatioPattern3::new( + client.clone(), + "unrealized_profit_to_own_gross_pnl".to_string(), + ), } } } @@ -6902,8 +9185,14 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_Loss { usd: SeriesPattern1::new(client.clone(), "unrealized_loss".to_string()), cents: SeriesPattern1::new(client.clone(), "unrealized_loss_cents".to_string()), negative: SeriesPattern1::new(client.clone(), "unrealized_loss_neg".to_string()), - to_mcap: BpsPercentRatioPattern3::new(client.clone(), "unrealized_loss_to_mcap".to_string()), - to_own_gross_pnl: BpsPercentRatioPattern3::new(client.clone(), "unrealized_loss_to_own_gross_pnl".to_string()), + to_mcap: BpsPercentRatioPattern3::new( + client.clone(), + "unrealized_loss_to_mcap".to_string(), + ), + to_own_gross_pnl: BpsPercentRatioPattern3::new( + client.clone(), + "unrealized_loss_to_own_gross_pnl".to_string(), + ), } } } @@ -6920,7 +9209,10 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl { Self { usd: SeriesPattern1::new(client.clone(), "net_unrealized_pnl".to_string()), cents: SeriesPattern1::new(client.clone(), "net_unrealized_pnl_cents".to_string()), - to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_to_own_gross_pnl".to_string()), + to_own_gross_pnl: BpsPercentRatioPattern::new( + client.clone(), + "net_unrealized_pnl_to_own_gross_pnl".to_string(), + ), } } } @@ -6957,10 +9249,19 @@ impl SeriesTree_Cohorts_Utxo_Sth { Self { supply: DeltaHalfInToTotalPattern2::new(client.clone(), "sth_supply".to_string()), outputs: SpendingSpentUnspentPattern::new(client.clone(), "sth".to_string()), - activity: CoindaysCoinyearsDormancyTransferPattern::new(client.clone(), "sth".to_string()), - realized: SeriesTree_Cohorts_Utxo_Sth_Realized::new(client.clone(), format!("{base_path}_realized")), + activity: CoindaysCoinyearsDormancyTransferPattern::new( + client.clone(), + "sth".to_string(), + ), + realized: SeriesTree_Cohorts_Utxo_Sth_Realized::new( + client.clone(), + format!("{base_path}_realized"), + ), cost_basis: InMaxMinPerSupplyPattern::new(client.clone(), "sth".to_string()), - unrealized: GrossInvestedInvestorLossNetNuplProfitSentimentPattern2::new(client.clone(), "sth".to_string()), + unrealized: GrossInvestedInvestorLossNetNuplProfitSentimentPattern2::new( + client.clone(), + "sth".to_string(), + ), } } } @@ -6985,17 +9286,41 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized { pub fn new(client: Arc, base_path: String) -> Self { Self { cap: CentsDeltaToUsdPattern::new(client.clone(), "sth_realized_cap".to_string()), - profit: BlockCumulativeSumPattern::new(client.clone(), "sth_realized_profit".to_string()), - loss: BlockCumulativeNegativeSumPattern::new(client.clone(), "sth_realized_loss".to_string()), - price: SeriesTree_Cohorts_Utxo_Sth_Realized_Price::new(client.clone(), format!("{base_path}_price")), + profit: BlockCumulativeSumPattern::new( + client.clone(), + "sth_realized_profit".to_string(), + ), + loss: BlockCumulativeNegativeSumPattern::new( + client.clone(), + "sth_realized_loss".to_string(), + ), + price: SeriesTree_Cohorts_Utxo_Sth_Realized_Price::new( + client.clone(), + format!("{base_path}_price"), + ), mvrv: SeriesPattern1::new(client.clone(), "sth_mvrv".to_string()), - net_pnl: BlockChangeCumulativeDeltaSumPattern::new(client.clone(), "sth_net".to_string()), + net_pnl: BlockChangeCumulativeDeltaSumPattern::new( + client.clone(), + "sth_net".to_string(), + ), sopr: AdjustedRatioValuePattern::new(client.clone(), "sth".to_string()), - gross_pnl: BlockCumulativeSumPattern::new(client.clone(), "sth_realized_gross_pnl".to_string()), - sell_side_risk_ratio: _1m1w1y24hPattern7::new(client.clone(), "sth_sell_side_risk_ratio".to_string()), - peak_regret: BlockCumulativeSumPattern::new(client.clone(), "sth_realized_peak_regret".to_string()), + gross_pnl: BlockCumulativeSumPattern::new( + client.clone(), + "sth_realized_gross_pnl".to_string(), + ), + sell_side_risk_ratio: _1m1w1y24hPattern7::new( + client.clone(), + "sth_sell_side_risk_ratio".to_string(), + ), + peak_regret: BlockCumulativeSumPattern::new( + client.clone(), + "sth_realized_peak_regret".to_string(), + ), investor: PricePattern::new(client.clone(), "sth_investor_price".to_string()), - profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "sth_realized_profit_to_loss_ratio".to_string()), + profit_to_loss_ratio: _1m1w1y24hPattern::new( + client.clone(), + "sth_realized_profit_to_loss_ratio".to_string(), + ), } } } @@ -7020,9 +9345,18 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price { sats: SeriesPattern1::new(client.clone(), "sth_realized_price_sats".to_string()), bps: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_bps".to_string()), ratio: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio".to_string()), - percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "sth_realized_price".to_string()), - sma: _1m1w1y2y4yAllPattern::new(client.clone(), "sth_realized_price_ratio_sma".to_string()), - std_dev: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev::new(client.clone(), format!("{base_path}_std_dev")), + percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new( + client.clone(), + "sth_realized_price".to_string(), + ), + sma: _1m1w1y2y4yAllPattern::new( + client.clone(), + "sth_realized_price_ratio_sma".to_string(), + ), + std_dev: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev::new( + client.clone(), + format!("{base_path}_std_dev"), + ), } } } @@ -7038,10 +9372,22 @@ pub struct SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev { impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_All::new(client.clone(), format!("{base_path}_all")), - _4y: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_4y::new(client.clone(), format!("{base_path}_4y")), - _2y: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_2y::new(client.clone(), format!("{base_path}_2y")), - _1y: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_1y::new(client.clone(), format!("{base_path}_1y")), + all: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_All::new( + client.clone(), + format!("{base_path}_all"), + ), + _4y: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_4y::new( + client.clone(), + format!("{base_path}_4y"), + ), + _2y: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_2y::new( + client.clone(), + format!("{base_path}_2y"), + ), + _1y: SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_1y::new( + client.clone(), + format!("{base_path}_1y"), + ), } } } @@ -7069,20 +9415,71 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_All { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_sd".to_string()), - zscore: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_zscore".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "sth_realized_price_ratio_zscore".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "sth_realized_price_0sd".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p0_5sd".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1sd".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1_5sd".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2sd".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2_5sd".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p3sd".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m0_5sd".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1sd".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1_5sd".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2sd".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2_5sd".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m3sd".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p0_5sd".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1sd".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1_5sd".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2sd".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2_5sd".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p3sd".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m0_5sd".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1sd".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1_5sd".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2sd".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2_5sd".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m3sd".to_string(), + ), } } } @@ -7110,20 +9507,71 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_4y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_sd_4y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_zscore_4y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "sth_realized_price_ratio_zscore_4y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "sth_realized_price_0sd_4y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p0_5sd_4y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1sd_4y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1_5sd_4y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2sd_4y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2_5sd_4y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p3sd_4y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m0_5sd_4y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1sd_4y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1_5sd_4y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2sd_4y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2_5sd_4y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m3sd_4y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p0_5sd_4y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1sd_4y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1_5sd_4y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2sd_4y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2_5sd_4y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p3sd_4y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m0_5sd_4y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1sd_4y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1_5sd_4y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2sd_4y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2_5sd_4y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m3sd_4y".to_string(), + ), } } } @@ -7151,20 +9599,71 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_2y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_sd_2y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_zscore_2y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "sth_realized_price_ratio_zscore_2y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "sth_realized_price_0sd_2y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p0_5sd_2y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1sd_2y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1_5sd_2y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2sd_2y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2_5sd_2y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p3sd_2y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m0_5sd_2y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1sd_2y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1_5sd_2y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2sd_2y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2_5sd_2y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m3sd_2y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p0_5sd_2y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1sd_2y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1_5sd_2y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2sd_2y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2_5sd_2y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p3sd_2y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m0_5sd_2y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1sd_2y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1_5sd_2y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2sd_2y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2_5sd_2y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m3sd_2y".to_string(), + ), } } } @@ -7192,20 +9691,71 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price_StdDev_1y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_sd_1y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_zscore_1y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "sth_realized_price_ratio_zscore_1y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "sth_realized_price_0sd_1y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p0_5sd_1y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1sd_1y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p1_5sd_1y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2sd_1y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p2_5sd_1y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "p3sd_1y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m0_5sd_1y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1sd_1y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m1_5sd_1y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2sd_1y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m2_5sd_1y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "sth_realized_price".to_string(), "m3sd_1y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p0_5sd_1y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1sd_1y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p1_5sd_1y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2sd_1y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p2_5sd_1y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "p3sd_1y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m0_5sd_1y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1sd_1y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m1_5sd_1y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2sd_1y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m2_5sd_1y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "sth_realized_price".to_string(), + "m3sd_1y".to_string(), + ), } } } @@ -7225,10 +9775,19 @@ impl SeriesTree_Cohorts_Utxo_Lth { Self { supply: DeltaHalfInToTotalPattern2::new(client.clone(), "lth_supply".to_string()), outputs: SpendingSpentUnspentPattern::new(client.clone(), "lth".to_string()), - activity: CoindaysCoinyearsDormancyTransferPattern::new(client.clone(), "lth".to_string()), - realized: SeriesTree_Cohorts_Utxo_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), + activity: CoindaysCoinyearsDormancyTransferPattern::new( + client.clone(), + "lth".to_string(), + ), + realized: SeriesTree_Cohorts_Utxo_Lth_Realized::new( + client.clone(), + format!("{base_path}_realized"), + ), cost_basis: InMaxMinPerSupplyPattern::new(client.clone(), "lth".to_string()), - unrealized: GrossInvestedInvestorLossNetNuplProfitSentimentPattern2::new(client.clone(), "lth".to_string()), + unrealized: GrossInvestedInvestorLossNetNuplProfitSentimentPattern2::new( + client.clone(), + "lth".to_string(), + ), } } } @@ -7253,17 +9812,44 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized { pub fn new(client: Arc, base_path: String) -> Self { Self { cap: CentsDeltaToUsdPattern::new(client.clone(), "lth_realized_cap".to_string()), - profit: BlockCumulativeSumPattern::new(client.clone(), "lth_realized_profit".to_string()), - loss: BlockCumulativeNegativeSumPattern::new(client.clone(), "lth_realized_loss".to_string()), - price: SeriesTree_Cohorts_Utxo_Lth_Realized_Price::new(client.clone(), format!("{base_path}_price")), + profit: BlockCumulativeSumPattern::new( + client.clone(), + "lth_realized_profit".to_string(), + ), + loss: BlockCumulativeNegativeSumPattern::new( + client.clone(), + "lth_realized_loss".to_string(), + ), + price: SeriesTree_Cohorts_Utxo_Lth_Realized_Price::new( + client.clone(), + format!("{base_path}_price"), + ), mvrv: SeriesPattern1::new(client.clone(), "lth_mvrv".to_string()), - net_pnl: BlockChangeCumulativeDeltaSumPattern::new(client.clone(), "lth_net".to_string()), - sopr: SeriesTree_Cohorts_Utxo_Lth_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), - gross_pnl: BlockCumulativeSumPattern::new(client.clone(), "lth_realized_gross_pnl".to_string()), - sell_side_risk_ratio: _1m1w1y24hPattern7::new(client.clone(), "lth_sell_side_risk_ratio".to_string()), - peak_regret: BlockCumulativeSumPattern::new(client.clone(), "lth_realized_peak_regret".to_string()), + net_pnl: BlockChangeCumulativeDeltaSumPattern::new( + client.clone(), + "lth_net".to_string(), + ), + sopr: SeriesTree_Cohorts_Utxo_Lth_Realized_Sopr::new( + client.clone(), + format!("{base_path}_sopr"), + ), + gross_pnl: BlockCumulativeSumPattern::new( + client.clone(), + "lth_realized_gross_pnl".to_string(), + ), + sell_side_risk_ratio: _1m1w1y24hPattern7::new( + client.clone(), + "lth_sell_side_risk_ratio".to_string(), + ), + peak_regret: BlockCumulativeSumPattern::new( + client.clone(), + "lth_realized_peak_regret".to_string(), + ), investor: PricePattern::new(client.clone(), "lth_investor_price".to_string()), - profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit_to_loss_ratio".to_string()), + profit_to_loss_ratio: _1m1w1y24hPattern::new( + client.clone(), + "lth_realized_profit_to_loss_ratio".to_string(), + ), } } } @@ -7288,9 +9874,18 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price { sats: SeriesPattern1::new(client.clone(), "lth_realized_price_sats".to_string()), bps: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_bps".to_string()), ratio: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio".to_string()), - percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "lth_realized_price".to_string()), - sma: _1m1w1y2y4yAllPattern::new(client.clone(), "lth_realized_price_ratio_sma".to_string()), - std_dev: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev::new(client.clone(), format!("{base_path}_std_dev")), + percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new( + client.clone(), + "lth_realized_price".to_string(), + ), + sma: _1m1w1y2y4yAllPattern::new( + client.clone(), + "lth_realized_price_ratio_sma".to_string(), + ), + std_dev: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev::new( + client.clone(), + format!("{base_path}_std_dev"), + ), } } } @@ -7306,10 +9901,22 @@ pub struct SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev { impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_All::new(client.clone(), format!("{base_path}_all")), - _4y: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_4y::new(client.clone(), format!("{base_path}_4y")), - _2y: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_2y::new(client.clone(), format!("{base_path}_2y")), - _1y: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_1y::new(client.clone(), format!("{base_path}_1y")), + all: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_All::new( + client.clone(), + format!("{base_path}_all"), + ), + _4y: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_4y::new( + client.clone(), + format!("{base_path}_4y"), + ), + _2y: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_2y::new( + client.clone(), + format!("{base_path}_2y"), + ), + _1y: SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_1y::new( + client.clone(), + format!("{base_path}_1y"), + ), } } } @@ -7337,20 +9944,71 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_All { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_sd".to_string()), - zscore: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_zscore".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "lth_realized_price_ratio_zscore".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "lth_realized_price_0sd".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p0_5sd".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1sd".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1_5sd".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2sd".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2_5sd".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p3sd".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m0_5sd".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1sd".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1_5sd".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2sd".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2_5sd".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m3sd".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p0_5sd".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1sd".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1_5sd".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2sd".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2_5sd".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p3sd".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m0_5sd".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1sd".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1_5sd".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2sd".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2_5sd".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m3sd".to_string(), + ), } } } @@ -7378,20 +10036,71 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_4y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_sd_4y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_zscore_4y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "lth_realized_price_ratio_zscore_4y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "lth_realized_price_0sd_4y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p0_5sd_4y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1sd_4y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1_5sd_4y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2sd_4y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2_5sd_4y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p3sd_4y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m0_5sd_4y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1sd_4y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1_5sd_4y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2sd_4y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2_5sd_4y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m3sd_4y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p0_5sd_4y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1sd_4y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1_5sd_4y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2sd_4y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2_5sd_4y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p3sd_4y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m0_5sd_4y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1sd_4y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1_5sd_4y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2sd_4y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2_5sd_4y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m3sd_4y".to_string(), + ), } } } @@ -7419,20 +10128,71 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_2y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_sd_2y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_zscore_2y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "lth_realized_price_ratio_zscore_2y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "lth_realized_price_0sd_2y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p0_5sd_2y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1sd_2y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1_5sd_2y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2sd_2y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2_5sd_2y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p3sd_2y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m0_5sd_2y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1sd_2y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1_5sd_2y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2sd_2y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2_5sd_2y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m3sd_2y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p0_5sd_2y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1sd_2y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1_5sd_2y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2sd_2y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2_5sd_2y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p3sd_2y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m0_5sd_2y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1sd_2y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1_5sd_2y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2sd_2y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2_5sd_2y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m3sd_2y".to_string(), + ), } } } @@ -7460,20 +10220,71 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price_StdDev_1y { pub fn new(client: Arc, base_path: String) -> Self { Self { sd: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_sd_1y".to_string()), - zscore: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_zscore_1y".to_string()), + zscore: SeriesPattern1::new( + client.clone(), + "lth_realized_price_ratio_zscore_1y".to_string(), + ), _0sd: CentsSatsUsdPattern::new(client.clone(), "lth_realized_price_0sd_1y".to_string()), - p0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p0_5sd_1y".to_string()), - p1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1sd_1y".to_string()), - p1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p1_5sd_1y".to_string()), - p2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2sd_1y".to_string()), - p2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p2_5sd_1y".to_string()), - p3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "p3sd_1y".to_string()), - m0_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m0_5sd_1y".to_string()), - m1sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1sd_1y".to_string()), - m1_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m1_5sd_1y".to_string()), - m2sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2sd_1y".to_string()), - m2_5sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m2_5sd_1y".to_string()), - m3sd: PriceRatioPattern::new(client.clone(), "lth_realized_price".to_string(), "m3sd_1y".to_string()), + p0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p0_5sd_1y".to_string(), + ), + p1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1sd_1y".to_string(), + ), + p1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p1_5sd_1y".to_string(), + ), + p2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2sd_1y".to_string(), + ), + p2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p2_5sd_1y".to_string(), + ), + p3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "p3sd_1y".to_string(), + ), + m0_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m0_5sd_1y".to_string(), + ), + m1sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1sd_1y".to_string(), + ), + m1_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m1_5sd_1y".to_string(), + ), + m2sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2sd_1y".to_string(), + ), + m2_5sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m2_5sd_1y".to_string(), + ), + m3sd: PriceRatioPattern::new( + client.clone(), + "lth_realized_price".to_string(), + "m3sd_1y".to_string(), + ), } } } @@ -7487,7 +10298,10 @@ pub struct SeriesTree_Cohorts_Utxo_Lth_Realized_Sopr { impl SeriesTree_Cohorts_Utxo_Lth_Realized_Sopr { pub fn new(client: Arc, base_path: String) -> Self { Self { - value_destroyed: AverageBlockCumulativeSumPattern::new(client.clone(), "lth_value_destroyed".to_string()), + value_destroyed: AverageBlockCumulativeSumPattern::new( + client.clone(), + "lth_value_destroyed".to_string(), + ), ratio: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), } } @@ -7521,27 +10335,90 @@ pub struct SeriesTree_Cohorts_Utxo_AgeRange { impl SeriesTree_Cohorts_Utxo_AgeRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - under_1h: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1h_old".to_string()), - _1h_to_1d: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1h_to_1d_old".to_string()), - _1d_to_1w: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1d_to_1w_old".to_string()), - _1w_to_1m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1w_to_1m_old".to_string()), - _1m_to_2m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1m_to_2m_old".to_string()), - _2m_to_3m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_2m_to_3m_old".to_string()), - _3m_to_4m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_3m_to_4m_old".to_string()), - _4m_to_5m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_4m_to_5m_old".to_string()), - _5m_to_6m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_5m_to_6m_old".to_string()), - _6m_to_1y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_6m_to_1y_old".to_string()), - _1y_to_2y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1y_to_2y_old".to_string()), - _2y_to_3y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_2y_to_3y_old".to_string()), - _3y_to_4y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_3y_to_4y_old".to_string()), - _4y_to_5y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_4y_to_5y_old".to_string()), - _5y_to_6y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_5y_to_6y_old".to_string()), - _6y_to_7y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_6y_to_7y_old".to_string()), - _7y_to_8y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_7y_to_8y_old".to_string()), - _8y_to_10y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_8y_to_10y_old".to_string()), - _10y_to_12y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10y_to_12y_old".to_string()), - _12y_to_15y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_12y_to_15y_old".to_string()), - over_15y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_15y_old".to_string()), + under_1h: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_1h_old".to_string(), + ), + _1h_to_1d: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_1h_to_1d_old".to_string(), + ), + _1d_to_1w: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_1d_to_1w_old".to_string(), + ), + _1w_to_1m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_1w_to_1m_old".to_string(), + ), + _1m_to_2m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_1m_to_2m_old".to_string(), + ), + _2m_to_3m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_2m_to_3m_old".to_string(), + ), + _3m_to_4m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_3m_to_4m_old".to_string(), + ), + _4m_to_5m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_4m_to_5m_old".to_string(), + ), + _5m_to_6m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_5m_to_6m_old".to_string(), + ), + _6m_to_1y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_6m_to_1y_old".to_string(), + ), + _1y_to_2y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_1y_to_2y_old".to_string(), + ), + _2y_to_3y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_2y_to_3y_old".to_string(), + ), + _3y_to_4y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_3y_to_4y_old".to_string(), + ), + _4y_to_5y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_4y_to_5y_old".to_string(), + ), + _5y_to_6y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_5y_to_6y_old".to_string(), + ), + _6y_to_7y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_6y_to_7y_old".to_string(), + ), + _7y_to_8y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_7y_to_8y_old".to_string(), + ), + _8y_to_10y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_8y_to_10y_old".to_string(), + ), + _10y_to_12y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_10y_to_12y_old".to_string(), + ), + _12y_to_15y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_12y_to_15y_old".to_string(), + ), + over_15y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_15y_old".to_string(), + ), } } } @@ -7571,24 +10448,78 @@ pub struct SeriesTree_Cohorts_Utxo_UnderAge { impl SeriesTree_Cohorts_Utxo_UnderAge { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1w: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1w_old".to_string()), - _1m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1m_old".to_string()), - _2m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_2m_old".to_string()), - _3m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_3m_old".to_string()), - _4m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_4m_old".to_string()), - _5m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_5m_old".to_string()), - _6m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_6m_old".to_string()), - _1y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1y_old".to_string()), - _2y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_2y_old".to_string()), - _3y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_3y_old".to_string()), - _4y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_4y_old".to_string()), - _5y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_5y_old".to_string()), - _6y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_6y_old".to_string()), - _7y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_7y_old".to_string()), - _8y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_8y_old".to_string()), - _10y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10y_old".to_string()), - _12y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_12y_old".to_string()), - _15y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_15y_old".to_string()), + _1w: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_1w_old".to_string(), + ), + _1m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_1m_old".to_string(), + ), + _2m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_2m_old".to_string(), + ), + _3m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_3m_old".to_string(), + ), + _4m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_4m_old".to_string(), + ), + _5m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_5m_old".to_string(), + ), + _6m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_6m_old".to_string(), + ), + _1y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_1y_old".to_string(), + ), + _2y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_2y_old".to_string(), + ), + _3y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_3y_old".to_string(), + ), + _4y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_4y_old".to_string(), + ), + _5y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_5y_old".to_string(), + ), + _6y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_6y_old".to_string(), + ), + _7y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_7y_old".to_string(), + ), + _8y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_8y_old".to_string(), + ), + _10y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_10y_old".to_string(), + ), + _12y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_12y_old".to_string(), + ), + _15y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_under_15y_old".to_string(), + ), } } } @@ -7618,24 +10549,78 @@ pub struct SeriesTree_Cohorts_Utxo_OverAge { impl SeriesTree_Cohorts_Utxo_OverAge { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1d: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1d_old".to_string()), - _1w: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1w_old".to_string()), - _1m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1m_old".to_string()), - _2m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_2m_old".to_string()), - _3m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_3m_old".to_string()), - _4m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_4m_old".to_string()), - _5m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_5m_old".to_string()), - _6m: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_6m_old".to_string()), - _1y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1y_old".to_string()), - _2y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_2y_old".to_string()), - _3y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_3y_old".to_string()), - _4y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_4y_old".to_string()), - _5y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_5y_old".to_string()), - _6y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_6y_old".to_string()), - _7y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_7y_old".to_string()), - _8y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_8y_old".to_string()), - _10y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10y_old".to_string()), - _12y: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_12y_old".to_string()), + _1d: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_1d_old".to_string(), + ), + _1w: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_1w_old".to_string(), + ), + _1m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_1m_old".to_string(), + ), + _2m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_2m_old".to_string(), + ), + _3m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_3m_old".to_string(), + ), + _4m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_4m_old".to_string(), + ), + _5m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_5m_old".to_string(), + ), + _6m: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_6m_old".to_string(), + ), + _1y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_1y_old".to_string(), + ), + _2y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_2y_old".to_string(), + ), + _3y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_3y_old".to_string(), + ), + _4y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_4y_old".to_string(), + ), + _5y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_5y_old".to_string(), + ), + _6y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_6y_old".to_string(), + ), + _7y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_7y_old".to_string(), + ), + _8y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_8y_old".to_string(), + ), + _10y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_10y_old".to_string(), + ), + _12y: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_12y_old".to_string(), + ), } } } @@ -7652,11 +10637,26 @@ pub struct SeriesTree_Cohorts_Utxo_Epoch { impl SeriesTree_Cohorts_Utxo_Epoch { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "epoch_0".to_string()), - _1: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "epoch_1".to_string()), - _2: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "epoch_2".to_string()), - _3: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "epoch_3".to_string()), - _4: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "epoch_4".to_string()), + _0: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "epoch_0".to_string(), + ), + _1: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "epoch_1".to_string(), + ), + _2: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "epoch_2".to_string(), + ), + _3: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "epoch_3".to_string(), + ), + _4: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "epoch_4".to_string(), + ), } } } @@ -7686,24 +10686,78 @@ pub struct SeriesTree_Cohorts_Utxo_Class { impl SeriesTree_Cohorts_Utxo_Class { pub fn new(client: Arc, base_path: String) -> Self { Self { - _2009: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2009".to_string()), - _2010: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2010".to_string()), - _2011: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2011".to_string()), - _2012: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2012".to_string()), - _2013: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2013".to_string()), - _2014: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2014".to_string()), - _2015: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2015".to_string()), - _2016: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2016".to_string()), - _2017: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2017".to_string()), - _2018: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2018".to_string()), - _2019: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2019".to_string()), - _2020: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2020".to_string()), - _2021: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2021".to_string()), - _2022: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2022".to_string()), - _2023: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2023".to_string()), - _2024: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2024".to_string()), - _2025: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2025".to_string()), - _2026: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "class_2026".to_string()), + _2009: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2009".to_string(), + ), + _2010: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2010".to_string(), + ), + _2011: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2011".to_string(), + ), + _2012: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2012".to_string(), + ), + _2013: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2013".to_string(), + ), + _2014: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2014".to_string(), + ), + _2015: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2015".to_string(), + ), + _2016: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2016".to_string(), + ), + _2017: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2017".to_string(), + ), + _2018: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2018".to_string(), + ), + _2019: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2019".to_string(), + ), + _2020: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2020".to_string(), + ), + _2021: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2021".to_string(), + ), + _2022: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2022".to_string(), + ), + _2023: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2023".to_string(), + ), + _2024: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2024".to_string(), + ), + _2025: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2025".to_string(), + ), + _2026: ActivityOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "class_2026".to_string(), + ), } } } @@ -7728,19 +10782,58 @@ pub struct SeriesTree_Cohorts_Utxo_OverAmount { impl SeriesTree_Cohorts_Utxo_OverAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1sat".to_string()), - _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10sats".to_string()), - _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_100sats".to_string()), - _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1k_sats".to_string()), - _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10k_sats".to_string()), - _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_100k_sats".to_string()), - _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1m_sats".to_string()), - _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10m_sats".to_string()), - _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1btc".to_string()), - _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10btc".to_string()), - _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_100btc".to_string()), - _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1k_btc".to_string()), - _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10k_btc".to_string()), + _1sat: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_1sat".to_string(), + ), + _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_10sats".to_string(), + ), + _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_100sats".to_string(), + ), + _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_1k_sats".to_string(), + ), + _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_10k_sats".to_string(), + ), + _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_100k_sats".to_string(), + ), + _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_1m_sats".to_string(), + ), + _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_10m_sats".to_string(), + ), + _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_1btc".to_string(), + ), + _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_10btc".to_string(), + ), + _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_100btc".to_string(), + ), + _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_1k_btc".to_string(), + ), + _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_10k_btc".to_string(), + ), } } } @@ -7767,21 +10860,66 @@ pub struct SeriesTree_Cohorts_Utxo_AmountRange { impl SeriesTree_Cohorts_Utxo_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_0sats".to_string()), - _1sat_to_10sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_1sat_to_10sats".to_string()), - _10sats_to_100sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_10sats_to_100sats".to_string()), - _100sats_to_1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_100sats_to_1k_sats".to_string()), - _1k_sats_to_10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_1k_sats_to_10k_sats".to_string()), - _10k_sats_to_100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_10k_sats_to_100k_sats".to_string()), - _100k_sats_to_1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_100k_sats_to_1m_sats".to_string()), - _1m_sats_to_10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_1m_sats_to_10m_sats".to_string()), - _10m_sats_to_1btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_10m_sats_to_1btc".to_string()), - _1btc_to_10btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_1btc_to_10btc".to_string()), - _10btc_to_100btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_10btc_to_100btc".to_string()), - _100btc_to_1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_100btc_to_1k_btc".to_string()), - _1k_btc_to_10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_1k_btc_to_10k_btc".to_string()), - _10k_btc_to_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_10k_btc_to_100k_btc".to_string()), - over_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_100k_btc".to_string()), + _0sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_0sats".to_string(), + ), + _1sat_to_10sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_1sat_to_10sats".to_string(), + ), + _10sats_to_100sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_10sats_to_100sats".to_string(), + ), + _100sats_to_1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_100sats_to_1k_sats".to_string(), + ), + _1k_sats_to_10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_1k_sats_to_10k_sats".to_string(), + ), + _10k_sats_to_100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_10k_sats_to_100k_sats".to_string(), + ), + _100k_sats_to_1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_100k_sats_to_1m_sats".to_string(), + ), + _1m_sats_to_10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_1m_sats_to_10m_sats".to_string(), + ), + _10m_sats_to_1btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_10m_sats_to_1btc".to_string(), + ), + _1btc_to_10btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_1btc_to_10btc".to_string(), + ), + _10btc_to_100btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_10btc_to_100btc".to_string(), + ), + _100btc_to_1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_100btc_to_1k_btc".to_string(), + ), + _1k_btc_to_10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_1k_btc_to_10k_btc".to_string(), + ), + _10k_btc_to_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_10k_btc_to_100k_btc".to_string(), + ), + over_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_over_100k_btc".to_string(), + ), } } } @@ -7806,19 +10944,58 @@ pub struct SeriesTree_Cohorts_Utxo_UnderAmount { impl SeriesTree_Cohorts_Utxo_UnderAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10sats".to_string()), - _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_100sats".to_string()), - _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1k_sats".to_string()), - _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10k_sats".to_string()), - _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_100k_sats".to_string()), - _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1m_sats".to_string()), - _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10m_sats".to_string()), - _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1btc".to_string()), - _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10btc".to_string()), - _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_100btc".to_string()), - _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1k_btc".to_string()), - _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10k_btc".to_string()), - _100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_100k_btc".to_string()), + _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_10sats".to_string(), + ), + _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_100sats".to_string(), + ), + _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_1k_sats".to_string(), + ), + _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_10k_sats".to_string(), + ), + _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_100k_sats".to_string(), + ), + _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_1m_sats".to_string(), + ), + _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_10m_sats".to_string(), + ), + _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_1btc".to_string(), + ), + _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_10btc".to_string(), + ), + _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_100btc".to_string(), + ), + _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_1k_btc".to_string(), + ), + _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_10k_btc".to_string(), + ), + _100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern2::new( + client.clone(), + "utxos_under_100k_btc".to_string(), + ), } } } @@ -7841,17 +11018,50 @@ pub struct SeriesTree_Cohorts_Utxo_Type { impl SeriesTree_Cohorts_Utxo_Type { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2pk65".to_string()), - p2pk33: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2pk33".to_string()), - p2pkh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2pkh".to_string()), - p2ms: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2ms".to_string()), - p2sh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2sh".to_string()), - p2wpkh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2wpkh".to_string()), - p2wsh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2wsh".to_string()), - p2tr: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2tr".to_string()), - p2a: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "p2a".to_string()), - unknown: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "unknown_outputs".to_string()), - empty: ActivityOutputsRealizedSupplyUnrealizedPattern3::new(client.clone(), "empty_outputs".to_string()), + p2pk65: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2pk65".to_string(), + ), + p2pk33: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2pk33".to_string(), + ), + p2pkh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2pkh".to_string(), + ), + p2ms: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2ms".to_string(), + ), + p2sh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2sh".to_string(), + ), + p2wpkh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2wpkh".to_string(), + ), + p2wsh: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2wsh".to_string(), + ), + p2tr: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2tr".to_string(), + ), + p2a: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "p2a".to_string(), + ), + unknown: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "unknown_outputs".to_string(), + ), + empty: ActivityOutputsRealizedSupplyUnrealizedPattern3::new( + client.clone(), + "empty_outputs".to_string(), + ), } } } @@ -7866,9 +11076,18 @@ pub struct SeriesTree_Cohorts_Utxo_Profitability { impl SeriesTree_Cohorts_Utxo_Profitability { pub fn new(client: Arc, base_path: String) -> Self { Self { - range: SeriesTree_Cohorts_Utxo_Profitability_Range::new(client.clone(), format!("{base_path}_range")), - profit: SeriesTree_Cohorts_Utxo_Profitability_Profit::new(client.clone(), format!("{base_path}_profit")), - loss: SeriesTree_Cohorts_Utxo_Profitability_Loss::new(client.clone(), format!("{base_path}_loss")), + range: SeriesTree_Cohorts_Utxo_Profitability_Range::new( + client.clone(), + format!("{base_path}_range"), + ), + profit: SeriesTree_Cohorts_Utxo_Profitability_Profit::new( + client.clone(), + format!("{base_path}_profit"), + ), + loss: SeriesTree_Cohorts_Utxo_Profitability_Loss::new( + client.clone(), + format!("{base_path}_loss"), + ), } } } @@ -7905,31 +11124,106 @@ pub struct SeriesTree_Cohorts_Utxo_Profitability_Range { impl SeriesTree_Cohorts_Utxo_Profitability_Range { pub fn new(client: Arc, base_path: String) -> Self { Self { - over_1000pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1000pct_in_profit".to_string()), - _500pct_to_1000pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_500pct_to_1000pct_in_profit".to_string()), - _300pct_to_500pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_300pct_to_500pct_in_profit".to_string()), - _200pct_to_300pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_200pct_to_300pct_in_profit".to_string()), - _100pct_to_200pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_100pct_to_200pct_in_profit".to_string()), - _90pct_to_100pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_90pct_to_100pct_in_profit".to_string()), - _80pct_to_90pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_80pct_to_90pct_in_profit".to_string()), - _70pct_to_80pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_70pct_to_80pct_in_profit".to_string()), - _60pct_to_70pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_60pct_to_70pct_in_profit".to_string()), - _50pct_to_60pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_50pct_to_60pct_in_profit".to_string()), - _40pct_to_50pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_40pct_to_50pct_in_profit".to_string()), - _30pct_to_40pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_30pct_to_40pct_in_profit".to_string()), - _20pct_to_30pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_20pct_to_30pct_in_profit".to_string()), - _10pct_to_20pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10pct_to_20pct_in_profit".to_string()), - _0pct_to_10pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_0pct_to_10pct_in_profit".to_string()), - _0pct_to_10pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_0pct_to_10pct_in_loss".to_string()), - _10pct_to_20pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10pct_to_20pct_in_loss".to_string()), - _20pct_to_30pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_20pct_to_30pct_in_loss".to_string()), - _30pct_to_40pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_30pct_to_40pct_in_loss".to_string()), - _40pct_to_50pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_40pct_to_50pct_in_loss".to_string()), - _50pct_to_60pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_50pct_to_60pct_in_loss".to_string()), - _60pct_to_70pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_60pct_to_70pct_in_loss".to_string()), - _70pct_to_80pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_70pct_to_80pct_in_loss".to_string()), - _80pct_to_90pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_80pct_to_90pct_in_loss".to_string()), - _90pct_to_100pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_90pct_to_100pct_in_loss".to_string()), + over_1000pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_1000pct_in_profit".to_string(), + ), + _500pct_to_1000pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_500pct_to_1000pct_in_profit".to_string(), + ), + _300pct_to_500pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_300pct_to_500pct_in_profit".to_string(), + ), + _200pct_to_300pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_200pct_to_300pct_in_profit".to_string(), + ), + _100pct_to_200pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_100pct_to_200pct_in_profit".to_string(), + ), + _90pct_to_100pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_90pct_to_100pct_in_profit".to_string(), + ), + _80pct_to_90pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_80pct_to_90pct_in_profit".to_string(), + ), + _70pct_to_80pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_70pct_to_80pct_in_profit".to_string(), + ), + _60pct_to_70pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_60pct_to_70pct_in_profit".to_string(), + ), + _50pct_to_60pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_50pct_to_60pct_in_profit".to_string(), + ), + _40pct_to_50pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_40pct_to_50pct_in_profit".to_string(), + ), + _30pct_to_40pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_30pct_to_40pct_in_profit".to_string(), + ), + _20pct_to_30pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_20pct_to_30pct_in_profit".to_string(), + ), + _10pct_to_20pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_10pct_to_20pct_in_profit".to_string(), + ), + _0pct_to_10pct_in_profit: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_0pct_to_10pct_in_profit".to_string(), + ), + _0pct_to_10pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_0pct_to_10pct_in_loss".to_string(), + ), + _10pct_to_20pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_10pct_to_20pct_in_loss".to_string(), + ), + _20pct_to_30pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_20pct_to_30pct_in_loss".to_string(), + ), + _30pct_to_40pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_30pct_to_40pct_in_loss".to_string(), + ), + _40pct_to_50pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_40pct_to_50pct_in_loss".to_string(), + ), + _50pct_to_60pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_50pct_to_60pct_in_loss".to_string(), + ), + _60pct_to_70pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_60pct_to_70pct_in_loss".to_string(), + ), + _70pct_to_80pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_70pct_to_80pct_in_loss".to_string(), + ), + _80pct_to_90pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_80pct_to_90pct_in_loss".to_string(), + ), + _90pct_to_100pct_in_loss: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_90pct_to_100pct_in_loss".to_string(), + ), } } } @@ -7955,20 +11249,62 @@ pub struct SeriesTree_Cohorts_Utxo_Profitability_Profit { impl SeriesTree_Cohorts_Utxo_Profitability_Profit { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_in_profit".to_string()), - _10pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10pct_in_profit".to_string()), - _20pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_20pct_in_profit".to_string()), - _30pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_30pct_in_profit".to_string()), - _40pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_40pct_in_profit".to_string()), - _50pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_50pct_in_profit".to_string()), - _60pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_60pct_in_profit".to_string()), - _70pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_70pct_in_profit".to_string()), - _80pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_80pct_in_profit".to_string()), - _90pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_90pct_in_profit".to_string()), - _100pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100pct_in_profit".to_string()), - _200pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_200pct_in_profit".to_string()), - _300pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_300pct_in_profit".to_string()), - _500pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_500pct_in_profit".to_string()), + all: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_in_profit".to_string(), + ), + _10pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_10pct_in_profit".to_string(), + ), + _20pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_20pct_in_profit".to_string(), + ), + _30pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_30pct_in_profit".to_string(), + ), + _40pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_40pct_in_profit".to_string(), + ), + _50pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_50pct_in_profit".to_string(), + ), + _60pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_60pct_in_profit".to_string(), + ), + _70pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_70pct_in_profit".to_string(), + ), + _80pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_80pct_in_profit".to_string(), + ), + _90pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_90pct_in_profit".to_string(), + ), + _100pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_100pct_in_profit".to_string(), + ), + _200pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_200pct_in_profit".to_string(), + ), + _300pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_300pct_in_profit".to_string(), + ), + _500pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_500pct_in_profit".to_string(), + ), } } } @@ -7989,15 +11325,42 @@ pub struct SeriesTree_Cohorts_Utxo_Profitability_Loss { impl SeriesTree_Cohorts_Utxo_Profitability_Loss { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_in_loss".to_string()), - _10pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10pct_in_loss".to_string()), - _20pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_20pct_in_loss".to_string()), - _30pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_30pct_in_loss".to_string()), - _40pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_40pct_in_loss".to_string()), - _50pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_50pct_in_loss".to_string()), - _60pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_60pct_in_loss".to_string()), - _70pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_70pct_in_loss".to_string()), - _80pct: NuplRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_80pct_in_loss".to_string()), + all: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_in_loss".to_string(), + ), + _10pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_10pct_in_loss".to_string(), + ), + _20pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_20pct_in_loss".to_string(), + ), + _30pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_30pct_in_loss".to_string(), + ), + _40pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_40pct_in_loss".to_string(), + ), + _50pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_50pct_in_loss".to_string(), + ), + _60pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_60pct_in_loss".to_string(), + ), + _70pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_70pct_in_loss".to_string(), + ), + _80pct: NuplRealizedSupplyUnrealizedPattern::new( + client.clone(), + "utxos_over_80pct_in_loss".to_string(), + ), } } } @@ -8030,27 +11393,90 @@ pub struct SeriesTree_Cohorts_Utxo_Matured { impl SeriesTree_Cohorts_Utxo_Matured { pub fn new(client: Arc, base_path: String) -> Self { Self { - under_1h: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_under_1h_old_matured_supply".to_string()), - _1h_to_1d: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_1h_to_1d_old_matured_supply".to_string()), - _1d_to_1w: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_1d_to_1w_old_matured_supply".to_string()), - _1w_to_1m: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_1w_to_1m_old_matured_supply".to_string()), - _1m_to_2m: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_1m_to_2m_old_matured_supply".to_string()), - _2m_to_3m: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_2m_to_3m_old_matured_supply".to_string()), - _3m_to_4m: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_3m_to_4m_old_matured_supply".to_string()), - _4m_to_5m: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_4m_to_5m_old_matured_supply".to_string()), - _5m_to_6m: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_5m_to_6m_old_matured_supply".to_string()), - _6m_to_1y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_6m_to_1y_old_matured_supply".to_string()), - _1y_to_2y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_1y_to_2y_old_matured_supply".to_string()), - _2y_to_3y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_2y_to_3y_old_matured_supply".to_string()), - _3y_to_4y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_3y_to_4y_old_matured_supply".to_string()), - _4y_to_5y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_4y_to_5y_old_matured_supply".to_string()), - _5y_to_6y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_5y_to_6y_old_matured_supply".to_string()), - _6y_to_7y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_6y_to_7y_old_matured_supply".to_string()), - _7y_to_8y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_7y_to_8y_old_matured_supply".to_string()), - _8y_to_10y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_8y_to_10y_old_matured_supply".to_string()), - _10y_to_12y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_10y_to_12y_old_matured_supply".to_string()), - _12y_to_15y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_12y_to_15y_old_matured_supply".to_string()), - over_15y: AverageBlockCumulativeSumPattern3::new(client.clone(), "utxos_over_15y_old_matured_supply".to_string()), + under_1h: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_under_1h_old_matured_supply".to_string(), + ), + _1h_to_1d: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_1h_to_1d_old_matured_supply".to_string(), + ), + _1d_to_1w: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_1d_to_1w_old_matured_supply".to_string(), + ), + _1w_to_1m: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_1w_to_1m_old_matured_supply".to_string(), + ), + _1m_to_2m: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_1m_to_2m_old_matured_supply".to_string(), + ), + _2m_to_3m: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_2m_to_3m_old_matured_supply".to_string(), + ), + _3m_to_4m: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_3m_to_4m_old_matured_supply".to_string(), + ), + _4m_to_5m: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_4m_to_5m_old_matured_supply".to_string(), + ), + _5m_to_6m: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_5m_to_6m_old_matured_supply".to_string(), + ), + _6m_to_1y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_6m_to_1y_old_matured_supply".to_string(), + ), + _1y_to_2y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_1y_to_2y_old_matured_supply".to_string(), + ), + _2y_to_3y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_2y_to_3y_old_matured_supply".to_string(), + ), + _3y_to_4y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_3y_to_4y_old_matured_supply".to_string(), + ), + _4y_to_5y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_4y_to_5y_old_matured_supply".to_string(), + ), + _5y_to_6y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_5y_to_6y_old_matured_supply".to_string(), + ), + _6y_to_7y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_6y_to_7y_old_matured_supply".to_string(), + ), + _7y_to_8y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_7y_to_8y_old_matured_supply".to_string(), + ), + _8y_to_10y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_8y_to_10y_old_matured_supply".to_string(), + ), + _10y_to_12y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_10y_to_12y_old_matured_supply".to_string(), + ), + _12y_to_15y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_12y_to_15y_old_matured_supply".to_string(), + ), + over_15y: AverageBlockCumulativeSumPattern3::new( + client.clone(), + "utxos_over_15y_old_matured_supply".to_string(), + ), } } } @@ -8065,9 +11491,18 @@ pub struct SeriesTree_Cohorts_Addr { impl SeriesTree_Cohorts_Addr { pub fn new(client: Arc, base_path: String) -> Self { Self { - over_amount: SeriesTree_Cohorts_Addr_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), - amount_range: SeriesTree_Cohorts_Addr_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), - under_amount: SeriesTree_Cohorts_Addr_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), + over_amount: SeriesTree_Cohorts_Addr_OverAmount::new( + client.clone(), + format!("{base_path}_over_amount"), + ), + amount_range: SeriesTree_Cohorts_Addr_AmountRange::new( + client.clone(), + format!("{base_path}_amount_range"), + ), + under_amount: SeriesTree_Cohorts_Addr_UnderAmount::new( + client.clone(), + format!("{base_path}_under_amount"), + ), } } } @@ -8092,19 +11527,58 @@ pub struct SeriesTree_Cohorts_Addr_OverAmount { impl SeriesTree_Cohorts_Addr_OverAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1sat".to_string()), - _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10sats".to_string()), - _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100sats".to_string()), - _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), - _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), - _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), - _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), - _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), - _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1btc".to_string()), - _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10btc".to_string()), - _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100btc".to_string()), - _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), - _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), + _1sat: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_1sat".to_string(), + ), + _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_10sats".to_string(), + ), + _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_100sats".to_string(), + ), + _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_1k_sats".to_string(), + ), + _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_10k_sats".to_string(), + ), + _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_100k_sats".to_string(), + ), + _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_1m_sats".to_string(), + ), + _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_10m_sats".to_string(), + ), + _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_1btc".to_string(), + ), + _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_10btc".to_string(), + ), + _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_100btc".to_string(), + ), + _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_1k_btc".to_string(), + ), + _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_10k_btc".to_string(), + ), } } } @@ -8131,21 +11605,66 @@ pub struct SeriesTree_Cohorts_Addr_AmountRange { impl SeriesTree_Cohorts_Addr_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_0sats".to_string()), - _1sat_to_10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1sat_to_10sats".to_string()), - _10sats_to_100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10sats_to_100sats".to_string()), - _100sats_to_1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100sats_to_1k_sats".to_string()), - _1k_sats_to_10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_sats_to_10k_sats".to_string()), - _10k_sats_to_100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_sats_to_100k_sats".to_string()), - _100k_sats_to_1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100k_sats_to_1m_sats".to_string()), - _1m_sats_to_10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1m_sats_to_10m_sats".to_string()), - _10m_sats_to_1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10m_sats_to_1btc".to_string()), - _1btc_to_10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1btc_to_10btc".to_string()), - _10btc_to_100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10btc_to_100btc".to_string()), - _100btc_to_1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100btc_to_1k_btc".to_string()), - _1k_btc_to_10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_btc_to_10k_btc".to_string()), - _10k_btc_to_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_btc_to_100k_btc".to_string()), - over_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_btc".to_string()), + _0sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_0sats".to_string(), + ), + _1sat_to_10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_1sat_to_10sats".to_string(), + ), + _10sats_to_100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_10sats_to_100sats".to_string(), + ), + _100sats_to_1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_100sats_to_1k_sats".to_string(), + ), + _1k_sats_to_10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_1k_sats_to_10k_sats".to_string(), + ), + _10k_sats_to_100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_10k_sats_to_100k_sats".to_string(), + ), + _100k_sats_to_1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_100k_sats_to_1m_sats".to_string(), + ), + _1m_sats_to_10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_1m_sats_to_10m_sats".to_string(), + ), + _10m_sats_to_1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_10m_sats_to_1btc".to_string(), + ), + _1btc_to_10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_1btc_to_10btc".to_string(), + ), + _10btc_to_100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_10btc_to_100btc".to_string(), + ), + _100btc_to_1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_100btc_to_1k_btc".to_string(), + ), + _1k_btc_to_10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_1k_btc_to_10k_btc".to_string(), + ), + _10k_btc_to_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_10k_btc_to_100k_btc".to_string(), + ), + over_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_over_100k_btc".to_string(), + ), } } } @@ -8170,19 +11689,58 @@ pub struct SeriesTree_Cohorts_Addr_UnderAmount { impl SeriesTree_Cohorts_Addr_UnderAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10sats".to_string()), - _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100sats".to_string()), - _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), - _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), - _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), - _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), - _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), - _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1btc".to_string()), - _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10btc".to_string()), - _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100btc".to_string()), - _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), - _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), - _100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), + _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_10sats".to_string(), + ), + _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_100sats".to_string(), + ), + _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_1k_sats".to_string(), + ), + _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_10k_sats".to_string(), + ), + _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_100k_sats".to_string(), + ), + _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_1m_sats".to_string(), + ), + _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_10m_sats".to_string(), + ), + _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_1btc".to_string(), + ), + _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_10btc".to_string(), + ), + _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_100btc".to_string(), + ), + _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_1k_btc".to_string(), + ), + _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_10k_btc".to_string(), + ), + _100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new( + client.clone(), + "addrs_under_100k_btc".to_string(), + ), } } } @@ -8227,20 +11785,26 @@ impl BrkClient { /// .last(10) /// .json::()?; /// ``` - pub fn series_endpoint(&self, series: impl Into, index: Index) -> SeriesEndpoint { - SeriesEndpoint::new( - self.base.clone(), - Arc::from(series.into().as_str()), - index, - ) + pub fn series_endpoint( + &self, + series: impl Into, + index: Index, + ) -> SeriesEndpoint { + SeriesEndpoint::new(self.base.clone(), Arc::from(series.into().as_str()), index) } /// Create a dynamic date-based series endpoint builder. /// /// Returns `Err` if the index is not date-based. - pub fn date_series_endpoint(&self, series: impl Into, index: Index) -> Result> { + pub fn date_series_endpoint( + &self, + series: impl Into, + index: Index, + ) -> Result> { if !index.is_date_based() { - return Err(BrkError { message: format!("{} is not a date-based index", index.name()) }); + return Err(BrkError { + message: format!("{} is not a date-based index", index.name()), + }); } Ok(DateSeriesEndpoint::new( self.base.clone(), @@ -8276,10 +11840,20 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions)* /// /// Endpoint: `GET /api/address/{address}/txs` - pub fn get_address_txs(&self, address: Addr, after_txid: Option) -> Result> { + pub fn get_address_txs( + &self, + address: Addr, + after_txid: Option, + ) -> Result> { let mut query = Vec::new(); - if let Some(v) = after_txid { query.push(format!("after_txid={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = after_txid { + query.push(format!("after_txid={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/address/{address}/txs{}", query_str); self.base.get_json(&path) } @@ -8291,10 +11865,20 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-chain)* /// /// Endpoint: `GET /api/address/{address}/txs/chain` - pub fn get_address_confirmed_txs(&self, address: Addr, after_txid: Option) -> Result> { + pub fn get_address_confirmed_txs( + &self, + address: Addr, + after_txid: Option, + ) -> Result> { let mut query = Vec::new(); - if let Some(v) = after_txid { query.push(format!("after_txid={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = after_txid { + query.push(format!("after_txid={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/address/{address}/txs/chain{}", query_str); self.base.get_json(&path) } @@ -8307,7 +11891,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/address/{address}/txs/mempool` pub fn get_address_mempool_txs(&self, address: Addr) -> Result> { - self.base.get_json(&format!("/api/address/{address}/txs/mempool")) + self.base + .get_json(&format!("/api/address/{address}/txs/mempool")) } /// Address UTXOs @@ -8373,7 +11958,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/block/{hash}/txid/{index}` pub fn get_block_txid(&self, hash: BlockHash, index: TxIndex) -> Result { - self.base.get_json(&format!("/api/block/{hash}/txid/{index}")) + self.base + .get_json(&format!("/api/block/{hash}/txid/{index}")) } /// Block transaction IDs @@ -8395,7 +11981,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/block/{hash}/txs/{start_index}` pub fn get_block_txs(&self, hash: BlockHash, start_index: TxIndex) -> Result> { - self.base.get_json(&format!("/api/block/{hash}/txs/{start_index}")) + self.base + .get_json(&format!("/api/block/{hash}/txs/{start_index}")) } /// Recent blocks @@ -8465,15 +12052,35 @@ impl BrkClient { /// Fetch multiple series in a single request. Supports filtering by index and date range. Returns an array of SeriesData objects. For a single series, use `get_series` instead. /// /// Endpoint: `GET /api/series/bulk` - pub fn get_series_bulk(&self, series: SeriesList, index: Index, start: Option, end: Option, limit: Option, format: Option) -> Result>> { + pub fn get_series_bulk( + &self, + series: SeriesList, + index: Index, + start: Option, + end: Option, + limit: Option, + format: Option, + ) -> Result>> { let mut query = Vec::new(); query.push(format!("series={}", series)); query.push(format!("index={}", index)); - if let Some(v) = start { query.push(format!("start={}", v)); } - if let Some(v) = end { query.push(format!("end={}", v)); } - if let Some(v) = limit { query.push(format!("limit={}", v)); } - if let Some(v) = format { query.push(format!("format={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = start { + query.push(format!("start={}", v)); + } + if let Some(v) = end { + query.push(format!("end={}", v)); + } + if let Some(v) = limit { + query.push(format!("limit={}", v)); + } + if let Some(v) = format { + query.push(format!("format={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/series/bulk{}", query_str); if format == Some(Format::CSV) { self.base.get_text(&path).map(FormatResponse::Csv) @@ -8497,7 +12104,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/series/cost-basis/{cohort}/dates` pub fn get_cost_basis_dates(&self, cohort: Cohort) -> Result> { - self.base.get_json(&format!("/api/series/cost-basis/{cohort}/dates")) + self.base + .get_json(&format!("/api/series/cost-basis/{cohort}/dates")) } /// Cost basis distribution @@ -8509,11 +12117,25 @@ impl BrkClient { /// - `value`: supply (default, in BTC), realized (USD), unrealized (USD) /// /// Endpoint: `GET /api/series/cost-basis/{cohort}/{date}` - pub fn get_cost_basis(&self, cohort: Cohort, date: &str, bucket: Option, value: Option) -> Result { + pub fn get_cost_basis( + &self, + cohort: Cohort, + date: &str, + bucket: Option, + value: Option, + ) -> Result { let mut query = Vec::new(); - if let Some(v) = bucket { query.push(format!("bucket={}", v)); } - if let Some(v) = value { query.push(format!("value={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = bucket { + query.push(format!("bucket={}", v)); + } + if let Some(v) = value { + query.push(format!("value={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/series/cost-basis/{cohort}/{date}{}", query_str); self.base.get_json(&path) } @@ -8543,9 +12165,17 @@ impl BrkClient { /// Endpoint: `GET /api/series/list` pub fn list_series(&self, page: Option, per_page: Option) -> Result { let mut query = Vec::new(); - if let Some(v) = page { query.push(format!("page={}", v)); } - if let Some(v) = per_page { query.push(format!("per_page={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = page { + query.push(format!("page={}", v)); + } + if let Some(v) = per_page { + query.push(format!("per_page={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/series/list{}", query_str); self.base.get_json(&path) } @@ -8558,8 +12188,14 @@ impl BrkClient { pub fn search_series(&self, q: SeriesName, limit: Option) -> Result> { let mut query = Vec::new(); query.push(format!("q={}", q)); - if let Some(v) = limit { query.push(format!("limit={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = limit { + query.push(format!("limit={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/series/search{}", query_str); self.base.get_json(&path) } @@ -8578,13 +12214,33 @@ impl BrkClient { /// Fetch data for a specific series at the given index. Use query parameters to filter by date range and format (json/csv). /// /// Endpoint: `GET /api/series/{series}/{index}` - pub fn get_series(&self, series: SeriesName, index: Index, start: Option, end: Option, limit: Option, format: Option) -> Result> { + pub fn get_series( + &self, + series: SeriesName, + index: Index, + start: Option, + end: Option, + limit: Option, + format: Option, + ) -> Result> { let mut query = Vec::new(); - if let Some(v) = start { query.push(format!("start={}", v)); } - if let Some(v) = end { query.push(format!("end={}", v)); } - if let Some(v) = limit { query.push(format!("limit={}", v)); } - if let Some(v) = format { query.push(format!("format={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = start { + query.push(format!("start={}", v)); + } + if let Some(v) = end { + query.push(format!("end={}", v)); + } + if let Some(v) = limit { + query.push(format!("limit={}", v)); + } + if let Some(v) = format { + query.push(format!("format={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/series/{series}/{}{}", index.name(), query_str); if format == Some(Format::CSV) { self.base.get_text(&path).map(FormatResponse::Csv) @@ -8598,13 +12254,33 @@ impl BrkClient { /// Returns just the data array without the SeriesData wrapper. Supports the same range and format parameters as the standard endpoint. /// /// Endpoint: `GET /api/series/{series}/{index}/data` - pub fn get_series_data(&self, series: SeriesName, index: Index, start: Option, end: Option, limit: Option, format: Option) -> Result>> { + pub fn get_series_data( + &self, + series: SeriesName, + index: Index, + start: Option, + end: Option, + limit: Option, + format: Option, + ) -> Result>> { let mut query = Vec::new(); - if let Some(v) = start { query.push(format!("start={}", v)); } - if let Some(v) = end { query.push(format!("end={}", v)); } - if let Some(v) = limit { query.push(format!("limit={}", v)); } - if let Some(v) = format { query.push(format!("format={}", v)); } - let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; + if let Some(v) = start { + query.push(format!("start={}", v)); + } + if let Some(v) = end { + query.push(format!("end={}", v)); + } + if let Some(v) = limit { + query.push(format!("limit={}", v)); + } + if let Some(v) = format { + query.push(format!("format={}", v)); + } + let query_str = if query.is_empty() { + String::new() + } else { + format!("?{}", query.join("&")) + }; let path = format!("/api/series/{series}/{}/data{}", index.name(), query_str); if format == Some(Format::CSV) { self.base.get_text(&path).map(FormatResponse::Csv) @@ -8619,7 +12295,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/series/{series}/{index}/latest` pub fn get_series_latest(&self, series: SeriesName, index: Index) -> Result { - self.base.get_json(&format!("/api/series/{series}/{}/latest", index.name())) + self.base + .get_json(&format!("/api/series/{series}/{}/latest", index.name())) } /// Get series data length @@ -8628,7 +12305,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/series/{series}/{index}/len` pub fn get_series_len(&self, series: SeriesName, index: Index) -> Result { - self.base.get_json(&format!("/api/series/{series}/{}/len", index.name())) + self.base + .get_json(&format!("/api/series/{series}/{}/len", index.name())) } /// Get series version @@ -8637,7 +12315,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/series/{series}/{index}/version` pub fn get_series_version(&self, series: SeriesName, index: Index) -> Result { - self.base.get_json(&format!("/api/series/{series}/{}/version", index.name())) + self.base + .get_json(&format!("/api/series/{series}/{}/version", index.name())) } /// Disk usage @@ -8688,7 +12367,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/tx/{txid}/outspend/{vout}` pub fn get_tx_outspend(&self, txid: Txid, vout: Vout) -> Result { - self.base.get_json(&format!("/api/tx/{txid}/outspend/{vout}")) + self.base + .get_json(&format!("/api/tx/{txid}/outspend/{vout}")) } /// All output spend statuses @@ -8721,7 +12401,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/difficulty-adjustment` pub fn get_difficulty_adjustment(&self) -> Result { - self.base.get_json(&format!("/api/v1/difficulty-adjustment")) + self.base + .get_json(&format!("/api/v1/difficulty-adjustment")) } /// Projected mempool blocks @@ -8754,7 +12435,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/blocks/fee-rates/{time_period}` pub fn get_block_fee_rates(&self, time_period: TimePeriod) -> Result { - self.base.get_json(&format!("/api/v1/mining/blocks/fee-rates/{time_period}")) + self.base + .get_json(&format!("/api/v1/mining/blocks/fee-rates/{time_period}")) } /// Block fees @@ -8765,7 +12447,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/blocks/fees/{time_period}` pub fn get_block_fees(&self, time_period: TimePeriod) -> Result> { - self.base.get_json(&format!("/api/v1/mining/blocks/fees/{time_period}")) + self.base + .get_json(&format!("/api/v1/mining/blocks/fees/{time_period}")) } /// Block rewards @@ -8776,7 +12459,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/blocks/rewards/{time_period}` pub fn get_block_rewards(&self, time_period: TimePeriod) -> Result> { - self.base.get_json(&format!("/api/v1/mining/blocks/rewards/{time_period}")) + self.base + .get_json(&format!("/api/v1/mining/blocks/rewards/{time_period}")) } /// Block sizes and weights @@ -8787,7 +12471,9 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/blocks/sizes-weights/{time_period}` pub fn get_block_sizes_weights(&self, time_period: TimePeriod) -> Result { - self.base.get_json(&format!("/api/v1/mining/blocks/sizes-weights/{time_period}")) + self.base.get_json(&format!( + "/api/v1/mining/blocks/sizes-weights/{time_period}" + )) } /// Block by timestamp @@ -8798,7 +12484,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/blocks/timestamp/{timestamp}` pub fn get_block_by_timestamp(&self, timestamp: Timestamp) -> Result { - self.base.get_json(&format!("/api/v1/mining/blocks/timestamp/{timestamp}")) + self.base + .get_json(&format!("/api/v1/mining/blocks/timestamp/{timestamp}")) } /// Difficulty adjustments (all time) @@ -8809,7 +12496,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/difficulty-adjustments` pub fn get_difficulty_adjustments(&self) -> Result> { - self.base.get_json(&format!("/api/v1/mining/difficulty-adjustments")) + self.base + .get_json(&format!("/api/v1/mining/difficulty-adjustments")) } /// Difficulty adjustments @@ -8819,8 +12507,13 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-difficulty-adjustments)* /// /// Endpoint: `GET /api/v1/mining/difficulty-adjustments/{time_period}` - pub fn get_difficulty_adjustments_by_period(&self, time_period: TimePeriod) -> Result> { - self.base.get_json(&format!("/api/v1/mining/difficulty-adjustments/{time_period}")) + pub fn get_difficulty_adjustments_by_period( + &self, + time_period: TimePeriod, + ) -> Result> { + self.base.get_json(&format!( + "/api/v1/mining/difficulty-adjustments/{time_period}" + )) } /// Network hashrate (all time) @@ -8842,7 +12535,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/hashrate/{time_period}` pub fn get_hashrate_by_period(&self, time_period: TimePeriod) -> Result { - self.base.get_json(&format!("/api/v1/mining/hashrate/{time_period}")) + self.base + .get_json(&format!("/api/v1/mining/hashrate/{time_period}")) } /// Mining pool details @@ -8875,7 +12569,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/pools/{time_period}` pub fn get_pool_stats(&self, time_period: TimePeriod) -> Result { - self.base.get_json(&format!("/api/v1/mining/pools/{time_period}")) + self.base + .get_json(&format!("/api/v1/mining/pools/{time_period}")) } /// Mining reward statistics @@ -8886,7 +12581,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/mining/reward-stats/{block_count}` pub fn get_reward_stats(&self, block_count: i64) -> Result { - self.base.get_json(&format!("/api/v1/mining/reward-stats/{block_count}")) + self.base + .get_json(&format!("/api/v1/mining/reward-stats/{block_count}")) } /// Validate address @@ -8897,7 +12593,8 @@ impl BrkClient { /// /// Endpoint: `GET /api/v1/validate-address/{address}` pub fn validate_address(&self, address: &str) -> Result { - self.base.get_json(&format!("/api/v1/validate-address/{address}")) + self.base + .get_json(&format!("/api/v1/validate-address/{address}")) } /// Health check @@ -8926,5 +12623,4 @@ impl BrkClient { pub fn get_version(&self) -> Result { self.base.get_json(&format!("/version")) } - } diff --git a/crates/brk_cohort/src/addr.rs b/crates/brk_cohort/src/addr.rs index f74bcd2b3..984efd151 100644 --- a/crates/brk_cohort/src/addr.rs +++ b/crates/brk_cohort/src/addr.rs @@ -75,7 +75,8 @@ impl AddrGroups { } pub fn iter_overlapping_mut(&mut self) -> impl Iterator { - self.under_amount.iter_mut().chain(self.over_amount.iter_mut()) + self.under_amount + .iter_mut() + .chain(self.over_amount.iter_mut()) } } - diff --git a/crates/brk_cohort/src/age_range.rs b/crates/brk_cohort/src/age_range.rs index 09b5657ab..2e26bcd66 100644 --- a/crates/brk_cohort/src/age_range.rs +++ b/crates/brk_cohort/src/age_range.rs @@ -201,7 +201,29 @@ impl AgeRange { } pub fn from_array(arr: [T; 21]) -> Self { - let [a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20] = arr; + let [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12, + a13, + a14, + a15, + a16, + a17, + a18, + a19, + a20, + ] = arr; Self { under_1h: a0, _1h_to_1d: a1, diff --git a/crates/brk_cohort/src/amount_range.rs b/crates/brk_cohort/src/amount_range.rs index a5338031a..9bed2f474 100644 --- a/crates/brk_cohort/src/amount_range.rs +++ b/crates/brk_cohort/src/amount_range.rs @@ -84,7 +84,11 @@ pub const AMOUNT_RANGE_NAMES: AmountRange = AmountRange { _10sats_to_100sats: CohortName::new("10sats_to_100sats", "10-100 sats", "10-100 Sats"), _100sats_to_1k_sats: CohortName::new("100sats_to_1k_sats", "100-1k sats", "100-1K Sats"), _1k_sats_to_10k_sats: CohortName::new("1k_sats_to_10k_sats", "1k-10k sats", "1K-10K Sats"), - _10k_sats_to_100k_sats: CohortName::new("10k_sats_to_100k_sats", "10k-100k sats", "10K-100K Sats"), + _10k_sats_to_100k_sats: CohortName::new( + "10k_sats_to_100k_sats", + "10k-100k sats", + "10K-100K Sats", + ), _100k_sats_to_1m_sats: CohortName::new("100k_sats_to_1m_sats", "100k-1M sats", "100K-1M Sats"), _1m_sats_to_10m_sats: CohortName::new("1m_sats_to_10m_sats", "1M-10M sats", "1M-10M Sats"), _10m_sats_to_1btc: CohortName::new("10m_sats_to_1btc", "0.1-1 BTC", "0.1-1 BTC"), diff --git a/crates/brk_cohort/src/lib.rs b/crates/brk_cohort/src/lib.rs index 303230653..f2905fe5d 100644 --- a/crates/brk_cohort/src/lib.rs +++ b/crates/brk_cohort/src/lib.rs @@ -1,8 +1,8 @@ #![doc = include_str!("../README.md")] mod addr; -mod amount_filter; mod age_range; +mod amount_filter; mod amount_range; mod by_addr_type; mod by_any_addr; @@ -30,8 +30,8 @@ mod utxo; pub use brk_types::{Age, Term}; pub use addr::*; -pub use amount_filter::*; pub use age_range::*; +pub use amount_filter::*; pub use amount_range::*; pub use by_addr_type::*; pub use by_any_addr::*; diff --git a/crates/brk_cohort/src/over_amount.rs b/crates/brk_cohort/src/over_amount.rs index 5c14bf4b5..ccfc026c8 100644 --- a/crates/brk_cohort/src/over_amount.rs +++ b/crates/brk_cohort/src/over_amount.rs @@ -43,19 +43,31 @@ pub const OVER_AMOUNT_NAMES: OverAmount = OverAmount { pub const OVER_AMOUNT_FILTERS: OverAmount = OverAmount { _1sat: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._1sat)), _10sats: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._10sats)), - _100sats: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._100sats)), - _1k_sats: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._1k_sats)), - _10k_sats: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._10k_sats)), + _100sats: Filter::Amount(AmountFilter::GreaterOrEqual( + OVER_AMOUNT_THRESHOLDS._100sats, + )), + _1k_sats: Filter::Amount(AmountFilter::GreaterOrEqual( + OVER_AMOUNT_THRESHOLDS._1k_sats, + )), + _10k_sats: Filter::Amount(AmountFilter::GreaterOrEqual( + OVER_AMOUNT_THRESHOLDS._10k_sats, + )), _100k_sats: Filter::Amount(AmountFilter::GreaterOrEqual( OVER_AMOUNT_THRESHOLDS._100k_sats, )), - _1m_sats: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._1m_sats)), - _10m_sats: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._10m_sats)), + _1m_sats: Filter::Amount(AmountFilter::GreaterOrEqual( + OVER_AMOUNT_THRESHOLDS._1m_sats, + )), + _10m_sats: Filter::Amount(AmountFilter::GreaterOrEqual( + OVER_AMOUNT_THRESHOLDS._10m_sats, + )), _1btc: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._1btc)), _10btc: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._10btc)), _100btc: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._100btc)), _1k_btc: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._1k_btc)), - _10k_btc: Filter::Amount(AmountFilter::GreaterOrEqual(OVER_AMOUNT_THRESHOLDS._10k_btc)), + _10k_btc: Filter::Amount(AmountFilter::GreaterOrEqual( + OVER_AMOUNT_THRESHOLDS._10k_btc, + )), }; #[derive(Default, Clone, Traversable, Serialize)] diff --git a/crates/brk_cohort/src/profit.rs b/crates/brk_cohort/src/profit.rs index 4b200fe20..0feae6b12 100644 --- a/crates/brk_cohort/src/profit.rs +++ b/crates/brk_cohort/src/profit.rs @@ -16,10 +16,26 @@ pub const PROFIT_NAMES: Profit = Profit { _70pct: CohortName::new("utxos_over_70pct_in_profit", ">=70%", "Over 70% in Profit"), _80pct: CohortName::new("utxos_over_80pct_in_profit", ">=80%", "Over 80% in Profit"), _90pct: CohortName::new("utxos_over_90pct_in_profit", ">=90%", "Over 90% in Profit"), - _100pct: CohortName::new("utxos_over_100pct_in_profit", ">=100%", "Over 100% in Profit"), - _200pct: CohortName::new("utxos_over_200pct_in_profit", ">=200%", "Over 200% in Profit"), - _300pct: CohortName::new("utxos_over_300pct_in_profit", ">=300%", "Over 300% in Profit"), - _500pct: CohortName::new("utxos_over_500pct_in_profit", ">=500%", "Over 500% in Profit"), + _100pct: CohortName::new( + "utxos_over_100pct_in_profit", + ">=100%", + "Over 100% in Profit", + ), + _200pct: CohortName::new( + "utxos_over_200pct_in_profit", + ">=200%", + "Over 200% in Profit", + ), + _300pct: CohortName::new( + "utxos_over_300pct_in_profit", + ">=300%", + "Over 300% in Profit", + ), + _500pct: CohortName::new( + "utxos_over_500pct_in_profit", + ">=500%", + "Over 500% in Profit", + ), }; /// Number of profit thresholds. diff --git a/crates/brk_cohort/src/profitability_range.rs b/crates/brk_cohort/src/profitability_range.rs index cad44f299..944962a9e 100644 --- a/crates/brk_cohort/src/profitability_range.rs +++ b/crates/brk_cohort/src/profitability_range.rs @@ -83,31 +83,131 @@ pub fn compute_profitability_boundaries(spot: Cents) -> [Cents; PROFITABILITY_BO /// Profitability range names (25 ranges, from most profitable to most in loss) pub const PROFITABILITY_RANGE_NAMES: ProfitabilityRange = ProfitabilityRange { - over_1000pct_in_profit: CohortName::new("utxos_over_1000pct_in_profit", "+>1000%", "Over 1000% in Profit"), - _500pct_to_1000pct_in_profit: CohortName::new("utxos_500pct_to_1000pct_in_profit", "+500-1000%", "500-1000% in Profit"), - _300pct_to_500pct_in_profit: CohortName::new("utxos_300pct_to_500pct_in_profit", "+300-500%", "300-500% in Profit"), - _200pct_to_300pct_in_profit: CohortName::new("utxos_200pct_to_300pct_in_profit", "+200-300%", "200-300% in Profit"), - _100pct_to_200pct_in_profit: CohortName::new("utxos_100pct_to_200pct_in_profit", "+100-200%", "100-200% in Profit"), - _90pct_to_100pct_in_profit: CohortName::new("utxos_90pct_to_100pct_in_profit", "+90-100%", "90-100% in Profit"), - _80pct_to_90pct_in_profit: CohortName::new("utxos_80pct_to_90pct_in_profit", "+80-90%", "80-90% in Profit"), - _70pct_to_80pct_in_profit: CohortName::new("utxos_70pct_to_80pct_in_profit", "+70-80%", "70-80% in Profit"), - _60pct_to_70pct_in_profit: CohortName::new("utxos_60pct_to_70pct_in_profit", "+60-70%", "60-70% in Profit"), - _50pct_to_60pct_in_profit: CohortName::new("utxos_50pct_to_60pct_in_profit", "+50-60%", "50-60% in Profit"), - _40pct_to_50pct_in_profit: CohortName::new("utxos_40pct_to_50pct_in_profit", "+40-50%", "40-50% in Profit"), - _30pct_to_40pct_in_profit: CohortName::new("utxos_30pct_to_40pct_in_profit", "+30-40%", "30-40% in Profit"), - _20pct_to_30pct_in_profit: CohortName::new("utxos_20pct_to_30pct_in_profit", "+20-30%", "20-30% in Profit"), - _10pct_to_20pct_in_profit: CohortName::new("utxos_10pct_to_20pct_in_profit", "+10-20%", "10-20% in Profit"), - _0pct_to_10pct_in_profit: CohortName::new("utxos_0pct_to_10pct_in_profit", "+0-10%", "0-10% in Profit"), - _0pct_to_10pct_in_loss: CohortName::new("utxos_0pct_to_10pct_in_loss", "-0-10%", "0-10% in Loss"), - _10pct_to_20pct_in_loss: CohortName::new("utxos_10pct_to_20pct_in_loss", "-10-20%", "10-20% in Loss"), - _20pct_to_30pct_in_loss: CohortName::new("utxos_20pct_to_30pct_in_loss", "-20-30%", "20-30% in Loss"), - _30pct_to_40pct_in_loss: CohortName::new("utxos_30pct_to_40pct_in_loss", "-30-40%", "30-40% in Loss"), - _40pct_to_50pct_in_loss: CohortName::new("utxos_40pct_to_50pct_in_loss", "-40-50%", "40-50% in Loss"), - _50pct_to_60pct_in_loss: CohortName::new("utxos_50pct_to_60pct_in_loss", "-50-60%", "50-60% in Loss"), - _60pct_to_70pct_in_loss: CohortName::new("utxos_60pct_to_70pct_in_loss", "-60-70%", "60-70% in Loss"), - _70pct_to_80pct_in_loss: CohortName::new("utxos_70pct_to_80pct_in_loss", "-70-80%", "70-80% in Loss"), - _80pct_to_90pct_in_loss: CohortName::new("utxos_80pct_to_90pct_in_loss", "-80-90%", "80-90% in Loss"), - _90pct_to_100pct_in_loss: CohortName::new("utxos_90pct_to_100pct_in_loss", "-90-100%", "90-100% in Loss"), + over_1000pct_in_profit: CohortName::new( + "utxos_over_1000pct_in_profit", + "+>1000%", + "Over 1000% in Profit", + ), + _500pct_to_1000pct_in_profit: CohortName::new( + "utxos_500pct_to_1000pct_in_profit", + "+500-1000%", + "500-1000% in Profit", + ), + _300pct_to_500pct_in_profit: CohortName::new( + "utxos_300pct_to_500pct_in_profit", + "+300-500%", + "300-500% in Profit", + ), + _200pct_to_300pct_in_profit: CohortName::new( + "utxos_200pct_to_300pct_in_profit", + "+200-300%", + "200-300% in Profit", + ), + _100pct_to_200pct_in_profit: CohortName::new( + "utxos_100pct_to_200pct_in_profit", + "+100-200%", + "100-200% in Profit", + ), + _90pct_to_100pct_in_profit: CohortName::new( + "utxos_90pct_to_100pct_in_profit", + "+90-100%", + "90-100% in Profit", + ), + _80pct_to_90pct_in_profit: CohortName::new( + "utxos_80pct_to_90pct_in_profit", + "+80-90%", + "80-90% in Profit", + ), + _70pct_to_80pct_in_profit: CohortName::new( + "utxos_70pct_to_80pct_in_profit", + "+70-80%", + "70-80% in Profit", + ), + _60pct_to_70pct_in_profit: CohortName::new( + "utxos_60pct_to_70pct_in_profit", + "+60-70%", + "60-70% in Profit", + ), + _50pct_to_60pct_in_profit: CohortName::new( + "utxos_50pct_to_60pct_in_profit", + "+50-60%", + "50-60% in Profit", + ), + _40pct_to_50pct_in_profit: CohortName::new( + "utxos_40pct_to_50pct_in_profit", + "+40-50%", + "40-50% in Profit", + ), + _30pct_to_40pct_in_profit: CohortName::new( + "utxos_30pct_to_40pct_in_profit", + "+30-40%", + "30-40% in Profit", + ), + _20pct_to_30pct_in_profit: CohortName::new( + "utxos_20pct_to_30pct_in_profit", + "+20-30%", + "20-30% in Profit", + ), + _10pct_to_20pct_in_profit: CohortName::new( + "utxos_10pct_to_20pct_in_profit", + "+10-20%", + "10-20% in Profit", + ), + _0pct_to_10pct_in_profit: CohortName::new( + "utxos_0pct_to_10pct_in_profit", + "+0-10%", + "0-10% in Profit", + ), + _0pct_to_10pct_in_loss: CohortName::new( + "utxos_0pct_to_10pct_in_loss", + "-0-10%", + "0-10% in Loss", + ), + _10pct_to_20pct_in_loss: CohortName::new( + "utxos_10pct_to_20pct_in_loss", + "-10-20%", + "10-20% in Loss", + ), + _20pct_to_30pct_in_loss: CohortName::new( + "utxos_20pct_to_30pct_in_loss", + "-20-30%", + "20-30% in Loss", + ), + _30pct_to_40pct_in_loss: CohortName::new( + "utxos_30pct_to_40pct_in_loss", + "-30-40%", + "30-40% in Loss", + ), + _40pct_to_50pct_in_loss: CohortName::new( + "utxos_40pct_to_50pct_in_loss", + "-40-50%", + "40-50% in Loss", + ), + _50pct_to_60pct_in_loss: CohortName::new( + "utxos_50pct_to_60pct_in_loss", + "-50-60%", + "50-60% in Loss", + ), + _60pct_to_70pct_in_loss: CohortName::new( + "utxos_60pct_to_70pct_in_loss", + "-60-70%", + "60-70% in Loss", + ), + _70pct_to_80pct_in_loss: CohortName::new( + "utxos_70pct_to_80pct_in_loss", + "-70-80%", + "70-80% in Loss", + ), + _80pct_to_90pct_in_loss: CohortName::new( + "utxos_80pct_to_90pct_in_loss", + "-80-90%", + "80-90% in Loss", + ), + _90pct_to_100pct_in_loss: CohortName::new( + "utxos_90pct_to_100pct_in_loss", + "-90-100%", + "90-100% in Loss", + ), }; impl ProfitabilityRange { diff --git a/crates/brk_cohort/src/utxo.rs b/crates/brk_cohort/src/utxo.rs index c76a5355c..38835faa9 100644 --- a/crates/brk_cohort/src/utxo.rs +++ b/crates/brk_cohort/src/utxo.rs @@ -2,8 +2,8 @@ use brk_traversable::Traversable; use rayon::prelude::*; use crate::{ - AgeRange, AmountRange, ByEpoch, OverAmount, UnderAmount, UnderAge, OverAge, - Class, SpendableType, ByTerm, Filter, + AgeRange, AmountRange, ByEpoch, ByTerm, Class, Filter, OverAge, OverAmount, SpendableType, + UnderAge, UnderAmount, }; #[derive(Default, Clone, Traversable)] diff --git a/crates/brk_computer/src/blocks/compute.rs b/crates/brk_computer/src/blocks/compute.rs index 894e51dea..80cfd06e6 100644 --- a/crates/brk_computer/src/blocks/compute.rs +++ b/crates/brk_computer/src/blocks/compute.rs @@ -38,8 +38,7 @@ impl Vecs { let r1 = s.spawn(|| count.compute(indexer, starting_indexes, exit)); let r2 = s.spawn(|| interval.compute(indexer, starting_indexes, exit)); let r3 = s.spawn(|| weight.compute(indexer, starting_indexes, exit)); - let r4 = - s.spawn(|| difficulty.compute(indexer, indexes, starting_indexes, exit)); + let r4 = s.spawn(|| difficulty.compute(indexer, indexes, starting_indexes, exit)); let r5 = s.spawn(|| halving.compute(indexes, starting_indexes, exit)); size.compute(indexer, &*lookback, starting_indexes, exit)?; r1.join().unwrap()?; diff --git a/crates/brk_computer/src/blocks/count/import.rs b/crates/brk_computer/src/blocks/count/import.rs index 1d6019169..e8aab9905 100644 --- a/crates/brk_computer/src/blocks/count/import.rs +++ b/crates/brk_computer/src/blocks/count/import.rs @@ -6,8 +6,8 @@ use super::Vecs; use crate::{ indexes, internal::{ - BlockCountTarget24h, BlockCountTarget1w, BlockCountTarget1m, BlockCountTarget1y, - CachedWindowStarts, PerBlockCumulativeRolling, ConstantVecs, Windows, + BlockCountTarget1m, BlockCountTarget1w, BlockCountTarget1y, BlockCountTarget24h, + CachedWindowStarts, ConstantVecs, PerBlockCumulativeRolling, Windows, }, }; @@ -20,10 +20,26 @@ impl Vecs { ) -> Result { Ok(Self { target: Windows { - _24h: ConstantVecs::new::("block_count_target_24h", version, indexes), - _1w: ConstantVecs::new::("block_count_target_1w", version, indexes), - _1m: ConstantVecs::new::("block_count_target_1m", version, indexes), - _1y: ConstantVecs::new::("block_count_target_1y", version, indexes), + _24h: ConstantVecs::new::( + "block_count_target_24h", + version, + indexes, + ), + _1w: ConstantVecs::new::( + "block_count_target_1w", + version, + indexes, + ), + _1m: ConstantVecs::new::( + "block_count_target_1m", + version, + indexes, + ), + _1y: ConstantVecs::new::( + "block_count_target_1y", + version, + indexes, + ), }, total: PerBlockCumulativeRolling::forced_import( db, diff --git a/crates/brk_computer/src/blocks/count/vecs.rs b/crates/brk_computer/src/blocks/count/vecs.rs index 5663742d6..be7d5c20f 100644 --- a/crates/brk_computer/src/blocks/count/vecs.rs +++ b/crates/brk_computer/src/blocks/count/vecs.rs @@ -2,7 +2,7 @@ use brk_traversable::Traversable; use brk_types::{StoredU32, StoredU64}; use vecdb::{Rw, StorageMode}; -use crate::internal::{PerBlockCumulativeRolling, ConstantVecs, Windows}; +use crate::internal::{ConstantVecs, PerBlockCumulativeRolling, Windows}; #[derive(Traversable)] pub struct Vecs { diff --git a/crates/brk_computer/src/blocks/difficulty/import.rs b/crates/brk_computer/src/blocks/difficulty/import.rs index 95814b107..57396fd52 100644 --- a/crates/brk_computer/src/blocks/difficulty/import.rs +++ b/crates/brk_computer/src/blocks/difficulty/import.rs @@ -27,12 +27,8 @@ impl Vecs { indexes, ); - let blocks_to_retarget = PerBlock::forced_import( - db, - "blocks_to_retarget", - version + v2, - indexes, - )?; + let blocks_to_retarget = + PerBlock::forced_import(db, "blocks_to_retarget", version + v2, indexes)?; let days_to_retarget = LazyPerBlock::from_computed::( "days_to_retarget", diff --git a/crates/brk_computer/src/blocks/difficulty/vecs.rs b/crates/brk_computer/src/blocks/difficulty/vecs.rs index 6395f0eda..34e35a72a 100644 --- a/crates/brk_computer/src/blocks/difficulty/vecs.rs +++ b/crates/brk_computer/src/blocks/difficulty/vecs.rs @@ -2,7 +2,7 @@ use brk_traversable::Traversable; use brk_types::{BasisPointsSigned32, Epoch, StoredF32, StoredF64, StoredU32}; use vecdb::{Rw, StorageMode}; -use crate::internal::{LazyPerBlock, PerBlock, Resolutions, PercentPerBlock}; +use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock, Resolutions}; #[derive(Traversable)] pub struct Vecs { pub value: Resolutions, diff --git a/crates/brk_computer/src/blocks/halving/import.rs b/crates/brk_computer/src/blocks/halving/import.rs index 876d73093..b54aecc25 100644 --- a/crates/brk_computer/src/blocks/halving/import.rs +++ b/crates/brk_computer/src/blocks/halving/import.rs @@ -16,9 +16,8 @@ impl Vecs { ) -> Result { let v2 = Version::TWO; - let blocks_to_halving = PerBlock::forced_import( - db, "blocks_to_halving", version + v2, indexes, - )?; + let blocks_to_halving = + PerBlock::forced_import(db, "blocks_to_halving", version + v2, indexes)?; let days_to_halving = LazyPerBlock::from_computed::( "days_to_halving", diff --git a/crates/brk_computer/src/blocks/import.rs b/crates/brk_computer/src/blocks/import.rs index 7cc84a49b..21540a32e 100644 --- a/crates/brk_computer/src/blocks/import.rs +++ b/crates/brk_computer/src/blocks/import.rs @@ -10,8 +10,7 @@ use crate::{ }; use super::{ - CountVecs, DifficultyVecs, HalvingVecs, IntervalVecs, LookbackVecs, SizeVecs, Vecs, - WeightVecs, + CountVecs, DifficultyVecs, HalvingVecs, IntervalVecs, LookbackVecs, SizeVecs, Vecs, WeightVecs, }; impl Vecs { diff --git a/crates/brk_computer/src/blocks/interval/compute.rs b/crates/brk_computer/src/blocks/interval/compute.rs index 38eee6f76..6a05f8f76 100644 --- a/crates/brk_computer/src/blocks/interval/compute.rs +++ b/crates/brk_computer/src/blocks/interval/compute.rs @@ -13,27 +13,26 @@ impl Vecs { exit: &Exit, ) -> Result<()> { let mut prev_timestamp = None; - self.0 - .compute(starting_indexes.height, exit, |vec| { - vec.compute_transform( - starting_indexes.height, - &indexer.vecs.blocks.timestamp, - |(h, timestamp, ..)| { - let interval = if let Some(prev_h) = h.decremented() { - let prev = prev_timestamp.unwrap_or_else(|| { - indexer.vecs.blocks.timestamp.collect_one(prev_h).unwrap() - }); - timestamp.checked_sub(prev).unwrap_or(Timestamp::ZERO) - } else { - Timestamp::ZERO - }; - prev_timestamp = Some(timestamp); - (h, interval) - }, - exit, - )?; - Ok(()) - })?; + self.0.compute(starting_indexes.height, exit, |vec| { + vec.compute_transform( + starting_indexes.height, + &indexer.vecs.blocks.timestamp, + |(h, timestamp, ..)| { + let interval = if let Some(prev_h) = h.decremented() { + let prev = prev_timestamp.unwrap_or_else(|| { + indexer.vecs.blocks.timestamp.collect_one(prev_h).unwrap() + }); + timestamp.checked_sub(prev).unwrap_or(Timestamp::ZERO) + } else { + Timestamp::ZERO + }; + prev_timestamp = Some(timestamp); + (h, interval) + }, + exit, + )?; + Ok(()) + })?; Ok(()) } diff --git a/crates/brk_computer/src/blocks/interval/import.rs b/crates/brk_computer/src/blocks/interval/import.rs index 60bac478b..4871d88ad 100644 --- a/crates/brk_computer/src/blocks/interval/import.rs +++ b/crates/brk_computer/src/blocks/interval/import.rs @@ -3,7 +3,10 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::{CachedWindowStarts, PerBlockRollingAverage}}; +use crate::{ + indexes, + internal::{CachedWindowStarts, PerBlockRollingAverage}, +}; impl Vecs { pub(crate) fn forced_import( diff --git a/crates/brk_computer/src/blocks/lookback.rs b/crates/brk_computer/src/blocks/lookback.rs index 07a9eafa4..917ce553e 100644 --- a/crates/brk_computer/src/blocks/lookback.rs +++ b/crates/brk_computer/src/blocks/lookback.rs @@ -1,11 +1,14 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Indexes, Timestamp, Version}; -use vecdb::{AnyVec, CachedVec, Cursor, Database, EagerVec, Exit, ImportableVec, PcoVec, ReadableVec, Rw, StorageMode, VecIndex}; +use vecdb::{ + AnyVec, CachedVec, Cursor, Database, EagerVec, Exit, ImportableVec, PcoVec, ReadableVec, Rw, + StorageMode, VecIndex, +}; use crate::{ indexes, - internal::{CachedWindowStarts, Windows, WindowStarts}, + internal::{CachedWindowStarts, WindowStarts, Windows}, }; #[derive(Traversable)] @@ -112,10 +115,49 @@ impl Vecs { Ok(Self { cached_window_starts, - _1h, _24h, _3d, _1w, _8d, _9d, _12d, _13d, _2w, _21d, _26d, - _1m, _34d, _55d, _2m, _9w, _12w, _89d, _3m, _14w, _111d, _144d, - _6m, _26w, _200d, _9m, _350d, _12m, _1y, _14m, _2y, _26m, _3y, - _200w, _4y, _5y, _6y, _8y, _9y, _10y, _12y, _14y, _26y, + _1h, + _24h, + _3d, + _1w, + _8d, + _9d, + _12d, + _13d, + _2w, + _21d, + _26d, + _1m, + _34d, + _55d, + _2m, + _9w, + _12w, + _89d, + _3m, + _14w, + _111d, + _144d, + _6m, + _26w, + _200d, + _9m, + _350d, + _12m, + _1y, + _14m, + _2y, + _26m, + _3y, + _200w, + _4y, + _5y, + _6y, + _8y, + _9y, + _10y, + _12y, + _14y, + _26y, }) } @@ -128,7 +170,6 @@ impl Vecs { } } - pub fn start_vec(&self, days: usize) -> &EagerVec> { match days { 1 => &self._24h, @@ -183,9 +224,7 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.compute_rolling_start_hours(indexes, starting_indexes, exit, 1, |s| { - &mut s._1h - })?; + self.compute_rolling_start_hours(indexes, starting_indexes, exit, 1, |s| &mut s._1h)?; self.compute_rolling_start(indexes, starting_indexes, exit, 1, |s| &mut s._24h)?; self.compute_rolling_start(indexes, starting_indexes, exit, 3, |s| &mut s._3d)?; self.compute_rolling_start(indexes, starting_indexes, exit, 7, |s| &mut s._1w)?; @@ -205,47 +244,29 @@ impl Vecs { self.compute_rolling_start(indexes, starting_indexes, exit, 89, |s| &mut s._89d)?; self.compute_rolling_start(indexes, starting_indexes, exit, 90, |s| &mut s._3m)?; self.compute_rolling_start(indexes, starting_indexes, exit, 98, |s| &mut s._14w)?; - self.compute_rolling_start(indexes, starting_indexes, exit, 111, |s| { - &mut s._111d - })?; - self.compute_rolling_start(indexes, starting_indexes, exit, 144, |s| { - &mut s._144d - })?; + self.compute_rolling_start(indexes, starting_indexes, exit, 111, |s| &mut s._111d)?; + self.compute_rolling_start(indexes, starting_indexes, exit, 144, |s| &mut s._144d)?; self.compute_rolling_start(indexes, starting_indexes, exit, 180, |s| &mut s._6m)?; self.compute_rolling_start(indexes, starting_indexes, exit, 182, |s| &mut s._26w)?; - self.compute_rolling_start(indexes, starting_indexes, exit, 200, |s| { - &mut s._200d - })?; + self.compute_rolling_start(indexes, starting_indexes, exit, 200, |s| &mut s._200d)?; self.compute_rolling_start(indexes, starting_indexes, exit, 270, |s| &mut s._9m)?; - self.compute_rolling_start(indexes, starting_indexes, exit, 350, |s| { - &mut s._350d - })?; + self.compute_rolling_start(indexes, starting_indexes, exit, 350, |s| &mut s._350d)?; self.compute_rolling_start(indexes, starting_indexes, exit, 360, |s| &mut s._12m)?; self.compute_rolling_start(indexes, starting_indexes, exit, 365, |s| &mut s._1y)?; self.compute_rolling_start(indexes, starting_indexes, exit, 420, |s| &mut s._14m)?; self.compute_rolling_start(indexes, starting_indexes, exit, 730, |s| &mut s._2y)?; self.compute_rolling_start(indexes, starting_indexes, exit, 780, |s| &mut s._26m)?; self.compute_rolling_start(indexes, starting_indexes, exit, 1095, |s| &mut s._3y)?; - self.compute_rolling_start(indexes, starting_indexes, exit, 1400, |s| { - &mut s._200w - })?; + self.compute_rolling_start(indexes, starting_indexes, exit, 1400, |s| &mut s._200w)?; self.compute_rolling_start(indexes, starting_indexes, exit, 1460, |s| &mut s._4y)?; self.compute_rolling_start(indexes, starting_indexes, exit, 1825, |s| &mut s._5y)?; self.compute_rolling_start(indexes, starting_indexes, exit, 2190, |s| &mut s._6y)?; self.compute_rolling_start(indexes, starting_indexes, exit, 2920, |s| &mut s._8y)?; self.compute_rolling_start(indexes, starting_indexes, exit, 3285, |s| &mut s._9y)?; - self.compute_rolling_start(indexes, starting_indexes, exit, 3650, |s| { - &mut s._10y - })?; - self.compute_rolling_start(indexes, starting_indexes, exit, 4380, |s| { - &mut s._12y - })?; - self.compute_rolling_start(indexes, starting_indexes, exit, 5110, |s| { - &mut s._14y - })?; - self.compute_rolling_start(indexes, starting_indexes, exit, 9490, |s| { - &mut s._26y - })?; + self.compute_rolling_start(indexes, starting_indexes, exit, 3650, |s| &mut s._10y)?; + self.compute_rolling_start(indexes, starting_indexes, exit, 4380, |s| &mut s._12y)?; + self.compute_rolling_start(indexes, starting_indexes, exit, 5110, |s| &mut s._14y)?; + self.compute_rolling_start(indexes, starting_indexes, exit, 9490, |s| &mut s._26y)?; Ok(()) } @@ -261,9 +282,13 @@ impl Vecs { where F: FnOnce(&mut Self) -> &mut EagerVec>, { - self.compute_rolling_start_inner(indexes, starting_indexes, exit, get_field, |t, prev_ts| { - t.difference_in_days_between(prev_ts) >= days - }) + self.compute_rolling_start_inner( + indexes, + starting_indexes, + exit, + get_field, + |t, prev_ts| t.difference_in_days_between(prev_ts) >= days, + ) } fn compute_rolling_start_hours( @@ -277,9 +302,13 @@ impl Vecs { where F: FnOnce(&mut Self) -> &mut EagerVec>, { - self.compute_rolling_start_inner(indexes, starting_indexes, exit, get_field, |t, prev_ts| { - t.difference_in_hours_between(prev_ts) >= hours - }) + self.compute_rolling_start_inner( + indexes, + starting_indexes, + exit, + get_field, + |t, prev_ts| t.difference_in_hours_between(prev_ts) >= hours, + ) } fn compute_rolling_start_inner( diff --git a/crates/brk_computer/src/cointime/activity/import.rs b/crates/brk_computer/src/cointime/activity/import.rs index 827ff89c9..48a9b0e27 100644 --- a/crates/brk_computer/src/cointime/activity/import.rs +++ b/crates/brk_computer/src/cointime/activity/import.rs @@ -28,10 +28,18 @@ impl Vecs { Ok(Self { coinblocks_created: PerBlockCumulativeRolling::forced_import( - db, "coinblocks_created", version, indexes, cached_starts, + db, + "coinblocks_created", + version, + indexes, + cached_starts, )?, coinblocks_stored: PerBlockCumulativeRolling::forced_import( - db, "coinblocks_stored", version, indexes, cached_starts, + db, + "coinblocks_stored", + version, + indexes, + cached_starts, )?, liveliness, vaultedness, diff --git a/crates/brk_computer/src/cointime/prices/compute.rs b/crates/brk_computer/src/cointime/prices/compute.rs index 997c24e35..d92776729 100644 --- a/crates/brk_computer/src/cointime/prices/compute.rs +++ b/crates/brk_computer/src/cointime/prices/compute.rs @@ -22,11 +22,8 @@ impl Vecs { let circulating_supply = &all_metrics.supply.total.btc.height; let realized_price = &all_metrics.realized.price.cents.height; - self.vaulted.compute_all( - prices, - starting_indexes, - exit, - |v| { + self.vaulted + .compute_all(prices, starting_indexes, exit, |v| { Ok(v.compute_transform2( starting_indexes.height, realized_price, @@ -36,14 +33,10 @@ impl Vecs { }, exit, )?) - }, - )?; + })?; - self.active.compute_all( - prices, - starting_indexes, - exit, - |v| { + self.active + .compute_all(prices, starting_indexes, exit, |v| { Ok(v.compute_transform2( starting_indexes.height, realized_price, @@ -53,14 +46,10 @@ impl Vecs { }, exit, )?) - }, - )?; + })?; - self.true_market_mean.compute_all( - prices, - starting_indexes, - exit, - |v| { + self.true_market_mean + .compute_all(prices, starting_indexes, exit, |v| { Ok(v.compute_transform2( starting_indexes.height, &cap.investor.cents.height, @@ -70,14 +59,10 @@ impl Vecs { }, exit, )?) - }, - )?; + })?; - self.cointime.compute_all( - prices, - starting_indexes, - exit, - |v| { + self.cointime + .compute_all(prices, starting_indexes, exit, |v| { Ok(v.compute_transform2( starting_indexes.height, &cap.cointime.cents.height, @@ -87,8 +72,7 @@ impl Vecs { }, exit, )?) - }, - )?; + })?; Ok(()) } diff --git a/crates/brk_computer/src/cointime/prices/import.rs b/crates/brk_computer/src/cointime/prices/import.rs index 4fd1faf9b..dd4e0839c 100644 --- a/crates/brk_computer/src/cointime/prices/import.rs +++ b/crates/brk_computer/src/cointime/prices/import.rs @@ -3,10 +3,7 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{ - indexes, - internal::PriceWithRatioExtendedPerBlock, -}; +use crate::{indexes, internal::PriceWithRatioExtendedPerBlock}; impl Vecs { pub(crate) fn forced_import( diff --git a/crates/brk_computer/src/cointime/supply/compute.rs b/crates/brk_computer/src/cointime/supply/compute.rs index 185f14e65..601e9af93 100644 --- a/crates/brk_computer/src/cointime/supply/compute.rs +++ b/crates/brk_computer/src/cointime/supply/compute.rs @@ -38,7 +38,8 @@ impl Vecs { exit, )?; - self.vaulted.compute(prices, starting_indexes.height, exit)?; + self.vaulted + .compute(prices, starting_indexes.height, exit)?; self.active.compute(prices, starting_indexes.height, exit)?; Ok(()) diff --git a/crates/brk_computer/src/cointime/supply/import.rs b/crates/brk_computer/src/cointime/supply/import.rs index bf47f4c81..75449ca26 100644 --- a/crates/brk_computer/src/cointime/supply/import.rs +++ b/crates/brk_computer/src/cointime/supply/import.rs @@ -12,12 +12,7 @@ impl Vecs { indexes: &indexes::Vecs, ) -> Result { Ok(Self { - vaulted: AmountPerBlock::forced_import( - db, - "vaulted_supply", - version, - indexes, - )?, + vaulted: AmountPerBlock::forced_import(db, "vaulted_supply", version, indexes)?, active: AmountPerBlock::forced_import(db, "active_supply", version, indexes)?, }) } diff --git a/crates/brk_computer/src/cointime/value/compute.rs b/crates/brk_computer/src/cointime/value/compute.rs index d028475ca..14110e9e9 100644 --- a/crates/brk_computer/src/cointime/value/compute.rs +++ b/crates/brk_computer/src/cointime/value/compute.rs @@ -31,52 +31,49 @@ impl Vecs { Ok(()) })?; - self.created - .compute(starting_indexes.height, exit, |vec| { - vec.compute_multiply( - starting_indexes.height, - &prices.spot.usd.height, - &activity.coinblocks_created.block, - exit, - )?; - Ok(()) - })?; + self.created.compute(starting_indexes.height, exit, |vec| { + vec.compute_multiply( + starting_indexes.height, + &prices.spot.usd.height, + &activity.coinblocks_created.block, + exit, + )?; + Ok(()) + })?; - self.stored - .compute(starting_indexes.height, exit, |vec| { - vec.compute_multiply( - starting_indexes.height, - &prices.spot.usd.height, - &activity.coinblocks_stored.block, - exit, - )?; - Ok(()) - })?; + self.stored.compute(starting_indexes.height, exit, |vec| { + vec.compute_multiply( + starting_indexes.height, + &prices.spot.usd.height, + &activity.coinblocks_stored.block, + exit, + )?; + Ok(()) + })?; // 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(starting_indexes.height, exit, |vec| { - vec.compute_transform3( - starting_indexes.height, - &prices.spot.usd.height, - &coindays_destroyed.block, - circulating_supply, - |(i, price, cdd, supply, _): (_, Dollars, StoredF64, Bitcoin, _)| { - 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(()) - })?; + self.vocdd.compute(starting_indexes.height, exit, |vec| { + vec.compute_transform3( + starting_indexes.height, + &prices.spot.usd.height, + &coindays_destroyed.block, + circulating_supply, + |(i, price, cdd, supply, _): (_, Dollars, StoredF64, Bitcoin, _)| { + 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(()) + })?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/addr/activity.rs b/crates/brk_computer/src/distribution/addr/activity.rs index e4d8fe923..ee8d89b2f 100644 --- a/crates/brk_computer/src/distribution/addr/activity.rs +++ b/crates/brk_computer/src/distribution/addr/activity.rs @@ -148,11 +148,7 @@ impl ActivityCountVecs { self.both.block.push(counts.both.into()); } - pub(crate) fn compute_rest( - &mut self, - max_from: Height, - exit: &Exit, - ) -> Result<()> { + pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> { self.reactivated.compute_rest(max_from, exit)?; self.sending.compute_rest(max_from, exit)?; self.receiving.compute_rest(max_from, exit)?; @@ -180,8 +176,8 @@ impl AddrTypeToActivityCountVecs { indexes: &indexes::Vecs, cached_starts: &CachedWindowStarts, ) -> Result { - Ok(Self::from( - ByAddrType::::new_with_name(|type_name| { + Ok(Self::from(ByAddrType::::new_with_name( + |type_name| { ActivityCountVecs::forced_import( db, &format!("{type_name}_{name}"), @@ -189,8 +185,8 @@ impl AddrTypeToActivityCountVecs { indexes, cached_starts, ) - })?, - )) + }, + )?)) } pub(crate) fn min_stateful_len(&self) -> usize { @@ -221,11 +217,7 @@ impl AddrTypeToActivityCountVecs { Ok(()) } - pub(crate) fn compute_rest( - &mut self, - max_from: Height, - exit: &Exit, - ) -> Result<()> { + pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> { for type_vecs in self.0.values_mut() { type_vecs.compute_rest(max_from, exit)?; } @@ -259,7 +251,11 @@ impl AddrActivityVecs { Ok(Self { all: ActivityCountVecs::forced_import(db, name, version, indexes, cached_starts)?, by_addr_type: AddrTypeToActivityCountVecs::forced_import( - db, name, version, indexes, cached_starts, + db, + name, + version, + indexes, + cached_starts, )?, }) } @@ -284,11 +280,7 @@ impl AddrActivityVecs { Ok(()) } - pub(crate) fn compute_rest( - &mut self, - max_from: Height, - exit: &Exit, - ) -> Result<()> { + pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> { self.all.compute_rest(max_from, exit)?; self.by_addr_type.compute_rest(max_from, exit)?; Ok(()) diff --git a/crates/brk_computer/src/distribution/addr/addr_count.rs b/crates/brk_computer/src/distribution/addr/addr_count.rs index a0c6677f7..8d8271344 100644 --- a/crates/brk_computer/src/distribution/addr/addr_count.rs +++ b/crates/brk_computer/src/distribution/addr/addr_count.rs @@ -12,9 +12,7 @@ use vecdb::{ use crate::{indexes, internal::PerBlock}; #[derive(Deref, DerefMut, Traversable)] -pub struct AddrCountVecs( - #[traversable(flatten)] pub PerBlock, -); +pub struct AddrCountVecs(#[traversable(flatten)] pub PerBlock); impl AddrCountVecs { pub(crate) fn forced_import( @@ -23,9 +21,7 @@ impl AddrCountVecs { version: Version, indexes: &indexes::Vecs, ) -> Result { - Ok(Self(PerBlock::forced_import( - db, name, version, indexes, - )?)) + Ok(Self(PerBlock::forced_import(db, name, version, indexes)?)) } } @@ -57,42 +53,17 @@ impl From<(&AddrTypeToAddrCountVecs, Height)> for AddrTypeToAddrCount { .collect_one(prev_height) .unwrap() .into(), - p2pkh: groups - .p2pkh - .height - .collect_one(prev_height) - .unwrap() - .into(), - p2sh: groups - .p2sh - .height - .collect_one(prev_height) - .unwrap() - .into(), + p2pkh: groups.p2pkh.height.collect_one(prev_height).unwrap().into(), + p2sh: groups.p2sh.height.collect_one(prev_height).unwrap().into(), p2wpkh: groups .p2wpkh .height .collect_one(prev_height) .unwrap() .into(), - p2wsh: groups - .p2wsh - .height - .collect_one(prev_height) - .unwrap() - .into(), - p2tr: groups - .p2tr - .height - .collect_one(prev_height) - .unwrap() - .into(), - p2a: groups - .p2a - .height - .collect_one(prev_height) - .unwrap() - .into(), + p2wsh: groups.p2wsh.height.collect_one(prev_height).unwrap().into(), + p2tr: groups.p2tr.height.collect_one(prev_height).unwrap().into(), + p2a: groups.p2a.height.collect_one(prev_height).unwrap().into(), }) } else { Default::default() @@ -177,7 +148,10 @@ impl AddrCountsVecs { } pub(crate) fn min_stateful_len(&self) -> usize { - self.all.height.len().min(self.by_addr_type.min_stateful_len()) + self.all + .height + .len() + .min(self.by_addr_type.min_stateful_len()) } pub(crate) fn par_iter_height_mut( @@ -199,11 +173,7 @@ impl AddrCountsVecs { self.by_addr_type.push_height(addr_counts); } - pub(crate) fn compute_rest( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { + pub(crate) fn compute_rest(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { let sources = self.by_addr_type.by_height(); self.all .height diff --git a/crates/brk_computer/src/distribution/addr/data.rs b/crates/brk_computer/src/distribution/addr/data.rs index 260268df1..0ab8a63be 100644 --- a/crates/brk_computer/src/distribution/addr/data.rs +++ b/crates/brk_computer/src/distribution/addr/data.rs @@ -1,8 +1,6 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{ - EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, Height, -}; +use brk_types::{EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, Height}; use rayon::prelude::*; use vecdb::{AnyStoredVec, BytesVec, Rw, Stamp, StorageMode, WritableVec}; diff --git a/crates/brk_computer/src/distribution/addr/delta.rs b/crates/brk_computer/src/distribution/addr/delta.rs index 07c52329c..4f8a21570 100644 --- a/crates/brk_computer/src/distribution/addr/delta.rs +++ b/crates/brk_computer/src/distribution/addr/delta.rs @@ -45,9 +45,6 @@ impl DeltaVecs { ) }); - Self { - all, - by_addr_type, - } + Self { all, by_addr_type } } } diff --git a/crates/brk_computer/src/distribution/addr/indexes/any.rs b/crates/brk_computer/src/distribution/addr/indexes/any.rs index 88cdb3dcb..ed5ad2e31 100644 --- a/crates/brk_computer/src/distribution/addr/indexes/any.rs +++ b/crates/brk_computer/src/distribution/addr/indexes/any.rs @@ -5,8 +5,8 @@ use brk_error::{Error, Result}; use brk_traversable::Traversable; use brk_types::{ AnyAddrIndex, Height, OutputType, P2AAddrIndex, P2PK33AddrIndex, P2PK65AddrIndex, - P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, - TypeIndex, Version, + P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, TypeIndex, + Version, }; use rayon::prelude::*; use rustc_hash::FxHashMap; diff --git a/crates/brk_computer/src/distribution/addr/new_addr_count.rs b/crates/brk_computer/src/distribution/addr/new_addr_count.rs index af87728f8..8ffad8fc0 100644 --- a/crates/brk_computer/src/distribution/addr/new_addr_count.rs +++ b/crates/brk_computer/src/distribution/addr/new_addr_count.rs @@ -44,10 +44,7 @@ impl NewAddrCountVecs { ) })?; - Ok(Self { - all, - by_addr_type, - }) + Ok(Self { all, by_addr_type }) } pub(crate) fn compute( diff --git a/crates/brk_computer/src/distribution/addr/total_addr_count.rs b/crates/brk_computer/src/distribution/addr/total_addr_count.rs index 55d50081a..cbe1a6f99 100644 --- a/crates/brk_computer/src/distribution/addr/total_addr_count.rs +++ b/crates/brk_computer/src/distribution/addr/total_addr_count.rs @@ -24,20 +24,11 @@ impl TotalAddrCountVecs { ) -> Result { let all = PerBlock::forced_import(db, "total_addr_count", version, indexes)?; - let by_addr_type: ByAddrType> = - ByAddrType::new_with_name(|name| { - PerBlock::forced_import( - db, - &format!("{name}_total_addr_count"), - version, - indexes, - ) - })?; + let by_addr_type: ByAddrType> = ByAddrType::new_with_name(|name| { + PerBlock::forced_import(db, &format!("{name}_total_addr_count"), version, indexes) + })?; - Ok(Self { - all, - by_addr_type, - }) + Ok(Self { all, by_addr_type }) } /// Eagerly compute total = addr_count + empty_addr_count. diff --git a/crates/brk_computer/src/distribution/block/cache/addr.rs b/crates/brk_computer/src/distribution/block/cache/addr.rs index 9d1740d9a..69c448668 100644 --- a/crates/brk_computer/src/distribution/block/cache/addr.rs +++ b/crates/brk_computer/src/distribution/block/cache/addr.rs @@ -103,9 +103,7 @@ pub(crate) fn load_uncached_addr_data( // Check if this is a new address (type_index >= first for this height) let first = *first_addr_indexes.get(addr_type).unwrap(); if first <= type_index { - return Ok(Some(WithAddrDataSource::New( - FundedAddrData::default(), - ))); + return Ok(Some(WithAddrDataSource::New(FundedAddrData::default()))); } // Skip if already in cache diff --git a/crates/brk_computer/src/distribution/block/cache/lookup.rs b/crates/brk_computer/src/distribution/block/cache/lookup.rs index 5dfa2bf26..eb9a6804d 100644 --- a/crates/brk_computer/src/distribution/block/cache/lookup.rs +++ b/crates/brk_computer/src/distribution/block/cache/lookup.rs @@ -26,10 +26,7 @@ impl<'a> AddrLookup<'a> { &mut self, output_type: OutputType, type_index: TypeIndex, - ) -> ( - &mut WithAddrDataSource, - TrackingStatus, - ) { + ) -> (&mut WithAddrDataSource, TrackingStatus) { use std::collections::hash_map::Entry; let map = self.funded.get_mut(output_type).unwrap(); diff --git a/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs b/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs index 8ca353974..80c22bc66 100644 --- a/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs +++ b/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs @@ -1,7 +1,7 @@ use brk_error::Result; use brk_types::{ - AnyAddrIndex, EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, - OutputType, TypeIndex, + AnyAddrIndex, EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, OutputType, + TypeIndex, }; use vecdb::AnyVec; diff --git a/crates/brk_computer/src/distribution/block/cohort/received.rs b/crates/brk_computer/src/distribution/block/cohort/received.rs index 638fc6000..7ad125e32 100644 --- a/crates/brk_computer/src/distribution/block/cohort/received.rs +++ b/crates/brk_computer/src/distribution/block/cohort/received.rs @@ -26,7 +26,11 @@ pub(crate) fn process_received( empty_addr_count: &mut ByAddrType, activity_counts: &mut AddrTypeToActivityCounts, ) { - let max_type_len = received_data.iter().map(|(_, v)| v.len()).max().unwrap_or(0); + let max_type_len = received_data + .iter() + .map(|(_, v)| v.len()) + .max() + .unwrap_or(0); let mut aggregated: FxHashMap = FxHashMap::with_capacity_and_hasher(max_type_len, Default::default()); diff --git a/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs b/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs index a4e792d0d..17f2b2468 100644 --- a/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs +++ b/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs @@ -41,10 +41,7 @@ pub(crate) fn update_tx_counts( .get_mut(&type_index) { addr_data.tx_count += tx_count; - } else if let Some(addr_data) = empty_cache - .get_mut(addr_type) - .unwrap() - .get_mut(&type_index) + } else if let Some(addr_data) = empty_cache.get_mut(addr_type).unwrap().get_mut(&type_index) { addr_data.tx_count += tx_count; } diff --git a/crates/brk_computer/src/distribution/block/utxo/inputs.rs b/crates/brk_computer/src/distribution/block/utxo/inputs.rs index c48d15efb..7ea356404 100644 --- a/crates/brk_computer/src/distribution/block/utxo/inputs.rs +++ b/crates/brk_computer/src/distribution/block/utxo/inputs.rs @@ -90,9 +90,7 @@ pub(crate) fn process_inputs( }; let items: Vec<_> = if input_count < 128 { - (0..input_count) - .map(map_fn) - .collect::>>()? + (0..input_count).map(map_fn).collect::>>()? } else { (0..input_count) .into_par_iter() @@ -109,10 +107,9 @@ pub(crate) fn process_inputs( Default::default(), ); let mut sent_data = HeightToAddrTypeToVec::with_capacity(estimated_unique_heights); - let mut addr_data = - AddrTypeToTypeIndexMap::>::with_capacity( - estimated_per_type, - ); + let mut addr_data = AddrTypeToTypeIndexMap::>::with_capacity( + estimated_per_type, + ); let mut tx_index_vecs = AddrTypeToTypeIndexMap::>::with_capacity(estimated_per_type); diff --git a/crates/brk_computer/src/distribution/block/utxo/outputs.rs b/crates/brk_computer/src/distribution/block/utxo/outputs.rs index 8878b62a8..94245c030 100644 --- a/crates/brk_computer/src/distribution/block/utxo/outputs.rs +++ b/crates/brk_computer/src/distribution/block/utxo/outputs.rs @@ -5,9 +5,7 @@ use rayon::prelude::*; use smallvec::SmallVec; use crate::distribution::{ - addr::{ - AddrTypeToTypeIndexMap, AddrTypeToVec, AddrsDataVecs, AnyAddrIndexesVecs, - }, + addr::{AddrTypeToTypeIndexMap, AddrTypeToVec, AddrsDataVecs, AnyAddrIndexesVecs}, compute::{TxOutData, VecsReaders}, state::Transacted, }; @@ -79,9 +77,7 @@ pub(crate) fn process_outputs( }; let items: Vec<_> = if output_count < 128 { - (0..output_count) - .map(map_fn) - .collect::>>()? + (0..output_count).map(map_fn).collect::>>()? } else { (0..output_count) .into_par_iter() @@ -93,10 +89,9 @@ pub(crate) fn process_outputs( let estimated_per_type = (output_count / 8).max(8); let mut transacted = Transacted::default(); let mut received_data = AddrTypeToVec::with_capacity(estimated_per_type); - let mut addr_data = - AddrTypeToTypeIndexMap::>::with_capacity( - estimated_per_type, - ); + let mut addr_data = AddrTypeToTypeIndexMap::>::with_capacity( + estimated_per_type, + ); let mut tx_index_vecs = AddrTypeToTypeIndexMap::>::with_capacity(estimated_per_type); diff --git a/crates/brk_computer/src/distribution/cohorts/addr/groups.rs b/crates/brk_computer/src/distribution/cohorts/addr/groups.rs index 967036e1e..13b104442 100644 --- a/crates/brk_computer/src/distribution/cohorts/addr/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/addr/groups.rs @@ -1,8 +1,6 @@ use std::path::Path; -use brk_cohort::{ - AddrGroups, AmountRange, OverAmount, UnderAmount, Filter, Filtered, -}; +use brk_cohort::{AddrGroups, AmountRange, Filter, Filtered, OverAmount, UnderAmount}; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Indexes, StoredU64, Version}; diff --git a/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs b/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs index a62fe7e20..379555909 100644 --- a/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs @@ -161,9 +161,7 @@ impl DynCohortVecs for AddrCohortVecs { } if let Some(state) = self.state.as_ref() { - self.addr_count - .height - .push(state.addr_count.into()); + self.addr_count.height.push(state.addr_count.into()); self.metrics.supply.push_state(&state.inner); self.metrics.outputs.push_state(&state.inner); self.metrics.activity.push_state(&state.inner); diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/receive.rs b/crates/brk_computer/src/distribution/cohorts/utxo/receive.rs index aee0173ae..f343f061a 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/receive.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/receive.rs @@ -1,4 +1,4 @@ -use brk_types::{CostBasisSnapshot, Cents, Height, Timestamp}; +use brk_types::{Cents, CostBasisSnapshot, Height, Timestamp}; use vecdb::Rw; use crate::distribution::state::Transacted; @@ -34,10 +34,16 @@ impl UTXOCohorts { .unwrap() .receive_utxo_snapshot(&supply_state, &snapshot); if let Some(v) = self.epoch.mut_vec_from_height(height) { - v.state.as_mut().unwrap().receive_utxo_snapshot(&supply_state, &snapshot); + v.state + .as_mut() + .unwrap() + .receive_utxo_snapshot(&supply_state, &snapshot); } if let Some(v) = self.class.mut_vec_from_timestamp(timestamp) { - v.state.as_mut().unwrap().receive_utxo_snapshot(&supply_state, &snapshot); + v.state + .as_mut() + .unwrap() + .receive_utxo_snapshot(&supply_state, &snapshot); } // Update output type cohorts (skip types with no outputs this block) diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/send.rs b/crates/brk_computer/src/distribution/cohorts/utxo/send.rs index fd60e8f43..da569736e 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/send.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/send.rs @@ -64,10 +64,16 @@ impl UTXOCohorts { .unwrap() .send_utxo_precomputed(&sent.spendable_supply, &pre); if let Some(v) = self.epoch.mut_vec_from_height(receive_height) { - v.state.as_mut().unwrap().send_utxo_precomputed(&sent.spendable_supply, &pre); + v.state + .as_mut() + .unwrap() + .send_utxo_precomputed(&sent.spendable_supply, &pre); } if let Some(v) = self.class.mut_vec_from_timestamp(block_state.timestamp) { - v.state.as_mut().unwrap().send_utxo_precomputed(&sent.spendable_supply, &pre); + v.state + .as_mut() + .unwrap() + .send_utxo_precomputed(&sent.spendable_supply, &pre); } } else if sent.spendable_supply.utxo_count > 0 { // Zero-value UTXOs: just subtract supply diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/tick_tock.rs b/crates/brk_computer/src/distribution/cohorts/utxo/tick_tock.rs index d17d9ae3f..b7559e644 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/tick_tock.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/tick_tock.rs @@ -67,9 +67,7 @@ impl UTXOCohorts { idx } else { let mut idx = cached[boundary_idx]; - while idx < chain_state.len() - && *chain_state[idx].timestamp <= lower_timestamp - { + while idx < chain_state.len() && *chain_state[idx].timestamp <= lower_timestamp { idx += 1; } cached[boundary_idx] = idx; @@ -84,8 +82,7 @@ impl UTXOCohorts { // Move supply from younger cohort to older cohort for block_state in &chain_state[start_idx..end_idx] { - let snapshot = - CostBasisSnapshot::from_utxo(block_state.price, &block_state.supply); + let snapshot = CostBasisSnapshot::from_utxo(block_state.price, &block_state.supply); if let Some(state) = age_cohorts[boundary_idx].as_mut() { state.decrement_snapshot(&snapshot); } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs index dbad94bb8..20bed684b 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs @@ -3,7 +3,10 @@ use brk_error::Result; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; -use crate::{distribution::{cohorts::traits::DynCohortVecs, metrics::CoreCohortMetrics}, prices}; +use crate::{ + distribution::{cohorts::traits::DynCohortVecs, metrics::CoreCohortMetrics}, + prices, +}; use super::UTXOCohortVecs; @@ -45,12 +48,8 @@ impl DynCohortVecs for UTXOCohortVecs { if let Some(state) = self.state.as_mut() { state.apply_pending(); let unrealized_state = state.compute_unrealized_state(height_price); - self.metrics - .unrealized - .push_state(&unrealized_state); - self.metrics - .supply - .push_profitability(&unrealized_state); + self.metrics.unrealized.push_state(&unrealized_state); + self.metrics.supply.push_profitability(&unrealized_state); } } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs index c0996f7a9..96f885a8b 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs @@ -3,7 +3,9 @@ use brk_error::Result; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; -use crate::{distribution::cohorts::traits::DynCohortVecs, distribution::metrics::TypeCohortMetrics, prices}; +use crate::{ + distribution::cohorts::traits::DynCohortVecs, distribution::metrics::TypeCohortMetrics, prices, +}; use super::UTXOCohortVecs; @@ -45,12 +47,8 @@ impl DynCohortVecs for UTXOCohortVecs { if let Some(state) = self.state.as_mut() { state.apply_pending(); let unrealized_state = state.compute_unrealized_state(height_price); - self.metrics - .unrealized - .push_state(&unrealized_state); - self.metrics - .supply - .push_profitability(&unrealized_state); + self.metrics.unrealized.push_state(&unrealized_state); + self.metrics.supply.push_profitability(&unrealized_state); } } diff --git a/crates/brk_computer/src/distribution/compute/block_loop.rs b/crates/brk_computer/src/distribution/compute/block_loop.rs index 02fe88101..21980299a 100644 --- a/crates/brk_computer/src/distribution/compute/block_loop.rs +++ b/crates/brk_computer/src/distribution/compute/block_loop.rs @@ -144,42 +144,50 @@ pub(crate) fn process_blocks( let first_p2a_vec = indexer .vecs .addrs - .p2a.first_index + .p2a + .first_index .collect_range_at(start_usize, end_usize); let first_p2pk33_vec = indexer .vecs .addrs - .p2pk33.first_index + .p2pk33 + .first_index .collect_range_at(start_usize, end_usize); let first_p2pk65_vec = indexer .vecs .addrs - .p2pk65.first_index + .p2pk65 + .first_index .collect_range_at(start_usize, end_usize); let first_p2pkh_vec = indexer .vecs .addrs - .p2pkh.first_index + .p2pkh + .first_index .collect_range_at(start_usize, end_usize); let first_p2sh_vec = indexer .vecs .addrs - .p2sh.first_index + .p2sh + .first_index .collect_range_at(start_usize, end_usize); let first_p2tr_vec = indexer .vecs .addrs - .p2tr.first_index + .p2tr + .first_index .collect_range_at(start_usize, end_usize); let first_p2wpkh_vec = indexer .vecs .addrs - .p2wpkh.first_index + .p2wpkh + .first_index .collect_range_at(start_usize, end_usize); let first_p2wsh_vec = indexer .vecs .addrs - .p2wsh.first_index + .p2wsh + .first_index .collect_range_at(start_usize, end_usize); // Track running totals - recover from previous height if resuming @@ -187,10 +195,8 @@ pub(crate) fn process_blocks( let (mut addr_counts, mut empty_addr_counts) = if starting_height > Height::ZERO { let addr_counts = AddrTypeToAddrCount::from((&vecs.addrs.funded.by_addr_type, starting_height)); - let empty_addr_counts = AddrTypeToAddrCount::from(( - &vecs.addrs.empty.by_addr_type, - starting_height, - )); + let empty_addr_counts = + AddrTypeToAddrCount::from((&vecs.addrs.empty.by_addr_type, starting_height)); (addr_counts, empty_addr_counts) } else { ( @@ -274,12 +280,18 @@ pub(crate) fn process_blocks( // processing closures so outputs and inputs collection overlap each other // and tick-tock, instead of running sequentially before the join. let (matured, oi_result) = rayon::join( - || vecs.utxo_cohorts.tick_tock_next_block(chain_state, timestamp), + || { + vecs.utxo_cohorts + .tick_tock_next_block(chain_state, timestamp) + }, || -> Result<_> { let (outputs_result, inputs_result) = rayon::join( || { - let txout_index_to_tx_index = txout_to_tx_index_buf - .build(first_tx_index, tx_count, tx_index_to_output_count); + let txout_index_to_tx_index = txout_to_tx_index_buf.build( + first_tx_index, + tx_count, + tx_index_to_output_count, + ); let txout_data_vec = txout_iters.collect_block_outputs(first_txout_index, output_count); process_outputs( @@ -294,14 +306,21 @@ pub(crate) fn process_blocks( }, || -> Result<_> { if input_count > 1 { - let txin_index_to_tx_index = txin_to_tx_index_buf - .build(first_tx_index, tx_count, tx_index_to_input_count); - let (input_values, input_prev_heights, input_output_types, input_type_indexes) = - txin_iters.collect_block_inputs( - first_txin_index + 1, - input_count - 1, - height, - ); + let txin_index_to_tx_index = txin_to_tx_index_buf.build( + first_tx_index, + tx_count, + tx_index_to_input_count, + ); + let ( + input_values, + input_prev_heights, + input_output_types, + input_type_indexes, + ) = txin_iters.collect_block_inputs( + first_txin_index + 1, + input_count - 1, + height, + ); process_inputs( input_count - 1, &txin_index_to_tx_index[1..], @@ -380,9 +399,9 @@ pub(crate) fn process_blocks( blocks_old as u128 * u64::from(sent.spendable_supply.value) as u128 }) .sum(); - vecs.coinblocks_destroyed.block.push( - StoredF64::from(total_satblocks as f64 / Sats::ONE_BTC_U128 as f64), - ); + vecs.coinblocks_destroyed.block.push(StoredF64::from( + total_satblocks as f64 / Sats::ONE_BTC_U128 as f64, + )); } // Record maturation (sats crossing age boundaries) @@ -451,9 +470,11 @@ pub(crate) fn process_blocks( vecs.utxo_cohorts.update_fenwick_from_pending(); // Push to height-indexed vectors - vecs.addrs.funded + vecs.addrs + .funded .push_height(addr_counts.sum(), &addr_counts); - vecs.addrs.empty + vecs.addrs + .empty .push_height(empty_addr_counts.sum(), &empty_addr_counts); vecs.addrs.activity.push_height(&activity_counts); @@ -467,11 +488,8 @@ pub(crate) fn process_blocks( block_price, ); - vecs.utxo_cohorts.push_aggregate_percentiles( - block_price, - date_opt, - &vecs.states_path, - )?; + vecs.utxo_cohorts + .push_aggregate_percentiles(block_price, date_opt, &vecs.states_path)?; // Periodic checkpoint flush if height != last_height @@ -534,20 +552,16 @@ fn push_cohort_states( // Phase 1: push + unrealized (no reset yet — states still needed for aggregation) rayon::join( || { - utxo_cohorts - .par_iter_separate_mut() - .for_each(|v| { - v.push_state(height); - v.push_unrealized_state(height_price); - }) + utxo_cohorts.par_iter_separate_mut().for_each(|v| { + v.push_state(height); + v.push_unrealized_state(height_price); + }) }, || { - addr_cohorts - .par_iter_separate_mut() - .for_each(|v| { - v.push_state(height); - v.push_unrealized_state(height_price); - }) + addr_cohorts.par_iter_separate_mut().for_each(|v| { + v.push_state(height); + v.push_unrealized_state(height_price); + }) }, ); diff --git a/crates/brk_computer/src/distribution/compute/readers.rs b/crates/brk_computer/src/distribution/compute/readers.rs index 0e4407ffe..563b40085 100644 --- a/crates/brk_computer/src/distribution/compute/readers.rs +++ b/crates/brk_computer/src/distribution/compute/readers.rs @@ -116,11 +116,10 @@ impl<'a> TxInReaders<'a> { current_height: Height, ) -> (&[Sats], &[Height], &[OutputType], &[TypeIndex]) { let end = first_txin_index + input_count; - self.txins.spent.value.collect_range_into_at( - first_txin_index, - end, - &mut self.values_buf, - ); + self.txins + .spent + .value + .collect_range_into_at(first_txin_index, end, &mut self.values_buf); self.indexer.vecs.inputs.outpoint.collect_range_into_at( first_txin_index, end, @@ -138,8 +137,8 @@ impl<'a> TxInReaders<'a> { ); self.prev_heights_buf.clear(); - self.prev_heights_buf.extend( - self.outpoints_buf.iter().map(|outpoint| { + self.prev_heights_buf + .extend(self.outpoints_buf.iter().map(|outpoint| { if outpoint.is_coinbase() { current_height } else { @@ -147,8 +146,7 @@ impl<'a> TxInReaders<'a> { .get(outpoint.tx_index()) .unwrap_or(current_height) } - }), - ); + })); ( &self.values_buf, @@ -166,10 +164,7 @@ pub struct VecsReaders { } impl VecsReaders { - pub(crate) fn new( - any_addr_indexes: &AnyAddrIndexesVecs, - addrs_data: &AddrsDataVecs, - ) -> Self { + pub(crate) fn new(any_addr_indexes: &AnyAddrIndexesVecs, addrs_data: &AddrsDataVecs) -> Self { Self { addr_type_index_to_any_addr_index: ByAddrType { p2a: any_addr_indexes.p2a.create_reader(), diff --git a/crates/brk_computer/src/distribution/compute/recover.rs b/crates/brk_computer/src/distribution/compute/recover.rs index 7db1db946..b199c876a 100644 --- a/crates/brk_computer/src/distribution/compute/recover.rs +++ b/crates/brk_computer/src/distribution/compute/recover.rs @@ -185,10 +185,7 @@ fn rollback_states( heights.insert(chain_height); let Ok(stamps) = addr_indexes_rollbacks else { - warn!( - "addr_indexes rollback failed: {:?}", - addr_indexes_rollbacks - ); + warn!("addr_indexes rollback failed: {:?}", addr_indexes_rollbacks); return Height::ZERO; }; for (i, s) in stamps.iter().enumerate() { diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs index 667b5cc9f..f0ad68a30 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/core.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/core.rs @@ -5,7 +5,10 @@ use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; use crate::{ - distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}, + distribution::{ + metrics::ImportConfig, + state::{CohortState, CostBasisOps, RealizedOps}, + }, internal::{AmountPerBlockCumulativeRolling, PerBlockCumulativeRolling}, prices, }; @@ -46,19 +49,18 @@ impl ActivityCore { } #[inline(always)] - pub(crate) fn push_state( - &mut self, - state: &CohortState, - ) { + pub(crate) fn push_state(&mut self, state: &CohortState) { self.minimal.push_state(state); - self.coindays_destroyed.block.push( - StoredF64::from(Bitcoin::from(state.satdays_destroyed)), - ); + self.coindays_destroyed + .block + .push(StoredF64::from(Bitcoin::from(state.satdays_destroyed))); self.transfer_volume_in_profit - .block.sats + .block + .sats .push(state.realized.sent_in_profit()); self.transfer_volume_in_loss - .block.sats + .block + .sats .push(state.realized.sent_in_loss()); } diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index d06b114fb..2521d92d0 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -7,7 +7,10 @@ use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, Rw, StorageMode}; use crate::internal::{Identity, LazyPerBlock, PerBlock, Windows}; use crate::{ - distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}, + distribution::{ + metrics::ImportConfig, + state::{CohortState, CostBasisOps, RealizedOps}, + }, prices, }; @@ -33,7 +36,12 @@ impl ActivityFull { let coinyears_destroyed = LazyPerBlock::from_height_source::>( &cfg.name("coinyears_destroyed"), cfg.version + v1, - inner.coindays_destroyed.sum._1y.height.read_only_boxed_clone(), + inner + .coindays_destroyed + .sum + ._1y + .height + .read_only_boxed_clone(), cfg.indexes, ); @@ -89,7 +97,8 @@ impl ActivityFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.inner.compute_rest_part1(prices, starting_indexes, exit)?; + self.inner + .compute_rest_part1(prices, starting_indexes, exit)?; for ((dormancy, cdd_sum), tv_sum) in self .dormancy diff --git a/crates/brk_computer/src/distribution/metrics/activity/minimal.rs b/crates/brk_computer/src/distribution/metrics/activity/minimal.rs index a8de3987f..6cf53bd93 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/minimal.rs @@ -4,7 +4,10 @@ use brk_types::{Indexes, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; use crate::{ - distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}, + distribution::{ + metrics::ImportConfig, + state::{CohortState, CostBasisOps, RealizedOps}, + }, internal::AmountPerBlockCumulativeRolling, prices, }; @@ -23,16 +26,11 @@ impl ActivityMinimal { } pub(crate) fn min_len(&self) -> usize { - self.transfer_volume - .block.sats - .len() + self.transfer_volume.block.sats.len() } #[inline(always)] - pub(crate) fn push_state( - &mut self, - state: &CohortState, - ) { + pub(crate) fn push_state(&mut self, state: &CohortState) { self.transfer_volume.block.sats.push(state.sent); } diff --git a/crates/brk_computer/src/distribution/metrics/activity/mod.rs b/crates/brk_computer/src/distribution/metrics/activity/mod.rs index b61dd56f6..fee676677 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/mod.rs @@ -19,10 +19,7 @@ pub trait ActivityLike: Send + Sync { fn as_core(&self) -> &ActivityCore; fn as_core_mut(&mut self) -> &mut ActivityCore; fn min_len(&self) -> usize; - fn push_state( - &mut self, - state: &CohortState, - ); + fn push_state(&mut self, state: &CohortState); fn validate_computed_versions(&mut self, base_version: Version) -> Result<()>; fn compute_from_stateful( &mut self, @@ -39,37 +36,69 @@ pub trait ActivityLike: Send + Sync { } impl ActivityLike for ActivityCore { - fn as_core(&self) -> &ActivityCore { self } - fn as_core_mut(&mut self) -> &mut ActivityCore { self } - fn min_len(&self) -> usize { self.min_len() } + fn as_core(&self) -> &ActivityCore { + self + } + fn as_core_mut(&mut self) -> &mut ActivityCore { + self + } + fn min_len(&self) -> usize { + self.min_len() + } fn push_state(&mut self, state: &CohortState) { self.push_state(state); } fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { self.validate_computed_versions(base_version) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityCore], exit: &Exit) -> Result<()> { + fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&ActivityCore], + exit: &Exit, + ) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } - fn compute_rest_part1(&mut self, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { + fn compute_rest_part1( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { self.compute_rest_part1(prices, starting_indexes, exit) } } impl ActivityLike for ActivityFull { - fn as_core(&self) -> &ActivityCore { &self.inner } - fn as_core_mut(&mut self) -> &mut ActivityCore { &mut self.inner } - fn min_len(&self) -> usize { self.full_min_len() } + fn as_core(&self) -> &ActivityCore { + &self.inner + } + fn as_core_mut(&mut self) -> &mut ActivityCore { + &mut self.inner + } + fn min_len(&self) -> usize { + self.full_min_len() + } fn push_state(&mut self, state: &CohortState) { self.full_push_state(state); } fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { self.inner.validate_computed_versions(base_version) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityCore], exit: &Exit) -> Result<()> { + fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&ActivityCore], + exit: &Exit, + ) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } - fn compute_rest_part1(&mut self, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { + fn compute_rest_part1( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { self.compute_rest_part1(prices, starting_indexes, exit) } } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index 1f4b784ef..663a56dfd 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -1,9 +1,7 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{ - Cents, Dollars, Height, Indexes, Version, -}; +use brk_types::{Cents, Dollars, Height, Indexes, Version}; use vecdb::AnyStoredVec; use vecdb::{Exit, ReadOnlyClone, ReadableVec, Rw, StorageMode}; @@ -136,11 +134,8 @@ impl AllCohortMetrics { )?; let all_utxo_count = self.outputs.unspent_count.height.read_only_clone(); - self.outputs.compute_part2( - starting_indexes.height, - &all_utxo_count, - exit, - )?; + self.outputs + .compute_part2(starting_indexes.height, &all_utxo_count, exit)?; self.cost_basis.compute_prices( starting_indexes, @@ -154,11 +149,8 @@ impl AllCohortMetrics { exit, )?; - self.unrealized.compute_sentiment( - starting_indexes, - &prices.spot.cents.height, - exit, - )?; + self.unrealized + .compute_sentiment(starting_indexes, &prices.spot.cents.height, exit)?; self.relative.compute( starting_indexes.height, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index 4bc378247..c16245ba1 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -87,16 +87,12 @@ impl BasicCohortMetrics { exit, )?; - self.relative.compute( - starting_indexes.height, - &self.supply, - all_supply_sats, - exit, - )?; + self.relative + .compute(starting_indexes.height, &self.supply, all_supply_sats, exit)?; - self.outputs.compute_part2(starting_indexes.height, all_utxo_count, exit)?; + self.outputs + .compute_part2(starting_indexes.height, all_utxo_count, exit)?; Ok(()) } - } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index 805304413..de14a707a 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -92,7 +92,10 @@ impl CoreCohortMetrics { )?; self.unrealized.compute_from_stateful( starting_indexes, - &others.iter().map(|v| v.unrealized_core()).collect::>(), + &others + .iter() + .map(|v| v.unrealized_core()) + .collect::>(), exit, )?; @@ -105,16 +108,14 @@ impl CoreCohortMetrics { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.supply - .compute(prices, starting_indexes.height, exit)?; + self.supply.compute(prices, starting_indexes.height, exit)?; self.outputs.compute_rest(starting_indexes.height, exit)?; self.activity .compute_rest_part1(prices, starting_indexes, exit)?; - self.realized - .compute_rest_part1(starting_indexes, exit)?; + self.realized.compute_rest_part1(starting_indexes, exit)?; self.unrealized.compute_rest(starting_indexes, exit)?; @@ -144,14 +145,11 @@ impl CoreCohortMetrics { exit, )?; - self.relative.compute( - starting_indexes.height, - &self.supply, - all_supply_sats, - exit, - )?; + self.relative + .compute(starting_indexes.height, &self.supply, all_supply_sats, exit)?; - self.outputs.compute_part2(starting_indexes.height, all_utxo_count, exit)?; + self.outputs + .compute_part2(starting_indexes.height, all_utxo_count, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index 4b45be071..834aed0db 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -104,8 +104,7 @@ impl MinimalCohortMetrics { self.outputs.compute_rest(starting_indexes.height, exit)?; self.activity .compute_rest_part1(prices, starting_indexes, exit)?; - self.realized - .compute_rest_part1(starting_indexes, exit)?; + self.realized.compute_rest_part1(starting_indexes, exit)?; Ok(()) } @@ -130,7 +129,8 @@ impl MinimalCohortMetrics { exit, )?; - self.outputs.compute_part2(starting_indexes.height, all_utxo_count, exit)?; + self.outputs + .compute_part2(starting_indexes.height, all_utxo_count, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/type.rs b/crates/brk_computer/src/distribution/metrics/cohort/type.rs index ca214e6f0..b0870b1bb 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/type.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/type.rs @@ -66,8 +66,7 @@ impl TypeCohortMetrics { self.outputs.compute_rest(starting_indexes.height, exit)?; self.activity .compute_rest_part1(prices, starting_indexes, exit)?; - self.realized - .compute_rest_part1(starting_indexes, exit)?; + self.realized.compute_rest_part1(starting_indexes, exit)?; Ok(()) } @@ -92,7 +91,8 @@ impl TypeCohortMetrics { exit, )?; - self.outputs.compute_part2(starting_indexes.height, all_utxo_count, exit)?; + self.outputs + .compute_part2(starting_indexes.height, all_utxo_count, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs index 363e85d87..e47fe1431 100644 --- a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs @@ -4,9 +4,7 @@ use brk_types::CentsSquaredSats; use brk_types::{BasisPoints16, Cents, Height, Indexes, Sats, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; -use crate::internal::{ - PERCENTILES_LEN, PerBlock, PercentPerBlock, PercentilesVecs, Price, -}; +use crate::internal::{PERCENTILES_LEN, PerBlock, PercentPerBlock, PercentilesVecs, Price}; use super::ImportConfig; @@ -33,12 +31,32 @@ impl CostBasis { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { in_profit: CostBasisSide { - per_coin: Price::forced_import(cfg.db, &cfg.name("cost_basis_in_profit_per_coin"), cfg.version + Version::ONE, cfg.indexes)?, - per_dollar: Price::forced_import(cfg.db, &cfg.name("cost_basis_in_profit_per_dollar"), cfg.version + Version::ONE, cfg.indexes)?, + per_coin: Price::forced_import( + cfg.db, + &cfg.name("cost_basis_in_profit_per_coin"), + cfg.version + Version::ONE, + cfg.indexes, + )?, + per_dollar: Price::forced_import( + cfg.db, + &cfg.name("cost_basis_in_profit_per_dollar"), + cfg.version + Version::ONE, + cfg.indexes, + )?, }, in_loss: CostBasisSide { - per_coin: Price::forced_import(cfg.db, &cfg.name("cost_basis_in_loss_per_coin"), cfg.version + Version::ONE, cfg.indexes)?, - per_dollar: Price::forced_import(cfg.db, &cfg.name("cost_basis_in_loss_per_dollar"), cfg.version + Version::ONE, cfg.indexes)?, + per_coin: Price::forced_import( + cfg.db, + &cfg.name("cost_basis_in_loss_per_coin"), + cfg.version + Version::ONE, + cfg.indexes, + )?, + per_dollar: Price::forced_import( + cfg.db, + &cfg.name("cost_basis_in_loss_per_dollar"), + cfg.version + Version::ONE, + cfg.indexes, + )?, }, min: cfg.import("cost_basis_min", Version::ZERO)?, max: cfg.import("cost_basis_max", Version::ZERO)?, diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index d6bacc655..6c349dd32 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -51,7 +51,12 @@ macro_rules! impl_cohort_accessors { fn unrealized_mut(&mut self) -> &mut Self::UnrealizedVecs { &mut self.unrealized } - fn supply_and_unrealized_mut(&mut self) -> (&$crate::distribution::metrics::SupplyCore, &mut Self::UnrealizedVecs) { + fn supply_and_unrealized_mut( + &mut self, + ) -> ( + &$crate::distribution::metrics::SupplyCore, + &mut Self::UnrealizedVecs, + ) { (&*self.supply, &mut self.unrealized) } }; @@ -94,7 +99,12 @@ macro_rules! impl_cohort_accessors_inner { fn unrealized_mut(&mut self) -> &mut Self::UnrealizedVecs { &mut self.inner.unrealized } - fn supply_and_unrealized_mut(&mut self) -> (&$crate::distribution::metrics::SupplyCore, &mut Self::UnrealizedVecs) { + fn supply_and_unrealized_mut( + &mut self, + ) -> ( + &$crate::distribution::metrics::SupplyCore, + &mut Self::UnrealizedVecs, + ) { (&*self.inner.supply, &mut self.inner.unrealized) } }; @@ -125,8 +135,7 @@ pub use realized::{ pub use relative::{RelativeForAll, RelativeToAll, RelativeWithExtended}; pub use supply::{SupplyBase, SupplyCore}; pub use unrealized::{ - UnrealizedBasic, UnrealizedCore, UnrealizedFull, UnrealizedLike, - UnrealizedMinimal, + UnrealizedBasic, UnrealizedCore, UnrealizedFull, UnrealizedLike, UnrealizedMinimal, }; use brk_cohort::Filter; @@ -250,10 +259,7 @@ pub trait CohortMetricsBase: .min(self.unrealized().min_stateful_len()) } - fn push_state( - &mut self, - state: &CohortState>, - ) { + fn push_state(&mut self, state: &CohortState>) { self.supply_mut().push_state(state); self.outputs_mut().push_state(state); self.activity_mut().push_state(state); diff --git a/crates/brk_computer/src/distribution/metrics/profitability.rs b/crates/brk_computer/src/distribution/metrics/profitability.rs index 03de07a96..96a879ab8 100644 --- a/crates/brk_computer/src/distribution/metrics/profitability.rs +++ b/crates/brk_computer/src/distribution/metrics/profitability.rs @@ -6,7 +6,9 @@ use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec}; use crate::{ indexes, - internal::{AmountPerBlock, AmountPerBlockWithDeltas, CachedWindowStarts, PerBlock, RatioPerBlock}, + internal::{ + AmountPerBlock, AmountPerBlockWithDeltas, CachedWindowStarts, PerBlock, RatioPerBlock, + }, prices, }; @@ -183,22 +185,34 @@ impl ProfitabilityBucket { self.supply.all.sats.height.compute_sum_of_others( max_from, - &sources.iter().map(|s| &s.supply.all.sats.height).collect::>(), + &sources + .iter() + .map(|s| &s.supply.all.sats.height) + .collect::>(), exit, )?; self.supply.sth.sats.height.compute_sum_of_others( max_from, - &sources.iter().map(|s| &s.supply.sth.sats.height).collect::>(), + &sources + .iter() + .map(|s| &s.supply.sth.sats.height) + .collect::>(), exit, )?; self.realized_cap.all.height.compute_sum_of_others( max_from, - &sources.iter().map(|s| &s.realized_cap.all.height).collect::>(), + &sources + .iter() + .map(|s| &s.realized_cap.all.height) + .collect::>(), exit, )?; self.realized_cap.sth.height.compute_sum_of_others( max_from, - &sources.iter().map(|s| &s.realized_cap.sth.height).collect::>(), + &sources + .iter() + .map(|s| &s.realized_cap.sth.height) + .collect::>(), exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs index 0bbefc0db..28353d4ae 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/core.rs @@ -1,6 +1,8 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Dollars, Height, Indexes, StoredF64, Version}; +use brk_types::{ + BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Dollars, Height, Indexes, StoredF64, Version, +}; use derive_more::{Deref, DerefMut}; use vecdb::{ AnyStoredVec, Exit, LazyVecFrom1, ReadableCloneableVec, ReadableVec, Rw, StorageMode, @@ -42,7 +44,8 @@ pub struct RealizedCore { #[traversable(wrap = "loss", rename = "negative")] pub neg_loss: NegRealizedLoss, - pub net_pnl: FiatPerBlockCumulativeWithSumsAndDeltas, + pub net_pnl: + FiatPerBlockCumulativeWithSumsAndDeltas, pub sopr: RealizedSoprCore, } @@ -107,7 +110,10 @@ impl RealizedCore { #[inline(always)] pub(crate) fn push_state(&mut self, state: &CohortState) { self.minimal.push_state(state); - self.sopr.value_destroyed.block.push(state.realized.value_destroyed()); + self.sopr + .value_destroyed + .block + .push(state.realized.value_destroyed()); } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { @@ -135,8 +141,7 @@ impl RealizedCore { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.minimal - .compute_rest_part1(starting_indexes, exit)?; + self.minimal.compute_rest_part1(starting_indexes, exit)?; self.sopr .value_destroyed @@ -169,8 +174,7 @@ impl RealizedCore { self.minimal .compute_rest_part2(prices, starting_indexes, height_to_supply, exit)?; - self.net_pnl - .compute_rest(starting_indexes.height, exit)?; + self.net_pnl.compute_rest(starting_indexes.height, exit)?; self.sopr .ratio diff --git a/crates/brk_computer/src/distribution/metrics/realized/full.rs b/crates/brk_computer/src/distribution/metrics/realized/full.rs index e8197d947..9c8e80357 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -178,7 +178,8 @@ impl RealizedFull { .push(state.realized.investor_cap_raw()); self.peak_regret .value - .block.cents + .block + .cents .push(state.realized.peak_regret()); } @@ -218,10 +219,7 @@ impl RealizedFull { }; self.investor.price.cents.height.push(investor_price); - self.peak_regret - .value - .block.cents - .push(accum.peak_regret()); + self.peak_regret.value.block.cents.push(accum.peak_regret()); } pub(crate) fn compute_rest_part1( diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs index 8f980c473..10c223a24 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -1,18 +1,16 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Height, Indexes, Sats, StoredF32, - Version, -}; -use vecdb::{ - AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec, + BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Height, Indexes, Sats, + StoredF32, Version, }; +use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{ distribution::state::{CohortState, CostBasisOps, RealizedOps}, internal::{ - FiatPerBlockCumulativeWithSums, - FiatPerBlockWithDeltas, Identity, LazyPerBlock, PriceWithRatioPerBlock, + FiatPerBlockCumulativeWithSums, FiatPerBlockWithDeltas, Identity, LazyPerBlock, + PriceWithRatioPerBlock, }, prices, }; @@ -111,23 +109,24 @@ impl RealizedMinimal { exit: &Exit, ) -> Result<()> { let cap = &self.cap.cents.height; - self.price.compute_all(prices, starting_indexes, exit, |v| { - Ok(v.compute_transform2( - starting_indexes.height, - cap, - height_to_supply, - |(i, cap_cents, supply, ..)| { - let cap = cap_cents.as_u128(); - let supply_sats = Sats::from(supply).as_u128(); - if supply_sats == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) - } - }, - exit, - )?) - })?; + self.price + .compute_all(prices, starting_indexes, exit, |v| { + Ok(v.compute_transform2( + starting_indexes.height, + cap, + height_to_supply, + |(i, cap_cents, supply, ..)| { + let cap = cap_cents.as_u128(); + let supply_sats = Sats::from(supply).as_u128(); + if supply_sats == 0 { + (i, Cents::ZERO) + } else { + (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) + } + }, + exit, + )?) + })?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/realized/mod.rs b/crates/brk_computer/src/distribution/metrics/realized/mod.rs index 70e39fe88..67971773e 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/mod.rs @@ -3,8 +3,8 @@ mod core; mod full; mod minimal; -pub use adjusted::AdjustedSopr; pub use self::core::RealizedCore; +pub use adjusted::AdjustedSopr; pub use full::{RealizedFull, RealizedFullAccum}; pub use minimal::RealizedMinimal; @@ -12,7 +12,7 @@ use brk_error::Result; use brk_types::Indexes; use vecdb::Exit; -use crate::distribution::state::{WithCapital, CohortState, CostBasisData, RealizedState}; +use crate::distribution::state::{CohortState, CostBasisData, RealizedState, WithCapital}; pub trait RealizedLike: Send + Sync { fn as_core(&self) -> &RealizedCore; @@ -29,9 +29,15 @@ pub trait RealizedLike: Send + Sync { } impl RealizedLike for RealizedCore { - fn as_core(&self) -> &RealizedCore { self } - fn as_core_mut(&mut self) -> &mut RealizedCore { self } - fn min_stateful_len(&self) -> usize { self.min_stateful_len() } + fn as_core(&self) -> &RealizedCore { + self + } + fn as_core_mut(&mut self) -> &mut RealizedCore { + self + } + fn min_stateful_len(&self) -> usize { + self.min_stateful_len() + } #[inline(always)] fn push_state(&mut self, state: &CohortState>) { self.push_state(state) @@ -39,15 +45,26 @@ impl RealizedLike for RealizedCore { fn compute_rest_part1(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { self.compute_rest_part1(starting_indexes, exit) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&RealizedCore], exit: &Exit) -> Result<()> { + fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&RealizedCore], + exit: &Exit, + ) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } } impl RealizedLike for RealizedFull { - fn as_core(&self) -> &RealizedCore { &self.core } - fn as_core_mut(&mut self) -> &mut RealizedCore { &mut self.core } - fn min_stateful_len(&self) -> usize { self.min_stateful_len() } + fn as_core(&self) -> &RealizedCore { + &self.core + } + fn as_core_mut(&mut self) -> &mut RealizedCore { + &mut self.core + } + fn min_stateful_len(&self) -> usize { + self.min_stateful_len() + } #[inline(always)] fn push_state(&mut self, state: &CohortState>) { self.push_state(state) @@ -55,7 +72,12 @@ impl RealizedLike for RealizedFull { fn compute_rest_part1(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { self.compute_rest_part1(starting_indexes, exit) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&RealizedCore], exit: &Exit) -> Result<()> { + fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&RealizedCore], + exit: &Exit, + ) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } } diff --git a/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs b/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs index ab515b3b8..6dd9e1f36 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs @@ -23,8 +23,7 @@ impl RelativeExtendedOwnMarketCap { let v2 = Version::new(2); Ok(Self { - unrealized_profit_to_own_mcap: cfg - .import("unrealized_profit_to_own_mcap", v2)?, + unrealized_profit_to_own_mcap: cfg.import("unrealized_profit_to_own_mcap", v2)?, unrealized_loss_to_own_mcap: cfg .import("unrealized_loss_to_own_mcap", Version::new(3))?, net_unrealized_pnl_to_own_mcap: cfg diff --git a/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs b/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs index a90eaf2fe..e89f95a8b 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs @@ -16,7 +16,6 @@ pub struct RelativeExtendedOwnPnl { pub unrealized_loss_to_own_gross_pnl: PercentPerBlock, #[traversable(wrap = "unrealized/net_pnl", rename = "to_own_gross_pnl")] pub net_unrealized_pnl_to_own_gross_pnl: PercentPerBlock, - } impl RelativeExtendedOwnPnl { @@ -26,8 +25,7 @@ impl RelativeExtendedOwnPnl { Ok(Self { unrealized_profit_to_own_gross_pnl: cfg .import("unrealized_profit_to_own_gross_pnl", v1)?, - unrealized_loss_to_own_gross_pnl: cfg - .import("unrealized_loss_to_own_gross_pnl", v1)?, + unrealized_loss_to_own_gross_pnl: cfg.import("unrealized_loss_to_own_gross_pnl", v1)?, net_unrealized_pnl_to_own_gross_pnl: cfg .import("net_unrealized_pnl_to_own_gross_pnl", Version::new(3))?, }) diff --git a/crates/brk_computer/src/distribution/metrics/relative/for_all.rs b/crates/brk_computer/src/distribution/metrics/relative/for_all.rs index 8a9566dc8..4b3deb65f 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/for_all.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/for_all.rs @@ -6,7 +6,7 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::distribution::metrics::{ImportConfig, SupplyCore, UnrealizedFull}; -use super::{RelativeFull, RelativeExtendedOwnPnl}; +use super::{RelativeExtendedOwnPnl, RelativeFull}; /// Relative metrics for the "all" cohort (base + own_pnl, NO rel_to_all). #[derive(Deref, DerefMut, Traversable)] @@ -35,15 +35,14 @@ impl RelativeForAll { market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.base.compute( + self.base + .compute(max_from, supply, &unrealized.inner.basic, market_cap, exit)?; + self.extended_own_pnl.compute( max_from, - supply, - &unrealized.inner.basic, - market_cap, + &unrealized.inner, + &unrealized.gross_pnl.usd.height, exit, )?; - self.extended_own_pnl - .compute(max_from, &unrealized.inner, &unrealized.gross_pnl.usd.height, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/relative/full.rs b/crates/brk_computer/src/distribution/metrics/relative/full.rs index bd7fe0118..826081f18 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/full.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/full.rs @@ -28,13 +28,10 @@ impl RelativeFull { let v2 = Version::new(2); Ok(Self { - supply_in_profit_to_own: cfg - .import("supply_in_profit_to_own", v1)?, + supply_in_profit_to_own: cfg.import("supply_in_profit_to_own", v1)?, supply_in_loss_to_own: cfg.import("supply_in_loss_to_own", v1)?, - unrealized_profit_to_mcap: cfg - .import("unrealized_profit_to_mcap", v2)?, - unrealized_loss_to_mcap: cfg - .import("unrealized_loss_to_mcap", v2)?, + unrealized_profit_to_mcap: cfg.import("unrealized_profit_to_mcap", v2)?, + unrealized_loss_to_mcap: cfg.import("unrealized_loss_to_mcap", v2)?, }) } diff --git a/crates/brk_computer/src/distribution/metrics/relative/to_all.rs b/crates/brk_computer/src/distribution/metrics/relative/to_all.rs index 2777b0839..2146432eb 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/to_all.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/to_all.rs @@ -21,8 +21,7 @@ pub struct RelativeToAll { impl RelativeToAll { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - supply_to_circulating: cfg - .import("supply_to_circulating", Version::ONE)?, + supply_to_circulating: cfg.import("supply_to_circulating", Version::ONE)?, supply_in_profit_to_circulating: cfg .import("supply_in_profit_to_circulating", Version::ONE)?, supply_in_loss_to_circulating: cfg diff --git a/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs b/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs index 8d56c7bba..64302ba44 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs @@ -6,7 +6,7 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::distribution::metrics::{ImportConfig, SupplyCore, UnrealizedFull}; -use super::{RelativeFull, RelativeExtendedOwnMarketCap, RelativeExtendedOwnPnl, RelativeToAll}; +use super::{RelativeExtendedOwnMarketCap, RelativeExtendedOwnPnl, RelativeFull, RelativeToAll}; /// Full extended relative metrics (base + rel_to_all + own_market_cap + own_pnl). /// Used by: sth, lth cohorts. @@ -45,23 +45,18 @@ impl RelativeWithExtended { own_market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.base.compute( - max_from, - supply, - &unrealized.inner.basic, - market_cap, - exit, - )?; - self.rel_to_all.compute( - max_from, - supply, - all_supply_sats, - exit, - )?; + self.base + .compute(max_from, supply, &unrealized.inner.basic, market_cap, exit)?; + self.rel_to_all + .compute(max_from, supply, all_supply_sats, exit)?; self.extended_own_market_cap .compute(max_from, &unrealized.inner, own_market_cap, exit)?; - self.extended_own_pnl - .compute(max_from, &unrealized.inner, &unrealized.gross_pnl.usd.height, exit)?; + self.extended_own_pnl.compute( + max_from, + &unrealized.inner, + &unrealized.gross_pnl.usd.height, + exit, + )?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/supply/base.rs b/crates/brk_computer/src/distribution/metrics/supply/base.rs index 223134bc1..678ed5303 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/base.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/base.rs @@ -3,12 +3,13 @@ use brk_traversable::Traversable; use brk_types::{BasisPointsSigned32, Height, Indexes, Sats, SatsSigned, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; -use crate::{distribution::state::{CohortState, CostBasisOps, RealizedOps}, prices}; - -use crate::internal::{ - AmountPerBlock, LazyRollingDeltasFromHeight, +use crate::{ + distribution::state::{CohortState, CostBasisOps, RealizedOps}, + prices, }; +use crate::internal::{AmountPerBlock, LazyRollingDeltasFromHeight}; + use crate::distribution::metrics::ImportConfig; /// Base supply metrics: total supply only (2 stored vecs). diff --git a/crates/brk_computer/src/distribution/metrics/supply/mod.rs b/crates/brk_computer/src/distribution/metrics/supply/mod.rs index 78e115300..635045a93 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/mod.rs @@ -1,5 +1,5 @@ mod base; mod core; -pub use base::SupplyBase; pub use self::core::SupplyCore; +pub use base::SupplyBase; diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs index af4e7bd12..3c3d43a48 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs @@ -54,14 +54,8 @@ impl UnrealizedBasic { #[inline(always)] pub(crate) fn push_state(&mut self, state: &UnrealizedState) { - self.profit - .cents - .height - .push(state.unrealized_profit); - self.loss - .cents - .height - .push(state.unrealized_loss); + self.profit.cents.height.push(state.unrealized_profit); + self.loss.cents.height.push(state.unrealized_loss); } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs index 455a0044e..dc66b4c4b 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs @@ -5,10 +5,7 @@ use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; use crate::{ - distribution::{ - metrics::ImportConfig, - state::UnrealizedState, - }, + distribution::{metrics::ImportConfig, state::UnrealizedState}, internal::{CentsSubtractToCentsSigned, FiatPerBlock}, }; @@ -60,11 +57,7 @@ impl UnrealizedCore { Ok(()) } - pub(crate) fn compute_rest( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { + pub(crate) fn compute_rest(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { self.net_pnl .cents .height diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs index 3b1764d75..183445f2b 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs @@ -77,6 +77,12 @@ impl UnrealizedLike for UnrealizedFull { supply_in_loss_sats: &(impl ReadableVec + Sync), exit: &Exit, ) -> Result<()> { - self.compute_rest_all(prices, starting_indexes, supply_in_profit_sats, supply_in_loss_sats, exit) + self.compute_rest_all( + prices, + starting_indexes, + supply_in_profit_sats, + supply_in_loss_sats, + exit, + ) } } diff --git a/crates/brk_computer/src/distribution/state/cohort/base.rs b/crates/brk_computer/src/distribution/state/cohort/base.rs index d5e1d6a88..e69101932 100644 --- a/crates/brk_computer/src/distribution/state/cohort/base.rs +++ b/crates/brk_computer/src/distribution/state/cohort/base.rs @@ -1,9 +1,15 @@ use std::path::Path; use brk_error::Result; -use brk_types::{Age, Cents, CentsCompact, CentsSats, CentsSquaredSats, CostBasisSnapshot, Height, Sats, SupplyState}; +use brk_types::{ + Age, Cents, CentsCompact, CentsSats, CentsSquaredSats, CostBasisSnapshot, Height, Sats, + SupplyState, +}; -use super::super::{cost_basis::{Accumulate, CostBasisData, CostBasisOps, RealizedOps, UnrealizedState}, pending::PendingDelta}; +use super::super::{ + cost_basis::{Accumulate, CostBasisData, CostBasisOps, RealizedOps, UnrealizedState}, + pending::PendingDelta, +}; pub struct SendPrecomputed { pub sats: Sats, @@ -193,11 +199,7 @@ impl CohortState { } } - pub(crate) fn send_utxo_precomputed( - &mut self, - supply: &SupplyState, - pre: &SendPrecomputed, - ) { + pub(crate) fn send_utxo_precomputed(&mut self, supply: &SupplyState, pre: &SendPrecomputed) { self.supply -= supply; self.sent += pre.sats; self.spent_utxo_count += supply.utxo_count; @@ -205,8 +207,13 @@ impl CohortState { self.satdays_destroyed += pre.age.satdays_destroyed(pre.sats); } - self.realized - .send(pre.sats, pre.current_ps, pre.prev_ps, pre.ath_ps, pre.prev_investor_cap); + self.realized.send( + pre.sats, + pre.current_ps, + pre.prev_ps, + pre.ath_ps, + pre.prev_investor_cap, + ); self.cost_basis .decrement(pre.prev_price, pre.sats, pre.prev_ps, pre.prev_investor_cap); diff --git a/crates/brk_computer/src/distribution/state/cost_basis/data.rs b/crates/brk_computer/src/distribution/state/cost_basis/data.rs index 91f238905..b9a3c55cb 100644 --- a/crates/brk_computer/src/distribution/state/cost_basis/data.rs +++ b/crates/brk_computer/src/distribution/state/cost_basis/data.rs @@ -370,7 +370,11 @@ impl CostBasisOps for CostBasisData { let (base, rest) = CostBasisDistribution::deserialize_with_rest(&data)?; self.map = Some(base); self.raw.state = Some(RawState::deserialize(rest)?); - debug_assert!(rest.len() >= 32, "CostBasisData state too short: {} bytes", rest.len()); + debug_assert!( + rest.len() >= 32, + "CostBasisData state too short: {} bytes", + rest.len() + ); self.investor_cap_raw = CentsSquaredSats::from_bytes(&rest[16..32])?; self.pending.clear(); self.raw.pending_cap = PendingCapDelta::default(); @@ -435,7 +439,9 @@ impl CostBasisOps for CostBasisData { Path: {:?}\n\ Current (after increments): {:?}\n\ Trying to decrement by: {:?}", - self.raw.pathbuf, self.investor_cap_raw, self.pending_investor_cap.dec + self.raw.pathbuf, + self.investor_cap_raw, + self.pending_investor_cap.dec ); self.investor_cap_raw -= self.pending_investor_cap.dec; self.pending_investor_cap = PendingInvestorCapDelta::default(); diff --git a/crates/brk_computer/src/distribution/state/cost_basis/mod.rs b/crates/brk_computer/src/distribution/state/cost_basis/mod.rs index f1f5a40aa..f71940038 100644 --- a/crates/brk_computer/src/distribution/state/cost_basis/mod.rs +++ b/crates/brk_computer/src/distribution/state/cost_basis/mod.rs @@ -6,7 +6,7 @@ pub use data::*; pub use realized::*; pub use unrealized::UnrealizedState; -pub(crate) use unrealized::{Accumulate, WithoutCapital, WithCapital}; +pub(crate) use unrealized::{Accumulate, WithCapital, WithoutCapital}; // Internal use only pub(super) use unrealized::CachedUnrealizedState; diff --git a/crates/brk_computer/src/distribution/state/cost_basis/unrealized.rs b/crates/brk_computer/src/distribution/state/cost_basis/unrealized.rs index 7e884de54..3539ecd13 100644 --- a/crates/brk_computer/src/distribution/state/cost_basis/unrealized.rs +++ b/crates/brk_computer/src/distribution/state/cost_basis/unrealized.rs @@ -58,10 +58,18 @@ pub trait Accumulate: Default + Clone + Send + Sync + 'static { fn core(&self) -> &WithoutCapital; fn core_mut(&mut self) -> &mut WithoutCapital; - fn supply_in_profit(&self) -> Sats { self.core().supply_in_profit } - fn supply_in_loss(&self) -> Sats { self.core().supply_in_loss } - fn unrealized_profit(&mut self) -> &mut u128 { &mut self.core_mut().unrealized_profit } - fn unrealized_loss(&mut self) -> &mut u128 { &mut self.core_mut().unrealized_loss } + fn supply_in_profit(&self) -> Sats { + self.core().supply_in_profit + } + fn supply_in_loss(&self) -> Sats { + self.core().supply_in_loss + } + fn unrealized_profit(&mut self) -> &mut u128 { + &mut self.core_mut().unrealized_profit + } + fn unrealized_loss(&mut self) -> &mut u128 { + &mut self.core_mut().unrealized_loss + } fn accumulate_profit(&mut self, price_u128: u128, sats: Sats); fn accumulate_loss(&mut self, price_u128: u128, sats: Sats); @@ -80,8 +88,12 @@ impl Accumulate for WithoutCapital { } } - fn core(&self) -> &WithoutCapital { self } - fn core_mut(&mut self) -> &mut WithoutCapital { self } + fn core(&self) -> &WithoutCapital { + self + } + fn core_mut(&mut self) -> &mut WithoutCapital { + self + } #[inline(always)] fn accumulate_profit(&mut self, _price_u128: u128, sats: Sats) { @@ -110,8 +122,12 @@ impl Accumulate for WithCapital { } } - fn core(&self) -> &WithoutCapital { &self.core } - fn core_mut(&mut self) -> &mut WithoutCapital { &mut self.core } + fn core(&self) -> &WithoutCapital { + &self.core + } + fn core_mut(&mut self) -> &mut WithoutCapital { + &mut self.core + } #[inline(always)] fn accumulate_profit(&mut self, price_u128: u128, sats: Sats) { diff --git a/crates/brk_computer/src/indexes/addr.rs b/crates/brk_computer/src/indexes/addr.rs index a5e71bfc6..7dc0ece1b 100644 --- a/crates/brk_computer/src/indexes/addr.rs +++ b/crates/brk_computer/src/indexes/addr.rs @@ -1,11 +1,10 @@ use brk_indexer::Indexer; use brk_traversable::Traversable; use brk_types::{ - Addr, AddrBytes, EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2ABytes, - P2MSOutputIndex, P2PK33AddrIndex, P2PK33Bytes, P2PK65AddrIndex, P2PK65Bytes, - P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, P2SHBytes, P2TRAddrIndex, P2TRBytes, - P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, TxIndex, UnknownOutputIndex, - Version, + Addr, AddrBytes, EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2ABytes, P2MSOutputIndex, + P2PK33AddrIndex, P2PK33Bytes, P2PK65AddrIndex, P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, + P2SHAddrIndex, P2SHBytes, P2TRAddrIndex, P2TRBytes, P2WPKHAddrIndex, P2WPKHBytes, + P2WSHAddrIndex, P2WSHBytes, TxIndex, UnknownOutputIndex, Version, }; use vecdb::{LazyVecFrom1, ReadableCloneableVec}; @@ -27,15 +26,13 @@ pub struct Vecs { #[derive(Clone, Traversable)] pub struct P2PK33Vecs { - pub identity: - LazyVecFrom1, + pub identity: LazyVecFrom1, pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2PK65Vecs { - pub identity: - LazyVecFrom1, + pub identity: LazyVecFrom1, pub addr: LazyVecFrom1, } @@ -59,8 +56,7 @@ pub struct P2TRVecs { #[derive(Clone, Traversable)] pub struct P2WPKHVecs { - pub identity: - LazyVecFrom1, + pub identity: LazyVecFrom1, pub addr: LazyVecFrom1, } @@ -215,7 +211,12 @@ impl Vecs { identity: LazyVecFrom1::init( "p2ms_output_index", version, - indexer.vecs.scripts.p2ms.to_tx_index.read_only_boxed_clone(), + indexer + .vecs + .scripts + .p2ms + .to_tx_index + .read_only_boxed_clone(), |index, _| index, ), }, @@ -226,7 +227,8 @@ impl Vecs { indexer .vecs .scripts - .empty.to_tx_index + .empty + .to_tx_index .read_only_boxed_clone(), |index, _| index, ), @@ -238,7 +240,8 @@ impl Vecs { indexer .vecs .scripts - .unknown.to_tx_index + .unknown + .to_tx_index .read_only_boxed_clone(), |index, _| index, ), @@ -250,7 +253,8 @@ impl Vecs { indexer .vecs .scripts - .op_return.to_tx_index + .op_return + .to_tx_index .read_only_boxed_clone(), |index, _| index, ), diff --git a/crates/brk_computer/src/indexes/height.rs b/crates/brk_computer/src/indexes/height.rs index 3e30d9be9..b7a05c50b 100644 --- a/crates/brk_computer/src/indexes/height.rs +++ b/crates/brk_computer/src/indexes/height.rs @@ -1,7 +1,7 @@ use brk_traversable::Traversable; use brk_types::{ - Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, - Month1, Month3, Month6, StoredU64, Version, Week1, Year1, Year10, + Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, + Month6, StoredU64, Version, Week1, Year1, Year10, }; use vecdb::{Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode}; diff --git a/crates/brk_computer/src/indexes/mod.rs b/crates/brk_computer/src/indexes/mod.rs index 55f806160..48d55721a 100644 --- a/crates/brk_computer/src/indexes/mod.rs +++ b/crates/brk_computer/src/indexes/mod.rs @@ -35,7 +35,6 @@ use vecdb::{CachedVec, Database, Exit, ReadableVec, Rw, StorageMode}; use crate::internal::db_utils::{finalize_db, open_db}; pub use addr::Vecs as AddrVecs; -pub use timestamp::Timestamps; pub use cached_mappings::CachedMappings; pub use day1::Vecs as Day1Vecs; pub use day3::Vecs as Day3Vecs; @@ -50,6 +49,7 @@ pub use minute30::Vecs as Minute30Vecs; pub use month1::Vecs as Month1Vecs; pub use month3::Vecs as Month3Vecs; pub use month6::Vecs as Month6Vecs; +pub use timestamp::Timestamps; pub use tx_index::Vecs as TxIndexVecs; pub use txin_index::Vecs as TxInIndexVecs; pub use txout_index::Vecs as TxOutIndexVecs; @@ -190,20 +190,10 @@ impl Vecs { self.compute_timestamp_mappings(&starting_indexes, exit)?; - let starting_day1 = self.compute_calendar_mappings( - indexer, - &starting_indexes, - prev_height, - exit, - )?; + let starting_day1 = + self.compute_calendar_mappings(indexer, &starting_indexes, prev_height, exit)?; - self.compute_period_vecs( - indexer, - &starting_indexes, - prev_height, - starting_day1, - exit, - )?; + self.compute_period_vecs(indexer, &starting_indexes, prev_height, starting_day1, exit)?; self.timestamp.compute_per_resolution( indexer, diff --git a/crates/brk_computer/src/indicators/compute.rs b/crates/brk_computer/src/indicators/compute.rs index a4015fdc3..fead9d4a0 100644 --- a/crates/brk_computer/src/indicators/compute.rs +++ b/crates/brk_computer/src/indicators/compute.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_types::{Bitcoin, Dollars, Indexes, StoredF32}; use vecdb::Exit; -use super::{gini, Vecs}; +use super::{Vecs, gini}; use crate::{distribution, internal::RatioDollarsBp32, market, mining, transactions}; impl Vecs { @@ -126,22 +126,20 @@ impl Vecs { )?; // Supply-Adjusted Dormancy = dormancy / circulating_supply_btc - self.dormancy.supply_adjusted - .height - .compute_transform2( - starting_indexes.height, - &all_activity.dormancy._24h.height, - supply_total_sats, - |(i, dormancy, supply_sats, ..)| { - let supply = f64::from(Bitcoin::from(supply_sats)); - if supply == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((f64::from(dormancy) / supply) as f32)) - } - }, - exit, - )?; + self.dormancy.supply_adjusted.height.compute_transform2( + starting_indexes.height, + &all_activity.dormancy._24h.height, + supply_total_sats, + |(i, dormancy, supply_sats, ..)| { + let supply = f64::from(Bitcoin::from(supply_sats)); + if supply == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from((f64::from(dormancy) / supply) as f32)) + } + }, + exit, + )?; // Stock-to-Flow: supply / annual_issuance // annual_issuance ≈ subsidy_per_block × 52560 (blocks/year) @@ -154,9 +152,10 @@ impl Vecs { if annual_flow == 0.0 { (i, StoredF32::from(0.0f32)) } else { - (i, StoredF32::from( - (supply_sats.as_u128() as f64 / annual_flow) as f32, - )) + ( + i, + StoredF32::from((supply_sats.as_u128() as f64 / annual_flow) as f32), + ) } }, exit, @@ -180,26 +179,25 @@ impl Vecs { )?; // Seller Exhaustion Constant: % supply_in_profit × 30d_volatility - self.seller_exhaustion - .height - .compute_transform3( - starting_indexes.height, - &all_metrics.supply.in_profit.sats.height, - &market.volatility._1m.height, - supply_total_sats, - |(i, profit_sats, volatility, total_sats, ..)| { - let total = total_sats.as_u128() as f64; - if total == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - let pct_in_profit = profit_sats.as_u128() as f64 / total; - (i, StoredF32::from( - (pct_in_profit * f64::from(volatility)) as f32, - )) - } - }, - exit, - )?; + self.seller_exhaustion.height.compute_transform3( + starting_indexes.height, + &all_metrics.supply.in_profit.sats.height, + &market.volatility._1m.height, + supply_total_sats, + |(i, profit_sats, volatility, total_sats, ..)| { + let total = total_sats.as_u128() as f64; + if total == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + let pct_in_profit = profit_sats.as_u128() as f64 / total; + ( + i, + StoredF32::from((pct_in_profit * f64::from(volatility)) as f32), + ) + } + }, + exit, + )?; let exit = exit.clone(); self.db.run_bg(move |db| { diff --git a/crates/brk_computer/src/indicators/import.rs b/crates/brk_computer/src/indicators/import.rs index eb6a61d2e..f8351945f 100644 --- a/crates/brk_computer/src/indicators/import.rs +++ b/crates/brk_computer/src/indicators/import.rs @@ -6,7 +6,10 @@ use brk_types::Version; use super::{Vecs, realized_envelope::RealizedEnvelope}; use crate::{ indexes, - internal::{PerBlock, PercentPerBlock, RatioPerBlock, db_utils::{finalize_db, open_db}}, + internal::{ + PerBlock, PercentPerBlock, RatioPerBlock, + db_utils::{finalize_db, open_db}, + }, }; const VERSION: Version = Version::new(1); @@ -35,8 +38,7 @@ impl Vecs { flow: PerBlock::forced_import(&db, "dormancy_flow", v, indexes)?, }; let stock_to_flow = PerBlock::forced_import(&db, "stock_to_flow", v, indexes)?; - let seller_exhaustion = - PerBlock::forced_import(&db, "seller_exhaustion", v, indexes)?; + let seller_exhaustion = PerBlock::forced_import(&db, "seller_exhaustion", v, indexes)?; let realized_envelope = RealizedEnvelope::forced_import(&db, v, indexes)?; diff --git a/crates/brk_computer/src/indicators/realized_envelope.rs b/crates/brk_computer/src/indicators/realized_envelope.rs index 16feec9d7..f496123f2 100644 --- a/crates/brk_computer/src/indicators/realized_envelope.rs +++ b/crates/brk_computer/src/indicators/realized_envelope.rs @@ -4,9 +4,7 @@ use brk_types::{Cents, Height, Indexes, StoredI8, Version}; use vecdb::{AnyVec, Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{ - cointime, - distribution, - indexes, + cointime, distribution, indexes, internal::{PerBlock, Price, RatioPerBlockPercentiles}, prices, }; @@ -82,16 +80,48 @@ impl RealizedEnvelope { } // Lower percentiles: max across all models (tightest lower bound) - self.pct0_5.cents.height.compute_max_of_others(starting_indexes.height, &sources!(pct0_5), exit)?; - self.pct1.cents.height.compute_max_of_others(starting_indexes.height, &sources!(pct1), exit)?; - self.pct2.cents.height.compute_max_of_others(starting_indexes.height, &sources!(pct2), exit)?; - self.pct5.cents.height.compute_max_of_others(starting_indexes.height, &sources!(pct5), exit)?; + self.pct0_5.cents.height.compute_max_of_others( + starting_indexes.height, + &sources!(pct0_5), + exit, + )?; + self.pct1.cents.height.compute_max_of_others( + starting_indexes.height, + &sources!(pct1), + exit, + )?; + self.pct2.cents.height.compute_max_of_others( + starting_indexes.height, + &sources!(pct2), + exit, + )?; + self.pct5.cents.height.compute_max_of_others( + starting_indexes.height, + &sources!(pct5), + exit, + )?; // Upper percentiles: min across all models (tightest upper bound) - self.pct95.cents.height.compute_min_of_others(starting_indexes.height, &sources!(pct95), exit)?; - self.pct98.cents.height.compute_min_of_others(starting_indexes.height, &sources!(pct98), exit)?; - self.pct99.cents.height.compute_min_of_others(starting_indexes.height, &sources!(pct99), exit)?; - self.pct99_5.cents.height.compute_min_of_others(starting_indexes.height, &sources!(pct99_5), exit)?; + self.pct95.cents.height.compute_min_of_others( + starting_indexes.height, + &sources!(pct95), + exit, + )?; + self.pct98.cents.height.compute_min_of_others( + starting_indexes.height, + &sources!(pct98), + exit, + )?; + self.pct99.cents.height.compute_min_of_others( + starting_indexes.height, + &sources!(pct99), + exit, + )?; + self.pct99_5.cents.height.compute_min_of_others( + starting_indexes.height, + &sources!(pct99_5), + exit, + )?; let spot = &prices.spot.cents.height; @@ -121,10 +151,15 @@ impl RealizedEnvelope { &self.pct99_5.cents.height, ]; - let dep_version: Version = bands.iter().map(|b| b.version()).sum::() + spot.version(); + let dep_version: Version = + bands.iter().map(|b| b.version()).sum::() + spot.version(); - self.index.height.validate_computed_version_or_reset(dep_version)?; - self.index.height.truncate_if_needed(starting_indexes.height)?; + self.index + .height + .validate_computed_version_or_reset(dep_version)?; + self.index + .height + .truncate_if_needed(starting_indexes.height)?; self.index.height.repeat_until_complete(exit, |vec| { let skip = vec.len(); @@ -142,14 +177,30 @@ impl RealizedEnvelope { let price = spot_batch[j]; let mut score: i8 = 0; - if price < b[3][j] { score -= 1; } - if price < b[2][j] { score -= 1; } - if price < b[1][j] { score -= 1; } - if price < b[0][j] { score -= 1; } - if price > b[4][j] { score += 1; } - if price > b[5][j] { score += 1; } - if price > b[6][j] { score += 1; } - if price > b[7][j] { score += 1; } + if price < b[3][j] { + score -= 1; + } + if price < b[2][j] { + score -= 1; + } + if price < b[1][j] { + score -= 1; + } + if price < b[0][j] { + score -= 1; + } + if price > b[4][j] { + score += 1; + } + if price > b[5][j] { + score += 1; + } + if price > b[6][j] { + score += 1; + } + if price > b[7][j] { + score += 1; + } vec.push(StoredI8::new(score)); } @@ -182,8 +233,12 @@ impl RealizedEnvelope { .sum::() + spot.version(); - self.score.height.validate_computed_version_or_reset(dep_version)?; - self.score.height.truncate_if_needed(starting_indexes.height)?; + self.score + .height + .validate_computed_version_or_reset(dep_version)?; + self.score + .height + .truncate_if_needed(starting_indexes.height)?; self.score.height.repeat_until_complete(exit, |vec| { let skip = vec.len(); @@ -233,14 +288,30 @@ impl RealizedEnvelope { let mut total: i8 = 0; for model in &bands { - if price < model[3][j] { total -= 1; } - if price < model[2][j] { total -= 1; } - if price < model[1][j] { total -= 1; } - if price < model[0][j] { total -= 1; } - if price > model[4][j] { total += 1; } - if price > model[5][j] { total += 1; } - if price > model[6][j] { total += 1; } - if price > model[7][j] { total += 1; } + if price < model[3][j] { + total -= 1; + } + if price < model[2][j] { + total -= 1; + } + if price < model[1][j] { + total -= 1; + } + if price < model[0][j] { + total -= 1; + } + if price > model[4][j] { + total += 1; + } + if price > model[5][j] { + total += 1; + } + if price > model[6][j] { + total += 1; + } + if price > model[7][j] { + total += 1; + } } vec.push(StoredI8::new(total)); diff --git a/crates/brk_computer/src/inputs/compute.rs b/crates/brk_computer/src/inputs/compute.rs index 7a33c119d..d0b7cc7f1 100644 --- a/crates/brk_computer/src/inputs/compute.rs +++ b/crates/brk_computer/src/inputs/compute.rs @@ -17,8 +17,7 @@ impl Vecs { ) -> Result<()> { self.db.sync_bg_tasks()?; - self.spent - .compute(indexer, starting_indexes, exit)?; + self.spent.compute(indexer, starting_indexes, exit)?; self.count .compute(indexer, indexes, blocks, starting_indexes, exit)?; diff --git a/crates/brk_computer/src/inputs/count/import.rs b/crates/brk_computer/src/inputs/count/import.rs index 2c07ff34e..b1e93868e 100644 --- a/crates/brk_computer/src/inputs/count/import.rs +++ b/crates/brk_computer/src/inputs/count/import.rs @@ -3,7 +3,10 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::{CachedWindowStarts, PerBlockAggregated}}; +use crate::{ + indexes, + internal::{CachedWindowStarts, PerBlockAggregated}, +}; impl Vecs { pub(crate) fn forced_import( diff --git a/crates/brk_computer/src/inputs/count/vecs.rs b/crates/brk_computer/src/inputs/count/vecs.rs index 8adf0e565..c27eb666c 100644 --- a/crates/brk_computer/src/inputs/count/vecs.rs +++ b/crates/brk_computer/src/inputs/count/vecs.rs @@ -7,6 +7,4 @@ use vecdb::{Rw, StorageMode}; use crate::internal::PerBlockAggregated; #[derive(Deref, DerefMut, Traversable)] -pub struct Vecs( - #[traversable(flatten)] pub PerBlockAggregated, -); +pub struct Vecs(#[traversable(flatten)] pub PerBlockAggregated); diff --git a/crates/brk_computer/src/inputs/import.rs b/crates/brk_computer/src/inputs/import.rs index 372604334..9b42342aa 100644 --- a/crates/brk_computer/src/inputs/import.rs +++ b/crates/brk_computer/src/inputs/import.rs @@ -5,7 +5,10 @@ use brk_types::Version; use crate::{ indexes, - internal::{CachedWindowStarts, db_utils::{finalize_db, open_db}}, + internal::{ + CachedWindowStarts, + db_utils::{finalize_db, open_db}, + }, }; use super::{CountVecs, SpentVecs, Vecs}; diff --git a/crates/brk_computer/src/internal/algo/expanding_percentiles.rs b/crates/brk_computer/src/internal/algo/expanding_percentiles.rs index eec37544d..a5b4b441c 100644 --- a/crates/brk_computer/src/internal/algo/expanding_percentiles.rs +++ b/crates/brk_computer/src/internal/algo/expanding_percentiles.rs @@ -146,5 +146,4 @@ mod tests { assert_eq!(ep.count(), 0); assert_eq!(quantile(&ep, 0.5), 0); } - } diff --git a/crates/brk_computer/src/internal/algo/sliding_distribution.rs b/crates/brk_computer/src/internal/algo/sliding_distribution.rs index f6131377b..7f25230f8 100644 --- a/crates/brk_computer/src/internal/algo/sliding_distribution.rs +++ b/crates/brk_computer/src/internal/algo/sliding_distribution.rs @@ -137,8 +137,7 @@ where } else { min_out.push(T::from(window.min())); max_out.push(T::from(window.max())); - let [p10, p25, p50, p75, p90] = - window.percentiles(&[0.10, 0.25, 0.50, 0.75, 0.90]); + let [p10, p25, p50, p75, p90] = window.percentiles(&[0.10, 0.25, 0.50, 0.75, 0.90]); p10_out.push(T::from(p10)); p25_out.push(T::from(p25)); median_out.push(T::from(p50)); @@ -165,13 +164,7 @@ where // Final flush let _lock = exit.lock(); for v in [ - min_out, - max_out, - p10_out, - p25_out, - median_out, - p75_out, - p90_out, + min_out, max_out, p10_out, p25_out, median_out, p75_out, p90_out, ] { v.write()?; } diff --git a/crates/brk_computer/src/internal/containers/constant.rs b/crates/brk_computer/src/internal/containers/constant.rs index 2c52f9bff..28d1d4761 100644 --- a/crates/brk_computer/src/internal/containers/constant.rs +++ b/crates/brk_computer/src/internal/containers/constant.rs @@ -1,7 +1,7 @@ use brk_traversable::Traversable; use brk_types::{ - Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, - Month1, Month3, Month6, Version, Week1, Year1, Year10, + Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, + Month6, Version, Week1, Year1, Year10, }; use schemars::JsonSchema; use serde::Serialize; diff --git a/crates/brk_computer/src/internal/containers/distribution_stats.rs b/crates/brk_computer/src/internal/containers/distribution_stats.rs index 3877a5d12..b41856c77 100644 --- a/crates/brk_computer/src/internal/containers/distribution_stats.rs +++ b/crates/brk_computer/src/internal/containers/distribution_stats.rs @@ -12,9 +12,8 @@ pub struct DistributionStats { } impl DistributionStats { - pub const SUFFIXES: [&'static str; 7] = [ - "min", "max", "pct10", "pct25", "median", "pct75", "pct90", - ]; + pub const SUFFIXES: [&'static str; 7] = + ["min", "max", "pct10", "pct25", "median", "pct75", "pct90"]; pub fn try_from_fn( mut f: impl FnMut(&str) -> std::result::Result, diff --git a/crates/brk_computer/src/internal/containers/mod.rs b/crates/brk_computer/src/internal/containers/mod.rs index 6da8e451b..91e0aa0b6 100644 --- a/crates/brk_computer/src/internal/containers/mod.rs +++ b/crates/brk_computer/src/internal/containers/mod.rs @@ -1,16 +1,16 @@ mod constant; mod distribution_stats; mod per_resolution; +mod percent; mod window_24h; mod windows; mod windows_from_1w; -mod percent; mod windows_to_1m; pub use constant::*; pub use distribution_stats::*; -pub use percent::*; pub use per_resolution::*; +pub use percent::*; pub use window_24h::*; pub use windows::*; pub use windows_from_1w::*; diff --git a/crates/brk_computer/src/internal/indexes/eager.rs b/crates/brk_computer/src/internal/indexes/eager.rs index 453fb06b4..eb449faa8 100644 --- a/crates/brk_computer/src/internal/indexes/eager.rs +++ b/crates/brk_computer/src/internal/indexes/eager.rs @@ -2,8 +2,8 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Indexes, Minute10, - Minute30, Month1, Month3, Month6, Version, Week1, Year1, Year10, + Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Indexes, Minute10, Minute30, Month1, + Month3, Month6, Version, Week1, Year1, Year10, }; use derive_more::{Deref, DerefMut}; use schemars::JsonSchema; diff --git a/crates/brk_computer/src/internal/indexes/lazy.rs b/crates/brk_computer/src/internal/indexes/lazy.rs index 15db3380d..8cda9dea9 100644 --- a/crates/brk_computer/src/internal/indexes/lazy.rs +++ b/crates/brk_computer/src/internal/indexes/lazy.rs @@ -1,7 +1,7 @@ use brk_traversable::Traversable; use brk_types::{ - Day1, Day3, Epoch, Halving, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, - Month3, Month6, Version, Week1, Year1, Year10, + Day1, Day3, Epoch, Halving, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, Month6, + Version, Week1, Year1, Year10, }; use derive_more::{Deref, DerefMut}; use schemars::JsonSchema; diff --git a/crates/brk_computer/src/internal/mod.rs b/crates/brk_computer/src/internal/mod.rs index e4b3fea3b..69195fb84 100644 --- a/crates/brk_computer/src/internal/mod.rs +++ b/crates/brk_computer/src/internal/mod.rs @@ -3,17 +3,17 @@ mod amount; mod cache_budget; mod containers; pub(crate) mod db_utils; +mod indexes; mod per_block; mod per_tx; -mod indexes; mod traits; mod transform; pub(crate) use amount::*; pub(crate) use cache_budget::*; pub(crate) use containers::*; +pub(crate) use indexes::*; pub(crate) use per_block::*; pub(crate) use per_tx::*; -pub(crate) use indexes::*; pub(crate) use traits::*; pub use transform::*; diff --git a/crates/brk_computer/src/internal/per_block/amount/base.rs b/crates/brk_computer/src/internal/per_block/amount/base.rs index c3baa2f29..3b2067882 100644 --- a/crates/brk_computer/src/internal/per_block/amount/base.rs +++ b/crates/brk_computer/src/internal/per_block/amount/base.rs @@ -5,9 +5,7 @@ use vecdb::{Database, Exit, ReadableCloneableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{ - CentsUnsignedToDollars, PerBlock, LazyPerBlock, SatsToBitcoin, SatsToCents, - }, + internal::{CentsUnsignedToDollars, LazyPerBlock, PerBlock, SatsToBitcoin, SatsToCents}, prices, }; @@ -26,8 +24,7 @@ impl AmountPerBlock { version: Version, indexes: &indexes::Vecs, ) -> Result { - let sats = - PerBlock::forced_import(db, &format!("{name}_sats"), version, indexes)?; + let sats = PerBlock::forced_import(db, &format!("{name}_sats"), version, indexes)?; let btc = LazyPerBlock::from_computed::( name, @@ -36,8 +33,7 @@ impl AmountPerBlock { &sats, ); - let cents = - PerBlock::forced_import(db, &format!("{name}_cents"), version, indexes)?; + let cents = PerBlock::forced_import(db, &format!("{name}_cents"), version, indexes)?; let usd = LazyPerBlock::from_computed::( &format!("{name}_usd"), @@ -68,6 +64,4 @@ impl AmountPerBlock { )?; Ok(()) } - } - diff --git a/crates/brk_computer/src/internal/per_block/amount/block.rs b/crates/brk_computer/src/internal/per_block/amount/block.rs index 744c673a9..e7897bb1c 100644 --- a/crates/brk_computer/src/internal/per_block/amount/block.rs +++ b/crates/brk_computer/src/internal/per_block/amount/block.rs @@ -1,7 +1,10 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, Version}; -use vecdb::{Database, EagerVec, Exit, ImportableVec, LazyVecFrom1, PcoVec, ReadableCloneableVec, Rw, StorageMode}; +use vecdb::{ + Database, EagerVec, Exit, ImportableVec, LazyVecFrom1, PcoVec, ReadableCloneableVec, Rw, + StorageMode, +}; use crate::{ internal::{CentsUnsignedToDollars, SatsToBitcoin, SatsToCents}, @@ -21,11 +24,8 @@ impl AmountBlock { pub(crate) fn forced_import(db: &Database, name: &str, version: Version) -> Result { let sats: EagerVec> = EagerVec::forced_import(db, &format!("{name}_sats"), version)?; - let btc = LazyVecFrom1::transformed::( - name, - version, - sats.read_only_boxed_clone(), - ); + let btc = + LazyVecFrom1::transformed::(name, version, sats.read_only_boxed_clone()); let cents: EagerVec> = EagerVec::forced_import(db, &format!("{name}_cents"), version)?; let usd = LazyVecFrom1::transformed::( @@ -33,7 +33,12 @@ impl AmountBlock { version, cents.read_only_boxed_clone(), ); - Ok(Self { btc, sats, usd, cents }) + Ok(Self { + btc, + sats, + usd, + cents, + }) } pub(crate) fn compute_cents( diff --git a/crates/brk_computer/src/internal/per_block/amount/full.rs b/crates/brk_computer/src/internal/per_block/amount/full.rs index caf65b489..7d40c5538 100644 --- a/crates/brk_computer/src/internal/per_block/amount/full.rs +++ b/crates/brk_computer/src/internal/per_block/amount/full.rs @@ -37,8 +37,7 @@ impl AmountPerBlockFull { let inner = AmountPerBlockCumulativeRolling::forced_import(db, name, v, indexes, cached_starts)?; - let distribution = - RollingDistributionAmountPerBlock::forced_import(db, name, v, indexes)?; + let distribution = RollingDistributionAmountPerBlock::forced_import(db, name, v, indexes)?; Ok(Self { inner, diff --git a/crates/brk_computer/src/internal/per_block/amount/lazy.rs b/crates/brk_computer/src/internal/per_block/amount/lazy.rs index 484954977..92cea30fb 100644 --- a/crates/brk_computer/src/internal/per_block/amount/lazy.rs +++ b/crates/brk_computer/src/internal/per_block/amount/lazy.rs @@ -5,7 +5,9 @@ use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, Version}; use derive_more::{Deref, DerefMut}; use vecdb::UnaryTransform; -use crate::internal::{AmountPerBlock, Identity, LazyAmount, LazyAmountDerivedResolutions, SatsToBitcoin}; +use crate::internal::{ + AmountPerBlock, Identity, LazyAmount, LazyAmountDerivedResolutions, SatsToBitcoin, +}; /// Lazy value wrapper with height + all derived last transforms from AmountPerBlock. #[derive(Clone, Deref, DerefMut, Traversable)] diff --git a/crates/brk_computer/src/internal/per_block/computed/base.rs b/crates/brk_computer/src/internal/per_block/computed/base.rs index 4bced8a58..a0b8419a0 100644 --- a/crates/brk_computer/src/internal/per_block/computed/base.rs +++ b/crates/brk_computer/src/internal/per_block/computed/base.rs @@ -11,7 +11,7 @@ use vecdb::{ use crate::indexes; -use crate::internal::{Resolutions, ComputedVecValue, NumericValue}; +use crate::internal::{ComputedVecValue, NumericValue, Resolutions}; #[derive(Deref, DerefMut, Traversable)] #[traversable(merge)] @@ -38,12 +38,8 @@ where ) -> Result { let height: EagerVec> = EagerVec::forced_import(db, name, version)?; - let resolutions = Resolutions::forced_import( - name, - height.read_only_boxed_clone(), - version, - indexes, - ); + let resolutions = + Resolutions::forced_import(name, height.read_only_boxed_clone(), version, indexes); Ok(Self { height, diff --git a/crates/brk_computer/src/internal/per_block/computed/distribution.rs b/crates/brk_computer/src/internal/per_block/computed/distribution.rs index 643aa4ca4..aa075df69 100644 --- a/crates/brk_computer/src/internal/per_block/computed/distribution.rs +++ b/crates/brk_computer/src/internal/per_block/computed/distribution.rs @@ -63,8 +63,7 @@ impl PerBlockDistribution { let pct75 = &mut pct75.height; let pct90 = &mut pct90.height; - let combined_version = - source.version() + first_indexes.version() + count_indexes.version(); + let combined_version = source.version() + first_indexes.version() + count_indexes.version(); let mut index = max_from; for vec in [ @@ -182,8 +181,7 @@ impl PerBlockDistribution { let pct75 = &mut pct75.height; let pct90 = &mut pct90.height; - let combined_version = - source.version() + first_indexes.version() + count_indexes.version(); + let combined_version = source.version() + first_indexes.version() + count_indexes.version(); let mut index = max_from; for vec in [ diff --git a/crates/brk_computer/src/internal/per_block/computed/lazy_distribution.rs b/crates/brk_computer/src/internal/per_block/computed/lazy_distribution.rs index 3491ab9fb..e21d6957b 100644 --- a/crates/brk_computer/src/internal/per_block/computed/lazy_distribution.rs +++ b/crates/brk_computer/src/internal/per_block/computed/lazy_distribution.rs @@ -3,7 +3,7 @@ use brk_types::{Height, Version}; use schemars::JsonSchema; use vecdb::{LazyVecFrom1, ReadableCloneableVec, UnaryTransform, VecIndex}; -use crate::internal::{ComputedVecValue, PerBlockDistribution, DistributionStats}; +use crate::internal::{ComputedVecValue, DistributionStats, PerBlockDistribution}; /// Lazy analog of `Distribution`: 7 `LazyVecFrom1` fields, /// each derived by transforming the corresponding field of a source `PerBlockDistribution`. diff --git a/crates/brk_computer/src/internal/per_block/computed/lazy_rolling.rs b/crates/brk_computer/src/internal/per_block/computed/lazy_rolling.rs index fac2d6bdf..0864a94d5 100644 --- a/crates/brk_computer/src/internal/per_block/computed/lazy_rolling.rs +++ b/crates/brk_computer/src/internal/per_block/computed/lazy_rolling.rs @@ -6,8 +6,8 @@ use vecdb::{ReadableCloneableVec, UnaryTransform}; use crate::{ indexes, internal::{ - CachedWindowStarts, PerBlockFull, ComputedVecValue, LazyPerBlock, LazyRollingComplete, - NumericValue, + CachedWindowStarts, ComputedVecValue, LazyPerBlock, LazyRollingComplete, NumericValue, + PerBlockFull, }, }; diff --git a/crates/brk_computer/src/internal/per_block/computed/rolling.rs b/crates/brk_computer/src/internal/per_block/computed/rolling.rs index b751a6afd..2a1d0d894 100644 --- a/crates/brk_computer/src/internal/per_block/computed/rolling.rs +++ b/crates/brk_computer/src/internal/per_block/computed/rolling.rs @@ -11,7 +11,7 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{CachedWindowStarts, PerBlock, NumericValue, RollingComplete, WindowStarts}, + internal::{CachedWindowStarts, NumericValue, PerBlock, RollingComplete, WindowStarts}, }; #[derive(Traversable)] diff --git a/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs b/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs index 7c8a96336..50a874cc0 100644 --- a/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs +++ b/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs @@ -7,9 +7,7 @@ use vecdb::{Rw, StorageMode}; use crate::{ indexes, - internal::{ - BpsType, CachedWindowStarts, PerBlock, LazyRollingDeltasFromHeight, NumericValue, - }, + internal::{BpsType, CachedWindowStarts, LazyRollingDeltasFromHeight, NumericValue, PerBlock}, }; #[derive(Deref, DerefMut, Traversable)] diff --git a/crates/brk_computer/src/internal/per_block/fiat/base.rs b/crates/brk_computer/src/internal/per_block/fiat/base.rs index 471b6d839..c14d1b225 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/base.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/base.rs @@ -7,8 +7,7 @@ use vecdb::{Database, ReadableCloneableVec, Rw, StorageMode, UnaryTransform}; use crate::{ indexes, internal::{ - CentsSignedToDollars, CentsUnsignedToDollars, PerBlock, LazyPerBlock, - NumericValue, + CentsSignedToDollars, CentsUnsignedToDollars, LazyPerBlock, NumericValue, PerBlock, }, }; @@ -40,8 +39,7 @@ impl FiatPerBlock { version: Version, indexes: &indexes::Vecs, ) -> Result { - let cents = - PerBlock::forced_import(db, &format!("{name}_cents"), version, indexes)?; + let cents = PerBlock::forced_import(db, &format!("{name}_cents"), version, indexes)?; let usd = LazyPerBlock::from_computed::( name, version, diff --git a/crates/brk_computer/src/internal/per_block/fiat/block.rs b/crates/brk_computer/src/internal/per_block/fiat/block.rs index 419c9acdf..6b8913ae6 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/block.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/block.rs @@ -1,7 +1,9 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Dollars, Height, Version}; -use vecdb::{Database, EagerVec, ImportableVec, LazyVecFrom1, PcoVec, ReadableCloneableVec, Rw, StorageMode}; +use vecdb::{ + Database, EagerVec, ImportableVec, LazyVecFrom1, PcoVec, ReadableCloneableVec, Rw, StorageMode, +}; use super::CentsType; @@ -16,11 +18,8 @@ impl FiatBlock { pub(crate) fn forced_import(db: &Database, name: &str, version: Version) -> Result { let cents: EagerVec> = EagerVec::forced_import(db, &format!("{name}_cents"), version)?; - let usd = LazyVecFrom1::transformed::( - name, - version, - cents.read_only_boxed_clone(), - ); + let usd = + LazyVecFrom1::transformed::(name, version, cents.read_only_boxed_clone()); Ok(Self { usd, cents }) } } diff --git a/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum.rs b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum.rs index 02900c570..c2e3c416c 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum.rs @@ -5,7 +5,9 @@ use vecdb::{Database, Exit, Rw, StorageMode}; use crate::{ indexes, - internal::{CachedWindowStarts, CentsType, FiatBlock, FiatPerBlock, LazyRollingSumsFiatFromHeight}, + internal::{ + CachedWindowStarts, CentsType, FiatBlock, FiatPerBlock, LazyRollingSumsFiatFromHeight, + }, }; #[derive(Traversable)] @@ -24,12 +26,8 @@ impl FiatPerBlockCumulativeWithSums { cached_starts: &CachedWindowStarts, ) -> Result { let block = FiatBlock::forced_import(db, name, version)?; - let cumulative = FiatPerBlock::forced_import( - db, - &format!("{name}_cumulative"), - version, - indexes, - )?; + let cumulative = + FiatPerBlock::forced_import(db, &format!("{name}_cumulative"), version, indexes)?; let sum = LazyRollingSumsFiatFromHeight::new( &format!("{name}_sum"), version, @@ -37,7 +35,11 @@ impl FiatPerBlockCumulativeWithSums { cached_starts, indexes, ); - Ok(Self { block, cumulative, sum }) + Ok(Self { + block, + cumulative, + sum, + }) } pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> diff --git a/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs index 31cd8de11..fff0aac64 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs @@ -39,8 +39,13 @@ where indexes: &indexes::Vecs, cached_starts: &CachedWindowStarts, ) -> Result { - let inner = - FiatPerBlockCumulativeWithSums::forced_import(db, name, version, indexes, cached_starts)?; + let inner = FiatPerBlockCumulativeWithSums::forced_import( + db, + name, + version, + indexes, + cached_starts, + )?; let delta = LazyRollingDeltasFiatFromHeight::new( &format!("{name}_delta"), diff --git a/crates/brk_computer/src/internal/per_block/fiat/lazy.rs b/crates/brk_computer/src/internal/per_block/fiat/lazy.rs index d9f815054..f3e9ca639 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/lazy.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/lazy.rs @@ -2,7 +2,7 @@ use brk_traversable::Traversable; use brk_types::{Dollars, Version}; use vecdb::ReadableCloneableVec; -use crate::internal::{CentsType, PerBlock, Identity, LazyPerBlock, NumericValue}; +use crate::internal::{CentsType, Identity, LazyPerBlock, NumericValue, PerBlock}; /// Lazy fiat: both cents and usd are lazy views of a stored source. /// Zero extra stored vecs. @@ -13,11 +13,7 @@ pub struct LazyFiatPerBlock { } impl LazyFiatPerBlock { - pub(crate) fn from_computed( - name: &str, - version: Version, - source: &PerBlock, - ) -> Self + pub(crate) fn from_computed(name: &str, version: Version, source: &PerBlock) -> Self where C: NumericValue, { diff --git a/crates/brk_computer/src/internal/per_block/lazy/derived_resolutions.rs b/crates/brk_computer/src/internal/per_block/lazy/derived_resolutions.rs index 19f9b5174..fedf327a8 100644 --- a/crates/brk_computer/src/internal/per_block/lazy/derived_resolutions.rs +++ b/crates/brk_computer/src/internal/per_block/lazy/derived_resolutions.rs @@ -1,7 +1,7 @@ use brk_traversable::Traversable; use brk_types::{ - Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, - Month1, Month3, Month6, Version, Week1, Year1, Year10, + Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, + Month6, Version, Week1, Year1, Year10, }; use derive_more::{Deref, DerefMut}; use schemars::JsonSchema; @@ -9,9 +9,7 @@ use vecdb::{ReadableBoxedVec, ReadableCloneableVec, UnaryTransform, VecValue}; use crate::{ indexes, - internal::{ - PerBlock, Resolutions, ComputedVecValue, NumericValue, PerResolution, - }, + internal::{ComputedVecValue, NumericValue, PerBlock, PerResolution, Resolutions}, }; use super::{LazyTransformLast, MapOption}; diff --git a/crates/brk_computer/src/internal/per_block/percent/lazy.rs b/crates/brk_computer/src/internal/per_block/percent/lazy.rs index a37fb3a6d..c567dd637 100644 --- a/crates/brk_computer/src/internal/per_block/percent/lazy.rs +++ b/crates/brk_computer/src/internal/per_block/percent/lazy.rs @@ -29,11 +29,8 @@ impl LazyPercentPerBlock { &source.bps, ); - let ratio = LazyPerBlock::from_lazy::( - &format!("{name}_ratio"), - version, - &bps, - ); + let ratio = + LazyPerBlock::from_lazy::(&format!("{name}_ratio"), version, &bps); let percent = LazyPerBlock::from_lazy::(name, version, &bps); diff --git a/crates/brk_computer/src/internal/per_block/ratio/base.rs b/crates/brk_computer/src/internal/per_block/ratio/base.rs index cf4385275..b1f1fe61f 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/base.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/base.rs @@ -5,7 +5,7 @@ use vecdb::{Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{BpsType, PerBlock, LazyPerBlock}, + internal::{BpsType, LazyPerBlock, PerBlock}, }; #[derive(Traversable)] diff --git a/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs b/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs index 98e638025..cd1ca1145 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs @@ -148,7 +148,8 @@ impl RatioPerBlockPercentiles { { let _lock = exit.lock(); - self.mut_pct_vecs().try_for_each(|v| v.write().map(|_| ()))?; + self.mut_pct_vecs() + .try_for_each(|v| v.write().map(|_| ()))?; } // Cents bands diff --git a/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs b/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs index d32c590de..13fe4a799 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs @@ -4,7 +4,7 @@ use brk_types::{BasisPoints32, Cents, Dollars, Height, Indexes, SatsFract, Store use derive_more::{Deref, DerefMut}; use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode}; -use crate::internal::{PerBlock, LazyPerBlock, Price}; +use crate::internal::{LazyPerBlock, PerBlock, Price}; use crate::{indexes, prices}; use super::{RatioPerBlock, RatioPerBlockPercentiles}; @@ -105,7 +105,8 @@ impl PriceWithRatioExtendedPerBlock { exit: &Exit, ) -> Result<()> { let close_price = &prices.spot.cents.height; - self.base.compute_ratio(starting_indexes, close_price, exit)?; + self.base + .compute_ratio(starting_indexes, close_price, exit)?; self.percentiles.compute( starting_indexes, exit, diff --git a/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs b/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs index dc198ac13..cc340fc88 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs @@ -28,14 +28,7 @@ impl RatioPerBlockStdDevBands { macro_rules! import_sd { ($period:expr, $days:expr) => { - StdDevPerBlockExtended::forced_import( - db, - name, - $period, - $days, - v, - indexes, - )? + StdDevPerBlockExtended::forced_import(db, name, $period, $days, v, indexes)? }; } diff --git a/crates/brk_computer/src/internal/per_block/ratio/windows.rs b/crates/brk_computer/src/internal/per_block/ratio/windows.rs index 170904b84..63bc6493c 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/windows.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/windows.rs @@ -13,9 +13,7 @@ use crate::{ /// with a lazy ratio float view. #[derive(Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct RatioRollingWindows( - pub Windows>, -); +pub struct RatioRollingWindows(pub Windows>); impl RatioRollingWindows { pub(crate) fn forced_import( @@ -50,7 +48,9 @@ impl RatioRollingWindows { .zip(sources1) .zip(sources2) { - target.bps.compute_binary::(max_from, s1, s2, exit)?; + target + .bps + .compute_binary::(max_from, s1, s2, exit)?; } Ok(()) } diff --git a/crates/brk_computer/src/internal/per_block/rolling/complete.rs b/crates/brk_computer/src/internal/per_block/rolling/complete.rs index 25d82b7d9..2d4d7f783 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/complete.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/complete.rs @@ -10,7 +10,7 @@ use vecdb::{Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; use crate::{ indexes, internal::{ - CachedWindowStarts, NumericValue, LazyRollingAvgsFromHeight, LazyRollingSumsFromHeight, + CachedWindowStarts, LazyRollingAvgsFromHeight, LazyRollingSumsFromHeight, NumericValue, RollingDistribution, WindowStarts, }, }; diff --git a/crates/brk_computer/src/internal/per_block/rolling/lazy_complete.rs b/crates/brk_computer/src/internal/per_block/rolling/lazy_complete.rs index f7e6b11a7..52a3b0919 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/lazy_complete.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/lazy_complete.rs @@ -6,8 +6,8 @@ use vecdb::{ReadableCloneableVec, UnaryTransform}; use crate::{ indexes, internal::{ - CachedWindowStarts, ComputedVecValue, LazyRollingAvgsFromHeight, - LazyRollingDistribution, LazyRollingSumsFromHeight, NumericValue, RollingComplete, + CachedWindowStarts, ComputedVecValue, LazyRollingAvgsFromHeight, LazyRollingDistribution, + LazyRollingSumsFromHeight, NumericValue, RollingComplete, }, }; diff --git a/crates/brk_computer/src/internal/per_block/rolling/mod.rs b/crates/brk_computer/src/internal/per_block/rolling/mod.rs index 3e991db44..1bc408997 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/mod.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/mod.rs @@ -1,8 +1,8 @@ mod avg; mod avgs; +mod complete; mod delta; mod distribution; -mod complete; mod lazy_complete; mod lazy_distribution; mod sum; @@ -11,9 +11,9 @@ mod windows; pub use avg::*; pub use avgs::*; +pub use complete::*; pub use delta::*; pub use distribution::*; -pub use complete::*; pub use lazy_complete::*; pub use lazy_distribution::*; pub use sum::*; diff --git a/crates/brk_computer/src/internal/per_block/rolling/windows.rs b/crates/brk_computer/src/internal/per_block/rolling/windows.rs index b9d8b4af8..b0f7a6942 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/windows.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/windows.rs @@ -15,7 +15,9 @@ use vecdb::CachedVec; use crate::{ indexes, - internal::{PerBlock, ComputedVecValue, NumericValue, RollingWindow24h, Windows, WindowsFrom1w}, + internal::{ + ComputedVecValue, NumericValue, PerBlock, RollingWindow24h, Windows, WindowsFrom1w, + }, }; /// Cached window starts for lazy rolling computations. @@ -52,9 +54,7 @@ where /// Single 24h rolling window backed by PerBlock (1 stored vec). #[derive(Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct RollingWindow24hPerBlock( - pub RollingWindow24h>, -) +pub struct RollingWindow24hPerBlock(pub RollingWindow24h>) where T: ComputedVecValue + PartialOrd + JsonSchema; @@ -69,12 +69,7 @@ where indexes: &indexes::Vecs, ) -> Result { Ok(Self(RollingWindow24h { - _24h: PerBlock::forced_import( - db, - &format!("{name}_24h"), - version, - indexes, - )?, + _24h: PerBlock::forced_import(db, &format!("{name}_24h"), version, indexes)?, })) } } diff --git a/crates/brk_computer/src/internal/per_block/stddev/base.rs b/crates/brk_computer/src/internal/per_block/stddev/base.rs index 3d26be4bb..1b4f9d24b 100644 --- a/crates/brk_computer/src/internal/per_block/stddev/base.rs +++ b/crates/brk_computer/src/internal/per_block/stddev/base.rs @@ -26,8 +26,7 @@ impl StdDevPerBlock { let version = parent_version + Version::TWO; let p = period_suffix(period); - let sma = - PerBlock::forced_import(db, &format!("{name}_sma{p}"), version, indexes)?; + let sma = PerBlock::forced_import(db, &format!("{name}_sma{p}"), version, indexes)?; let sd = PerBlock::forced_import(db, &format!("{name}_sd{p}"), version, indexes)?; Ok(Self { days, sma, sd }) @@ -41,9 +40,13 @@ impl StdDevPerBlock { source: &impl ReadableVec, ) -> Result<()> { if self.days == usize::MAX { - self.sma - .height - .compute_sma_(starting_indexes.height, source, usize::MAX, exit, None)?; + self.sma.height.compute_sma_( + starting_indexes.height, + source, + usize::MAX, + exit, + None, + )?; self.sd.height.compute_expanding_sd( starting_indexes.height, source, diff --git a/crates/brk_computer/src/internal/per_block/stddev/extended.rs b/crates/brk_computer/src/internal/per_block/stddev/extended.rs index cf6b4ffae..797be803e 100644 --- a/crates/brk_computer/src/internal/per_block/stddev/extended.rs +++ b/crates/brk_computer/src/internal/per_block/stddev/extended.rs @@ -162,7 +162,8 @@ impl StdDevPerBlockExtended { { let _lock = exit.lock(); - self.mut_band_height_vecs().try_for_each(|v| v.write().map(|_| ()))?; + self.mut_band_height_vecs() + .try_for_each(|v| v.write().map(|_| ()))?; } self.zscore.height.compute_zscore( diff --git a/crates/brk_computer/src/internal/per_tx/distribution.rs b/crates/brk_computer/src/internal/per_tx/distribution.rs index a003c52d5..40b365d8f 100644 --- a/crates/brk_computer/src/internal/per_tx/distribution.rs +++ b/crates/brk_computer/src/internal/per_tx/distribution.rs @@ -29,7 +29,12 @@ impl PerTxDistribution where T: NumericValue + JsonSchema, { - pub(crate) fn forced_import(db: &Database, name: &str, version: Version, indexes: &indexes::Vecs) -> Result { + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + indexes: &indexes::Vecs, + ) -> Result { let tx_index = EagerVec::forced_import(db, name, version)?; let distribution = TxDerivedDistribution::forced_import(db, name, version, indexes)?; Ok(Self { diff --git a/crates/brk_computer/src/internal/traits.rs b/crates/brk_computer/src/internal/traits.rs index bc87836a0..173a816d0 100644 --- a/crates/brk_computer/src/internal/traits.rs +++ b/crates/brk_computer/src/internal/traits.rs @@ -1,6 +1,8 @@ use std::ops::{Add, AddAssign, Div}; -use brk_types::{BasisPoints16, BasisPoints32, BasisPointsSigned16, BasisPointsSigned32, StoredF32}; +use brk_types::{ + BasisPoints16, BasisPoints32, BasisPointsSigned16, BasisPointsSigned32, StoredF32, +}; use schemars::JsonSchema; use serde::Serialize; use vecdb::{CheckedSub, Formattable, PcoVecValue, UnaryTransform}; diff --git a/crates/brk_computer/src/internal/transform/arithmetic.rs b/crates/brk_computer/src/internal/transform/arithmetic.rs index 78cc31f6e..a240bbf90 100644 --- a/crates/brk_computer/src/internal/transform/arithmetic.rs +++ b/crates/brk_computer/src/internal/transform/arithmetic.rs @@ -1,6 +1,9 @@ use std::marker::PhantomData; -use brk_types::{BasisPoints16, Bitcoin, Cents, Dollars, Sats, StoredF32, StoredF64, StoredI8, StoredU16, StoredU32, StoredU64, VSize, Weight}; +use brk_types::{ + BasisPoints16, Bitcoin, Cents, Dollars, Sats, StoredF32, StoredF64, StoredI8, StoredU16, + StoredU32, StoredU64, VSize, Weight, +}; use vecdb::{BinaryTransform, UnaryTransform, VecValue}; pub struct Identity(PhantomData); @@ -12,7 +15,6 @@ impl UnaryTransform for Identity { } } - pub struct HalveSats; impl UnaryTransform for HalveSats { diff --git a/crates/brk_computer/src/internal/transform/mod.rs b/crates/brk_computer/src/internal/transform/mod.rs index 8a4527632..410b9a038 100644 --- a/crates/brk_computer/src/internal/transform/mod.rs +++ b/crates/brk_computer/src/internal/transform/mod.rs @@ -15,8 +15,8 @@ pub use bps::{ Bps32ToFloat, Bps32ToPercent, }; pub use currency::{ - CentsSignedToDollars, CentsSubtractToCentsSigned, CentsTimesTenths, CentsUnsignedToDollars, - CentsUnsignedToSats, DollarsToSatsFract, AvgCentsToUsd, AvgSatsToBtc, + AvgCentsToUsd, AvgSatsToBtc, CentsSignedToDollars, CentsSubtractToCentsSigned, + CentsTimesTenths, CentsUnsignedToDollars, CentsUnsignedToSats, DollarsToSatsFract, NegCentsUnsignedToDollars, SatsToBitcoin, SatsToCents, }; pub use derived::{ diff --git a/crates/brk_computer/src/internal/transform/ratio.rs b/crates/brk_computer/src/internal/transform/ratio.rs index 42416d002..cafcea06e 100644 --- a/crates/brk_computer/src/internal/transform/ratio.rs +++ b/crates/brk_computer/src/internal/transform/ratio.rs @@ -1,6 +1,6 @@ use brk_types::{ - BasisPoints16, BasisPoints32, BasisPointsSigned32, Cents, CentsSigned, Dollars, Sats, StoredF32, - StoredU64, + BasisPoints16, BasisPoints32, BasisPointsSigned32, Cents, CentsSigned, Dollars, Sats, + StoredF32, StoredU64, }; use vecdb::BinaryTransform; diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index 6ed12009d..fb08dc0d3 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -14,8 +14,8 @@ mod blocks; mod cointime; mod constants; mod distribution; -mod indicators; pub mod indexes; +mod indicators; mod inputs; mod internal; mod investing; @@ -104,8 +104,9 @@ impl Computer { let cached_starts = &blocks.lookback.cached_window_starts; - let (inputs, outputs, mining, transactions, scripts, pools, cointime) = - timed("Imported inputs/outputs/mining/tx/scripts/pools/cointime", || { + let (inputs, outputs, mining, transactions, scripts, pools, cointime) = timed( + "Imported inputs/outputs/mining/tx/scripts/pools/cointime", + || { thread::scope(|s| -> Result<_> { let inputs_handle = big_thread().spawn_scoped(s, || -> Result<_> { Ok(Box::new(inputs::Vecs::forced_import( @@ -176,9 +177,18 @@ impl Computer { let scripts = scripts_handle.join().unwrap()?; let pools = pools_handle.join().unwrap()?; - Ok((inputs, outputs, mining, transactions, scripts, pools, cointime)) + Ok(( + inputs, + outputs, + mining, + transactions, + scripts, + pools, + cointime, + )) }) - })?; + }, + )?; // Market, indicators, and distribution are independent; import in parallel. // Supply depends on distribution so it runs after. @@ -317,8 +327,7 @@ impl Computer { let compute_start = Instant::now(); let mut starting_indexes = timed("Computed indexes", || { - self.indexes - .compute(indexer, starting_indexes, exit) + self.indexes.compute(indexer, starting_indexes, exit) })?; thread::scope(|scope| -> Result<()> { @@ -362,12 +371,8 @@ impl Computer { }); timed("Computed scripts", || { - self.scripts.compute( - indexer, - &self.prices, - &starting_indexes, - exit, - ) + self.scripts + .compute(indexer, &self.prices, &starting_indexes, exit) })?; timed("Computed outputs", || { @@ -551,8 +556,25 @@ macro_rules! impl_iter_named { }; } -impl_iter_named!(blocks, mining, transactions, scripts, positions, cointime, - constants, indicators, indexes, investing, market, pools, prices, distribution, supply, inputs, outputs); +impl_iter_named!( + blocks, + mining, + transactions, + scripts, + positions, + cointime, + constants, + indicators, + indexes, + investing, + market, + pools, + prices, + distribution, + supply, + inputs, + outputs +); fn timed(label: &str, f: impl FnOnce() -> T) -> T { let start = Instant::now(); diff --git a/crates/brk_computer/src/market/ath/import.rs b/crates/brk_computer/src/market/ath/import.rs index 8503ace9c..a4480379a 100644 --- a/crates/brk_computer/src/market/ath/import.rs +++ b/crates/brk_computer/src/market/ath/import.rs @@ -30,8 +30,7 @@ impl Vecs { &max_days_between, ); - let days_since = - PerBlock::forced_import(db, "days_since_price_ath", v, indexes)?; + let days_since = PerBlock::forced_import(db, "days_since_price_ath", v, indexes)?; let years_since = LazyPerBlock::from_computed::( "years_since_price_ath", diff --git a/crates/brk_computer/src/market/compute.rs b/crates/brk_computer/src/market/compute.rs index 3992ada97..8aeba53da 100644 --- a/crates/brk_computer/src/market/compute.rs +++ b/crates/brk_computer/src/market/compute.rs @@ -22,7 +22,10 @@ impl Vecs { || { rayon::join( || self.ath.compute(prices, indexes, starting_indexes, exit), - || self.lookback.compute(blocks, prices, starting_indexes, exit), + || { + self.lookback + .compute(blocks, prices, starting_indexes, exit) + }, ) }, || { diff --git a/crates/brk_computer/src/market/import.rs b/crates/brk_computer/src/market/import.rs index 10526ae6e..a0645f70a 100644 --- a/crates/brk_computer/src/market/import.rs +++ b/crates/brk_computer/src/market/import.rs @@ -9,8 +9,8 @@ use crate::{ }; use super::{ - AthVecs, TechnicalVecs, LookbackVecs, MovingAverageVecs, RangeVecs, ReturnsVecs, - Vecs, VolatilityVecs, + AthVecs, LookbackVecs, MovingAverageVecs, RangeVecs, ReturnsVecs, TechnicalVecs, Vecs, + VolatilityVecs, }; impl Vecs { diff --git a/crates/brk_computer/src/market/mod.rs b/crates/brk_computer/src/market/mod.rs index 738e570f7..335bea087 100644 --- a/crates/brk_computer/src/market/mod.rs +++ b/crates/brk_computer/src/market/mod.rs @@ -1,22 +1,22 @@ pub mod ath; mod compute; mod import; -pub mod technical; pub mod lookback; pub mod moving_average; pub mod range; pub mod returns; +pub mod technical; pub mod volatility; use brk_traversable::Traversable; use vecdb::{Database, Rw, StorageMode}; pub use ath::Vecs as AthVecs; -pub use technical::Vecs as TechnicalVecs; pub use lookback::Vecs as LookbackVecs; pub use moving_average::Vecs as MovingAverageVecs; pub use range::Vecs as RangeVecs; pub use returns::Vecs as ReturnsVecs; +pub use technical::Vecs as TechnicalVecs; pub use volatility::Vecs as VolatilityVecs; pub const DB_NAME: &str = "market"; diff --git a/crates/brk_computer/src/market/moving_average/import.rs b/crates/brk_computer/src/market/moving_average/import.rs index 56dabfdd8..801025053 100644 --- a/crates/brk_computer/src/market/moving_average/import.rs +++ b/crates/brk_computer/src/market/moving_average/import.rs @@ -3,8 +3,8 @@ use brk_types::Version; use vecdb::Database; use super::{ - vecs::{EmaVecs, SmaVecs}, Vecs, + vecs::{EmaVecs, SmaVecs}, }; use crate::{ indexes, diff --git a/crates/brk_computer/src/market/range/compute.rs b/crates/brk_computer/src/market/range/compute.rs index 6acef0785..fd9645246 100644 --- a/crates/brk_computer/src/market/range/compute.rs +++ b/crates/brk_computer/src/market/range/compute.rs @@ -80,29 +80,24 @@ impl Vecs { exit, )?; - self.choppiness_index_2w - .bps - .height - .compute_transform4( - starting_indexes.height, - &self.true_range_sum_2w.height, - &self.max._2w.cents.height, - &self.min._2w.cents.height, - &blocks.lookback._2w, - |(h, tr_sum, max, min, window_start, ..)| { - let range = f64::from(max) - f64::from(min); - let n = (h.to_usize() - window_start.to_usize() + 1) as f32; - let ci = if range > 0.0 && n > 1.0 { - BasisPoints16::from( - (*tr_sum / range as f32).log10() as f64 / n.log10() as f64, - ) - } else { - BasisPoints16::ZERO - }; - (h, ci) - }, - exit, - )?; + self.choppiness_index_2w.bps.height.compute_transform4( + starting_indexes.height, + &self.true_range_sum_2w.height, + &self.max._2w.cents.height, + &self.min._2w.cents.height, + &blocks.lookback._2w, + |(h, tr_sum, max, min, window_start, ..)| { + let range = f64::from(max) - f64::from(min); + let n = (h.to_usize() - window_start.to_usize() + 1) as f32; + let ci = if range > 0.0 && n > 1.0 { + BasisPoints16::from((*tr_sum / range as f32).log10() as f64 / n.log10() as f64) + } else { + BasisPoints16::ZERO + }; + (h, ci) + }, + exit, + )?; Ok(()) } diff --git a/crates/brk_computer/src/market/range/import.rs b/crates/brk_computer/src/market/range/import.rs index 9967719c8..32c2a2413 100644 --- a/crates/brk_computer/src/market/range/import.rs +++ b/crates/brk_computer/src/market/range/import.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_types::Version; use vecdb::Database; -use super::{vecs::PriceMinMaxVecs, Vecs}; +use super::{Vecs, vecs::PriceMinMaxVecs}; use crate::{ indexes, internal::{PerBlock, PercentPerBlock, Price}, @@ -29,12 +29,7 @@ impl Vecs { _1m: Price::forced_import(db, "price_max_1m", version + v1, indexes)?, _1y: Price::forced_import(db, "price_max_1y", version + v1, indexes)?, }, - true_range: PerBlock::forced_import( - db, - "price_true_range", - version + v1, - indexes, - )?, + true_range: PerBlock::forced_import(db, "price_true_range", version + v1, indexes)?, true_range_sum_2w: PerBlock::forced_import( db, "price_true_range_sum_2w", diff --git a/crates/brk_computer/src/market/returns/compute.rs b/crates/brk_computer/src/market/returns/compute.rs index 51333dc45..4f46c022d 100644 --- a/crates/brk_computer/src/market/returns/compute.rs +++ b/crates/brk_computer/src/market/returns/compute.rs @@ -3,7 +3,9 @@ use brk_types::{BasisPointsSigned32, Dollars, Indexes}; use vecdb::Exit; use super::Vecs; -use crate::{blocks, internal::RatioDiffDollarsBps32, investing::ByDcaPeriod, market::lookback, prices}; +use crate::{ + blocks, internal::RatioDiffDollarsBps32, investing::ByDcaPeriod, market::lookback, prices, +}; impl Vecs { pub(crate) fn compute( diff --git a/crates/brk_computer/src/market/returns/import.rs b/crates/brk_computer/src/market/returns/import.rs index ab475ce0a..1e964bb76 100644 --- a/crates/brk_computer/src/market/returns/import.rs +++ b/crates/brk_computer/src/market/returns/import.rs @@ -6,7 +6,7 @@ use super::super::lookback::ByLookbackPeriod; use super::Vecs; use crate::{ indexes, - internal::{StdDevPerBlock, PercentPerBlock, Windows}, + internal::{PercentPerBlock, StdDevPerBlock, Windows}, investing::ByDcaCagr, }; @@ -39,6 +39,10 @@ impl Vecs { ) })?; - Ok(Self { periods, cagr, sd_24h }) + Ok(Self { + periods, + cagr, + sd_24h, + }) } } diff --git a/crates/brk_computer/src/market/technical/compute.rs b/crates/brk_computer/src/market/technical/compute.rs index 65ca6a97f..a787bf6a4 100644 --- a/crates/brk_computer/src/market/technical/compute.rs +++ b/crates/brk_computer/src/market/technical/compute.rs @@ -6,7 +6,11 @@ use super::{ super::{moving_average, returns}, Vecs, macd, rsi, }; -use crate::{blocks, internal::{RatioDollarsBp32, WindowsTo1m}, prices}; +use crate::{ + blocks, + internal::{RatioDollarsBp32, WindowsTo1m}, + prices, +}; impl Vecs { #[allow(clippy::too_many_arguments)] @@ -20,7 +24,12 @@ impl Vecs { exit: &Exit, ) -> Result<()> { let daily_returns = &returns.periods._24h.ratio.height; - for (rsi_chain, &m) in self.rsi.as_mut_array().into_iter().zip(&WindowsTo1m::<()>::DAYS) { + for (rsi_chain, &m) in self + .rsi + .as_mut_array() + .into_iter() + .zip(&WindowsTo1m::<()>::DAYS) + { rsi::compute( rsi_chain, blocks, @@ -32,7 +41,12 @@ impl Vecs { )?; } - for (macd_chain, &m) in self.macd.as_mut_array().into_iter().zip(&WindowsTo1m::<()>::DAYS) { + for (macd_chain, &m) in self + .macd + .as_mut_array() + .into_iter() + .zip(&WindowsTo1m::<()>::DAYS) + { macd::compute( macd_chain, blocks, diff --git a/crates/brk_computer/src/market/technical/import.rs b/crates/brk_computer/src/market/technical/import.rs index c5d9aab05..08cc9b80a 100644 --- a/crates/brk_computer/src/market/technical/import.rs +++ b/crates/brk_computer/src/market/technical/import.rs @@ -19,12 +19,7 @@ impl RsiChain { ) -> Result { macro_rules! import { ($name:expr) => { - PerBlock::forced_import( - db, - &format!("rsi_{}_{}", $name, tf), - version, - indexes, - )? + PerBlock::forced_import(db, &format!("rsi_{}_{}", $name, tf), version, indexes)? }; } @@ -66,17 +61,11 @@ impl MacdChain { version: Version, indexes: &indexes::Vecs, ) -> Result { - let line = - PerBlock::forced_import(db, &format!("macd_line_{tf}"), version, indexes)?; - let signal = - PerBlock::forced_import(db, &format!("macd_signal_{tf}"), version, indexes)?; + let line = PerBlock::forced_import(db, &format!("macd_line_{tf}"), version, indexes)?; + let signal = PerBlock::forced_import(db, &format!("macd_signal_{tf}"), version, indexes)?; - let histogram = PerBlock::forced_import( - db, - &format!("macd_histogram_{tf}"), - version, - indexes, - )?; + let histogram = + PerBlock::forced_import(db, &format!("macd_histogram_{tf}"), version, indexes)?; Ok(Self { ema_fast: PerBlock::forced_import( @@ -106,8 +95,9 @@ impl Vecs { ) -> Result { let v = version + VERSION; - let rsi = - WindowsTo1m::try_from_fn(|tf| RsiChain::forced_import(db, tf, v + Version::TWO, indexes))?; + let rsi = WindowsTo1m::try_from_fn(|tf| { + RsiChain::forced_import(db, tf, v + Version::TWO, indexes) + })?; let macd = WindowsTo1m::try_from_fn(|tf| MacdChain::forced_import(db, tf, v, indexes))?; let pi_cycle = RatioPerBlock::forced_import_raw(db, "pi_cycle", v, indexes)?; diff --git a/crates/brk_computer/src/market/volatility/import.rs b/crates/brk_computer/src/market/volatility/import.rs index 2ba45f88c..240878519 100644 --- a/crates/brk_computer/src/market/volatility/import.rs +++ b/crates/brk_computer/src/market/volatility/import.rs @@ -38,6 +38,11 @@ impl Vecs { &returns.sd_24h._1y.sd, ); - Ok(Windows { _24h, _1w, _1m, _1y }) + Ok(Windows { + _24h, + _1w, + _1m, + _1y, + }) } } diff --git a/crates/brk_computer/src/mining/hashrate/import.rs b/crates/brk_computer/src/mining/hashrate/import.rs index 3e2f64d4f..d49e1be47 100644 --- a/crates/brk_computer/src/mining/hashrate/import.rs +++ b/crates/brk_computer/src/mining/hashrate/import.rs @@ -3,8 +3,8 @@ use brk_types::Version; use vecdb::{Database, ReadableCloneableVec}; use super::{ - vecs::{HashPriceValueVecs, HashRateSmaVecs, RateVecs}, Vecs, + vecs::{HashPriceValueVecs, HashRateSmaVecs, RateVecs}, }; use crate::{ indexes, @@ -21,21 +21,35 @@ impl Vecs { let v5 = Version::new(5); let price_ths = PerBlock::forced_import(db, "hash_price_ths", version + v4, indexes)?; - let price_ths_min = PerBlock::forced_import(db, "hash_price_ths_min", version + v4, indexes)?; + let price_ths_min = + PerBlock::forced_import(db, "hash_price_ths_min", version + v4, indexes)?; let price_phs = LazyPerBlock::from_computed::( - "hash_price_phs", version + v4, price_ths.height.read_only_boxed_clone(), &price_ths, + "hash_price_phs", + version + v4, + price_ths.height.read_only_boxed_clone(), + &price_ths, ); let price_phs_min = LazyPerBlock::from_computed::( - "hash_price_phs_min", version + v4, price_ths_min.height.read_only_boxed_clone(), &price_ths_min, + "hash_price_phs_min", + version + v4, + price_ths_min.height.read_only_boxed_clone(), + &price_ths_min, ); let value_ths = PerBlock::forced_import(db, "hash_value_ths", version + v4, indexes)?; - let value_ths_min = PerBlock::forced_import(db, "hash_value_ths_min", version + v4, indexes)?; + let value_ths_min = + PerBlock::forced_import(db, "hash_value_ths_min", version + v4, indexes)?; let value_phs = LazyPerBlock::from_computed::( - "hash_value_phs", version + v4, value_ths.height.read_only_boxed_clone(), &value_ths, + "hash_value_phs", + version + v4, + value_ths.height.read_only_boxed_clone(), + &value_ths, ); let value_phs_min = LazyPerBlock::from_computed::( - "hash_value_phs_min", version + v4, value_ths_min.height.read_only_boxed_clone(), &value_ths_min, + "hash_value_phs_min", + version + v4, + value_ths_min.height.read_only_boxed_clone(), + &value_ths_min, ); Ok(Self { @@ -48,21 +62,36 @@ impl Vecs { _1y: PerBlock::forced_import(db, "hash_rate_sma_1y", version, indexes)?, }, ath: PerBlock::forced_import(db, "hash_rate_ath", version, indexes)?, - drawdown: PercentPerBlock::forced_import(db, "hash_rate_drawdown", version, indexes)?, + drawdown: PercentPerBlock::forced_import( + db, + "hash_rate_drawdown", + version, + indexes, + )?, }, price: HashPriceValueVecs { ths: price_ths, ths_min: price_ths_min, phs: price_phs, phs_min: price_phs_min, - rebound: PercentPerBlock::forced_import(db, "hash_price_rebound", version + v4, indexes)?, + rebound: PercentPerBlock::forced_import( + db, + "hash_price_rebound", + version + v4, + indexes, + )?, }, value: HashPriceValueVecs { ths: value_ths, ths_min: value_ths_min, phs: value_phs, phs_min: value_phs_min, - rebound: PercentPerBlock::forced_import(db, "hash_value_rebound", version + v4, indexes)?, + rebound: PercentPerBlock::forced_import( + db, + "hash_value_rebound", + version + v4, + indexes, + )?, }, }) } diff --git a/crates/brk_computer/src/mining/import.rs b/crates/brk_computer/src/mining/import.rs index 09d0ee778..8a8ae6b3b 100644 --- a/crates/brk_computer/src/mining/import.rs +++ b/crates/brk_computer/src/mining/import.rs @@ -5,7 +5,10 @@ use brk_types::Version; use crate::{ indexes, - internal::{CachedWindowStarts, db_utils::{finalize_db, open_db}}, + internal::{ + CachedWindowStarts, + db_utils::{finalize_db, open_db}, + }, }; use super::{HashrateVecs, RewardsVecs, Vecs}; diff --git a/crates/brk_computer/src/mining/rewards/compute.rs b/crates/brk_computer/src/mining/rewards/compute.rs index 2037c7604..01d056092 100644 --- a/crates/brk_computer/src/mining/rewards/compute.rs +++ b/crates/brk_computer/src/mining/rewards/compute.rs @@ -4,7 +4,11 @@ use brk_types::{CheckedSub, Dollars, Halving, Indexes, Sats}; use vecdb::{Exit, ReadableVec, VecIndex}; use super::Vecs; -use crate::{blocks, indexes, internal::{RatioDollarsBp32, RatioSatsBp16}, prices, transactions}; +use crate::{ + blocks, indexes, + internal::{RatioDollarsBp32, RatioSatsBp16}, + prices, transactions, +}; impl Vecs { #[allow(clippy::too_many_arguments)] @@ -22,13 +26,9 @@ impl Vecs { let window_starts = lookback.window_starts(); let (r_coinbase, r_fees) = rayon::join( || { - self.coinbase.compute( - starting_indexes.height, - prices, - exit, - |vec| { - let mut txout_cursor = - indexer.vecs.transactions.first_txout_index.cursor(); + self.coinbase + .compute(starting_indexes.height, prices, exit, |vec| { + let mut txout_cursor = indexer.vecs.transactions.first_txout_index.cursor(); let mut count_cursor = indexes.tx_index.output_count.cursor(); vec.compute_transform( @@ -38,12 +38,10 @@ impl Vecs { let ti = tx_index.to_usize(); txout_cursor.advance(ti - txout_cursor.position()); - let first_txout_index = - txout_cursor.next().unwrap().to_usize(); + let first_txout_index = txout_cursor.next().unwrap().to_usize(); count_cursor.advance(ti - count_cursor.position()); - let output_count: usize = - count_cursor.next().unwrap().into(); + let output_count: usize = count_cursor.next().unwrap().into(); let sats = indexer.vecs.outputs.value.fold_range_at( first_txout_index, @@ -56,8 +54,7 @@ impl Vecs { exit, )?; Ok(()) - }, - ) + }) }, || { self.fees.compute( @@ -95,7 +92,8 @@ impl Vecs { }, exit, )?; - self.subsidy.compute_rest(starting_indexes.height, prices, exit)?; + self.subsidy + .compute_rest(starting_indexes.height, prices, exit)?; self.unclaimed.block.sats.compute_transform( starting_indexes.height, @@ -107,7 +105,8 @@ impl Vecs { }, exit, )?; - self.unclaimed.compute(prices, starting_indexes.height, exit)?; + self.unclaimed + .compute(prices, starting_indexes.height, exit)?; self.fee_dominance .compute_binary::( diff --git a/crates/brk_computer/src/mining/rewards/import.rs b/crates/brk_computer/src/mining/rewards/import.rs index 26dad2a23..b06a13c73 100644 --- a/crates/brk_computer/src/mining/rewards/import.rs +++ b/crates/brk_computer/src/mining/rewards/import.rs @@ -7,8 +7,8 @@ use crate::{ indexes, internal::{ AmountPerBlockCumulative, AmountPerBlockCumulativeRolling, AmountPerBlockFull, - CachedWindowStarts, LazyPercentRollingWindows, OneMinusBp16, - PercentPerBlock, PercentRollingWindows, RatioRollingWindows, + CachedWindowStarts, LazyPercentRollingWindows, OneMinusBp16, PercentPerBlock, + PercentRollingWindows, RatioRollingWindows, }, }; @@ -19,12 +19,8 @@ impl Vecs { indexes: &indexes::Vecs, cached_starts: &CachedWindowStarts, ) -> Result { - let fee_dominance_rolling = PercentRollingWindows::forced_import( - db, - "fee_dominance", - version, - indexes, - )?; + let fee_dominance_rolling = + PercentRollingWindows::forced_import(db, "fee_dominance", version, indexes)?; let subsidy_dominance_rolling = LazyPercentRollingWindows::from_rolling::( "subsidy_dominance", @@ -34,10 +30,18 @@ impl Vecs { Ok(Self { coinbase: AmountPerBlockCumulativeRolling::forced_import( - db, "coinbase", version, indexes, cached_starts, + db, + "coinbase", + version, + indexes, + cached_starts, )?, subsidy: AmountPerBlockCumulativeRolling::forced_import( - db, "subsidy", version, indexes, cached_starts, + db, + "subsidy", + version, + indexes, + cached_starts, )?, fees: AmountPerBlockFull::forced_import(db, "fees", version, indexes, cached_starts)?, unclaimed: AmountPerBlockCumulative::forced_import( diff --git a/crates/brk_computer/src/outputs/count/import.rs b/crates/brk_computer/src/outputs/count/import.rs index 3b2b63571..d14ac80e8 100644 --- a/crates/brk_computer/src/outputs/count/import.rs +++ b/crates/brk_computer/src/outputs/count/import.rs @@ -23,12 +23,7 @@ impl Vecs { indexes, cached_starts, )?, - unspent: PerBlock::forced_import( - db, - "utxo_count_bis", - version, - indexes, - )?, + unspent: PerBlock::forced_import(db, "utxo_count_bis", version, indexes)?, }) } } diff --git a/crates/brk_computer/src/outputs/import.rs b/crates/brk_computer/src/outputs/import.rs index 372604334..9b42342aa 100644 --- a/crates/brk_computer/src/outputs/import.rs +++ b/crates/brk_computer/src/outputs/import.rs @@ -5,7 +5,10 @@ use brk_types::Version; use crate::{ indexes, - internal::{CachedWindowStarts, db_utils::{finalize_db, open_db}}, + internal::{ + CachedWindowStarts, + db_utils::{finalize_db, open_db}, + }, }; use super::{CountVecs, SpentVecs, Vecs}; diff --git a/crates/brk_computer/src/outputs/spent/compute.rs b/crates/brk_computer/src/outputs/spent/compute.rs index 97e30c47b..44ad24950 100644 --- a/crates/brk_computer/src/outputs/spent/compute.rs +++ b/crates/brk_computer/src/outputs/spent/compute.rs @@ -46,7 +46,12 @@ impl Vecs { let mut hi = starting_indexes.height.to_usize() + 1; while lo < hi { let mid = lo + (hi - lo) / 2; - if first_txout_index_vec.collect_one_at(mid).unwrap().to_usize() <= min_txout_index { + if first_txout_index_vec + .collect_one_at(mid) + .unwrap() + .to_usize() + <= min_txout_index + { lo = mid + 1; } else { hi = mid; diff --git a/crates/brk_computer/src/pools/major.rs b/crates/brk_computer/src/pools/major.rs index d7501668c..d8e85ac29 100644 --- a/crates/brk_computer/src/pools/major.rs +++ b/crates/brk_computer/src/pools/major.rs @@ -57,7 +57,6 @@ impl Vecs { }) } - #[allow(clippy::too_many_arguments)] pub(crate) fn compute( &mut self, starting_indexes: &Indexes, @@ -67,8 +66,7 @@ impl Vecs { mining: &mining::Vecs, exit: &Exit, ) -> Result<()> { - self.base - .compute(starting_indexes, pool, blocks, exit)?; + self.base.compute(starting_indexes, pool, blocks, exit)?; for (dom, (mined, total)) in self.dominance_rolling.as_mut_array().into_iter().zip( self.base @@ -86,11 +84,8 @@ impl Vecs { )?; } - self.rewards.compute( - starting_indexes.height, - prices, - exit, - |vec| { + self.rewards + .compute(starting_indexes.height, prices, exit, |vec| { Ok(vec.compute_transform2( starting_indexes.height, &self.base.blocks_mined.block, @@ -98,8 +93,7 @@ impl Vecs { |(h, mask, val, ..)| (h, MaskSats::apply(mask, val)), exit, )?) - }, - )?; + })?; Ok(()) } diff --git a/crates/brk_computer/src/pools/minor.rs b/crates/brk_computer/src/pools/minor.rs index 67aaa7cdd..83169b6cc 100644 --- a/crates/brk_computer/src/pools/minor.rs +++ b/crates/brk_computer/src/pools/minor.rs @@ -1,15 +1,11 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU32, StoredU64}; -use vecdb::{ - Database, Exit, ReadableVec, Rw, StorageMode, Version, -}; +use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode, Version}; use crate::{ blocks, indexes, - internal::{ - CachedWindowStarts, PerBlockCumulativeRolling, PercentPerBlock, RatioU64Bp16, - }, + internal::{CachedWindowStarts, PerBlockCumulativeRolling, PercentPerBlock, RatioU64Bp16}, }; #[derive(Traversable)] @@ -39,8 +35,7 @@ impl Vecs { cached_starts, )?; - let dominance = - PercentPerBlock::forced_import(db, &suffix("dominance"), version, indexes)?; + let dominance = PercentPerBlock::forced_import(db, &suffix("dominance"), version, indexes)?; Ok(Self { slug, diff --git a/crates/brk_computer/src/pools/mod.rs b/crates/brk_computer/src/pools/mod.rs index e1d1ae0a5..aa36d7c96 100644 --- a/crates/brk_computer/src/pools/mod.rs +++ b/crates/brk_computer/src/pools/mod.rs @@ -4,9 +4,7 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_store::AnyStore; use brk_traversable::Traversable; -use brk_types::{ - Addr, AddrBytes, Height, Indexes, OutputType, PoolSlug, Pools, TxOutIndex, pools, -}; +use brk_types::{Addr, AddrBytes, Height, Indexes, OutputType, PoolSlug, Pools, TxOutIndex, pools}; use rayon::prelude::*; use vecdb::{ AnyStoredVec, AnyVec, BytesVec, Database, Exit, ImportableVec, ReadableVec, Rw, StorageMode, @@ -18,7 +16,10 @@ pub mod minor; use crate::{ blocks, indexes, - internal::{CachedWindowStarts, db_utils::{finalize_db, open_db}}, + internal::{ + CachedWindowStarts, + db_utils::{finalize_db, open_db}, + }, mining, prices, }; @@ -91,19 +92,12 @@ impl Vecs { self.compute_pool(indexer, indexes, starting_indexes, exit)?; self.major.par_iter_mut().try_for_each(|(_, vecs)| { - vecs.compute( - starting_indexes, - &self.pool, - blocks, - prices, - mining, - exit, - ) + vecs.compute(starting_indexes, &self.pool, blocks, prices, mining, exit) })?; - self.minor.par_iter_mut().try_for_each(|(_, vecs)| { - vecs.compute(starting_indexes, &self.pool, blocks, exit) - })?; + self.minor + .par_iter_mut() + .try_for_each(|(_, vecs)| vecs.compute(starting_indexes, &self.pool, blocks, exit))?; let exit = exit.clone(); self.db.run_bg(move |db| { @@ -137,10 +131,7 @@ impl Vecs { let unknown = self.pools.get_unknown(); - let min = starting_indexes - .height - .to_usize() - .min(self.pool.len()); + let min = starting_indexes.height.to_usize().min(self.pool.len()); // Cursors avoid per-height PcoVec page decompression. // Heights are sequential, tx_index values derived from them are monotonically diff --git a/crates/brk_computer/src/positions.rs b/crates/brk_computer/src/positions.rs index 4cf35d0c3..4f7cf0ee8 100644 --- a/crates/brk_computer/src/positions.rs +++ b/crates/brk_computer/src/positions.rs @@ -91,10 +91,8 @@ impl Vecs { // Validate computed versions against dependencies let dep_version = indexer.vecs.transactions.first_tx_index.version() + indexer.vecs.transactions.height.version(); - self.block - .validate_computed_version_or_reset(dep_version)?; - self.tx - .validate_computed_version_or_reset(dep_version)?; + self.block.validate_computed_version_or_reset(dep_version)?; + self.tx.validate_computed_version_or_reset(dep_version)?; let min_tx_index = TxIndex::from(self.tx.len()).min(starting_indexes.tx_index); diff --git a/crates/brk_computer/src/prices/by_unit.rs b/crates/brk_computer/src/prices/by_unit.rs index a2be0f87e..6b9d9cdef 100644 --- a/crates/brk_computer/src/prices/by_unit.rs +++ b/crates/brk_computer/src/prices/by_unit.rs @@ -2,9 +2,7 @@ use brk_traversable::Traversable; use brk_types::{Cents, Dollars, OHLCCents, OHLCDollars, OHLCSats, Sats}; use vecdb::{Rw, StorageMode}; -use crate::internal::{ - PerBlock, Resolutions, EagerIndexes, LazyEagerIndexes, LazyPerBlock, -}; +use crate::internal::{EagerIndexes, LazyEagerIndexes, LazyPerBlock, PerBlock, Resolutions}; use super::ohlcs::{LazyOhlcVecs, OhlcVecs}; diff --git a/crates/brk_computer/src/prices/mod.rs b/crates/brk_computer/src/prices/mod.rs index d58ba7163..1b72ca26d 100644 --- a/crates/brk_computer/src/prices/mod.rs +++ b/crates/brk_computer/src/prices/mod.rs @@ -11,8 +11,8 @@ use vecdb::{Database, ReadableCloneableVec, Rw, StorageMode}; use crate::{ indexes, internal::{ - CentsUnsignedToDollars, CentsUnsignedToSats, PerBlock, Resolutions, - EagerIndexes, LazyEagerIndexes, LazyPerBlock, OhlcCentsToDollars, OhlcCentsToSats, + CentsUnsignedToDollars, CentsUnsignedToSats, EagerIndexes, LazyEagerIndexes, LazyPerBlock, + OhlcCentsToDollars, OhlcCentsToSats, PerBlock, Resolutions, db_utils::{finalize_db, open_db}, }, }; @@ -182,5 +182,4 @@ impl Vecs { spot, }) } - } diff --git a/crates/brk_computer/src/prices/ohlcs.rs b/crates/brk_computer/src/prices/ohlcs.rs index 4a9bb7285..357267c1f 100644 --- a/crates/brk_computer/src/prices/ohlcs.rs +++ b/crates/brk_computer/src/prices/ohlcs.rs @@ -1,9 +1,8 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - Cents, Close, Day1, Day3, Epoch, Halving, High, Hour1, Hour4, Hour12, Indexes, - Low, Minute10, Minute30, Month1, Month3, Month6, OHLCCents, Open, Version, Week1, Year1, - Year10, + Cents, Close, Day1, Day3, Epoch, Halving, High, Hour1, Hour4, Hour12, Indexes, Low, Minute10, + Minute30, Month1, Month3, Month6, OHLCCents, Open, Version, Week1, Year1, Year10, }; use derive_more::{Deref, DerefMut}; use schemars::JsonSchema; @@ -15,7 +14,7 @@ use vecdb::{ use crate::{ indexes, - internal::{Resolutions, EagerIndexes, PerResolution}, + internal::{EagerIndexes, PerResolution, Resolutions}, }; #[derive(Deref, DerefMut, Traversable)] diff --git a/crates/brk_computer/src/scripts/count/import.rs b/crates/brk_computer/src/scripts/count/import.rs index 1d11f2eb3..caaf15bb0 100644 --- a/crates/brk_computer/src/scripts/count/import.rs +++ b/crates/brk_computer/src/scripts/count/import.rs @@ -15,24 +15,69 @@ impl Vecs { indexes: &indexes::Vecs, cached_starts: &CachedWindowStarts, ) -> Result { - let p2a = - PerBlockCumulativeRolling::forced_import(db, "p2a_count", version, indexes, cached_starts)?; - let p2ms = - PerBlockCumulativeRolling::forced_import(db, "p2ms_count", version, indexes, cached_starts)?; - let p2pk33 = - PerBlockCumulativeRolling::forced_import(db, "p2pk33_count", version, indexes, cached_starts)?; - let p2pk65 = - PerBlockCumulativeRolling::forced_import(db, "p2pk65_count", version, indexes, cached_starts)?; - let p2pkh = - PerBlockCumulativeRolling::forced_import(db, "p2pkh_count", version, indexes, cached_starts)?; - let p2sh = - PerBlockCumulativeRolling::forced_import(db, "p2sh_count", version, indexes, cached_starts)?; - let p2tr = - PerBlockCumulativeRolling::forced_import(db, "p2tr_count", version, indexes, cached_starts)?; - let p2wpkh = - PerBlockCumulativeRolling::forced_import(db, "p2wpkh_count", version, indexes, cached_starts)?; - let p2wsh = - PerBlockCumulativeRolling::forced_import(db, "p2wsh_count", version, indexes, cached_starts)?; + let p2a = PerBlockCumulativeRolling::forced_import( + db, + "p2a_count", + version, + indexes, + cached_starts, + )?; + let p2ms = PerBlockCumulativeRolling::forced_import( + db, + "p2ms_count", + version, + indexes, + cached_starts, + )?; + let p2pk33 = PerBlockCumulativeRolling::forced_import( + db, + "p2pk33_count", + version, + indexes, + cached_starts, + )?; + let p2pk65 = PerBlockCumulativeRolling::forced_import( + db, + "p2pk65_count", + version, + indexes, + cached_starts, + )?; + let p2pkh = PerBlockCumulativeRolling::forced_import( + db, + "p2pkh_count", + version, + indexes, + cached_starts, + )?; + let p2sh = PerBlockCumulativeRolling::forced_import( + db, + "p2sh_count", + version, + indexes, + cached_starts, + )?; + let p2tr = PerBlockCumulativeRolling::forced_import( + db, + "p2tr_count", + version, + indexes, + cached_starts, + )?; + let p2wpkh = PerBlockCumulativeRolling::forced_import( + db, + "p2wpkh_count", + version, + indexes, + cached_starts, + )?; + let p2wsh = PerBlockCumulativeRolling::forced_import( + db, + "p2wsh_count", + version, + indexes, + cached_starts, + )?; Ok(Self { p2a, p2ms, diff --git a/crates/brk_computer/src/scripts/value/compute.rs b/crates/brk_computer/src/scripts/value/compute.rs index 449953f36..22d80324a 100644 --- a/crates/brk_computer/src/scripts/value/compute.rs +++ b/crates/brk_computer/src/scripts/value/compute.rs @@ -14,11 +14,8 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.op_return.compute_with( - starting_indexes.height, - prices, - exit, - |height_vec| { + self.op_return + .compute_with(starting_indexes.height, prices, exit, |height_vec| { // Validate computed versions against dependencies let dep_version = indexer.vecs.outputs.first_txout_index.version() + indexer.vecs.outputs.output_type.version() @@ -71,16 +68,16 @@ impl Vecs { let out_end = next_first_txout_index.to_usize(); // Pre-collect both vecs into reusable buffers - indexer - .vecs - .outputs - .output_type - .collect_range_into_at(out_start, out_end, &mut output_types_buf); - indexer - .vecs - .outputs - .value - .collect_range_into_at(out_start, out_end, &mut values_buf); + indexer.vecs.outputs.output_type.collect_range_into_at( + out_start, + out_end, + &mut output_types_buf, + ); + indexer.vecs.outputs.value.collect_range_into_at( + out_start, + out_end, + &mut values_buf, + ); let mut op_return_value = Sats::ZERO; for (ot, val) in output_types_buf.iter().zip(values_buf.iter()) { @@ -95,8 +92,7 @@ impl Vecs { height_vec.write()?; Ok(()) - }, - )?; + })?; Ok(()) } diff --git a/crates/brk_computer/src/supply/burned/compute.rs b/crates/brk_computer/src/supply/burned/compute.rs index 4997c718c..831c3e402 100644 --- a/crates/brk_computer/src/supply/burned/compute.rs +++ b/crates/brk_computer/src/supply/burned/compute.rs @@ -14,23 +14,23 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.total.compute_with( - starting_indexes.height, - prices, - exit, - |sats| { + self.total + .compute_with(starting_indexes.height, prices, exit, |sats| { Ok(sats.compute_transform2( starting_indexes.height, &scripts.value.op_return.block.sats, &mining.rewards.unclaimed.block.sats, |(h, op_return, unclaimed, ..)| { - let genesis = if h.to_usize() == 0 { Sats::FIFTY_BTC } else { Sats::ZERO }; + let genesis = if h.to_usize() == 0 { + Sats::FIFTY_BTC + } else { + Sats::ZERO + }; (h, genesis + op_return + unclaimed) }, exit, )?) - }, - )?; + })?; Ok(()) } diff --git a/crates/brk_computer/src/supply/compute.rs b/crates/brk_computer/src/supply/compute.rs index be9834265..1fae118be 100644 --- a/crates/brk_computer/src/supply/compute.rs +++ b/crates/brk_computer/src/supply/compute.rs @@ -24,13 +24,8 @@ impl Vecs { self.db.sync_bg_tasks()?; // 1. Compute burned/unspendable supply - self.burned.compute( - scripts, - mining, - prices, - starting_indexes, - exit, - )?; + self.burned + .compute(scripts, mining, prices, starting_indexes, exit)?; // 2. Compute inflation rate: (supply[h] / supply[1y_ago]) - 1 // Skip when lookback supply <= first block (50 BTC = 5B sats), diff --git a/crates/brk_computer/src/supply/import.rs b/crates/brk_computer/src/supply/import.rs index d6169529f..4ef37fb2e 100644 --- a/crates/brk_computer/src/supply/import.rs +++ b/crates/brk_computer/src/supply/import.rs @@ -6,8 +6,8 @@ use brk_types::Version; use crate::{ cointime, distribution, indexes, internal::{ - CachedWindowStarts, LazyAmountPerBlock, LazyFiatPerBlock, - LazyRollingDeltasFiatFromHeight, PercentPerBlock, RollingWindows, + CachedWindowStarts, LazyAmountPerBlock, LazyFiatPerBlock, LazyRollingDeltasFiatFromHeight, + PercentPerBlock, RollingWindows, db_utils::{finalize_db, open_db}, }, supply::burned, @@ -37,12 +37,8 @@ impl Vecs { let burned = burned::Vecs::forced_import(&db, version, indexes)?; // Inflation rate - let inflation_rate = PercentPerBlock::forced_import( - &db, - "inflation_rate", - version + Version::ONE, - indexes, - )?; + let inflation_rate = + PercentPerBlock::forced_import(&db, "inflation_rate", version + Version::ONE, indexes)?; // Velocity let velocity = super::velocity::Vecs::forced_import(&db, version, indexes)?; @@ -67,8 +63,11 @@ impl Vecs { indexes, )?; - let hodled_or_lost = - LazyAmountPerBlock::identity("hodled_or_lost_supply", &cointime.supply.vaulted, version); + let hodled_or_lost = LazyAmountPerBlock::identity( + "hodled_or_lost_supply", + &cointime.supply.vaulted, + version, + ); let this = Self { db, diff --git a/crates/brk_computer/src/supply/vecs.rs b/crates/brk_computer/src/supply/vecs.rs index 62aee7ea9..27bb94827 100644 --- a/crates/brk_computer/src/supply/vecs.rs +++ b/crates/brk_computer/src/supply/vecs.rs @@ -4,8 +4,8 @@ use vecdb::{Database, Rw, StorageMode}; use super::{burned, velocity}; use crate::internal::{ - LazyFiatPerBlock, LazyAmountPerBlock, LazyRollingDeltasFiatFromHeight, - PercentPerBlock, RollingWindows, + LazyAmountPerBlock, LazyFiatPerBlock, LazyRollingDeltasFiatFromHeight, PercentPerBlock, + RollingWindows, }; #[derive(Traversable)] diff --git a/crates/brk_computer/src/transactions/count/import.rs b/crates/brk_computer/src/transactions/count/import.rs index 37474827f..37c56ba5a 100644 --- a/crates/brk_computer/src/transactions/count/import.rs +++ b/crates/brk_computer/src/transactions/count/import.rs @@ -4,7 +4,10 @@ use brk_types::{StoredBool, TxIndex, Version}; use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec}; use super::Vecs; -use crate::{indexes, internal::{CachedWindowStarts, PerBlockFull}}; +use crate::{ + indexes, + internal::{CachedWindowStarts, PerBlockFull}, +}; impl Vecs { pub(crate) fn forced_import( @@ -27,13 +30,7 @@ impl Vecs { ); Ok(Self { - total: PerBlockFull::forced_import( - db, - "tx_count", - version, - indexes, - cached_starts, - )?, + total: PerBlockFull::forced_import(db, "tx_count", version, indexes, cached_starts)?, is_coinbase: tx_index_to_is_coinbase, }) } diff --git a/crates/brk_computer/src/transactions/fees/compute.rs b/crates/brk_computer/src/transactions/fees/compute.rs index ba093bc08..54eefff1e 100644 --- a/crates/brk_computer/src/transactions/fees/compute.rs +++ b/crates/brk_computer/src/transactions/fees/compute.rs @@ -36,8 +36,14 @@ impl Vecs { self.compute_fee_and_fee_rate(size_vecs, starting_indexes, exit)?; let (r3, r4) = rayon::join( - || self.fee.derive_from_with_skip(indexer, indexes, starting_indexes, exit, 1), - || self.fee_rate.derive_from_with_skip(indexer, indexes, starting_indexes, exit, 1), + || { + self.fee + .derive_from_with_skip(indexer, indexes, starting_indexes, exit, 1) + }, + || { + self.fee_rate + .derive_from_with_skip(indexer, indexes, starting_indexes, exit, 1) + }, ); r3?; r4?; @@ -78,8 +84,12 @@ impl Vecs { return Ok(()); } - self.fee.tx_index.truncate_if_needed(starting_indexes.tx_index)?; - self.fee_rate.tx_index.truncate_if_needed(starting_indexes.tx_index)?; + self.fee + .tx_index + .truncate_if_needed(starting_indexes.tx_index)?; + self.fee_rate + .tx_index + .truncate_if_needed(starting_indexes.tx_index)?; loop { let skip = self.fee.tx_index.len(); diff --git a/crates/brk_computer/src/transactions/fees/import.rs b/crates/brk_computer/src/transactions/fees/import.rs index d0e806fd6..45a7f284e 100644 --- a/crates/brk_computer/src/transactions/fees/import.rs +++ b/crates/brk_computer/src/transactions/fees/import.rs @@ -9,7 +9,11 @@ use crate::{indexes, internal::PerTxDistribution}; const VERSION: Version = Version::new(2); impl Vecs { - pub(crate) fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result { + pub(crate) fn forced_import( + db: &Database, + version: Version, + indexes: &indexes::Vecs, + ) -> Result { let v = version + VERSION; Ok(Self { input_value: EagerVec::forced_import(db, "input_value", version)?, diff --git a/crates/brk_computer/src/transactions/import.rs b/crates/brk_computer/src/transactions/import.rs index 4be2a16e2..de1753b39 100644 --- a/crates/brk_computer/src/transactions/import.rs +++ b/crates/brk_computer/src/transactions/import.rs @@ -6,7 +6,10 @@ use brk_types::Version; use crate::{ indexes, - internal::{CachedWindowStarts, db_utils::{finalize_db, open_db}}, + internal::{ + CachedWindowStarts, + db_utils::{finalize_db, open_db}, + }, }; use super::{CountVecs, FeesVecs, SizeVecs, Vecs, VersionsVecs, VolumeVecs}; diff --git a/crates/brk_computer/src/transactions/size/import.rs b/crates/brk_computer/src/transactions/size/import.rs index eef97a901..c0fcb2558 100644 --- a/crates/brk_computer/src/transactions/size/import.rs +++ b/crates/brk_computer/src/transactions/size/import.rs @@ -4,7 +4,10 @@ use brk_types::{TxIndex, VSize, Version, Weight}; use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec}; use super::Vecs; -use crate::{indexes, internal::{LazyPerTxDistribution, LazyPerTxDistributionTransformed, VSizeToWeight}}; +use crate::{ + indexes, + internal::{LazyPerTxDistribution, LazyPerTxDistributionTransformed, VSizeToWeight}, +}; impl Vecs { pub(crate) fn forced_import( @@ -23,8 +26,13 @@ impl Vecs { }, ); - let vsize = - LazyPerTxDistribution::forced_import(db, "tx_vsize", version, indexes, tx_index_to_vsize)?; + let vsize = LazyPerTxDistribution::forced_import( + db, + "tx_vsize", + version, + indexes, + tx_index_to_vsize, + )?; let tx_index_to_weight = LazyVecFrom2::init( "tx_weight", diff --git a/crates/brk_computer/src/transactions/versions/compute.rs b/crates/brk_computer/src/transactions/versions/compute.rs index 50de5638f..223c6e8f6 100644 --- a/crates/brk_computer/src/transactions/versions/compute.rs +++ b/crates/brk_computer/src/transactions/versions/compute.rs @@ -16,11 +16,7 @@ impl Vecs { + indexer.vecs.transactions.first_tx_index.version() + indexer.vecs.transactions.txid.version(); - for vec in [ - &mut self.v1.block, - &mut self.v2.block, - &mut self.v3.block, - ] { + for vec in [&mut self.v1.block, &mut self.v2.block, &mut self.v3.block] { vec.validate_and_truncate(dep_version, starting_indexes.height)?; } diff --git a/crates/brk_computer/src/transactions/versions/import.rs b/crates/brk_computer/src/transactions/versions/import.rs index f51aa8d50..15187bb93 100644 --- a/crates/brk_computer/src/transactions/versions/import.rs +++ b/crates/brk_computer/src/transactions/versions/import.rs @@ -16,9 +16,27 @@ impl Vecs { cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - v1: PerBlockCumulativeRolling::forced_import(db, "tx_v1", version, indexes, cached_starts)?, - v2: PerBlockCumulativeRolling::forced_import(db, "tx_v2", version, indexes, cached_starts)?, - v3: PerBlockCumulativeRolling::forced_import(db, "tx_v3", version, indexes, cached_starts)?, + v1: PerBlockCumulativeRolling::forced_import( + db, + "tx_v1", + version, + indexes, + cached_starts, + )?, + v2: PerBlockCumulativeRolling::forced_import( + db, + "tx_v2", + version, + indexes, + cached_starts, + )?, + v3: PerBlockCumulativeRolling::forced_import( + db, + "tx_v3", + version, + indexes, + cached_starts, + )?, }) } } diff --git a/crates/brk_fetcher/src/binance.rs b/crates/brk_fetcher/src/binance.rs index 2e284cfca..899c76d4b 100644 --- a/crates/brk_fetcher/src/binance.rs +++ b/crates/brk_fetcher/src/binance.rs @@ -46,7 +46,11 @@ impl Binance { previous_timestamp: Option, ) -> Result { // Try live API data first - if self._1mn.as_ref().and_then(|m| m.last_key_value()).is_none_or(|(k, _)| k <= ×tamp) + if self + ._1mn + .as_ref() + .and_then(|m| m.last_key_value()) + .is_none_or(|(k, _)| k <= ×tamp) { self._1mn.replace(self.fetch_1mn()?); } @@ -87,7 +91,12 @@ impl Binance { } pub fn get_from_1d(&mut self, date: &Date) -> Result { - if self._1d.as_ref().and_then(|m| m.last_key_value()).is_none_or(|(k, _)| k <= date) { + if self + ._1d + .as_ref() + .and_then(|m| m.last_key_value()) + .is_none_or(|(k, _)| k <= date) + { self._1d.replace(self.fetch_1d()?); } @@ -214,7 +223,9 @@ impl Binance { } pub fn ping(&self) -> Result<()> { - self.agent.get("https://api.binance.com/api/v3/ping").call()?; + self.agent + .get("https://api.binance.com/api/v3/ping") + .call()?; Ok(()) } } diff --git a/crates/brk_indexer/src/indexes.rs b/crates/brk_indexer/src/indexes.rs index 95bca0aea..feb76d006 100644 --- a/crates/brk_indexer/src/indexes.rs +++ b/crates/brk_indexer/src/indexes.rs @@ -30,40 +30,52 @@ impl IndexesExt for Indexes { .first_txout_index .checked_push(height, self.txout_index)?; vecs.scripts - .empty.first_index + .empty + .first_index .checked_push(height, self.empty_output_index)?; vecs.scripts - .p2ms.first_index + .p2ms + .first_index .checked_push(height, self.p2ms_output_index)?; vecs.scripts - .op_return.first_index + .op_return + .first_index .checked_push(height, self.op_return_index)?; vecs.addrs - .p2a.first_index + .p2a + .first_index .checked_push(height, self.p2a_addr_index)?; vecs.scripts - .unknown.first_index + .unknown + .first_index .checked_push(height, self.unknown_output_index)?; vecs.addrs - .p2pk33.first_index + .p2pk33 + .first_index .checked_push(height, self.p2pk33_addr_index)?; vecs.addrs - .p2pk65.first_index + .p2pk65 + .first_index .checked_push(height, self.p2pk65_addr_index)?; vecs.addrs - .p2pkh.first_index + .p2pkh + .first_index .checked_push(height, self.p2pkh_addr_index)?; vecs.addrs - .p2sh.first_index + .p2sh + .first_index .checked_push(height, self.p2sh_addr_index)?; vecs.addrs - .p2tr.first_index + .p2tr + .first_index .checked_push(height, self.p2tr_addr_index)?; vecs.addrs - .p2wpkh.first_index + .p2wpkh + .first_index .checked_push(height, self.p2wpkh_addr_index)?; vecs.addrs - .p2wsh.first_index + .p2wsh + .first_index .checked_push(height, self.p2wsh_addr_index)?; Ok(()) diff --git a/crates/brk_indexer/src/processor/tx.rs b/crates/brk_indexer/src/processor/tx.rs index 8a1adc8b7..2cd7a06d0 100644 --- a/crates/brk_indexer/src/processor/tx.rs +++ b/crates/brk_indexer/src/processor/tx.rs @@ -104,7 +104,8 @@ pub(super) fn store_tx_metadata( md.txid.checked_push(ct.tx_index, ct.txid)?; md.raw_locktime .checked_push(ct.tx_index, ct.tx.lock_time.into())?; - md.base_size.checked_push(ct.tx_index, ct.base_size.into())?; + md.base_size + .checked_push(ct.tx_index, ct.base_size.into())?; md.total_size .checked_push(ct.tx_index, ct.total_size.into())?; md.is_explicitly_rbf diff --git a/crates/brk_indexer/src/processor/txout.rs b/crates/brk_indexer/src/processor/txout.rs index de340536f..c88051bcc 100644 --- a/crates/brk_indexer/src/processor/txout.rs +++ b/crates/brk_indexer/src/processor/txout.rs @@ -2,8 +2,8 @@ use brk_cohort::ByAddrType; use brk_error::{Error, Result}; use brk_store::Store; use brk_types::{ - AddrBytes, AddrHash, AddrIndexOutPoint, AddrIndexTxIndex, OutPoint, OutputType, - Sats, TxIndex, TxOutIndex, TypeIndex, Unit, Vout, + AddrBytes, AddrHash, AddrIndexOutPoint, AddrIndexTxIndex, OutPoint, OutputType, Sats, TxIndex, + TxOutIndex, TypeIndex, Unit, Vout, }; use rayon::prelude::*; use rustc_hash::{FxHashMap, FxHashSet}; @@ -119,9 +119,7 @@ pub(super) fn finalize_outputs( already_added_addr_hash: &mut ByAddrType>, same_block_output_info: &mut FxHashMap, ) -> Result<()> { - already_added_addr_hash - .values_mut() - .for_each(|m| m.clear()); + already_added_addr_hash.values_mut().for_each(|m| m.clear()); same_block_output_info.clear(); for ProcessedOutput { @@ -168,25 +166,29 @@ pub(super) fn finalize_outputs( match output_type { OutputType::P2MS => { scripts - .p2ms.to_tx_index + .p2ms + .to_tx_index .checked_push(indexes.p2ms_output_index, tx_index)?; indexes.p2ms_output_index.copy_then_increment() } OutputType::OpReturn => { scripts - .op_return.to_tx_index + .op_return + .to_tx_index .checked_push(indexes.op_return_index, tx_index)?; indexes.op_return_index.copy_then_increment() } OutputType::Empty => { scripts - .empty.to_tx_index + .empty + .to_tx_index .checked_push(indexes.empty_output_index, tx_index)?; indexes.empty_output_index.copy_then_increment() } OutputType::Unknown => { scripts - .unknown.to_tx_index + .unknown + .to_tx_index .checked_push(indexes.unknown_output_index, tx_index)?; indexes.unknown_output_index.copy_then_increment() } diff --git a/crates/brk_indexer/src/processor/types.rs b/crates/brk_indexer/src/processor/types.rs index 52436cb9e..4ab884e2b 100644 --- a/crates/brk_indexer/src/processor/types.rs +++ b/crates/brk_indexer/src/processor/types.rs @@ -1,8 +1,8 @@ use bitcoin::{Transaction, TxOut}; use brk_cohort::ByAddrType; use brk_types::{ - AddrBytes, AddrHash, OutPoint, OutputType, TxIndex, TxOutIndex, Txid, TxidPrefix, - TypeIndex, Vin, Vout, + AddrBytes, AddrHash, OutPoint, OutputType, TxIndex, TxOutIndex, Txid, TxidPrefix, TypeIndex, + Vin, Vout, }; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/crates/brk_indexer/src/readers.rs b/crates/brk_indexer/src/readers.rs index cd0a17f4d..d66ecbf97 100644 --- a/crates/brk_indexer/src/readers.rs +++ b/crates/brk_indexer/src/readers.rs @@ -1,9 +1,8 @@ use bitcoin::ScriptBuf; use brk_types::{ - AddrBytes, OutputType, P2AAddrIndex, P2ABytes, P2PK33AddrIndex, P2PK33Bytes, - P2PK65AddrIndex, P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, P2SHBytes, - P2TRAddrIndex, P2TRBytes, P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, - TxIndex, TxOutIndex, Txid, TypeIndex, + AddrBytes, OutputType, P2AAddrIndex, P2ABytes, P2PK33AddrIndex, P2PK33Bytes, P2PK65AddrIndex, + P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, P2SHBytes, P2TRAddrIndex, P2TRBytes, + P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, TxIndex, TxOutIndex, Txid, TypeIndex, }; use vecdb::{BytesStrategy, VecReader}; diff --git a/crates/brk_indexer/src/stores.rs b/crates/brk_indexer/src/stores.rs index a6d5b725d..5b3a3f525 100644 --- a/crates/brk_indexer/src/stores.rs +++ b/crates/brk_indexer/src/stores.rs @@ -219,7 +219,10 @@ impl Stores { for store in self.addr_type_to_addr_index_and_tx_index.values_mut() { take!(store); } - for store in self.addr_type_to_addr_index_and_unspent_outpoint.values_mut() { + for store in self + .addr_type_to_addr_index_and_unspent_outpoint + .values_mut() + { take!(store); } diff --git a/crates/brk_indexer/src/vecs/addrs.rs b/crates/brk_indexer/src/vecs/addrs.rs index fbdff7e76..464b28d06 100644 --- a/crates/brk_indexer/src/vecs/addrs.rs +++ b/crates/brk_indexer/src/vecs/addrs.rs @@ -1,10 +1,10 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - AddrBytes, AddrHash, Height, OutputType, P2AAddrIndex, P2ABytes, P2PK33AddrIndex, - P2PK33Bytes, P2PK65AddrIndex, P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, - P2SHBytes, P2TRAddrIndex, P2TRBytes, P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, - P2WSHBytes, TypeIndex, Version, + AddrBytes, AddrHash, Height, OutputType, P2AAddrIndex, P2ABytes, P2PK33AddrIndex, P2PK33Bytes, + P2PK65AddrIndex, P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, P2SHBytes, + P2TRAddrIndex, P2TRBytes, P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, TypeIndex, + Version, }; use rayon::prelude::*; use schemars::JsonSchema; @@ -18,7 +18,11 @@ use crate::parallel_import; use crate::readers::AddrReaders; #[derive(Traversable)] -pub struct AddrTypeVecs { +pub struct AddrTypeVecs< + I: VecIndex + PcoVecValue + Formattable + Serialize + JsonSchema, + B: BytesVecValue + Formattable + Serialize + JsonSchema, + M: StorageMode = Rw, +> { pub first_index: M::Stored>, pub bytes: M::Stored>, } @@ -73,14 +77,38 @@ impl AddrsVecs { p2a_bytes = BytesVec::forced_import(db, "p2a_bytes", version), }; Ok(Self { - p2pk65: AddrTypeVecs { first_index: first_p2pk65_addr_index, bytes: p2pk65_bytes }, - p2pk33: AddrTypeVecs { first_index: first_p2pk33_addr_index, bytes: p2pk33_bytes }, - p2pkh: AddrTypeVecs { first_index: first_p2pkh_addr_index, bytes: p2pkh_bytes }, - p2sh: AddrTypeVecs { first_index: first_p2sh_addr_index, bytes: p2sh_bytes }, - p2wpkh: AddrTypeVecs { first_index: first_p2wpkh_addr_index, bytes: p2wpkh_bytes }, - p2wsh: AddrTypeVecs { first_index: first_p2wsh_addr_index, bytes: p2wsh_bytes }, - p2tr: AddrTypeVecs { first_index: first_p2tr_addr_index, bytes: p2tr_bytes }, - p2a: AddrTypeVecs { first_index: first_p2a_addr_index, bytes: p2a_bytes }, + p2pk65: AddrTypeVecs { + first_index: first_p2pk65_addr_index, + bytes: p2pk65_bytes, + }, + p2pk33: AddrTypeVecs { + first_index: first_p2pk33_addr_index, + bytes: p2pk33_bytes, + }, + p2pkh: AddrTypeVecs { + first_index: first_p2pkh_addr_index, + bytes: p2pkh_bytes, + }, + p2sh: AddrTypeVecs { + first_index: first_p2sh_addr_index, + bytes: p2sh_bytes, + }, + p2wpkh: AddrTypeVecs { + first_index: first_p2wpkh_addr_index, + bytes: p2wpkh_bytes, + }, + p2wsh: AddrTypeVecs { + first_index: first_p2wsh_addr_index, + bytes: p2wsh_bytes, + }, + p2tr: AddrTypeVecs { + first_index: first_p2tr_addr_index, + bytes: p2tr_bytes, + }, + p2a: AddrTypeVecs { + first_index: first_p2a_addr_index, + bytes: p2a_bytes, + }, }) } @@ -98,37 +126,53 @@ impl AddrsVecs { p2a_addr_index: P2AAddrIndex, stamp: Stamp, ) -> Result<()> { - self.p2pk65.first_index + self.p2pk65 + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2pk33.first_index + self.p2pk33 + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2pkh.first_index + self.p2pkh + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2sh.first_index + self.p2sh + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2wpkh.first_index + self.p2wpkh + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2wsh.first_index + self.p2wsh + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2tr.first_index + self.p2tr + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2a.first_index + self.p2a + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2pk65.bytes + self.p2pk65 + .bytes .truncate_if_needed_with_stamp(p2pk65_addr_index, stamp)?; - self.p2pk33.bytes + self.p2pk33 + .bytes .truncate_if_needed_with_stamp(p2pk33_addr_index, stamp)?; - self.p2pkh.bytes + self.p2pkh + .bytes .truncate_if_needed_with_stamp(p2pkh_addr_index, stamp)?; - self.p2sh.bytes + self.p2sh + .bytes .truncate_if_needed_with_stamp(p2sh_addr_index, stamp)?; - self.p2wpkh.bytes + self.p2wpkh + .bytes .truncate_if_needed_with_stamp(p2wpkh_addr_index, stamp)?; - self.p2wsh.bytes + self.p2wsh + .bytes .truncate_if_needed_with_stamp(p2wsh_addr_index, stamp)?; - self.p2tr.bytes + self.p2tr + .bytes .truncate_if_needed_with_stamp(p2tr_addr_index, stamp)?; - self.p2a.bytes + self.p2a + .bytes .truncate_if_needed_with_stamp(p2a_addr_index, stamp)?; Ok(()) } @@ -165,35 +209,43 @@ impl AddrsVecs { ) -> Option { match addr_type { OutputType::P2PK65 => self - .p2pk65.bytes + .p2pk65 + .bytes .get_pushed_or_read(type_index.into(), &readers.p2pk65) .map(AddrBytes::from), OutputType::P2PK33 => self - .p2pk33.bytes + .p2pk33 + .bytes .get_pushed_or_read(type_index.into(), &readers.p2pk33) .map(AddrBytes::from), OutputType::P2PKH => self - .p2pkh.bytes + .p2pkh + .bytes .get_pushed_or_read(type_index.into(), &readers.p2pkh) .map(AddrBytes::from), OutputType::P2SH => self - .p2sh.bytes + .p2sh + .bytes .get_pushed_or_read(type_index.into(), &readers.p2sh) .map(AddrBytes::from), OutputType::P2WPKH => self - .p2wpkh.bytes + .p2wpkh + .bytes .get_pushed_or_read(type_index.into(), &readers.p2wpkh) .map(AddrBytes::from), OutputType::P2WSH => self - .p2wsh.bytes + .p2wsh + .bytes .get_pushed_or_read(type_index.into(), &readers.p2wsh) .map(AddrBytes::from), OutputType::P2TR => self - .p2tr.bytes + .p2tr + .bytes .get_pushed_or_read(type_index.into(), &readers.p2tr) .map(AddrBytes::from), OutputType::P2A => self - .p2a.bytes + .p2a + .bytes .get_pushed_or_read(type_index.into(), &readers.p2a) .map(AddrBytes::from), _ => unreachable!("get_bytes_by_type called with non-address type"), @@ -237,8 +289,7 @@ impl AddrsVecs { as Box + '_>) } None => { - Ok(Box::new(std::iter::empty()) - as Box + '_>) + Ok(Box::new(std::iter::empty()) as Box + '_>) } } }}; diff --git a/crates/brk_indexer/src/vecs/blocks.rs b/crates/brk_indexer/src/vecs/blocks.rs index 45e00c51f..2f3e35ffa 100644 --- a/crates/brk_indexer/src/vecs/blocks.rs +++ b/crates/brk_indexer/src/vecs/blocks.rs @@ -47,8 +47,7 @@ impl BlocksVecs { .truncate_if_needed_with_stamp(height, stamp)?; self.timestamp .truncate_if_needed_with_stamp(height, stamp)?; - self.total - .truncate_if_needed_with_stamp(height, stamp)?; + self.total.truncate_if_needed_with_stamp(height, stamp)?; self.weight.truncate_if_needed_with_stamp(height, stamp)?; Ok(()) } diff --git a/crates/brk_indexer/src/vecs/mod.rs b/crates/brk_indexer/src/vecs/mod.rs index 00a6571c1..7a25ee373 100644 --- a/crates/brk_indexer/src/vecs/mod.rs +++ b/crates/brk_indexer/src/vecs/mod.rs @@ -172,5 +172,4 @@ impl Vecs { .chain(self.addrs.par_iter_mut_any()) .chain(self.scripts.par_iter_mut_any()) } - } diff --git a/crates/brk_indexer/src/vecs/outputs.rs b/crates/brk_indexer/src/vecs/outputs.rs index fcc2d93e2..46d8510f9 100644 --- a/crates/brk_indexer/src/vecs/outputs.rs +++ b/crates/brk_indexer/src/vecs/outputs.rs @@ -35,7 +35,12 @@ impl OutputsVecs { }) } - pub fn truncate(&mut self, height: Height, txout_index: TxOutIndex, stamp: Stamp) -> Result<()> { + pub fn truncate( + &mut self, + height: Height, + txout_index: TxOutIndex, + stamp: Stamp, + ) -> Result<()> { self.first_txout_index .truncate_if_needed_with_stamp(height, stamp)?; self.value diff --git a/crates/brk_indexer/src/vecs/scripts.rs b/crates/brk_indexer/src/vecs/scripts.rs index fd4c207e0..f013d1a0e 100644 --- a/crates/brk_indexer/src/vecs/scripts.rs +++ b/crates/brk_indexer/src/vecs/scripts.rs @@ -14,7 +14,10 @@ use vecdb::{ use crate::parallel_import; #[derive(Traversable)] -pub struct ScriptTypeVecs { +pub struct ScriptTypeVecs< + I: VecIndex + PcoVecValue + Formattable + Serialize + JsonSchema, + M: StorageMode = Rw, +> { pub first_index: M::Stored>, pub to_tx_index: M::Stored>, } @@ -49,10 +52,22 @@ impl ScriptsVecs { unknown_output_index_to_tx_index = PcoVec::forced_import(db, "tx_index", version), }; Ok(Self { - empty: ScriptTypeVecs { first_index: first_empty_output_index, to_tx_index: empty_output_index_to_tx_index }, - op_return: ScriptTypeVecs { first_index: first_op_return_index, to_tx_index: op_return_index_to_tx_index }, - p2ms: ScriptTypeVecs { first_index: first_p2ms_output_index, to_tx_index: p2ms_output_index_to_tx_index }, - unknown: ScriptTypeVecs { first_index: first_unknown_output_index, to_tx_index: unknown_output_index_to_tx_index }, + empty: ScriptTypeVecs { + first_index: first_empty_output_index, + to_tx_index: empty_output_index_to_tx_index, + }, + op_return: ScriptTypeVecs { + first_index: first_op_return_index, + to_tx_index: op_return_index_to_tx_index, + }, + p2ms: ScriptTypeVecs { + first_index: first_p2ms_output_index, + to_tx_index: p2ms_output_index_to_tx_index, + }, + unknown: ScriptTypeVecs { + first_index: first_unknown_output_index, + to_tx_index: unknown_output_index_to_tx_index, + }, }) } @@ -65,21 +80,29 @@ impl ScriptsVecs { unknown_output_index: UnknownOutputIndex, stamp: Stamp, ) -> Result<()> { - self.empty.first_index + self.empty + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.op_return.first_index + self.op_return + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.p2ms.first_index + self.p2ms + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.unknown.first_index + self.unknown + .first_index .truncate_if_needed_with_stamp(height, stamp)?; - self.empty.to_tx_index + self.empty + .to_tx_index .truncate_if_needed_with_stamp(empty_output_index, stamp)?; - self.op_return.to_tx_index + self.op_return + .to_tx_index .truncate_if_needed_with_stamp(op_return_index, stamp)?; - self.p2ms.to_tx_index + self.p2ms + .to_tx_index .truncate_if_needed_with_stamp(p2ms_output_index, stamp)?; - self.unknown.to_tx_index + self.unknown + .to_tx_index .truncate_if_needed_with_stamp(unknown_output_index, stamp)?; Ok(()) } diff --git a/crates/brk_query/src/impl/mining/block_rewards.rs b/crates/brk_query/src/impl/mining/block_rewards.rs index c425f5ad3..c48ba08e5 100644 --- a/crates/brk_query/src/impl/mining/block_rewards.rs +++ b/crates/brk_query/src/impl/mining/block_rewards.rs @@ -17,8 +17,7 @@ impl Query { match time_period { // Per-block, exact rewards TimePeriod::Day | TimePeriod::ThreeDays => { - let rewards: Vec = - coinbase_vec.collect_range_at(start, current_height + 1); + let rewards: Vec = coinbase_vec.collect_range_at(start, current_height + 1); let timestamps: Vec = timestamp_vec.collect_range_at(start, current_height + 1); @@ -45,8 +44,7 @@ impl Query { .collect_one(Height::from(current_height)) .unwrap_or_default(); - let total_days = - end_di.to_usize().saturating_sub(start_di.to_usize()) + 1; + let total_days = end_di.to_usize().saturating_sub(start_di.to_usize()) + 1; let step = (total_days / 200).max(1); let mut entries = Vec::with_capacity(total_days / step + 1); @@ -63,12 +61,9 @@ impl Query { let block_count = next_h.to_usize() - first_h.to_usize(); if block_count > 0 { - let sum = coinbase_vec.fold_range( - first_h, - next_h, - Sats::ZERO, - |acc, v| acc + v, - ); + let sum = + coinbase_vec + .fold_range(first_h, next_h, Sats::ZERO, |acc, v| acc + v); let avg = *sum / block_count as u64; if let Some(ts) = timestamp_vec.collect_one(first_h) { diff --git a/crates/brk_query/src/impl/mining/hashrate.rs b/crates/brk_query/src/impl/mining/hashrate.rs index acb042b0c..b8ff57d81 100644 --- a/crates/brk_query/src/impl/mining/hashrate.rs +++ b/crates/brk_query/src/impl/mining/hashrate.rs @@ -30,7 +30,8 @@ impl Query { let current_hashrate = *computer .mining .hashrate - .rate.base + .rate + .base .day1 .collect_one_flat(current_day1) .unwrap_or_default() as u128; diff --git a/crates/brk_query/src/impl/series.rs b/crates/brk_query/src/impl/series.rs index 185216c42..5725d6792 100644 --- a/crates/brk_query/src/impl/series.rs +++ b/crates/brk_query/src/impl/series.rs @@ -4,9 +4,9 @@ use brk_error::{Error, Result}; use brk_traversable::TreeNode; use brk_types::{ Date, DetailedSeriesCount, Epoch, Etag, Format, Halving, Height, Index, IndexInfo, LegacyValue, - Limit, SeriesName, SeriesData, SeriesInfo, SeriesOutput, SeriesOutputLegacy, SeriesSelection, - Output, OutputLegacy, PaginatedSeries, Pagination, PaginationIndex, RangeIndex, RangeMap, - SearchQuery, Timestamp, Version, + Limit, Output, OutputLegacy, PaginatedSeries, Pagination, PaginationIndex, RangeIndex, + RangeMap, SearchQuery, SeriesData, SeriesInfo, SeriesName, SeriesOutput, SeriesOutputLegacy, + SeriesSelection, Timestamp, Version, }; use parking_lot::RwLock; use vecdb::{AnyExportableVec, ReadableVec}; @@ -46,7 +46,8 @@ impl Query { // Series doesn't exist, suggest alternatives let matches = self - .vecs().matches(series, Limit::DEFAULT) + .vecs() + .matches(series, Limit::DEFAULT) .into_iter() .map(|s| s.to_string()) .collect(); @@ -261,7 +262,12 @@ impl Query { } let ResolvedQuery { - vecs, version, total, start, end, .. + vecs, + version, + total, + start, + end, + .. } = resolved; let count = end.saturating_sub(start); @@ -309,7 +315,10 @@ impl Query { } pub fn series_info(&self, series: &SeriesName) -> Option { - let index_to_vec = self.vecs().series_to_index_to_vec.get(series.replace("-", "_").as_str())?; + let index_to_vec = self + .vecs() + .series_to_index_to_vec + .get(series.replace("-", "_").as_str())?; let value_type = index_to_vec.values().next()?.value_type_to_string(); let indexes = index_to_vec.keys().copied().collect(); Some(SeriesInfo { diff --git a/crates/brk_query/src/impl/tx.rs b/crates/brk_query/src/impl/tx.rs index f6d2b6b6c..de41a3756 100644 --- a/crates/brk_query/src/impl/tx.rs +++ b/crates/brk_query/src/impl/tx.rs @@ -359,7 +359,12 @@ impl Query { let indexer = self.indexer(); // Look up spending tx_index directly - let spending_tx_index = indexer.vecs.inputs.tx_index.collect_one(txin_index).unwrap(); + let spending_tx_index = indexer + .vecs + .inputs + .tx_index + .collect_one(txin_index) + .unwrap(); // Calculate vin let spending_first_txin_index = indexer @@ -371,7 +376,11 @@ impl Query { let vin = Vin::from(usize::from(txin_index) - usize::from(spending_first_txin_index)); // Get spending tx details - let spending_txid = indexer.vecs.transactions.txid.read_once(spending_tx_index)?; + let spending_txid = indexer + .vecs + .transactions + .txid + .read_once(spending_tx_index)?; let spending_height = indexer .vecs .transactions diff --git a/crates/brk_query/src/vecs.rs b/crates/brk_query/src/vecs.rs index 401868ee7..1d35a1907 100644 --- a/crates/brk_query/src/vecs.rs +++ b/crates/brk_query/src/vecs.rs @@ -4,7 +4,7 @@ use brk_computer::Computer; use brk_indexer::Indexer; use brk_traversable::{Traversable, TreeNode}; use brk_types::{ - Index, IndexInfo, Limit, PaginatedSeries, Pagination, PaginationIndex, SeriesName, SeriesCount, + Index, IndexInfo, Limit, PaginatedSeries, Pagination, PaginationIndex, SeriesCount, SeriesName, }; use derive_more::{Deref, DerefMut}; use quickmatch::{QuickMatch, QuickMatchConfig}; diff --git a/crates/brk_server/src/api/metrics_legacy/mod.rs b/crates/brk_server/src/api/metrics_legacy/mod.rs index 161eed856..b8fae5138 100644 --- a/crates/brk_server/src/api/metrics_legacy/mod.rs +++ b/crates/brk_server/src/api/metrics_legacy/mod.rs @@ -10,8 +10,8 @@ use axum::{ use brk_traversable::TreeNode; use brk_types::{ CostBasisCohortParam, CostBasisFormatted, CostBasisParams, CostBasisQuery, DataRangeFormat, - Date, DetailedSeriesCount, Index, IndexInfo, PaginatedSeries, Pagination, SearchQuery, SeriesName, - SeriesData, SeriesInfo, SeriesList, SeriesSelection, SeriesSelectionLegacy, + Date, DetailedSeriesCount, Index, IndexInfo, PaginatedSeries, Pagination, SearchQuery, + SeriesData, SeriesInfo, SeriesList, SeriesName, SeriesSelection, SeriesSelectionLegacy, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/crates/brk_server/src/api/mod.rs b/crates/brk_server/src/api/mod.rs index 9ad05ca43..7d31f09d2 100644 --- a/crates/brk_server/src/api/mod.rs +++ b/crates/brk_server/src/api/mod.rs @@ -15,8 +15,8 @@ use crate::{ Error, api::{ addrs::AddrRoutes, blocks::BlockRoutes, mempool::MempoolRoutes, - metrics_legacy::ApiMetricsLegacyRoutes, mining::MiningRoutes, - series::ApiSeriesRoutes, server::ServerRoutes, transactions::TxRoutes, + metrics_legacy::ApiMetricsLegacyRoutes, mining::MiningRoutes, series::ApiSeriesRoutes, + server::ServerRoutes, transactions::TxRoutes, }, extended::{ResponseExtended, TransformResponseExtended}, }; @@ -27,9 +27,9 @@ mod addrs; mod blocks; mod mempool; mod metrics_legacy; -mod series; mod mining; mod openapi; +mod series; mod server; mod transactions; diff --git a/crates/brk_server/src/lib.rs b/crates/brk_server/src/lib.rs index 0838f3e62..a70b681e3 100644 --- a/crates/brk_server/src/lib.rs +++ b/crates/brk_server/src/lib.rs @@ -38,8 +38,8 @@ mod error; mod extended; mod state; -use api::*; pub use api::ApiRoutes; +use api::*; pub use brk_types::Port; pub use brk_website::Website; pub use cache::{CacheParams, CacheStrategy}; diff --git a/crates/brk_types/src/addr_index_outpoint.rs b/crates/brk_types/src/addr_index_outpoint.rs index 3dd98da4a..ca1e8bebe 100644 --- a/crates/brk_types/src/addr_index_outpoint.rs +++ b/crates/brk_types/src/addr_index_outpoint.rs @@ -12,7 +12,7 @@ use super::{OutPoint, TxIndex, TypeIndex}; #[repr(C)] pub struct AddrIndexOutPoint { addr_index_tx_index: AddrIndexTxIndex, // u64 - vout: Vout, // u16 + vout: Vout, // u16 } impl AddrIndexOutPoint { diff --git a/crates/brk_types/src/basis_points_16.rs b/crates/brk_types/src/basis_points_16.rs index d8f626585..dc8c93ddb 100644 --- a/crates/brk_types/src/basis_points_16.rs +++ b/crates/brk_types/src/basis_points_16.rs @@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div, Sub}; use derive_more::Deref; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use vecdb::{unlikely, CheckedSub, Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco, unlikely}; use super::StoredF32; diff --git a/crates/brk_types/src/basis_points_32.rs b/crates/brk_types/src/basis_points_32.rs index 032b8acf1..b670a0bb2 100644 --- a/crates/brk_types/src/basis_points_32.rs +++ b/crates/brk_types/src/basis_points_32.rs @@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div}; use derive_more::Deref; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use vecdb::{unlikely, CheckedSub, Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco, unlikely}; use super::StoredF32; diff --git a/crates/brk_types/src/basis_points_signed_16.rs b/crates/brk_types/src/basis_points_signed_16.rs index c5d153288..4e20d13f8 100644 --- a/crates/brk_types/src/basis_points_signed_16.rs +++ b/crates/brk_types/src/basis_points_signed_16.rs @@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div, Sub, SubAssign}; use derive_more::Deref; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use vecdb::{unlikely, CheckedSub, Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco, unlikely}; use super::StoredF32; diff --git a/crates/brk_types/src/basis_points_signed_32.rs b/crates/brk_types/src/basis_points_signed_32.rs index 4c80e8edf..68d543286 100644 --- a/crates/brk_types/src/basis_points_signed_32.rs +++ b/crates/brk_types/src/basis_points_signed_32.rs @@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div, Sub, SubAssign}; use derive_more::Deref; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use vecdb::{unlikely, CheckedSub, Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco, unlikely}; use super::StoredF32; diff --git a/crates/brk_types/src/cost_basis_distribution.rs b/crates/brk_types/src/cost_basis_distribution.rs index af6052ee3..a9d061f55 100644 --- a/crates/brk_types/src/cost_basis_distribution.rs +++ b/crates/brk_types/src/cost_basis_distribution.rs @@ -44,7 +44,8 @@ impl CostBasisDistribution { if data.len() < rest_start { return Err(brk_error::Error::Deserialization(format!( "CostBasisDistribution: data too short ({} bytes, need >= {})", - data.len(), rest_start + data.len(), + rest_start ))); } diff --git a/crates/brk_types/src/index.rs b/crates/brk_types/src/index.rs index 305d2a43c..46dc11b47 100644 --- a/crates/brk_types/src/index.rs +++ b/crates/brk_types/src/index.rs @@ -6,13 +6,13 @@ use serde::{Deserialize, Serialize}; use vecdb::PrintableIndex; use super::{ - Date, Day1, Day3, EmptyAddrIndex, EmptyOutputIndex, Epoch, FundedAddrIndex, Halving, - Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, Month6, OpReturnIndex, - P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, - P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, Timestamp, - TxInIndex, TxIndex, TxOutIndex, UnknownOutputIndex, Week1, Year1, Year10, - hour1::HOUR1_INTERVAL, hour4::HOUR4_INTERVAL, hour12::HOUR12_INTERVAL, - minute10::MINUTE10_INTERVAL, minute30::MINUTE30_INTERVAL, timestamp::INDEX_EPOCH, + Date, Day1, Day3, EmptyAddrIndex, EmptyOutputIndex, Epoch, FundedAddrIndex, Halving, Height, + Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, Month6, OpReturnIndex, P2AAddrIndex, + P2MSOutputIndex, P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, + P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, Timestamp, TxInIndex, TxIndex, TxOutIndex, + UnknownOutputIndex, Week1, Year1, Year10, hour1::HOUR1_INTERVAL, hour4::HOUR4_INTERVAL, + hour12::HOUR12_INTERVAL, minute10::MINUTE10_INTERVAL, minute30::MINUTE30_INTERVAL, + timestamp::INDEX_EPOCH, }; /// Aggregation dimension for querying series. Includes time-based (date, week, month, year), diff --git a/crates/brk_types/src/indexes.rs b/crates/brk_types/src/indexes.rs index ce3c9ca3e..04614747e 100644 --- a/crates/brk_types/src/indexes.rs +++ b/crates/brk_types/src/indexes.rs @@ -1,8 +1,7 @@ use crate::{ EmptyOutputIndex, Height, OpReturnIndex, OutputType, P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, - P2WPKHAddrIndex, P2WSHAddrIndex, TxInIndex, TxIndex, TxOutIndex, TypeIndex, - UnknownOutputIndex, + P2WPKHAddrIndex, P2WSHAddrIndex, TxInIndex, TxIndex, TxOutIndex, TypeIndex, UnknownOutputIndex, }; /// Blockchain-level indexes tracking current positions for various entity types. diff --git a/crates/brk_types/src/pagination.rs b/crates/brk_types/src/pagination.rs index 20561b790..a8cedc144 100644 --- a/crates/brk_types/src/pagination.rs +++ b/crates/brk_types/src/pagination.rs @@ -29,9 +29,7 @@ impl Pagination { } pub fn start(&self, len: usize) -> usize { - self.page() - .saturating_mul(self.per_page()) - .min(len) + self.page().saturating_mul(self.per_page()).min(len) } pub fn end(&self, len: usize) -> usize { diff --git a/crates/brk_types/src/series_selection.rs b/crates/brk_types/src/series_selection.rs index ea133d2eb..5440d8785 100644 --- a/crates/brk_types/src/series_selection.rs +++ b/crates/brk_types/src/series_selection.rs @@ -2,7 +2,7 @@ use derive_more::Deref; use schemars::JsonSchema; use serde::Deserialize; -use crate::{DataRangeFormat, Index, SeriesName, SeriesList}; +use crate::{DataRangeFormat, Index, SeriesList, SeriesName}; /// Selection of series to query #[derive(Debug, Deref, Deserialize, JsonSchema)] diff --git a/crates/brk_types/src/stored_bool.rs b/crates/brk_types/src/stored_bool.rs index b761310a1..fe15c08cd 100644 --- a/crates/brk_types/src/stored_bool.rs +++ b/crates/brk_types/src/stored_bool.rs @@ -5,18 +5,7 @@ use vecdb::{Formattable, Pco, PrintableIndex}; /// Fixed-size boolean value optimized for on-disk storage (stored as u8) #[derive( - Debug, - Deref, - Clone, - Default, - Copy, - PartialEq, - Eq, - PartialOrd, - Ord, - Serialize, - Deserialize, - Pco, + Debug, Deref, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Pco, )] pub struct StoredBool(u8); diff --git a/crates/brk_types/src/stored_u16.rs b/crates/brk_types/src/stored_u16.rs index 826f0f043..fdafb3fd2 100644 --- a/crates/brk_types/src/stored_u16.rs +++ b/crates/brk_types/src/stored_u16.rs @@ -7,8 +7,8 @@ use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; use super::{ EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, - P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, - P2WSHAddrIndex, UnknownOutputIndex, + P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, + UnknownOutputIndex, }; #[derive( diff --git a/crates/brk_types/src/stored_u32.rs b/crates/brk_types/src/stored_u32.rs index ac15044b8..e62b5e27a 100644 --- a/crates/brk_types/src/stored_u32.rs +++ b/crates/brk_types/src/stored_u32.rs @@ -7,8 +7,8 @@ use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; use super::{ EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, - P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, - P2WSHAddrIndex, UnknownOutputIndex, + P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, + UnknownOutputIndex, }; /// Fixed-size 32-bit unsigned integer optimized for on-disk storage diff --git a/crates/brk_types/src/stored_u64.rs b/crates/brk_types/src/stored_u64.rs index 07489157b..765e1bcb5 100644 --- a/crates/brk_types/src/stored_u64.rs +++ b/crates/brk_types/src/stored_u64.rs @@ -8,8 +8,8 @@ use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; use super::{ Day1, EmptyOutputIndex, Height, Month1, OpReturnIndex, P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, - P2WPKHAddrIndex, P2WSHAddrIndex, StoredU32, TxInIndex, TxIndex, TxOutIndex, - UnknownOutputIndex, Year1, + P2WPKHAddrIndex, P2WSHAddrIndex, StoredU32, TxInIndex, TxIndex, TxOutIndex, UnknownOutputIndex, + Year1, }; /// Fixed-size 64-bit unsigned integer optimized for on-disk storage diff --git a/crates/brk_types/src/tree_node.rs b/crates/brk_types/src/tree_node.rs index 9a1d7993e..6c5ca74fe 100644 --- a/crates/brk_types/src/tree_node.rs +++ b/crates/brk_types/src/tree_node.rs @@ -548,10 +548,7 @@ mod tests { fn merge_no_conflict_same_series_different_indexes() { // Same key, same series name, different indexes → merges indexes → collapses to Leaf let tree = branch(vec![ - ( - "a", - branch(vec![("sum", leaf("s_sum", Index::Height))]), - ), + ("a", branch(vec![("sum", leaf("s_sum", Index::Height))])), ("b", branch(vec![("sum", leaf("s_sum", Index::Day1))])), ]); let result = tree.merge_branches(); @@ -727,19 +724,10 @@ mod tests { // - rest (flatten): DerivedComputedBlockSum → branches with "sum" children let tree = branch(vec![ // height wrapped as "raw" - ( - "height", - branch(vec![("raw", leaf("s", Index::Height))]), - ), + ("height", branch(vec![("raw", leaf("s", Index::Height))])), // rest (flattened) produces branches - ( - "day1", - branch(vec![("sum", leaf("s_sum", Index::Day1))]), - ), - ( - "week1", - branch(vec![("sum", leaf("s_sum", Index::Week1))]), - ), + ("day1", branch(vec![("sum", leaf("s_sum", Index::Day1))])), + ("week1", branch(vec![("sum", leaf("s_sum", Index::Week1))])), ]); let merged = tree.merge_branches().unwrap(); @@ -778,15 +766,9 @@ mod tests { // - rest (flatten): DerivedComputedBlockLast → branches with "last" children let tree = branch(vec![ // height wrapped as "raw" - ( - "height", - branch(vec![("raw", leaf("s", Index::Height))]), - ), + ("height", branch(vec![("raw", leaf("s", Index::Height))])), // rest (flattened) produces branches with "last" key - ( - "day1", - branch(vec![("last", leaf("s_last", Index::Day1))]), - ), + ("day1", branch(vec![("last", leaf("s_last", Index::Day1))])), ( "week1", branch(vec![("last", leaf("s_last", Index::Week1))]), @@ -833,17 +815,11 @@ mod tests { // } let tree = branch(vec![ // height wrapped as "raw" (raw values at height granularity) - ( - "height", - branch(vec![("raw", leaf("s", Index::Height))]), - ), + ("height", branch(vec![("raw", leaf("s", Index::Height))])), // height_cumulative wrapped as cumulative ( "height_cumulative", - branch(vec![( - "cumulative", - leaf("s_cumulative", Index::Height), - )]), + branch(vec![("cumulative", leaf("s_cumulative", Index::Height))]), ), // day1 Full ( @@ -971,10 +947,7 @@ mod tests { // sats wrapped, rest flattened with bitcoin/dollars as plain leaves let tree = branch(vec![ // sats with wrap="sats" produces Branch { sats: Leaf } - ( - "sats", - branch(vec![("sats", leaf("s", Index::Height))]), - ), + ("sats", branch(vec![("sats", leaf("s", Index::Height))])), // rest with flatten: LazyDerivedBlockValue fields lifted ( "rest", @@ -1018,17 +991,11 @@ mod tests { // Tree AFTER derive applies inner merges, flatten lifts rest's children: let tree = branch(vec![ // height with wrap="raw" - ( - "height", - branch(vec![("raw", leaf("s", Index::Height))]), - ), + ("height", branch(vec![("raw", leaf("s", Index::Height))])), // height_cumulative with wrap="cumulative" ( "height_cumulative", - branch(vec![( - "cumulative", - leaf("s_cumulative", Index::Height), - )]), + branch(vec![("cumulative", leaf("s_cumulative", Index::Height))]), ), // From rest (flatten) - inner struct already merged to { sum, cumulative } // Each leaf has merged indexes from all time periods @@ -1135,18 +1102,9 @@ mod tests { // week1: { last: Leaf }, month1: { last: Leaf }, etc. // After merge: all "last" keys merge, same series name → collapses to Leaf let tree = branch(vec![ - ( - "week1", - branch(vec![("last", leaf("s", Index::Week1))]), - ), - ( - "month1", - branch(vec![("last", leaf("s", Index::Month1))]), - ), - ( - "year1", - branch(vec![("last", leaf("s", Index::Year1))]), - ), + ("week1", branch(vec![("last", leaf("s", Index::Week1))])), + ("month1", branch(vec![("last", leaf("s", Index::Month1))])), + ("year1", branch(vec![("last", leaf("s", Index::Year1))])), ]); let merged = tree.merge_branches().unwrap(); @@ -1214,10 +1172,7 @@ mod tests { // Simulating the pre-merge structure let tree = branch(vec![ // From sats_day1 with wrap="sats" - ( - "sats_day1", - branch(vec![("sats", leaf("s", Index::Day1))]), - ), + ("sats_day1", branch(vec![("sats", leaf("s", Index::Day1))])), // From rest (flatten): ValueDerivedDateLast ( "rest",