diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 923665bad..689dcc3a5 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -1104,36 +1104,36 @@ impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 { } /// Pattern struct for repeated tree structure. -pub struct CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern { - pub cap: CentsDeltaRawRelUsdPattern, - pub gross_pnl: RawSellSumPattern, - pub investor: CapLowerPriceUpperPattern, +pub struct CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern { + pub cap: CentsDeltaRelUsdPattern, + pub gross_pnl: CumulativeRawSumPattern2, + pub investor: LowerPriceUpperPattern, pub loss: CapitulationCumulativeNegativeRawRelSumValuePattern, pub mvrv: MetricPattern1, pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, - pub nupl: BpsRatioPattern, pub peak_regret: CumulativeRawRelPattern, pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, pub profit: CumulativeDistributionRawRelSumValuePattern, pub profit_to_loss_ratio: _1m1w1y24hPattern, + pub sell_side_risk_ratio: _1m1w1y24hPattern2, pub sopr: AdjustedRatioValuePattern, } -impl CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern { +impl CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - cap: CentsDeltaRawRelUsdPattern::new(client.clone(), acc.clone()), - gross_pnl: RawSellSumPattern::new(client.clone(), acc.clone()), - investor: CapLowerPriceUpperPattern::new(client.clone(), acc.clone()), + cap: CentsDeltaRelUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), + gross_pnl: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "realized_gross_pnl")), + investor: LowerPriceUpperPattern::new(client.clone(), acc.clone()), loss: CapitulationCumulativeNegativeRawRelSumValuePattern::new(client.clone(), acc.clone()), mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), net_pnl: ChangeCumulativeDeltaRawRelSumPattern::new(client.clone(), _m(&acc, "net")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), peak_regret: CumulativeRawRelPattern::new(client.clone(), _m(&acc, "realized_peak_regret")), price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern::new(client.clone(), _m(&acc, "realized_price")), profit: CumulativeDistributionRawRelSumValuePattern::new(client.clone(), acc.clone()), profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit_to_loss_ratio")), + sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")), sopr: AdjustedRatioValuePattern::new(client.clone(), acc.clone()), } } @@ -1269,36 +1269,6 @@ impl AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 { } } -/// Pattern struct for repeated tree structure. -pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 { - pub average: BtcCentsSatsUsdPattern, - pub max: BtcCentsSatsUsdPattern, - pub median: BtcCentsSatsUsdPattern, - pub min: BtcCentsSatsUsdPattern, - pub pct10: BtcCentsSatsUsdPattern, - pub pct25: BtcCentsSatsUsdPattern, - pub pct75: BtcCentsSatsUsdPattern, - pub pct90: BtcCentsSatsUsdPattern, - pub sum: BtcCentsSatsUsdPattern, -} - -impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - average: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "average")), - max: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "max")), - median: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "median")), - min: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "min")), - pct10: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct10")), - pct25: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct25")), - pct75: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct75")), - pct90: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct90")), - sum: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "sum")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern { pub average: _1m1w1y24hPattern, @@ -1330,29 +1300,29 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern { } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hBtcCentsSatsUsdPattern { - pub _1m: BtcCentsSatsUsdPattern, - pub _1w: BtcCentsSatsUsdPattern, - pub _1y: BtcCentsSatsUsdPattern, - pub _24h: BtcCentsSatsUsdPattern, - pub btc: MetricPattern18, - pub cents: MetricPattern18, - pub sats: MetricPattern18, - pub usd: MetricPattern18, +pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { + pub average: BtcCentsSatsUsdPattern, + pub max: BtcCentsSatsUsdPattern, + pub median: BtcCentsSatsUsdPattern, + pub min: BtcCentsSatsUsdPattern, + pub pct10: BtcCentsSatsUsdPattern, + pub pct25: BtcCentsSatsUsdPattern, + pub pct75: BtcCentsSatsUsdPattern, + pub pct90: BtcCentsSatsUsdPattern, } -impl _1m1w1y24hBtcCentsSatsUsdPattern { +impl AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - _1m: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "1m")), - _1w: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "1w")), - _1y: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "1y")), - _24h: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "24h")), - btc: MetricPattern18::new(client.clone(), acc.clone()), - cents: MetricPattern18::new(client.clone(), _m(&acc, "cents")), - sats: MetricPattern18::new(client.clone(), _m(&acc, "sats")), - usd: MetricPattern18::new(client.clone(), _m(&acc, "usd")), + average: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "average")), + max: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "max")), + median: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "median")), + min: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "min")), + pct10: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct10")), + pct25: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct25")), + pct75: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct75")), + pct90: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct90")), } } } @@ -1385,34 +1355,6 @@ impl BpsCentsPercentilesRatioSatsSmaStdUsdPattern { } } -/// Pattern struct for repeated tree structure. -pub struct CapLossMvrvNetNuplPriceProfitSoprPattern { - pub cap: CentsDeltaUsdPattern, - pub loss: CumulativeNegativeRawSumPattern, - pub mvrv: MetricPattern1, - pub net_pnl: RawSumPattern3, - pub nupl: BpsRatioPattern, - pub price: BpsCentsRatioSatsUsdPattern, - pub profit: CumulativeRawSumPattern2, - pub sopr: RatioValuePattern, -} - -impl CapLossMvrvNetNuplPriceProfitSoprPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cap: CentsDeltaUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), - loss: CumulativeNegativeRawSumPattern::new(client.clone(), acc.clone()), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - net_pnl: RawSumPattern3::new(client.clone(), _m(&acc, "net_realized_pnl")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), - price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - profit: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "realized_profit")), - sopr: RatioValuePattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct CapitulationCumulativeNegativeRawRelSumValuePattern { pub capitulation_flow: MetricPattern1, @@ -1420,9 +1362,9 @@ pub struct CapitulationCumulativeNegativeRawRelSumValuePattern { pub negative: MetricPattern1, pub raw: CentsUsdPattern, pub rel_to_rcap: BpsPercentRatioPattern, - pub sum: _1m1w1y24hPattern5, - pub value_created: RawSumPattern, - pub value_destroyed: RawSumPattern, + pub sum: _1m1w1y24hPattern3, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, } impl CapitulationCumulativeNegativeRawRelSumValuePattern { @@ -1434,15 +1376,15 @@ impl CapitulationCumulativeNegativeRawRelSumValuePattern { negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), raw: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_loss")), rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_rcap")), - sum: _1m1w1y24hPattern5::new(client.clone(), _m(&acc, "realized_loss")), - value_created: RawSumPattern::new(client.clone(), _m(&acc, "loss_value_created")), - value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "loss_value_destroyed")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "realized_loss_sum")), + value_created: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "loss_value_created")), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "loss_value_destroyed")), } } } /// Pattern struct for repeated tree structure. -pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { +pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2 { pub average: MetricPattern18, pub max: MetricPattern18, pub median: MetricPattern18, @@ -1453,7 +1395,7 @@ pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { pub pct90: MetricPattern18, } -impl AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { +impl AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -1522,27 +1464,27 @@ impl _1m1w1y24hBpsPercentRatioPattern { } /// Pattern struct for repeated tree structure. -pub struct CapLossMvrvNuplPriceProfitSoprPattern { - pub cap: CentsUsdPattern, - pub loss: RawSumPattern2, +pub struct CapLossMvrvNetPriceProfitSoprPattern { + pub cap: CentsDeltaUsdPattern, + pub loss: CumulativeNegativeRawSumPattern, pub mvrv: MetricPattern1, - pub nupl: BpsRatioPattern, + pub net_pnl: CumulativeRawSumPattern, pub price: BpsCentsRatioSatsUsdPattern, - pub profit: RawSumPattern2, - pub sopr: ValuePattern, + pub profit: CumulativeRawSumPattern2, + pub sopr: RatioValuePattern, } -impl CapLossMvrvNuplPriceProfitSoprPattern { +impl CapLossMvrvNetPriceProfitSoprPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - cap: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), - loss: RawSumPattern2::new(client.clone(), _m(&acc, "realized_loss")), + cap: CentsDeltaUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), + loss: CumulativeNegativeRawSumPattern::new(client.clone(), acc.clone()), mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), + net_pnl: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - profit: RawSumPattern2::new(client.clone(), _m(&acc, "realized_profit")), - sopr: ValuePattern::new(client.clone(), _m(&acc, "value")), + profit: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "realized_profit")), + sopr: RatioValuePattern::new(client.clone(), acc.clone()), } } } @@ -1553,9 +1495,9 @@ pub struct CumulativeDistributionRawRelSumValuePattern { pub distribution_flow: MetricPattern1, pub raw: CentsUsdPattern, pub rel_to_rcap: BpsPercentRatioPattern, - pub sum: _1m1w1y24hPattern5, - pub value_created: RawSumPattern, - pub value_destroyed: RawSumPattern, + pub sum: _1m1w1y24hPattern3, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, } impl CumulativeDistributionRawRelSumValuePattern { @@ -1563,37 +1505,63 @@ impl CumulativeDistributionRawRelSumValuePattern { pub fn new(client: Arc, acc: String) -> Self { Self { cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_cumulative")), - distribution_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")), + distribution_flow: MetricPattern1::new(client.clone(), _m(&acc, "distribution_flow")), raw: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_profit")), rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_rcap")), - sum: _1m1w1y24hPattern5::new(client.clone(), _m(&acc, "realized_profit")), - value_created: RawSumPattern::new(client.clone(), _m(&acc, "profit_value_created")), - value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "profit_value_destroyed")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "realized_profit_sum")), + value_created: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "profit_value_created")), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "profit_value_destroyed")), } } } /// Pattern struct for repeated tree structure. -pub struct GrossInvestedInvestorLossNetProfitSentimentPattern2 { +pub struct CumulativeNegativeRawRelSumPattern2 { + pub cumulative: MetricPattern1, + pub negative: MetricPattern1, + pub raw: CentsUsdPattern, + pub rel_to_mcap: BpsPercentRatioPattern, + pub rel_to_own_gross: BpsPercentRatioPattern, + pub rel_to_own_mcap: BpsPercentRatioPattern, + pub sum: _1m1w1y24hPattern3, +} + +impl CumulativeNegativeRawRelSumPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_cumulative")), + negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), + raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), + rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_mcap")), + rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")), + rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_mcap")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "unrealized_loss_sum")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct GrossInvestedLossNetNuplProfitSentimentPattern2 { pub gross_pnl: CentsUsdPattern, - pub invested_capital: InPattern2, - pub investor_cap: InPattern, - pub loss: NegativeRawRelSumPattern2, + pub invested_capital: InPattern, + pub loss: CumulativeNegativeRawRelSumPattern2, pub net_pnl: CentsRelUsdPattern2, - pub profit: RawRelSumPattern2, + pub nupl: BpsRatioPattern, + pub profit: CumulativeRawRelSumPattern2, pub sentiment: GreedNetPainPattern, } -impl GrossInvestedInvestorLossNetProfitSentimentPattern2 { +impl GrossInvestedLossNetNuplProfitSentimentPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), - invested_capital: InPattern2::new(client.clone(), _m(&acc, "invested_capital_in")), - investor_cap: InPattern::new(client.clone(), _m(&acc, "investor_cap_in")), - loss: NegativeRawRelSumPattern2::new(client.clone(), acc.clone()), + invested_capital: InPattern::new(client.clone(), _m(&acc, "invested_capital_in")), + loss: CumulativeNegativeRawRelSumPattern2::new(client.clone(), acc.clone()), net_pnl: CentsRelUsdPattern2::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - profit: RawRelSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + profit: CumulativeRawRelSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), sentiment: GreedNetPainPattern::new(client.clone(), acc.clone()), } } @@ -1671,11 +1639,35 @@ impl BtcCentsRelSatsUsdPattern3 { } } +/// Pattern struct for repeated tree structure. +pub struct CapLossMvrvPriceProfitSoprPattern { + pub cap: CentsUsdPattern, + pub loss: CumulativeRawSumPattern2, + pub mvrv: MetricPattern1, + pub price: BpsCentsRatioSatsUsdPattern, + pub profit: CumulativeRawSumPattern2, + pub sopr: ValuePattern, +} + +impl CapLossMvrvPriceProfitSoprPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cap: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), + loss: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "realized_loss")), + mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + profit: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "realized_profit")), + sopr: ValuePattern::new(client.clone(), _m(&acc, "value")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct ChangeCumulativeDeltaRawRelSumPattern { pub change_1m: RelPattern, pub cumulative: MetricPattern1, - pub delta: ChangeRatePattern4, + pub delta: ChangeRatePattern2, pub raw: MetricPattern1, pub rel_to_rcap: BpsPercentRatioPattern, pub sum: _1m1w1y24hPattern, @@ -1687,10 +1679,58 @@ impl ChangeCumulativeDeltaRawRelSumPattern { Self { change_1m: RelPattern::new(client.clone(), _m(&acc, "pnl_change_1m_rel_to")), cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_pnl_cumulative")), - delta: ChangeRatePattern4::new(client.clone(), _m(&acc, "pnl_delta")), + delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "pnl_delta")), raw: MetricPattern1::new(client.clone(), _m(&acc, "realized_pnl")), rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_pnl_rel_to_rcap")), - sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_pnl")), + sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_pnl_sum")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CumulativeRawRelSumPattern2 { + pub cumulative: MetricPattern1, + pub raw: CentsUsdPattern, + pub rel_to_mcap: BpsPercentRatioPattern, + pub rel_to_own_gross: BpsPercentRatioPattern, + pub rel_to_own_mcap: BpsPercentRatioPattern, + pub sum: _1m1w1y24hPattern3, +} + +impl CumulativeRawRelSumPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + raw: CentsUsdPattern::new(client.clone(), acc.clone()), + rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_mcap")), + rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_gross_pnl")), + rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_mcap")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "sum")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct DeltaHalfInRelTotalPattern { + pub delta: ChangeRatePattern, + pub half: BtcCentsSatsUsdPattern, + pub in_loss: BtcCentsRelSatsUsdPattern, + pub in_profit: BtcCentsRelSatsUsdPattern, + pub rel_to_circulating: BpsPercentRatioPattern, + pub total: BtcCentsSatsUsdPattern, +} + +impl DeltaHalfInRelTotalPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), + half: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "half")), + in_loss: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "in_loss")), + in_profit: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "in_profit")), + rel_to_circulating: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating")), + total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), } } } @@ -1719,54 +1759,6 @@ impl DeltaHalfInRelTotalPattern2 { } } -/// Pattern struct for repeated tree structure. -pub struct DeltaHalfInRelTotalPattern { - pub delta: ChangeRatePattern2, - pub half: BtcCentsSatsUsdPattern, - pub in_loss: BtcCentsRelSatsUsdPattern, - pub in_profit: BtcCentsRelSatsUsdPattern, - pub rel_to_circulating: BpsPercentRatioPattern, - pub total: BtcCentsSatsUsdPattern, -} - -impl DeltaHalfInRelTotalPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), - half: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "half")), - in_loss: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "in_loss")), - in_profit: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "in_profit")), - rel_to_circulating: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating")), - total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct NegativeRawRelSumPattern2 { - pub negative: MetricPattern1, - pub raw: CentsUsdPattern, - pub rel_to_mcap: BpsPercentRatioPattern, - pub rel_to_own_gross: BpsPercentRatioPattern, - pub rel_to_own_mcap: BpsPercentRatioPattern, - pub sum: _24hPattern, -} - -impl NegativeRawRelSumPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_mcap")), - rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")), - rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_mcap")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct Pct1Pct2Pct5Pct95Pct98Pct99Pattern { pub pct1: BpsPriceRatioPattern, @@ -1795,9 +1787,9 @@ impl Pct1Pct2Pct5Pct95Pct98Pct99Pattern { pub struct ActivityOutputsRealizedSupplyUnrealizedPattern { pub activity: CoindaysSentPattern, pub outputs: UnspentPattern2, - pub realized: CapLossMvrvNetNuplPriceProfitSoprPattern, + pub realized: CapLossMvrvNetPriceProfitSoprPattern, pub supply: DeltaHalfInRelTotalPattern, - pub unrealized: InvestedInvestorLossNetProfitPattern, + pub unrealized: LossNetNuplProfitPattern, } impl ActivityOutputsRealizedSupplyUnrealizedPattern { @@ -1806,31 +1798,31 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern { Self { activity: CoindaysSentPattern::new(client.clone(), acc.clone()), outputs: UnspentPattern2::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNetNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), + realized: CapLossMvrvNetPriceProfitSoprPattern::new(client.clone(), acc.clone()), supply: DeltaHalfInRelTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: InvestedInvestorLossNetProfitPattern::new(client.clone(), acc.clone()), + unrealized: LossNetNuplProfitPattern::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. -pub struct ActivityOutputsRealizedSupplyUnrealizedPattern2 { - pub activity: CoindaysSentPattern, - pub outputs: UnspentPattern2, - pub realized: CapLossMvrvNetNuplPriceProfitSoprPattern, - pub supply: DeltaHalfInRelTotalPattern, - pub unrealized: LossNetProfitPattern, +pub struct AddressOutputsRealizedSupplyUnrealizedPattern { + pub address_count: DeltaInnerPattern, + pub outputs: UnspentPattern, + pub realized: CapLossMvrvPriceProfitSoprPattern, + pub supply: HalfTotalPattern, + pub unrealized: NuplPattern, } -impl ActivityOutputsRealizedSupplyUnrealizedPattern2 { +impl AddressOutputsRealizedSupplyUnrealizedPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - activity: CoindaysSentPattern::new(client.clone(), acc.clone()), - outputs: UnspentPattern2::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNetNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), - supply: DeltaHalfInRelTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: LossNetProfitPattern::new(client.clone(), acc.clone()), + address_count: DeltaInnerPattern::new(client.clone(), _m(&acc, "address_count")), + outputs: UnspentPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvPriceProfitSoprPattern::new(client.clone(), acc.clone()), + supply: HalfTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: NuplPattern::new(client.clone(), _m(&acc, "nupl")), } } } @@ -1901,34 +1893,12 @@ impl BtcCentsRelSatsUsdPattern2 { } } -/// Pattern struct for repeated tree structure. -pub struct CentsDeltaRawRelUsdPattern { - pub cents: MetricPattern1, - pub delta: ChangeRatePattern4, - pub raw: MetricPattern18, - pub rel_to_own_mcap: BpsPercentRatioPattern, - pub usd: MetricPattern1, -} - -impl CentsDeltaRawRelUsdPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - delta: ChangeRatePattern4::new(client.clone(), _m(&acc, "realized_cap_delta")), - raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")), - rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_cap_rel_to_own_mcap")), - usd: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct CoindaysCoinyearsDormancySentVelocityPattern { pub coindays_destroyed: CumulativeRawSumPattern, pub coinyears_destroyed: MetricPattern1, pub dormancy: MetricPattern1, - pub sent: InRawSumPattern2, + pub sent: CumulativeInRawSumPattern, pub velocity: MetricPattern1, } @@ -1939,12 +1909,34 @@ impl CoindaysCoinyearsDormancySentVelocityPattern { coindays_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), - sent: InRawSumPattern2::new(client.clone(), _m(&acc, "sent")), + sent: CumulativeInRawSumPattern::new(client.clone(), _m(&acc, "sent")), velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), } } } +/// Pattern struct for repeated tree structure. +pub struct CumulativeInRawSumPattern { + pub cumulative: MetricPattern1, + pub in_loss: CumulativeRawSumPattern3, + pub in_profit: CumulativeRawSumPattern3, + pub raw: MetricPattern1, + pub sum: _1m1w1y24hPattern, +} + +impl CumulativeInRawSumPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + in_loss: CumulativeRawSumPattern3::new(client.clone(), _m(&acc, "in_loss")), + in_profit: CumulativeRawSumPattern3::new(client.clone(), _m(&acc, "in_profit")), + raw: MetricPattern1::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sum")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct EmaHistogramLineSignalPattern { pub ema_fast: MetricPattern1, @@ -1967,28 +1959,6 @@ impl EmaHistogramLineSignalPattern { } } -/// Pattern struct for repeated tree structure. -pub struct InvestedInvestorLossNetProfitPattern { - pub invested_capital: InPattern, - pub investor_cap: InPattern, - pub loss: NegativeRawSumPattern, - pub net_pnl: CentsUsdPattern, - pub profit: RawSumPattern2, -} - -impl InvestedInvestorLossNetProfitPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - invested_capital: InPattern::new(client.clone(), _m(&acc, "invested_capital_in")), - investor_cap: InPattern::new(client.clone(), _m(&acc, "investor_cap_in")), - loss: NegativeRawSumPattern::new(client.clone(), acc.clone()), - net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - profit: RawSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct InvestedMaxMinPercentilesSupplyPattern { pub invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, @@ -2033,28 +2003,6 @@ impl PhsReboundThsPattern { } } -/// Pattern struct for repeated tree structure. -pub struct RawRelSumPattern2 { - pub raw: CentsUsdPattern, - pub rel_to_mcap: BpsPercentRatioPattern, - pub rel_to_own_gross: BpsPercentRatioPattern, - pub rel_to_own_mcap: BpsPercentRatioPattern, - pub sum: _24hPattern, -} - -impl RawRelSumPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: CentsUsdPattern::new(client.clone(), acc.clone()), - rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_mcap")), - rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_gross_pnl")), - rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_mcap")), - sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hHeightPattern { pub _1m: MetricPattern1, @@ -2089,23 +2037,23 @@ impl _1m1w1y24hPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - _1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1m")), - _1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1w")), - _1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1y")), - _24h: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "24h")), + _1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1m_rate")), + _1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1w_rate")), + _1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1y_rate")), + _24h: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "24h_rate")), } } } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern8 { +pub struct _1m1w1y24hPattern4 { pub _1m: BtcCentsSatsUsdPattern, pub _1w: BtcCentsSatsUsdPattern, pub _1y: BtcCentsSatsUsdPattern, pub _24h: BtcCentsSatsUsdPattern, } -impl _1m1w1y24hPattern8 { +impl _1m1w1y24hPattern4 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2117,26 +2065,6 @@ impl _1m1w1y24hPattern8 { } } -/// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern5 { - pub _1m: MetricPattern1, - pub _1w: MetricPattern1, - pub _1y: MetricPattern1, - pub _24h: CentsUsdPattern, -} - -impl _1m1w1y24hPattern5 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: MetricPattern1::new(client.clone(), _m(&acc, "1m")), - _1w: MetricPattern1::new(client.clone(), _m(&acc, "1w")), - _1y: MetricPattern1::new(client.clone(), _m(&acc, "1y")), - _24h: CentsUsdPattern::new(client.clone(), _m(&acc, "24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y2wPattern { pub _1m: CentsSatsUsdPattern, @@ -2158,14 +2086,14 @@ impl _1m1w1y2wPattern { } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern4 { +pub struct _1m1w1y24hPattern3 { pub _1m: CentsUsdPattern, pub _1w: CentsUsdPattern, pub _1y: CentsUsdPattern, pub _24h: CentsUsdPattern, } -impl _1m1w1y24hPattern4 { +impl _1m1w1y24hPattern3 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2177,26 +2105,6 @@ impl _1m1w1y24hPattern4 { } } -/// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern3 { - pub _1m: MetricPattern1, - pub _1w: MetricPattern1, - pub _1y: MetricPattern1, - pub _24h: BtcCentsSatsUsdPattern, -} - -impl _1m1w1y24hPattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: MetricPattern1::new(client.clone(), _m(&acc, "1m")), - _1w: MetricPattern1::new(client.clone(), _m(&acc, "1w")), - _1y: MetricPattern1::new(client.clone(), _m(&acc, "1y")), - _24h: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1y2y4yAllPattern { pub _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern, @@ -2217,32 +2125,12 @@ impl _1y2y4yAllPattern { } } -/// Pattern struct for repeated tree structure. -pub struct AddressOutputsRealizedSupplyPattern { - pub address_count: DeltaRawPattern, - pub outputs: UnspentPattern, - pub realized: CapLossMvrvNuplPriceProfitSoprPattern, - pub supply: HalfTotalPattern, -} - -impl AddressOutputsRealizedSupplyPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - address_count: DeltaRawPattern::new(client.clone(), _m(&acc, "address_count")), - outputs: UnspentPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), - supply: HalfTotalPattern::new(client.clone(), _m(&acc, "supply")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AdjustedRatioValuePattern { pub adjusted: RatioValuePattern2, pub ratio: _1m1w1y24hPattern, - pub value_created: RawSumPattern, - pub value_destroyed: RawSumPattern, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, } impl AdjustedRatioValuePattern { @@ -2251,8 +2139,8 @@ impl AdjustedRatioValuePattern { Self { adjusted: RatioValuePattern2::new(client.clone(), acc.clone()), ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), - value_created: RawSumPattern::new(client.clone(), _m(&acc, "value_created")), - value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), + value_created: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "value_created")), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), } } } @@ -2298,21 +2186,21 @@ impl BtcCentsSatsUsdPattern { } /// Pattern struct for repeated tree structure. -pub struct CapLowerPriceUpperPattern { - pub cap: RawPattern2, - pub lower_price_band: CentsSatsUsdPattern, - pub price: BpsCentsPercentilesRatioSatsUsdPattern, - pub upper_price_band: CentsSatsUsdPattern, +pub struct CentsDeltaRelUsdPattern { + pub cents: MetricPattern1, + pub delta: ChangeRatePattern2, + pub rel_to_own_mcap: BpsPercentRatioPattern, + pub usd: MetricPattern1, } -impl CapLowerPriceUpperPattern { +impl CentsDeltaRelUsdPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - cap: RawPattern2::new(client.clone(), _m(&acc, "investor_cap_raw")), - lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")), - price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")), - upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), + rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_mcap")), + usd: MetricPattern1::new(client.clone(), acc.clone()), } } } @@ -2342,17 +2230,17 @@ pub struct CumulativeNegativeRawSumPattern { pub cumulative: MetricPattern1, pub negative: MetricPattern1, pub raw: CentsUsdPattern, - pub sum: _24hPattern, + pub sum: _1m1w1y24hPattern3, } impl CumulativeNegativeRawSumPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_cumulative")), - negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_loss")), - sum: _24hPattern::new(client.clone(), _m(&acc, "realized_loss_24h")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_cumulative")), + negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), + raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "unrealized_loss_sum")), } } } @@ -2378,41 +2266,41 @@ impl HalfInTotalPattern { } /// Pattern struct for repeated tree structure. -pub struct InRawSumPattern { - pub in_loss: RawSumPattern4, - pub in_profit: RawSumPattern4, - pub raw: MetricPattern1, - pub sum: _24hPattern2, +pub struct LossNetNuplProfitPattern { + pub loss: CumulativeNegativeRawSumPattern, + pub net_pnl: CentsUsdPattern, + pub nupl: BpsRatioPattern, + pub profit: CumulativeRawSumPattern2, } -impl InRawSumPattern { +impl LossNetNuplProfitPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - in_loss: RawSumPattern4::new(client.clone(), _m(&acc, "in_loss")), - in_profit: RawSumPattern4::new(client.clone(), _m(&acc, "in_profit")), - raw: MetricPattern1::new(client.clone(), acc.clone()), - sum: _24hPattern2::new(client.clone(), _m(&acc, "24h")), + loss: CumulativeNegativeRawSumPattern::new(client.clone(), acc.clone()), + net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + profit: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), } } } /// Pattern struct for repeated tree structure. -pub struct InRawSumPattern2 { - pub in_loss: RawSumPattern5, - pub in_profit: RawSumPattern5, - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, +pub struct OutputsRealizedSupplyUnrealizedPattern2 { + pub outputs: UnspentPattern, + pub realized: CapLossMvrvPriceProfitSoprPattern, + pub supply: HalfInTotalPattern, + pub unrealized: LossNuplProfitPattern, } -impl InRawSumPattern2 { +impl OutputsRealizedSupplyUnrealizedPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - in_loss: RawSumPattern5::new(client.clone(), _m(&acc, "in_loss")), - in_profit: RawSumPattern5::new(client.clone(), _m(&acc, "in_profit")), - raw: MetricPattern1::new(client.clone(), acc.clone()), - sum: _1m1w1y24hPattern::new(client.clone(), acc.clone()), + outputs: UnspentPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvPriceProfitSoprPattern::new(client.clone(), acc.clone()), + supply: HalfInTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: LossNuplProfitPattern::new(client.clone(), acc.clone()), } } } @@ -2420,9 +2308,9 @@ impl InRawSumPattern2 { /// Pattern struct for repeated tree structure. pub struct OutputsRealizedSupplyUnrealizedPattern { pub outputs: UnspentPattern, - pub realized: CapLossMvrvNuplPriceProfitSoprPattern, - pub supply: HalfInTotalPattern, - pub unrealized: LossProfitPattern, + pub realized: CapLossMvrvPriceProfitSoprPattern, + pub supply: HalfTotalPattern, + pub unrealized: NuplPattern, } impl OutputsRealizedSupplyUnrealizedPattern { @@ -2430,9 +2318,9 @@ impl OutputsRealizedSupplyUnrealizedPattern { pub fn new(client: Arc, acc: String) -> Self { Self { outputs: UnspentPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), - supply: HalfInTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: LossProfitPattern::new(client.clone(), _m(&acc, "unrealized")), + realized: CapLossMvrvPriceProfitSoprPattern::new(client.clone(), acc.clone()), + supply: HalfTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: NuplPattern::new(client.clone(), _m(&acc, "nupl")), } } } @@ -2457,29 +2345,11 @@ impl _1m1w1y24hPattern { } } -/// Pattern struct for repeated tree structure. -pub struct BaseCumulativeSumPattern { - pub base: BtcCentsSatsUsdPattern, - pub cumulative: BtcCentsSatsUsdPattern, - pub sum: _1m1w1y24hPattern8, -} - -impl BaseCumulativeSumPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - base: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - cumulative: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "cumulative")), - sum: _1m1w1y24hPattern8::new(client.clone(), _m(&acc, "sum")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct BlocksDominanceRewardsPattern { pub blocks_mined: CumulativeRawSumPattern, pub dominance: _1m1w1y24hBpsPercentRatioPattern, - pub rewards: BaseCumulativeSumPattern, + pub rewards: CumulativeRawSumPattern3, } impl BlocksDominanceRewardsPattern { @@ -2488,7 +2358,7 @@ impl BlocksDominanceRewardsPattern { Self { blocks_mined: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "blocks_mined")), dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance")), - rewards: BaseCumulativeSumPattern::new(client.clone(), _m(&acc, "rewards")), + rewards: CumulativeRawSumPattern3::new(client.clone(), _m(&acc, "rewards")), } } } @@ -2550,7 +2420,7 @@ impl CentsSatsUsdPattern2 { /// Pattern struct for repeated tree structure. pub struct CentsDeltaUsdPattern { pub cents: MetricPattern1, - pub delta: ChangeRatePattern3, + pub delta: ChangeRatePattern2, pub usd: MetricPattern1, } @@ -2559,25 +2429,7 @@ impl CentsDeltaUsdPattern { pub fn new(client: Arc, acc: String) -> Self { Self { cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), - delta: ChangeRatePattern3::new(client.clone(), _m(&acc, "delta")), - usd: MetricPattern1::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct CentsRawUsdPattern { - pub cents: MetricPattern1, - pub raw: MetricPattern18, - pub usd: MetricPattern1, -} - -impl CentsRawUsdPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), - raw: MetricPattern18::new(client.clone(), _m(&acc, "raw")), + delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), usd: MetricPattern1::new(client.clone(), acc.clone()), } } @@ -2601,6 +2453,24 @@ impl CentsSatsUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CumulativeRawSumPattern3 { + pub cumulative: BtcCentsSatsUsdPattern, + pub raw: BtcCentsSatsUsdPattern, + pub sum: _1m1w1y24hPattern4, +} + +impl CumulativeRawSumPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "cumulative")), + raw: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern4::new(client.clone(), _m(&acc, "sum")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CumulativeRawRelPattern { pub cumulative: MetricPattern1, @@ -2623,7 +2493,7 @@ impl CumulativeRawRelPattern { pub struct CumulativeRawSumPattern2 { pub cumulative: MetricPattern1, pub raw: CentsUsdPattern, - pub sum: _24hPattern, + pub sum: _1m1w1y24hPattern3, } impl CumulativeRawSumPattern2 { @@ -2632,7 +2502,7 @@ impl CumulativeRawSumPattern2 { Self { cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), raw: CentsUsdPattern::new(client.clone(), acc.clone()), - sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "sum")), } } } @@ -2656,55 +2526,37 @@ impl GreedNetPainPattern { } /// Pattern struct for repeated tree structure. -pub struct LossNetProfitPattern { - pub loss: NegativeRawSumPattern, - pub net_pnl: CentsUsdPattern, - pub profit: RawSumPattern2, +pub struct LossNuplProfitPattern { + pub loss: CumulativeRawSumPattern2, + pub nupl: BpsRatioPattern, + pub profit: CumulativeRawSumPattern2, } -impl LossNetProfitPattern { +impl LossNuplProfitPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - loss: NegativeRawSumPattern::new(client.clone(), acc.clone()), - net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - profit: RawSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), + loss: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "unrealized_loss")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + profit: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), } } } /// Pattern struct for repeated tree structure. -pub struct NegativeRawSumPattern { - pub negative: MetricPattern1, - pub raw: CentsUsdPattern, - pub sum: _24hPattern, +pub struct LowerPriceUpperPattern { + pub lower_price_band: CentsSatsUsdPattern, + pub price: BpsCentsPercentilesRatioSatsUsdPattern, + pub upper_price_band: CentsSatsUsdPattern, } -impl NegativeRawSumPattern { +impl LowerPriceUpperPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct OutputsRealizedSupplyPattern { - pub outputs: UnspentPattern, - pub realized: CapLossMvrvNuplPriceProfitSoprPattern, - pub supply: HalfTotalPattern, -} - -impl OutputsRealizedSupplyPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - outputs: UnspentPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), - supply: HalfTotalPattern::new(client.clone(), _m(&acc, "supply")), + lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")), + price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")), + upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")), } } } @@ -2712,8 +2564,8 @@ impl OutputsRealizedSupplyPattern { /// Pattern struct for repeated tree structure. pub struct RatioValuePattern2 { pub ratio: _1m1w1y24hPattern, - pub value_created: RawSumPattern, - pub value_destroyed: RawSumPattern, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, } impl RatioValuePattern2 { @@ -2721,52 +2573,34 @@ impl RatioValuePattern2 { pub fn new(client: Arc, acc: String) -> Self { Self { ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "asopr")), - value_created: RawSumPattern::new(client.clone(), _m(&acc, "adj_value_created")), - value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "adj_value_destroyed")), + value_created: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "adj_value_created")), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "adj_value_destroyed")), } } } /// Pattern struct for repeated tree structure. pub struct RatioValuePattern { - pub ratio: _24hPattern2, - pub value_created: RawSumPattern3, - pub value_destroyed: RawSumPattern3, + pub ratio: _24hPattern, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, } impl RatioValuePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - ratio: _24hPattern2::new(client.clone(), _m(&acc, "sopr_24h")), - value_created: RawSumPattern3::new(client.clone(), _m(&acc, "value_created")), - value_destroyed: RawSumPattern3::new(client.clone(), _m(&acc, "value_destroyed")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawSellSumPattern { - pub raw: CentsUsdPattern, - pub sell_side_risk_ratio: _1m1w1y24hPattern2, - pub sum: _1m1w1y24hPattern, -} - -impl RawSellSumPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), - sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")), - sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")), + ratio: _24hPattern::new(client.clone(), _m(&acc, "sopr_24h")), + value_created: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "value_created")), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), } } } /// Pattern struct for repeated tree structure. pub struct _6bBlockTxindexPattern { - pub _6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, - pub block: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, + pub _6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2, + pub block: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2, pub txindex: MetricPattern19, } @@ -2774,8 +2608,8 @@ impl _6bBlockTxindexPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - _6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "6b")), - block: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), acc.clone()), + _6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2::new(client.clone(), _m(&acc, "6b")), + block: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2::new(client.clone(), acc.clone()), txindex: MetricPattern19::new(client.clone(), acc.clone()), } } @@ -2794,14 +2628,14 @@ impl CumulativeRawSumPattern { Self { cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), raw: MetricPattern1::new(client.clone(), acc.clone()), - sum: _1m1w1y24hPattern::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sum")), } } } /// Pattern struct for repeated tree structure. pub struct BlocksDominancePattern { - pub blocks_mined: CumulativeRawPattern, + pub blocks_mined: CumulativeRawSumPattern, pub dominance: BpsPercentRatioPattern, } @@ -2809,7 +2643,7 @@ impl BlocksDominancePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - blocks_mined: CumulativeRawPattern::new(client.clone(), _m(&acc, "blocks_mined")), + blocks_mined: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "blocks_mined")), dominance: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance")), } } @@ -2857,95 +2691,63 @@ impl ChangeRatePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - change: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "change")), - rate: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "rate")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct ChangeRatePattern4 { - pub change: _1m1w1y24hPattern4, - pub rate: _1m1w1y24hPattern2, -} - -impl ChangeRatePattern4 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - change: _1m1w1y24hPattern4::new(client.clone(), _m(&acc, "change")), - rate: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "rate")), + change: _1m1w1y24hPattern::new(client.clone(), acc.clone()), + rate: _1m1w1y24hPattern2::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. pub struct ChangeRatePattern2 { - pub change: _1mPattern, - pub rate: _1mPattern2, + pub change: _1m1w1y24hPattern3, + pub rate: _1m1w1y24hPattern2, } impl ChangeRatePattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - change: _1mPattern::new(client.clone(), _m(&acc, "change_1m")), - rate: _1mPattern2::new(client.clone(), _m(&acc, "rate_1m")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct ChangeRatePattern3 { - pub change: _1mPattern3, - pub rate: _1mPattern2, -} - -impl ChangeRatePattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - change: _1mPattern3::new(client.clone(), _m(&acc, "change_1m")), - rate: _1mPattern2::new(client.clone(), _m(&acc, "rate_1m")), + change: _1m1w1y24hPattern3::new(client.clone(), acc.clone()), + rate: _1m1w1y24hPattern2::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. pub struct CoindaysSentPattern { - pub coindays_destroyed: RawSumPattern3, - pub sent: InRawSumPattern, + pub coindays_destroyed: CumulativeRawSumPattern, + pub sent: CumulativeInRawSumPattern, } impl CoindaysSentPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - coindays_destroyed: RawSumPattern3::new(client.clone(), _m(&acc, "coindays_destroyed")), - sent: InRawSumPattern::new(client.clone(), _m(&acc, "sent")), + coindays_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + sent: CumulativeInRawSumPattern::new(client.clone(), _m(&acc, "sent")), } } } /// Pattern struct for repeated tree structure. -pub struct DeltaRawPattern2 { +pub struct DeltaInnerPattern { pub delta: ChangeRatePattern, - pub raw: MetricPattern1, + pub inner: MetricPattern1, } -impl DeltaRawPattern2 { +impl DeltaInnerPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), - raw: MetricPattern1::new(client.clone(), acc.clone()), + inner: MetricPattern1::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. pub struct DeltaRawPattern { - pub delta: ChangeRatePattern2, + pub delta: ChangeRatePattern, pub raw: MetricPattern1, } @@ -2953,7 +2755,7 @@ impl DeltaRawPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), + delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), raw: MetricPattern1::new(client.clone(), acc.clone()), } } @@ -2975,50 +2777,18 @@ impl HalfTotalPattern { } } -/// Pattern struct for repeated tree structure. -pub struct InPattern2 { - pub in_loss: CentsRawUsdPattern, - pub in_profit: CentsRawUsdPattern, -} - -impl InPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - in_loss: CentsRawUsdPattern::new(client.clone(), _m(&acc, "loss")), - in_profit: CentsRawUsdPattern::new(client.clone(), _m(&acc, "profit")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct InPattern { - pub in_loss: RawPattern2, - pub in_profit: RawPattern2, + pub in_loss: CentsUsdPattern, + pub in_profit: CentsUsdPattern, } impl InPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - in_loss: RawPattern2::new(client.clone(), _m(&acc, "loss_raw")), - in_profit: RawPattern2::new(client.clone(), _m(&acc, "profit_raw")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct LossProfitPattern { - pub loss: RawSumPattern2, - pub profit: RawSumPattern2, -} - -impl LossProfitPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - loss: RawSumPattern2::new(client.clone(), _m(&acc, "loss")), - profit: RawSumPattern2::new(client.clone(), _m(&acc, "profit")), + in_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "loss")), + in_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "profit")), } } } @@ -3039,54 +2809,6 @@ impl PriceValuePattern { } } -/// Pattern struct for repeated tree structure. -pub struct RawSumPattern5 { - pub raw: BtcCentsSatsUsdPattern, - pub sum: _1m1w1y24hPattern3, -} - -impl RawSumPattern5 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - sum: _1m1w1y24hPattern3::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawSumPattern4 { - pub raw: BtcCentsSatsUsdPattern, - pub sum: _24hPattern3, -} - -impl RawSumPattern4 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - sum: _24hPattern3::new(client.clone(), _m(&acc, "24h")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawSumPattern2 { - pub raw: CentsUsdPattern, - pub sum: _24hPattern, -} - -impl RawSumPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: CentsUsdPattern::new(client.clone(), acc.clone()), - sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct RealizedSupplyPattern { pub realized_cap: MetricPattern1, @@ -3137,120 +2859,44 @@ impl SdSmaPattern { /// Pattern struct for repeated tree structure. pub struct ValuePattern { - pub value_created: RawSumPattern3, - pub value_destroyed: RawSumPattern3, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, } impl ValuePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - value_created: RawSumPattern3::new(client.clone(), _m(&acc, "created")), - value_destroyed: RawSumPattern3::new(client.clone(), _m(&acc, "destroyed")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct CumulativeRawPattern { - pub cumulative: MetricPattern1, - pub raw: MetricPattern1, -} - -impl CumulativeRawPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - raw: MetricPattern1::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawSumPattern { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl RawSumPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), acc.clone()), - sum: _1m1w1y24hPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawSumPattern3 { - pub raw: MetricPattern1, - pub sum: _24hPattern2, -} - -impl RawSumPattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), acc.clone()), - sum: _24hPattern2::new(client.clone(), _m(&acc, "24h")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _1mPattern2 { - pub _1m: BpsPercentRatioPattern, -} - -impl _1mPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: BpsPercentRatioPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _1mPattern3 { - pub _1m: CentsUsdPattern, -} - -impl _1mPattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: CentsUsdPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _24hPattern3 { - pub _24h: BtcCentsSatsUsdPattern, -} - -impl _24hPattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _24h: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + value_created: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "created")), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "destroyed")), } } } /// Pattern struct for repeated tree structure. pub struct _24hPattern { - pub _24h: CentsUsdPattern, + pub _24h: MetricPattern1, } impl _24hPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - _24h: CentsUsdPattern::new(client.clone(), acc.clone()), + _24h: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct NuplPattern { + pub nupl: BpsRatioPattern, +} + +impl NuplPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + nupl: BpsRatioPattern::new(client.clone(), acc.clone()), } } } @@ -3269,20 +2915,6 @@ impl UnspentPattern2 { } } -/// Pattern struct for repeated tree structure. -pub struct UnspentPattern3 { - pub unspent_count: DeltaRawPattern2, -} - -impl UnspentPattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - unspent_count: DeltaRawPattern2::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct UnspentPattern { pub unspent_count: MetricPattern1, @@ -3297,48 +2929,6 @@ impl UnspentPattern { } } -/// Pattern struct for repeated tree structure. -pub struct _1mPattern { - pub _1m: MetricPattern1, -} - -impl _1mPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: MetricPattern1::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _24hPattern2 { - pub _24h: MetricPattern1, -} - -impl _24hPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _24h: MetricPattern1::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawPattern2 { - pub raw: MetricPattern18, -} - -impl RawPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: MetricPattern18::new(client.clone(), acc.clone()), - } - } -} - // Metrics tree /// Metrics tree node. @@ -3350,7 +2940,6 @@ pub struct MetricsTree { pub addresses: MetricsTree_Addresses, pub scripts: MetricsTree_Scripts, pub mining: MetricsTree_Mining, - pub positions: MetricsTree_Positions, pub cointime: MetricsTree_Cointime, pub constants: MetricsTree_Constants, pub indexes: MetricsTree_Indexes, @@ -3358,8 +2947,8 @@ pub struct MetricsTree { pub market: MetricsTree_Market, pub pools: MetricsTree_Pools, pub prices: MetricsTree_Prices, - pub distribution: MetricsTree_Distribution, pub supply: MetricsTree_Supply, + pub cohorts: MetricsTree_Cohorts, } impl MetricsTree { @@ -3372,7 +2961,6 @@ impl MetricsTree { addresses: MetricsTree_Addresses::new(client.clone(), format!("{base_path}_addresses")), scripts: MetricsTree_Scripts::new(client.clone(), format!("{base_path}_scripts")), mining: MetricsTree_Mining::new(client.clone(), format!("{base_path}_mining")), - positions: MetricsTree_Positions::new(client.clone(), format!("{base_path}_positions")), cointime: MetricsTree_Cointime::new(client.clone(), format!("{base_path}_cointime")), constants: MetricsTree_Constants::new(client.clone(), format!("{base_path}_constants")), indexes: MetricsTree_Indexes::new(client.clone(), format!("{base_path}_indexes")), @@ -3380,8 +2968,8 @@ impl MetricsTree { market: MetricsTree_Market::new(client.clone(), format!("{base_path}_market")), pools: MetricsTree_Pools::new(client.clone(), format!("{base_path}_pools")), prices: MetricsTree_Prices::new(client.clone(), format!("{base_path}_prices")), - distribution: MetricsTree_Distribution::new(client.clone(), format!("{base_path}_distribution")), supply: MetricsTree_Supply::new(client.clone(), format!("{base_path}_supply")), + cohorts: MetricsTree_Cohorts::new(client.clone(), format!("{base_path}_cohorts")), } } } @@ -3793,9 +3381,8 @@ impl MetricsTree_Transactions_Versions { /// Metrics tree node. pub struct MetricsTree_Transactions_Volume { - pub sent_sum: _1m1w1y24hBtcCentsSatsUsdPattern, - pub received_sum: _1m1w1y24hBtcCentsSatsUsdPattern, - pub annualized: BtcCentsSatsUsdPattern, + pub sent_sum: CumulativeRawSumPattern3, + pub received_sum: CumulativeRawSumPattern3, pub tx_per_sec: MetricPattern1, pub outputs_per_sec: MetricPattern1, pub inputs_per_sec: MetricPattern1, @@ -3804,9 +3391,8 @@ pub struct MetricsTree_Transactions_Volume { impl MetricsTree_Transactions_Volume { pub fn new(client: Arc, base_path: String) -> Self { Self { - sent_sum: _1m1w1y24hBtcCentsSatsUsdPattern::new(client.clone(), "sent_sum".to_string()), - received_sum: _1m1w1y24hBtcCentsSatsUsdPattern::new(client.clone(), "received_sum".to_string()), - annualized: BtcCentsSatsUsdPattern::new(client.clone(), "annualized_volume".to_string()), + sent_sum: CumulativeRawSumPattern3::new(client.clone(), "sent_sum".to_string()), + received_sum: CumulativeRawSumPattern3::new(client.clone(), "received_sum".to_string()), tx_per_sec: MetricPattern1::new(client.clone(), "tx_per_sec".to_string()), outputs_per_sec: MetricPattern1::new(client.clone(), "outputs_per_sec".to_string()), inputs_per_sec: MetricPattern1::new(client.clone(), "inputs_per_sec".to_string()), @@ -3936,12 +3522,28 @@ impl MetricsTree_Outputs_Count { /// Metrics tree node. pub struct MetricsTree_Addresses { pub raw: MetricsTree_Addresses_Raw, + pub indexes: MetricsTree_Addresses_Indexes, + pub data: MetricsTree_Addresses_Data, + pub funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, + pub empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, + pub activity: MetricsTree_Addresses_Activity, + pub total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, + pub new: MetricsTree_Addresses_New, + pub delta: MetricsTree_Addresses_Delta, } impl MetricsTree_Addresses { pub fn new(client: Arc, base_path: String) -> Self { Self { raw: MetricsTree_Addresses_Raw::new(client.clone(), format!("{base_path}_raw")), + indexes: MetricsTree_Addresses_Indexes::new(client.clone(), format!("{base_path}_indexes")), + data: MetricsTree_Addresses_Data::new(client.clone(), format!("{base_path}_data")), + funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "address_count".to_string()), + empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "empty_address_count".to_string()), + activity: MetricsTree_Addresses_Activity::new(client.clone(), format!("{base_path}_activity")), + total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "total_address_count".to_string()), + new: MetricsTree_Addresses_New::new(client.clone(), format!("{base_path}_new")), + delta: MetricsTree_Addresses_Delta::new(client.clone(), format!("{base_path}_delta")), } } } @@ -4093,6 +3695,139 @@ impl MetricsTree_Addresses_Raw_P2a { } } +/// Metrics tree node. +pub struct MetricsTree_Addresses_Indexes { + pub p2a: MetricPattern24, + pub p2pk33: MetricPattern26, + pub p2pk65: MetricPattern27, + pub p2pkh: MetricPattern28, + pub p2sh: MetricPattern29, + pub p2tr: MetricPattern30, + pub p2wpkh: MetricPattern31, + pub p2wsh: MetricPattern32, + pub funded: MetricPattern34, + pub empty: MetricPattern35, +} + +impl MetricsTree_Addresses_Indexes { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + p2a: MetricPattern24::new(client.clone(), "anyaddressindex".to_string()), + p2pk33: MetricPattern26::new(client.clone(), "anyaddressindex".to_string()), + p2pk65: MetricPattern27::new(client.clone(), "anyaddressindex".to_string()), + p2pkh: MetricPattern28::new(client.clone(), "anyaddressindex".to_string()), + p2sh: MetricPattern29::new(client.clone(), "anyaddressindex".to_string()), + p2tr: MetricPattern30::new(client.clone(), "anyaddressindex".to_string()), + p2wpkh: MetricPattern31::new(client.clone(), "anyaddressindex".to_string()), + p2wsh: MetricPattern32::new(client.clone(), "anyaddressindex".to_string()), + funded: MetricPattern34::new(client.clone(), "funded_address_index".to_string()), + empty: MetricPattern35::new(client.clone(), "empty_address_index".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Addresses_Data { + pub funded: MetricPattern34, + pub empty: MetricPattern35, +} + +impl MetricsTree_Addresses_Data { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + funded: MetricPattern34::new(client.clone(), "fundedaddressdata".to_string()), + empty: MetricPattern35::new(client.clone(), "emptyaddressdata".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Addresses_Activity { + pub all: BothReactivatedReceivingSendingPattern, + pub p2pk65: BothReactivatedReceivingSendingPattern, + pub p2pk33: BothReactivatedReceivingSendingPattern, + pub p2pkh: BothReactivatedReceivingSendingPattern, + pub p2sh: BothReactivatedReceivingSendingPattern, + pub p2wpkh: BothReactivatedReceivingSendingPattern, + pub p2wsh: BothReactivatedReceivingSendingPattern, + pub p2tr: BothReactivatedReceivingSendingPattern, + pub p2a: BothReactivatedReceivingSendingPattern, +} + +impl MetricsTree_Addresses_Activity { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + all: BothReactivatedReceivingSendingPattern::new(client.clone(), "address_activity".to_string()), + p2pk65: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_address_activity".to_string()), + p2pk33: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_address_activity".to_string()), + p2pkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_address_activity".to_string()), + p2sh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_address_activity".to_string()), + p2wpkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_address_activity".to_string()), + p2wsh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_address_activity".to_string()), + p2tr: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_address_activity".to_string()), + p2a: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_address_activity".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Addresses_New { + pub all: CumulativeRawSumPattern, + pub p2pk65: CumulativeRawSumPattern, + pub p2pk33: CumulativeRawSumPattern, + pub p2pkh: CumulativeRawSumPattern, + pub p2sh: CumulativeRawSumPattern, + pub p2wpkh: CumulativeRawSumPattern, + pub p2wsh: CumulativeRawSumPattern, + pub p2tr: CumulativeRawSumPattern, + pub p2a: CumulativeRawSumPattern, +} + +impl MetricsTree_Addresses_New { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + all: CumulativeRawSumPattern::new(client.clone(), "new_address_count".to_string()), + p2pk65: CumulativeRawSumPattern::new(client.clone(), "p2pk65_new_address_count".to_string()), + p2pk33: CumulativeRawSumPattern::new(client.clone(), "p2pk33_new_address_count".to_string()), + p2pkh: CumulativeRawSumPattern::new(client.clone(), "p2pkh_new_address_count".to_string()), + p2sh: CumulativeRawSumPattern::new(client.clone(), "p2sh_new_address_count".to_string()), + p2wpkh: CumulativeRawSumPattern::new(client.clone(), "p2wpkh_new_address_count".to_string()), + p2wsh: CumulativeRawSumPattern::new(client.clone(), "p2wsh_new_address_count".to_string()), + p2tr: CumulativeRawSumPattern::new(client.clone(), "p2tr_new_address_count".to_string()), + p2a: CumulativeRawSumPattern::new(client.clone(), "p2a_new_address_count".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Addresses_Delta { + pub all: ChangeRatePattern, + pub p2pk65: ChangeRatePattern, + pub p2pk33: ChangeRatePattern, + pub p2pkh: ChangeRatePattern, + pub p2sh: ChangeRatePattern, + pub p2wpkh: ChangeRatePattern, + pub p2wsh: ChangeRatePattern, + pub p2tr: ChangeRatePattern, + pub p2a: ChangeRatePattern, +} + +impl MetricsTree_Addresses_Delta { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + all: ChangeRatePattern::new(client.clone(), "address_count".to_string()), + p2pk65: ChangeRatePattern::new(client.clone(), "p2pk65_address_count".to_string()), + p2pk33: ChangeRatePattern::new(client.clone(), "p2pk33_address_count".to_string()), + p2pkh: ChangeRatePattern::new(client.clone(), "p2pkh_address_count".to_string()), + p2sh: ChangeRatePattern::new(client.clone(), "p2sh_address_count".to_string()), + p2wpkh: ChangeRatePattern::new(client.clone(), "p2wpkh_address_count".to_string()), + p2wsh: ChangeRatePattern::new(client.clone(), "p2wsh_address_count".to_string()), + p2tr: ChangeRatePattern::new(client.clone(), "p2tr_address_count".to_string()), + p2a: ChangeRatePattern::new(client.clone(), "p2a_address_count".to_string()), + } + } +} + /// Metrics tree node. pub struct MetricsTree_Scripts { pub raw: MetricsTree_Scripts_Raw, @@ -4288,19 +4023,19 @@ impl MetricsTree_Mining { /// Metrics tree node. pub struct MetricsTree_Mining_Rewards { - pub coinbase: BaseCumulativeSumPattern, + pub coinbase: CumulativeRawSumPattern3, pub subsidy: MetricsTree_Mining_Rewards_Subsidy, pub fees: MetricsTree_Mining_Rewards_Fees, - pub unclaimed: BaseCumulativeSumPattern, + pub unclaimed: CumulativeRawSumPattern3, } impl MetricsTree_Mining_Rewards { pub fn new(client: Arc, base_path: String) -> Self { Self { - coinbase: BaseCumulativeSumPattern::new(client.clone(), "coinbase".to_string()), + coinbase: CumulativeRawSumPattern3::new(client.clone(), "coinbase".to_string()), subsidy: MetricsTree_Mining_Rewards_Subsidy::new(client.clone(), format!("{base_path}_subsidy")), fees: MetricsTree_Mining_Rewards_Fees::new(client.clone(), format!("{base_path}_fees")), - unclaimed: BaseCumulativeSumPattern::new(client.clone(), "unclaimed_rewards".to_string()), + unclaimed: CumulativeRawSumPattern3::new(client.clone(), "unclaimed_rewards".to_string()), } } } @@ -4328,10 +4063,11 @@ impl MetricsTree_Mining_Rewards_Subsidy { pub struct MetricsTree_Mining_Rewards_Fees { pub base: BtcCentsSatsUsdPattern, pub cumulative: BtcCentsSatsUsdPattern, - pub _24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2, - pub _1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2, - pub _1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2, - pub _1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2, + pub sum: _1m1w1y24hPattern4, + pub _24h: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, + pub _1w: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, + pub _1m: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, + pub _1y: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, pub dominance: _1m1w1y24hBpsPercentRatioPattern, pub ratio_multiple: MetricsTree_Mining_Rewards_Fees_RatioMultiple, } @@ -4341,10 +4077,11 @@ impl MetricsTree_Mining_Rewards_Fees { Self { base: BtcCentsSatsUsdPattern::new(client.clone(), "fees".to_string()), cumulative: BtcCentsSatsUsdPattern::new(client.clone(), "fees_cumulative".to_string()), - _24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_24h".to_string()), - _1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_1w".to_string()), - _1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_1m".to_string()), - _1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_1y".to_string()), + sum: _1m1w1y24hPattern4::new(client.clone(), "fees_sum".to_string()), + _24h: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), "fees_24h".to_string()), + _1w: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), "fees_1w".to_string()), + _1m: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), "fees_1m".to_string()), + _1y: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), "fees_1y".to_string()), dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "fee_dominance".to_string()), ratio_multiple: MetricsTree_Mining_Rewards_Fees_RatioMultiple::new(client.clone(), format!("{base_path}_ratio_multiple")), } @@ -4425,21 +4162,6 @@ impl MetricsTree_Mining_Hashrate_Rate_Sma { } } -/// Metrics tree node. -pub struct MetricsTree_Positions { - pub block: MetricPattern18, - pub tx: MetricPattern19, -} - -impl MetricsTree_Positions { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - block: MetricPattern18::new(client.clone(), "position".to_string()), - tx: MetricPattern19::new(client.clone(), "position".to_string()), - } - } -} - /// Metrics tree node. pub struct MetricsTree_Cointime { pub activity: MetricsTree_Cointime_Activity, @@ -4449,6 +4171,7 @@ pub struct MetricsTree_Cointime { pub prices: MetricsTree_Cointime_Prices, pub adjusted: MetricsTree_Cointime_Adjusted, pub reserve_risk: MetricsTree_Cointime_ReserveRisk, + pub coinblocks_destroyed: MetricsTree_Cointime_CoinblocksDestroyed, } impl MetricsTree_Cointime { @@ -4461,6 +4184,7 @@ impl MetricsTree_Cointime { prices: MetricsTree_Cointime_Prices::new(client.clone(), format!("{base_path}_prices")), adjusted: MetricsTree_Cointime_Adjusted::new(client.clone(), format!("{base_path}_adjusted")), reserve_risk: MetricsTree_Cointime_ReserveRisk::new(client.clone(), format!("{base_path}_reserve_risk")), + coinblocks_destroyed: MetricsTree_Cointime_CoinblocksDestroyed::new(client.clone(), format!("{base_path}_coinblocks_destroyed")), } } } @@ -4606,6 +4330,21 @@ impl MetricsTree_Cointime_ReserveRisk { } } +/// Metrics tree node. +pub struct MetricsTree_Cointime_CoinblocksDestroyed { + pub raw: MetricPattern1, + pub cumulative: MetricPattern1, +} + +impl MetricsTree_Cointime_CoinblocksDestroyed { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + raw: MetricPattern1::new(client.clone(), "coinblocks_destroyed".to_string()), + cumulative: MetricPattern1::new(client.clone(), "coinblocks_destroyed_cumulative".to_string()), + } + } +} + /// Metrics tree node. pub struct MetricsTree_Constants { pub _0: MetricPattern1, @@ -6544,398 +6283,141 @@ impl MetricsTree_Prices_Spot { } /// Metrics tree node. -pub struct MetricsTree_Distribution { - pub supply_state: MetricPattern18, - pub addresses: MetricsTree_Distribution_Addresses, - pub cohorts: MetricsTree_Distribution_Cohorts, - pub coinblocks_destroyed: CumulativeRawPattern, +pub struct MetricsTree_Supply { + pub circulating: BtcCentsSatsUsdPattern, + pub burned: MetricsTree_Supply_Burned, + pub inflation_rate: BpsPercentRatioPattern, + pub velocity: MetricsTree_Supply_Velocity, + pub market_cap: CentsDeltaUsdPattern, + pub market_minus_realized_cap_growth_rate: _1m1w1y24hPattern, + pub hodled_or_lost: BtcCentsSatsUsdPattern, + pub state: MetricPattern18, } -impl MetricsTree_Distribution { +impl MetricsTree_Supply { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply_state: MetricPattern18::new(client.clone(), "supply_state".to_string()), - addresses: MetricsTree_Distribution_Addresses::new(client.clone(), format!("{base_path}_addresses")), - cohorts: MetricsTree_Distribution_Cohorts::new(client.clone(), format!("{base_path}_cohorts")), - coinblocks_destroyed: CumulativeRawPattern::new(client.clone(), "coinblocks_destroyed".to_string()), + circulating: BtcCentsSatsUsdPattern::new(client.clone(), "circulating_supply".to_string()), + burned: MetricsTree_Supply_Burned::new(client.clone(), format!("{base_path}_burned")), + inflation_rate: BpsPercentRatioPattern::new(client.clone(), "inflation_rate".to_string()), + velocity: MetricsTree_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: BtcCentsSatsUsdPattern::new(client.clone(), "hodled_or_lost_coins".to_string()), + state: MetricPattern18::new(client.clone(), "supply_state".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses { - pub indexes: MetricsTree_Distribution_Addresses_Indexes, - pub data: MetricsTree_Distribution_Addresses_Data, - pub funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, - pub empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, - pub activity: MetricsTree_Distribution_Addresses_Activity, - pub total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, - pub new: MetricsTree_Distribution_Addresses_New, - pub delta: MetricsTree_Distribution_Addresses_Delta, +pub struct MetricsTree_Supply_Burned { + pub opreturn: CumulativeRawSumPattern3, + pub unspendable: CumulativeRawSumPattern3, } -impl MetricsTree_Distribution_Addresses { +impl MetricsTree_Supply_Burned { pub fn new(client: Arc, base_path: String) -> Self { Self { - indexes: MetricsTree_Distribution_Addresses_Indexes::new(client.clone(), format!("{base_path}_indexes")), - data: MetricsTree_Distribution_Addresses_Data::new(client.clone(), format!("{base_path}_data")), - funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "address_count".to_string()), - empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "empty_address_count".to_string()), - activity: MetricsTree_Distribution_Addresses_Activity::new(client.clone(), format!("{base_path}_activity")), - total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "total_address_count".to_string()), - new: MetricsTree_Distribution_Addresses_New::new(client.clone(), format!("{base_path}_new")), - delta: MetricsTree_Distribution_Addresses_Delta::new(client.clone(), format!("{base_path}_delta")), + opreturn: CumulativeRawSumPattern3::new(client.clone(), "opreturn_supply".to_string()), + unspendable: CumulativeRawSumPattern3::new(client.clone(), "unspendable_supply".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_Indexes { - pub p2a: MetricPattern24, - pub p2pk33: MetricPattern26, - pub p2pk65: MetricPattern27, - pub p2pkh: MetricPattern28, - pub p2sh: MetricPattern29, - pub p2tr: MetricPattern30, - pub p2wpkh: MetricPattern31, - pub p2wsh: MetricPattern32, - pub funded: MetricPattern34, - pub empty: MetricPattern35, +pub struct MetricsTree_Supply_Velocity { + pub btc: MetricPattern1, + pub usd: MetricPattern1, } -impl MetricsTree_Distribution_Addresses_Indexes { +impl MetricsTree_Supply_Velocity { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2a: MetricPattern24::new(client.clone(), "anyaddressindex".to_string()), - p2pk33: MetricPattern26::new(client.clone(), "anyaddressindex".to_string()), - p2pk65: MetricPattern27::new(client.clone(), "anyaddressindex".to_string()), - p2pkh: MetricPattern28::new(client.clone(), "anyaddressindex".to_string()), - p2sh: MetricPattern29::new(client.clone(), "anyaddressindex".to_string()), - p2tr: MetricPattern30::new(client.clone(), "anyaddressindex".to_string()), - p2wpkh: MetricPattern31::new(client.clone(), "anyaddressindex".to_string()), - p2wsh: MetricPattern32::new(client.clone(), "anyaddressindex".to_string()), - funded: MetricPattern34::new(client.clone(), "funded_address_index".to_string()), - empty: MetricPattern35::new(client.clone(), "empty_address_index".to_string()), + btc: MetricPattern1::new(client.clone(), "velocity_btc".to_string()), + usd: MetricPattern1::new(client.clone(), "velocity_usd".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_Data { - pub funded: MetricPattern34, - pub empty: MetricPattern35, +pub struct MetricsTree_Cohorts { + pub utxo: MetricsTree_Cohorts_Utxo, + pub address: MetricsTree_Cohorts_Address, } -impl MetricsTree_Distribution_Addresses_Data { +impl MetricsTree_Cohorts { pub fn new(client: Arc, base_path: String) -> Self { Self { - funded: MetricPattern34::new(client.clone(), "fundedaddressdata".to_string()), - empty: MetricPattern35::new(client.clone(), "emptyaddressdata".to_string()), + utxo: MetricsTree_Cohorts_Utxo::new(client.clone(), format!("{base_path}_utxo")), + address: MetricsTree_Cohorts_Address::new(client.clone(), format!("{base_path}_address")), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_Activity { - pub all: BothReactivatedReceivingSendingPattern, - pub p2pk65: BothReactivatedReceivingSendingPattern, - pub p2pk33: BothReactivatedReceivingSendingPattern, - pub p2pkh: BothReactivatedReceivingSendingPattern, - pub p2sh: BothReactivatedReceivingSendingPattern, - pub p2wpkh: BothReactivatedReceivingSendingPattern, - pub p2wsh: BothReactivatedReceivingSendingPattern, - pub p2tr: BothReactivatedReceivingSendingPattern, - pub p2a: BothReactivatedReceivingSendingPattern, +pub struct MetricsTree_Cohorts_Utxo { + pub all: MetricsTree_Cohorts_Utxo_All, + pub sth: MetricsTree_Cohorts_Utxo_Sth, + pub lth: MetricsTree_Cohorts_Utxo_Lth, + pub age_range: MetricsTree_Cohorts_Utxo_AgeRange, + pub under_age: MetricsTree_Cohorts_Utxo_UnderAge, + pub over_age: MetricsTree_Cohorts_Utxo_OverAge, + pub epoch: MetricsTree_Cohorts_Utxo_Epoch, + pub class: MetricsTree_Cohorts_Utxo_Class, + pub over_amount: MetricsTree_Cohorts_Utxo_OverAmount, + pub amount_range: MetricsTree_Cohorts_Utxo_AmountRange, + pub under_amount: MetricsTree_Cohorts_Utxo_UnderAmount, + pub r#type: MetricsTree_Cohorts_Utxo_Type, + pub profitability: MetricsTree_Cohorts_Utxo_Profitability, + pub matured: MetricsTree_Cohorts_Utxo_Matured, } -impl MetricsTree_Distribution_Addresses_Activity { +impl MetricsTree_Cohorts_Utxo { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: BothReactivatedReceivingSendingPattern::new(client.clone(), "address_activity".to_string()), - p2pk65: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_address_activity".to_string()), - p2pk33: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_address_activity".to_string()), - p2pkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_address_activity".to_string()), - p2sh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_address_activity".to_string()), - p2wpkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_address_activity".to_string()), - p2wsh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_address_activity".to_string()), - p2tr: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_address_activity".to_string()), - p2a: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_address_activity".to_string()), + all: MetricsTree_Cohorts_Utxo_All::new(client.clone(), format!("{base_path}_all")), + sth: MetricsTree_Cohorts_Utxo_Sth::new(client.clone(), format!("{base_path}_sth")), + lth: MetricsTree_Cohorts_Utxo_Lth::new(client.clone(), format!("{base_path}_lth")), + age_range: MetricsTree_Cohorts_Utxo_AgeRange::new(client.clone(), format!("{base_path}_age_range")), + under_age: MetricsTree_Cohorts_Utxo_UnderAge::new(client.clone(), format!("{base_path}_under_age")), + over_age: MetricsTree_Cohorts_Utxo_OverAge::new(client.clone(), format!("{base_path}_over_age")), + epoch: MetricsTree_Cohorts_Utxo_Epoch::new(client.clone(), format!("{base_path}_epoch")), + class: MetricsTree_Cohorts_Utxo_Class::new(client.clone(), format!("{base_path}_class")), + over_amount: MetricsTree_Cohorts_Utxo_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), + amount_range: MetricsTree_Cohorts_Utxo_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), + under_amount: MetricsTree_Cohorts_Utxo_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), + r#type: MetricsTree_Cohorts_Utxo_Type::new(client.clone(), format!("{base_path}_type")), + profitability: MetricsTree_Cohorts_Utxo_Profitability::new(client.clone(), format!("{base_path}_profitability")), + matured: MetricsTree_Cohorts_Utxo_Matured::new(client.clone(), format!("{base_path}_matured")), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New { - pub all: MetricsTree_Distribution_Addresses_New_All, - pub p2pk65: MetricsTree_Distribution_Addresses_New_P2pk65, - pub p2pk33: MetricsTree_Distribution_Addresses_New_P2pk33, - pub p2pkh: MetricsTree_Distribution_Addresses_New_P2pkh, - pub p2sh: MetricsTree_Distribution_Addresses_New_P2sh, - pub p2wpkh: MetricsTree_Distribution_Addresses_New_P2wpkh, - pub p2wsh: MetricsTree_Distribution_Addresses_New_P2wsh, - pub p2tr: MetricsTree_Distribution_Addresses_New_P2tr, - pub p2a: MetricsTree_Distribution_Addresses_New_P2a, -} - -impl MetricsTree_Distribution_Addresses_New { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - all: MetricsTree_Distribution_Addresses_New_All::new(client.clone(), format!("{base_path}_all")), - p2pk65: MetricsTree_Distribution_Addresses_New_P2pk65::new(client.clone(), format!("{base_path}_p2pk65")), - p2pk33: MetricsTree_Distribution_Addresses_New_P2pk33::new(client.clone(), format!("{base_path}_p2pk33")), - p2pkh: MetricsTree_Distribution_Addresses_New_P2pkh::new(client.clone(), format!("{base_path}_p2pkh")), - p2sh: MetricsTree_Distribution_Addresses_New_P2sh::new(client.clone(), format!("{base_path}_p2sh")), - p2wpkh: MetricsTree_Distribution_Addresses_New_P2wpkh::new(client.clone(), format!("{base_path}_p2wpkh")), - p2wsh: MetricsTree_Distribution_Addresses_New_P2wsh::new(client.clone(), format!("{base_path}_p2wsh")), - p2tr: MetricsTree_Distribution_Addresses_New_P2tr::new(client.clone(), format!("{base_path}_p2tr")), - p2a: MetricsTree_Distribution_Addresses_New_P2a::new(client.clone(), format!("{base_path}_p2a")), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_All { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_All { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2pk65 { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2pk65 { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2pk65_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2pk65_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2pk33 { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2pk33 { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2pk33_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2pk33_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2pkh { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2pkh { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2pkh_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2pkh_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2sh { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2sh { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2sh_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2sh_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2wpkh { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2wpkh { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2wpkh_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2wpkh_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2wsh { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2wsh { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2wsh_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2wsh_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2tr { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2tr { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2tr_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2tr_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_New_P2a { - pub raw: MetricPattern1, - pub sum: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_Addresses_New_P2a { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - raw: MetricPattern1::new(client.clone(), "p2a_new_address_count".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "p2a_new_address_count_sum".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Addresses_Delta { - pub all: ChangeRatePattern, - pub p2pk65: ChangeRatePattern, - pub p2pk33: ChangeRatePattern, - pub p2pkh: ChangeRatePattern, - pub p2sh: ChangeRatePattern, - pub p2wpkh: ChangeRatePattern, - pub p2wsh: ChangeRatePattern, - pub p2tr: ChangeRatePattern, - pub p2a: ChangeRatePattern, -} - -impl MetricsTree_Distribution_Addresses_Delta { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - all: ChangeRatePattern::new(client.clone(), "address_count".to_string()), - p2pk65: ChangeRatePattern::new(client.clone(), "p2pk65_address_count".to_string()), - p2pk33: ChangeRatePattern::new(client.clone(), "p2pk33_address_count".to_string()), - p2pkh: ChangeRatePattern::new(client.clone(), "p2pkh_address_count".to_string()), - p2sh: ChangeRatePattern::new(client.clone(), "p2sh_address_count".to_string()), - p2wpkh: ChangeRatePattern::new(client.clone(), "p2wpkh_address_count".to_string()), - p2wsh: ChangeRatePattern::new(client.clone(), "p2wsh_address_count".to_string()), - p2tr: ChangeRatePattern::new(client.clone(), "p2tr_address_count".to_string()), - p2a: ChangeRatePattern::new(client.clone(), "p2a_address_count".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts { - pub utxo: MetricsTree_Distribution_Cohorts_Utxo, - pub address: MetricsTree_Distribution_Cohorts_Address, -} - -impl MetricsTree_Distribution_Cohorts { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - utxo: MetricsTree_Distribution_Cohorts_Utxo::new(client.clone(), format!("{base_path}_utxo")), - address: MetricsTree_Distribution_Cohorts_Address::new(client.clone(), format!("{base_path}_address")), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo { - pub all: MetricsTree_Distribution_Cohorts_Utxo_All, - pub sth: MetricsTree_Distribution_Cohorts_Utxo_Sth, - pub lth: MetricsTree_Distribution_Cohorts_Utxo_Lth, - pub age_range: MetricsTree_Distribution_Cohorts_Utxo_AgeRange, - pub under_age: MetricsTree_Distribution_Cohorts_Utxo_UnderAge, - pub over_age: MetricsTree_Distribution_Cohorts_Utxo_OverAge, - pub epoch: MetricsTree_Distribution_Cohorts_Utxo_Epoch, - pub class: MetricsTree_Distribution_Cohorts_Utxo_Class, - pub over_amount: MetricsTree_Distribution_Cohorts_Utxo_OverAmount, - pub amount_range: MetricsTree_Distribution_Cohorts_Utxo_AmountRange, - pub under_amount: MetricsTree_Distribution_Cohorts_Utxo_UnderAmount, - pub r#type: MetricsTree_Distribution_Cohorts_Utxo_Type, - pub profitability: MetricsTree_Distribution_Cohorts_Utxo_Profitability, - pub matured: MetricsTree_Distribution_Cohorts_Utxo_Matured, -} - -impl MetricsTree_Distribution_Cohorts_Utxo { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - all: MetricsTree_Distribution_Cohorts_Utxo_All::new(client.clone(), format!("{base_path}_all")), - sth: MetricsTree_Distribution_Cohorts_Utxo_Sth::new(client.clone(), format!("{base_path}_sth")), - lth: MetricsTree_Distribution_Cohorts_Utxo_Lth::new(client.clone(), format!("{base_path}_lth")), - age_range: MetricsTree_Distribution_Cohorts_Utxo_AgeRange::new(client.clone(), format!("{base_path}_age_range")), - under_age: MetricsTree_Distribution_Cohorts_Utxo_UnderAge::new(client.clone(), format!("{base_path}_under_age")), - over_age: MetricsTree_Distribution_Cohorts_Utxo_OverAge::new(client.clone(), format!("{base_path}_over_age")), - epoch: MetricsTree_Distribution_Cohorts_Utxo_Epoch::new(client.clone(), format!("{base_path}_epoch")), - class: MetricsTree_Distribution_Cohorts_Utxo_Class::new(client.clone(), format!("{base_path}_class")), - over_amount: MetricsTree_Distribution_Cohorts_Utxo_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), - amount_range: MetricsTree_Distribution_Cohorts_Utxo_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), - under_amount: MetricsTree_Distribution_Cohorts_Utxo_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), - r#type: MetricsTree_Distribution_Cohorts_Utxo_Type::new(client.clone(), format!("{base_path}_type")), - profitability: MetricsTree_Distribution_Cohorts_Utxo_Profitability::new(client.clone(), format!("{base_path}_profitability")), - matured: MetricsTree_Distribution_Cohorts_Utxo_Matured::new(client.clone(), format!("{base_path}_matured")), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_All { - pub supply: MetricsTree_Distribution_Cohorts_Utxo_All_Supply, - pub outputs: UnspentPattern3, +pub struct MetricsTree_Cohorts_Utxo_All { + pub supply: MetricsTree_Cohorts_Utxo_All_Supply, + pub outputs: UnspentPattern2, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, - pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern, + pub realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern, pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, - pub unrealized: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized, + pub unrealized: MetricsTree_Cohorts_Utxo_All_Unrealized, } -impl MetricsTree_Distribution_Cohorts_Utxo_All { +impl MetricsTree_Cohorts_Utxo_All { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply: MetricsTree_Distribution_Cohorts_Utxo_All_Supply::new(client.clone(), format!("{base_path}_supply")), - outputs: UnspentPattern3::new(client.clone(), "utxo_count".to_string()), + supply: MetricsTree_Cohorts_Utxo_All_Supply::new(client.clone(), format!("{base_path}_supply")), + outputs: UnspentPattern2::new(client.clone(), "utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "".to_string()), - realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern::new(client.clone(), "".to_string()), + realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern::new(client.clone(), "".to_string()), cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "".to_string()), - unrealized: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized::new(client.clone(), format!("{base_path}_unrealized")), + unrealized: MetricsTree_Cohorts_Utxo_All_Unrealized::new(client.clone(), format!("{base_path}_unrealized")), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_All_Supply { +pub struct MetricsTree_Cohorts_Utxo_All_Supply { pub delta: ChangeRatePattern, pub in_profit: BtcCentsRelSatsUsdPattern2, pub in_loss: BtcCentsRelSatsUsdPattern2, @@ -6943,7 +6425,7 @@ pub struct MetricsTree_Distribution_Cohorts_Utxo_All_Supply { pub half: BtcCentsSatsUsdPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_All_Supply { +impl MetricsTree_Cohorts_Utxo_All_Supply { pub fn new(client: Arc, base_path: String) -> Self { Self { delta: ChangeRatePattern::new(client.clone(), "supply_delta".to_string()), @@ -6956,45 +6438,47 @@ impl MetricsTree_Distribution_Cohorts_Utxo_All_Supply { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized { +pub struct MetricsTree_Cohorts_Utxo_All_Unrealized { pub gross_pnl: CentsUsdPattern, - pub invested_capital: InPattern2, + pub invested_capital: InPattern, pub sentiment: GreedNetPainPattern, - pub investor_cap: InPattern, - pub loss: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss, - pub net_pnl: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl, - pub profit: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit, + pub loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss, + pub net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl, + pub profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit, + pub nupl: BpsRatioPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized { +impl MetricsTree_Cohorts_Utxo_All_Unrealized { pub fn new(client: Arc, base_path: String) -> Self { Self { gross_pnl: CentsUsdPattern::new(client.clone(), "unrealized_gross_pnl".to_string()), - invested_capital: InPattern2::new(client.clone(), "invested_capital_in".to_string()), + invested_capital: InPattern::new(client.clone(), "invested_capital_in".to_string()), sentiment: GreedNetPainPattern::new(client.clone(), "".to_string()), - investor_cap: InPattern::new(client.clone(), "investor_cap_in".to_string()), - loss: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), - net_pnl: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), - profit: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), + loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), + net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), + profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), + nupl: BpsRatioPattern::new(client.clone(), "nupl".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss { +pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_Loss { pub negative: MetricPattern1, pub raw: CentsUsdPattern, - pub sum: _24hPattern, + pub cumulative: MetricPattern1, + pub sum: _1m1w1y24hPattern3, pub rel_to_mcap: BpsPercentRatioPattern, pub rel_to_own_gross: BpsPercentRatioPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss { +impl MetricsTree_Cohorts_Utxo_All_Unrealized_Loss { pub fn new(client: Arc, base_path: String) -> Self { Self { negative: MetricPattern1::new(client.clone(), "neg_unrealized_loss".to_string()), raw: CentsUsdPattern::new(client.clone(), "unrealized_loss".to_string()), - sum: _24hPattern::new(client.clone(), "unrealized_loss_24h".to_string()), + cumulative: MetricPattern1::new(client.clone(), "unrealized_loss_cumulative".to_string()), + sum: _1m1w1y24hPattern3::new(client.clone(), "unrealized_loss_sum".to_string()), rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_mcap".to_string()), rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()), } @@ -7002,13 +6486,13 @@ impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl { +pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl { pub cents: MetricPattern1, pub usd: MetricPattern1, pub rel_to_own_gross: BpsPercentRatioPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl { +impl MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl { pub fn new(client: Arc, base_path: String) -> Self { Self { cents: MetricPattern1::new(client.clone(), "net_unrealized_pnl_cents".to_string()), @@ -7019,18 +6503,20 @@ impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit { +pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_Profit { pub raw: CentsUsdPattern, - pub sum: _24hPattern, + pub cumulative: MetricPattern1, + pub sum: _1m1w1y24hPattern3, pub rel_to_mcap: BpsPercentRatioPattern, pub rel_to_own_gross: BpsPercentRatioPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit { +impl MetricsTree_Cohorts_Utxo_All_Unrealized_Profit { pub fn new(client: Arc, base_path: String) -> Self { Self { raw: CentsUsdPattern::new(client.clone(), "unrealized_profit".to_string()), - sum: _24hPattern::new(client.clone(), "unrealized_profit_24h".to_string()), + cumulative: MetricPattern1::new(client.clone(), "unrealized_profit_cumulative".to_string()), + sum: _1m1w1y24hPattern3::new(client.clone(), "unrealized_profit_sum".to_string()), rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_mcap".to_string()), rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_own_gross_pnl".to_string()), } @@ -7038,105 +6524,124 @@ impl MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Sth { - pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern, +pub struct MetricsTree_Cohorts_Utxo_Sth { + pub realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern, pub supply: DeltaHalfInRelTotalPattern2, - pub outputs: UnspentPattern3, + pub outputs: UnspentPattern2, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, - pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2, + pub unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2, } -impl MetricsTree_Distribution_Cohorts_Utxo_Sth { +impl MetricsTree_Cohorts_Utxo_Sth { pub fn new(client: Arc, base_path: String) -> Self { Self { - realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern::new(client.clone(), "sth".to_string()), + realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern::new(client.clone(), "sth".to_string()), supply: DeltaHalfInRelTotalPattern2::new(client.clone(), "sth_supply".to_string()), - outputs: UnspentPattern3::new(client.clone(), "sth_utxo_count".to_string()), + outputs: UnspentPattern2::new(client.clone(), "sth_utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "sth".to_string()), cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "sth".to_string()), - unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2::new(client.clone(), "sth".to_string()), + unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2::new(client.clone(), "sth".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Lth { +pub struct MetricsTree_Cohorts_Utxo_Lth { pub supply: DeltaHalfInRelTotalPattern2, - pub outputs: UnspentPattern3, + pub outputs: UnspentPattern2, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, - pub realized: MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized, + pub realized: MetricsTree_Cohorts_Utxo_Lth_Realized, pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, - pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2, + pub unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2, } -impl MetricsTree_Distribution_Cohorts_Utxo_Lth { +impl MetricsTree_Cohorts_Utxo_Lth { pub fn new(client: Arc, base_path: String) -> Self { Self { supply: DeltaHalfInRelTotalPattern2::new(client.clone(), "lth_supply".to_string()), - outputs: UnspentPattern3::new(client.clone(), "lth_utxo_count".to_string()), + outputs: UnspentPattern2::new(client.clone(), "lth_utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "lth".to_string()), - realized: MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), + realized: MetricsTree_Cohorts_Utxo_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "lth".to_string()), - unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2::new(client.clone(), "lth".to_string()), + unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2::new(client.clone(), "lth".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized { +pub struct MetricsTree_Cohorts_Utxo_Lth_Realized { pub profit: CumulativeDistributionRawRelSumValuePattern, pub loss: CapitulationCumulativeNegativeRawRelSumValuePattern, - pub gross_pnl: RawSellSumPattern, + pub gross_pnl: CumulativeRawSumPattern2, + pub sell_side_risk_ratio: MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio, pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, - pub sopr: MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr, + pub sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr, pub peak_regret: CumulativeRawRelPattern, - pub investor: CapLowerPriceUpperPattern, + pub investor: LowerPriceUpperPattern, pub profit_to_loss_ratio: _1m1w1y24hPattern, - pub cap: CentsDeltaRawRelUsdPattern, + pub cap: CentsDeltaRelUsdPattern, pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, pub mvrv: MetricPattern1, - pub nupl: BpsRatioPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized { +impl MetricsTree_Cohorts_Utxo_Lth_Realized { pub fn new(client: Arc, base_path: String) -> Self { Self { profit: CumulativeDistributionRawRelSumValuePattern::new(client.clone(), "lth".to_string()), loss: CapitulationCumulativeNegativeRawRelSumValuePattern::new(client.clone(), "lth".to_string()), - gross_pnl: RawSellSumPattern::new(client.clone(), "lth".to_string()), + gross_pnl: CumulativeRawSumPattern2::new(client.clone(), "lth_realized_gross_pnl".to_string()), + sell_side_risk_ratio: MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio::new(client.clone(), format!("{base_path}_sell_side_risk_ratio")), net_pnl: ChangeCumulativeDeltaRawRelSumPattern::new(client.clone(), "lth_net".to_string()), - sopr: MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), + sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), peak_regret: CumulativeRawRelPattern::new(client.clone(), "lth_realized_peak_regret".to_string()), - investor: CapLowerPriceUpperPattern::new(client.clone(), "lth".to_string()), + investor: LowerPriceUpperPattern::new(client.clone(), "lth".to_string()), profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit_to_loss_ratio".to_string()), - cap: CentsDeltaRawRelUsdPattern::new(client.clone(), "lth".to_string()), + cap: CentsDeltaRelUsdPattern::new(client.clone(), "lth_realized_cap".to_string()), price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern::new(client.clone(), "lth_realized_price".to_string()), mvrv: MetricPattern1::new(client.clone(), "lth_mvrv".to_string()), - nupl: BpsRatioPattern::new(client.clone(), "lth_nupl_ratio".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr { - pub value_created: RawSumPattern, - pub value_destroyed: RawSumPattern, - pub ratio: _1m1w1y24hPattern, +pub struct MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio { + pub _24h: BpsPercentRatioPattern, + pub _1w: BpsPercentRatioPattern, + pub _1m: BpsPercentRatioPattern, + pub _1y: BpsPercentRatioPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr { +impl MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio { pub fn new(client: Arc, base_path: String) -> Self { Self { - value_created: RawSumPattern::new(client.clone(), "lth_value_created".to_string()), - value_destroyed: RawSumPattern::new(client.clone(), "lth_value_destroyed".to_string()), - ratio: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), + _24h: BpsPercentRatioPattern::new(client.clone(), "lth_sell_side_risk_ratio_24h".to_string()), + _1w: BpsPercentRatioPattern::new(client.clone(), "lth_sell_side_risk_ratio_1w".to_string()), + _1m: BpsPercentRatioPattern::new(client.clone(), "lth_sell_side_risk_ratio_1m".to_string()), + _1y: BpsPercentRatioPattern::new(client.clone(), "lth_sell_side_risk_ratio_1y".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_AgeRange { +pub struct MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr { + pub ratio: _1m1w1y24hPattern, + pub value_created: CumulativeRawSumPattern, + pub value_destroyed: CumulativeRawSumPattern, +} + +impl MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + ratio: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), + value_created: CumulativeRawSumPattern::new(client.clone(), "lth_value_created".to_string()), + value_destroyed: CumulativeRawSumPattern::new(client.clone(), "lth_value_destroyed".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Cohorts_Utxo_AgeRange { pub under_1h: ActivityOutputsRealizedSupplyUnrealizedPattern, pub _1h_to_1d: ActivityOutputsRealizedSupplyUnrealizedPattern, pub _1d_to_1w: ActivityOutputsRealizedSupplyUnrealizedPattern, @@ -7160,7 +6665,7 @@ pub struct MetricsTree_Distribution_Cohorts_Utxo_AgeRange { pub over_15y: ActivityOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_AgeRange { +impl MetricsTree_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()), @@ -7189,334 +6694,334 @@ impl MetricsTree_Distribution_Cohorts_Utxo_AgeRange { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_UnderAge { - pub _1w: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _1m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _3m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _4m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _5m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _6m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _1y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _3y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _4y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _5y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _6y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _7y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _8y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _10y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _12y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _15y: ActivityOutputsRealizedSupplyUnrealizedPattern2, +pub struct MetricsTree_Cohorts_Utxo_UnderAge { + pub _1w: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _3m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _4m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _5m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _6m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _3y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _4y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _5y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _6y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _7y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _8y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _10y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _12y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _15y: ActivityOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_UnderAge { +impl MetricsTree_Cohorts_Utxo_UnderAge { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1w: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1w_old".to_string()), - _1m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1m_old".to_string()), - _2m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_2m_old".to_string()), - _3m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_3m_old".to_string()), - _4m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_4m_old".to_string()), - _5m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_5m_old".to_string()), - _6m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_6m_old".to_string()), - _1y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1y_old".to_string()), - _2y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_2y_old".to_string()), - _3y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_3y_old".to_string()), - _4y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_4y_old".to_string()), - _5y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_5y_old".to_string()), - _6y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_6y_old".to_string()), - _7y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_7y_old".to_string()), - _8y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_8y_old".to_string()), - _10y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10y_old".to_string()), - _12y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_12y_old".to_string()), - _15y: ActivityOutputsRealizedSupplyUnrealizedPattern2::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()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_OverAge { - pub _1d: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _1w: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _1m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _3m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _4m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _5m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _6m: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _1y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _3y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _4y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _5y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _6y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _7y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _8y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _10y: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _12y: ActivityOutputsRealizedSupplyUnrealizedPattern2, +pub struct MetricsTree_Cohorts_Utxo_OverAge { + pub _1d: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1w: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _3m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _4m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _5m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _6m: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _3y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _4y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _5y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _6y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _7y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _8y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _10y: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _12y: ActivityOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_OverAge { +impl MetricsTree_Cohorts_Utxo_OverAge { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1d: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1d_old".to_string()), - _1w: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1w_old".to_string()), - _1m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1m_old".to_string()), - _2m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_2m_old".to_string()), - _3m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_3m_old".to_string()), - _4m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_4m_old".to_string()), - _5m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_5m_old".to_string()), - _6m: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_6m_old".to_string()), - _1y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1y_old".to_string()), - _2y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_2y_old".to_string()), - _3y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_3y_old".to_string()), - _4y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_4y_old".to_string()), - _5y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_5y_old".to_string()), - _6y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_6y_old".to_string()), - _7y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_7y_old".to_string()), - _8y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_8y_old".to_string()), - _10y: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10y_old".to_string()), - _12y: ActivityOutputsRealizedSupplyUnrealizedPattern2::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()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Epoch { - pub _0: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _1: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _3: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _4: ActivityOutputsRealizedSupplyUnrealizedPattern2, +pub struct MetricsTree_Cohorts_Utxo_Epoch { + pub _0: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _3: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _4: ActivityOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Epoch { +impl MetricsTree_Cohorts_Utxo_Epoch { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "epoch_0".to_string()), - _1: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "epoch_1".to_string()), - _2: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "epoch_2".to_string()), - _3: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "epoch_3".to_string()), - _4: ActivityOutputsRealizedSupplyUnrealizedPattern2::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()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Class { - pub _2009: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2010: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2011: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2012: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2013: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2014: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2015: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2016: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2017: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2018: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2019: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2020: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2021: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2022: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2023: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2024: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2025: ActivityOutputsRealizedSupplyUnrealizedPattern2, - pub _2026: ActivityOutputsRealizedSupplyUnrealizedPattern2, +pub struct MetricsTree_Cohorts_Utxo_Class { + pub _2009: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2010: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2011: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2012: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2013: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2014: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2015: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2016: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2017: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2018: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2019: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2020: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2021: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2022: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2023: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2024: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2025: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _2026: ActivityOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Class { +impl MetricsTree_Cohorts_Utxo_Class { pub fn new(client: Arc, base_path: String) -> Self { Self { - _2009: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2009".to_string()), - _2010: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2010".to_string()), - _2011: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2011".to_string()), - _2012: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2012".to_string()), - _2013: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2013".to_string()), - _2014: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2014".to_string()), - _2015: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2015".to_string()), - _2016: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2016".to_string()), - _2017: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2017".to_string()), - _2018: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2018".to_string()), - _2019: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2019".to_string()), - _2020: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2020".to_string()), - _2021: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2021".to_string()), - _2022: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2022".to_string()), - _2023: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2023".to_string()), - _2024: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2024".to_string()), - _2025: ActivityOutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "class_2025".to_string()), - _2026: ActivityOutputsRealizedSupplyUnrealizedPattern2::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()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_OverAmount { - pub _1sat: OutputsRealizedSupplyPattern, - pub _10sats: OutputsRealizedSupplyPattern, - pub _100sats: OutputsRealizedSupplyPattern, - pub _1k_sats: OutputsRealizedSupplyPattern, - pub _10k_sats: OutputsRealizedSupplyPattern, - pub _100k_sats: OutputsRealizedSupplyPattern, - pub _1m_sats: OutputsRealizedSupplyPattern, - pub _10m_sats: OutputsRealizedSupplyPattern, - pub _1btc: OutputsRealizedSupplyPattern, - pub _10btc: OutputsRealizedSupplyPattern, - pub _100btc: OutputsRealizedSupplyPattern, - pub _1k_btc: OutputsRealizedSupplyPattern, - pub _10k_btc: OutputsRealizedSupplyPattern, +pub struct MetricsTree_Cohorts_Utxo_OverAmount { + pub _1sat: OutputsRealizedSupplyUnrealizedPattern, + pub _10sats: OutputsRealizedSupplyUnrealizedPattern, + pub _100sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1btc: OutputsRealizedSupplyUnrealizedPattern, + pub _10btc: OutputsRealizedSupplyUnrealizedPattern, + pub _100btc: OutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc: OutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc: OutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_OverAmount { +impl MetricsTree_Cohorts_Utxo_OverAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1sat".to_string()), - _10sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10sats".to_string()), - _100sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100sats".to_string()), - _1k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1k_sats".to_string()), - _10k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10k_sats".to_string()), - _100k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100k_sats".to_string()), - _1m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1m_sats".to_string()), - _10m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10m_sats".to_string()), - _1btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1btc".to_string()), - _10btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10btc".to_string()), - _100btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100btc".to_string()), - _1k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1k_btc".to_string()), - _10k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10k_btc".to_string()), + _1sat: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1sat".to_string()), + _10sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10sats".to_string()), + _100sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100sats".to_string()), + _1k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1k_sats".to_string()), + _10k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10k_sats".to_string()), + _100k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100k_sats".to_string()), + _1m_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1m_sats".to_string()), + _10m_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10m_sats".to_string()), + _1btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1btc".to_string()), + _10btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10btc".to_string()), + _100btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100btc".to_string()), + _1k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1k_btc".to_string()), + _10k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10k_btc".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_AmountRange { - pub _0sats: OutputsRealizedSupplyPattern, - pub _1sat_to_10sats: OutputsRealizedSupplyPattern, - pub _10sats_to_100sats: OutputsRealizedSupplyPattern, - pub _100sats_to_1k_sats: OutputsRealizedSupplyPattern, - pub _1k_sats_to_10k_sats: OutputsRealizedSupplyPattern, - pub _10k_sats_to_100k_sats: OutputsRealizedSupplyPattern, - pub _100k_sats_to_1m_sats: OutputsRealizedSupplyPattern, - pub _1m_sats_to_10m_sats: OutputsRealizedSupplyPattern, - pub _10m_sats_to_1btc: OutputsRealizedSupplyPattern, - pub _1btc_to_10btc: OutputsRealizedSupplyPattern, - pub _10btc_to_100btc: OutputsRealizedSupplyPattern, - pub _100btc_to_1k_btc: OutputsRealizedSupplyPattern, - pub _1k_btc_to_10k_btc: OutputsRealizedSupplyPattern, - pub _10k_btc_to_100k_btc: OutputsRealizedSupplyPattern, - pub over_100k_btc: OutputsRealizedSupplyPattern, +pub struct MetricsTree_Cohorts_Utxo_AmountRange { + pub _0sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1sat_to_10sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10sats_to_100sats: OutputsRealizedSupplyUnrealizedPattern, + pub _100sats_to_1k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats_to_10k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats_to_100k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats_to_1m_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats_to_10m_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats_to_1btc: OutputsRealizedSupplyUnrealizedPattern, + pub _1btc_to_10btc: OutputsRealizedSupplyUnrealizedPattern, + pub _10btc_to_100btc: OutputsRealizedSupplyUnrealizedPattern, + pub _100btc_to_1k_btc: OutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc_to_10k_btc: OutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc_to_100k_btc: OutputsRealizedSupplyUnrealizedPattern, + pub over_100k_btc: OutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_AmountRange { +impl MetricsTree_Cohorts_Utxo_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_0sats".to_string()), - _1sat_to_10sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_1sat_to_10sats".to_string()), - _10sats_to_100sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_10sats_to_100sats".to_string()), - _100sats_to_1k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_100sats_to_1k_sats".to_string()), - _1k_sats_to_10k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_1k_sats_to_10k_sats".to_string()), - _10k_sats_to_100k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_10k_sats_to_100k_sats".to_string()), - _100k_sats_to_1m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_100k_sats_to_1m_sats".to_string()), - _1m_sats_to_10m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_1m_sats_to_10m_sats".to_string()), - _10m_sats_to_1btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_10m_sats_to_1btc".to_string()), - _1btc_to_10btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_1btc_to_10btc".to_string()), - _10btc_to_100btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_10btc_to_100btc".to_string()), - _100btc_to_1k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_100btc_to_1k_btc".to_string()), - _1k_btc_to_10k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_1k_btc_to_10k_btc".to_string()), - _10k_btc_to_100k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_10k_btc_to_100k_btc".to_string()), - over_100k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100k_btc".to_string()), + _0sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_0sats".to_string()), + _1sat_to_10sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1sat_to_10sats".to_string()), + _10sats_to_100sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10sats_to_100sats".to_string()), + _100sats_to_1k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_100sats_to_1k_sats".to_string()), + _1k_sats_to_10k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1k_sats_to_10k_sats".to_string()), + _10k_sats_to_100k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10k_sats_to_100k_sats".to_string()), + _100k_sats_to_1m_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_100k_sats_to_1m_sats".to_string()), + _1m_sats_to_10m_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1m_sats_to_10m_sats".to_string()), + _10m_sats_to_1btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10m_sats_to_1btc".to_string()), + _1btc_to_10btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1btc_to_10btc".to_string()), + _10btc_to_100btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10btc_to_100btc".to_string()), + _100btc_to_1k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_100btc_to_1k_btc".to_string()), + _1k_btc_to_10k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_1k_btc_to_10k_btc".to_string()), + _10k_btc_to_100k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_10k_btc_to_100k_btc".to_string()), + over_100k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100k_btc".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_UnderAmount { - pub _10sats: OutputsRealizedSupplyPattern, - pub _100sats: OutputsRealizedSupplyPattern, - pub _1k_sats: OutputsRealizedSupplyPattern, - pub _10k_sats: OutputsRealizedSupplyPattern, - pub _100k_sats: OutputsRealizedSupplyPattern, - pub _1m_sats: OutputsRealizedSupplyPattern, - pub _10m_sats: OutputsRealizedSupplyPattern, - pub _1btc: OutputsRealizedSupplyPattern, - pub _10btc: OutputsRealizedSupplyPattern, - pub _100btc: OutputsRealizedSupplyPattern, - pub _1k_btc: OutputsRealizedSupplyPattern, - pub _10k_btc: OutputsRealizedSupplyPattern, - pub _100k_btc: OutputsRealizedSupplyPattern, +pub struct MetricsTree_Cohorts_Utxo_UnderAmount { + pub _10sats: OutputsRealizedSupplyUnrealizedPattern, + pub _100sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats: OutputsRealizedSupplyUnrealizedPattern, + pub _1btc: OutputsRealizedSupplyUnrealizedPattern, + pub _10btc: OutputsRealizedSupplyUnrealizedPattern, + pub _100btc: OutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc: OutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc: OutputsRealizedSupplyUnrealizedPattern, + pub _100k_btc: OutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_UnderAmount { +impl MetricsTree_Cohorts_Utxo_UnderAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10sats".to_string()), - _100sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100sats".to_string()), - _1k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1k_sats".to_string()), - _10k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10k_sats".to_string()), - _100k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100k_sats".to_string()), - _1m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1m_sats".to_string()), - _10m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10m_sats".to_string()), - _1btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1btc".to_string()), - _10btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10btc".to_string()), - _100btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100btc".to_string()), - _1k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1k_btc".to_string()), - _10k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10k_btc".to_string()), - _100k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100k_btc".to_string()), + _10sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10sats".to_string()), + _100sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100sats".to_string()), + _1k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1k_sats".to_string()), + _10k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10k_sats".to_string()), + _100k_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100k_sats".to_string()), + _1m_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1m_sats".to_string()), + _10m_sats: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10m_sats".to_string()), + _1btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1btc".to_string()), + _10btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10btc".to_string()), + _100btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100btc".to_string()), + _1k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1k_btc".to_string()), + _10k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10k_btc".to_string()), + _100k_btc: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100k_btc".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Type { - pub p2pk65: OutputsRealizedSupplyUnrealizedPattern, - pub p2pk33: OutputsRealizedSupplyUnrealizedPattern, - pub p2pkh: OutputsRealizedSupplyUnrealizedPattern, - pub p2ms: OutputsRealizedSupplyUnrealizedPattern, - pub p2sh: OutputsRealizedSupplyUnrealizedPattern, - pub p2wpkh: OutputsRealizedSupplyUnrealizedPattern, - pub p2wsh: OutputsRealizedSupplyUnrealizedPattern, - pub p2tr: OutputsRealizedSupplyUnrealizedPattern, - pub p2a: OutputsRealizedSupplyUnrealizedPattern, - pub unknown: OutputsRealizedSupplyUnrealizedPattern, - pub empty: OutputsRealizedSupplyUnrealizedPattern, +pub struct MetricsTree_Cohorts_Utxo_Type { + pub p2pk65: OutputsRealizedSupplyUnrealizedPattern2, + pub p2pk33: OutputsRealizedSupplyUnrealizedPattern2, + pub p2pkh: OutputsRealizedSupplyUnrealizedPattern2, + pub p2ms: OutputsRealizedSupplyUnrealizedPattern2, + pub p2sh: OutputsRealizedSupplyUnrealizedPattern2, + pub p2wpkh: OutputsRealizedSupplyUnrealizedPattern2, + pub p2wsh: OutputsRealizedSupplyUnrealizedPattern2, + pub p2tr: OutputsRealizedSupplyUnrealizedPattern2, + pub p2a: OutputsRealizedSupplyUnrealizedPattern2, + pub unknown: OutputsRealizedSupplyUnrealizedPattern2, + pub empty: OutputsRealizedSupplyUnrealizedPattern2, } -impl MetricsTree_Distribution_Cohorts_Utxo_Type { +impl MetricsTree_Cohorts_Utxo_Type { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pk65".to_string()), - p2pk33: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pk33".to_string()), - p2pkh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pkh".to_string()), - p2ms: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2ms".to_string()), - p2sh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2sh".to_string()), - p2wpkh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2wpkh".to_string()), - p2wsh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2wsh".to_string()), - p2tr: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2tr".to_string()), - p2a: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2a".to_string()), - unknown: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "unknown_outputs".to_string()), - empty: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "empty_outputs".to_string()), + p2pk65: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2pk65".to_string()), + p2pk33: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2pk33".to_string()), + p2pkh: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2pkh".to_string()), + p2ms: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2ms".to_string()), + p2sh: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2sh".to_string()), + p2wpkh: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2wpkh".to_string()), + p2wsh: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2wsh".to_string()), + p2tr: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2tr".to_string()), + p2a: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "p2a".to_string()), + unknown: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "unknown_outputs".to_string()), + empty: OutputsRealizedSupplyUnrealizedPattern2::new(client.clone(), "empty_outputs".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability { - pub range: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range, - pub profit: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit, - pub loss: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss, +pub struct MetricsTree_Cohorts_Utxo_Profitability { + pub range: MetricsTree_Cohorts_Utxo_Profitability_Range, + pub profit: MetricsTree_Cohorts_Utxo_Profitability_Profit, + pub loss: MetricsTree_Cohorts_Utxo_Profitability_Loss, } -impl MetricsTree_Distribution_Cohorts_Utxo_Profitability { +impl MetricsTree_Cohorts_Utxo_Profitability { pub fn new(client: Arc, base_path: String) -> Self { Self { - range: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range::new(client.clone(), format!("{base_path}_range")), - profit: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit::new(client.clone(), format!("{base_path}_profit")), - loss: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss::new(client.clone(), format!("{base_path}_loss")), + range: MetricsTree_Cohorts_Utxo_Profitability_Range::new(client.clone(), format!("{base_path}_range")), + profit: MetricsTree_Cohorts_Utxo_Profitability_Profit::new(client.clone(), format!("{base_path}_profit")), + loss: MetricsTree_Cohorts_Utxo_Profitability_Loss::new(client.clone(), format!("{base_path}_loss")), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range { +pub struct MetricsTree_Cohorts_Utxo_Profitability_Range { pub over_1000pct_in_profit: RealizedSupplyPattern, pub _500pct_to_1000pct_in_profit: RealizedSupplyPattern, pub _300pct_to_500pct_in_profit: RealizedSupplyPattern, @@ -7544,7 +7049,7 @@ pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range { pub _90pct_to_100pct_in_loss: RealizedSupplyPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range { +impl MetricsTree_Cohorts_Utxo_Profitability_Range { pub fn new(client: Arc, base_path: String) -> Self { Self { over_1000pct_in_profit: RealizedSupplyPattern::new(client.clone(), "utxos_over_1000pct_in_profit".to_string()), @@ -7577,7 +7082,7 @@ impl MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit { +pub struct MetricsTree_Cohorts_Utxo_Profitability_Profit { pub breakeven: RealizedSupplyPattern, pub _10pct: RealizedSupplyPattern, pub _20pct: RealizedSupplyPattern, @@ -7594,7 +7099,7 @@ pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit { pub _500pct: RealizedSupplyPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit { +impl MetricsTree_Cohorts_Utxo_Profitability_Profit { pub fn new(client: Arc, base_path: String) -> Self { Self { breakeven: RealizedSupplyPattern::new(client.clone(), "utxos_in_profit".to_string()), @@ -7616,7 +7121,7 @@ impl MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss { +pub struct MetricsTree_Cohorts_Utxo_Profitability_Loss { pub breakeven: RealizedSupplyPattern, pub _10pct: RealizedSupplyPattern, pub _20pct: RealizedSupplyPattern, @@ -7628,7 +7133,7 @@ pub struct MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss { pub _80pct: RealizedSupplyPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss { +impl MetricsTree_Cohorts_Utxo_Profitability_Loss { pub fn new(client: Arc, base_path: String) -> Self { Self { breakeven: RealizedSupplyPattern::new(client.clone(), "utxos_in_loss".to_string()), @@ -7645,7 +7150,7 @@ impl MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Utxo_Matured { +pub struct MetricsTree_Cohorts_Utxo_Matured { pub under_1h: BtcCentsSatsUsdPattern, pub _1h_to_1d: BtcCentsSatsUsdPattern, pub _1d_to_1w: BtcCentsSatsUsdPattern, @@ -7669,7 +7174,7 @@ pub struct MetricsTree_Distribution_Cohorts_Utxo_Matured { pub over_15y: BtcCentsSatsUsdPattern, } -impl MetricsTree_Distribution_Cohorts_Utxo_Matured { +impl MetricsTree_Cohorts_Utxo_Matured { pub fn new(client: Arc, base_path: String) -> Self { Self { under_1h: BtcCentsSatsUsdPattern::new(client.clone(), "utxo_under_1h_old_matured".to_string()), @@ -7698,205 +7203,133 @@ impl MetricsTree_Distribution_Cohorts_Utxo_Matured { } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Address { - pub over_amount: MetricsTree_Distribution_Cohorts_Address_OverAmount, - pub amount_range: MetricsTree_Distribution_Cohorts_Address_AmountRange, - pub under_amount: MetricsTree_Distribution_Cohorts_Address_UnderAmount, +pub struct MetricsTree_Cohorts_Address { + pub over_amount: MetricsTree_Cohorts_Address_OverAmount, + pub amount_range: MetricsTree_Cohorts_Address_AmountRange, + pub under_amount: MetricsTree_Cohorts_Address_UnderAmount, } -impl MetricsTree_Distribution_Cohorts_Address { +impl MetricsTree_Cohorts_Address { pub fn new(client: Arc, base_path: String) -> Self { Self { - over_amount: MetricsTree_Distribution_Cohorts_Address_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), - amount_range: MetricsTree_Distribution_Cohorts_Address_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), - under_amount: MetricsTree_Distribution_Cohorts_Address_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), + over_amount: MetricsTree_Cohorts_Address_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), + amount_range: MetricsTree_Cohorts_Address_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), + under_amount: MetricsTree_Cohorts_Address_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Address_OverAmount { - pub _1sat: AddressOutputsRealizedSupplyPattern, - pub _10sats: AddressOutputsRealizedSupplyPattern, - pub _100sats: AddressOutputsRealizedSupplyPattern, - pub _1k_sats: AddressOutputsRealizedSupplyPattern, - pub _10k_sats: AddressOutputsRealizedSupplyPattern, - pub _100k_sats: AddressOutputsRealizedSupplyPattern, - pub _1m_sats: AddressOutputsRealizedSupplyPattern, - pub _10m_sats: AddressOutputsRealizedSupplyPattern, - pub _1btc: AddressOutputsRealizedSupplyPattern, - pub _10btc: AddressOutputsRealizedSupplyPattern, - pub _100btc: AddressOutputsRealizedSupplyPattern, - pub _1k_btc: AddressOutputsRealizedSupplyPattern, - pub _10k_btc: AddressOutputsRealizedSupplyPattern, +pub struct MetricsTree_Cohorts_Address_OverAmount { + pub _1sat: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Address_OverAmount { +impl MetricsTree_Cohorts_Address_OverAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1sat".to_string()), - _10sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10sats".to_string()), - _100sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100sats".to_string()), - _1k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), - _10k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), - _100k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), - _1m_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), - _10m_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), - _1btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1btc".to_string()), - _10btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10btc".to_string()), - _100btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100btc".to_string()), - _1k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), - _10k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), + _1sat: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1sat".to_string()), + _10sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10sats".to_string()), + _100sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100sats".to_string()), + _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), + _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), + _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), + _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), + _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), + _1btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1btc".to_string()), + _10btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10btc".to_string()), + _100btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100btc".to_string()), + _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), + _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Address_AmountRange { - pub _0sats: AddressOutputsRealizedSupplyPattern, - pub _1sat_to_10sats: AddressOutputsRealizedSupplyPattern, - pub _10sats_to_100sats: AddressOutputsRealizedSupplyPattern, - pub _100sats_to_1k_sats: AddressOutputsRealizedSupplyPattern, - pub _1k_sats_to_10k_sats: AddressOutputsRealizedSupplyPattern, - pub _10k_sats_to_100k_sats: AddressOutputsRealizedSupplyPattern, - pub _100k_sats_to_1m_sats: AddressOutputsRealizedSupplyPattern, - pub _1m_sats_to_10m_sats: AddressOutputsRealizedSupplyPattern, - pub _10m_sats_to_1btc: AddressOutputsRealizedSupplyPattern, - pub _1btc_to_10btc: AddressOutputsRealizedSupplyPattern, - pub _10btc_to_100btc: AddressOutputsRealizedSupplyPattern, - pub _100btc_to_1k_btc: AddressOutputsRealizedSupplyPattern, - pub _1k_btc_to_10k_btc: AddressOutputsRealizedSupplyPattern, - pub _10k_btc_to_100k_btc: AddressOutputsRealizedSupplyPattern, - pub over_100k_btc: AddressOutputsRealizedSupplyPattern, +pub struct MetricsTree_Cohorts_Address_AmountRange { + pub _0sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1sat_to_10sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10sats_to_100sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100sats_to_1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats_to_10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats_to_100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats_to_1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats_to_10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats_to_1btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1btc_to_10btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10btc_to_100btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100btc_to_1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc_to_10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc_to_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub over_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Address_AmountRange { +impl MetricsTree_Cohorts_Address_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_0sats".to_string()), - _1sat_to_10sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_1sat_to_10sats".to_string()), - _10sats_to_100sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_10sats_to_100sats".to_string()), - _100sats_to_1k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_100sats_to_1k_sats".to_string()), - _1k_sats_to_10k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_1k_sats_to_10k_sats".to_string()), - _10k_sats_to_100k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_10k_sats_to_100k_sats".to_string()), - _100k_sats_to_1m_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_100k_sats_to_1m_sats".to_string()), - _1m_sats_to_10m_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_1m_sats_to_10m_sats".to_string()), - _10m_sats_to_1btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_10m_sats_to_1btc".to_string()), - _1btc_to_10btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_1btc_to_10btc".to_string()), - _10btc_to_100btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_10btc_to_100btc".to_string()), - _100btc_to_1k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_100btc_to_1k_btc".to_string()), - _1k_btc_to_10k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_1k_btc_to_10k_btc".to_string()), - _10k_btc_to_100k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_10k_btc_to_100k_btc".to_string()), - over_100k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100k_btc".to_string()), + _0sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_0sats".to_string()), + _1sat_to_10sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1sat_to_10sats".to_string()), + _10sats_to_100sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10sats_to_100sats".to_string()), + _100sats_to_1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100sats_to_1k_sats".to_string()), + _1k_sats_to_10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_sats_to_10k_sats".to_string()), + _10k_sats_to_100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_sats_to_100k_sats".to_string()), + _100k_sats_to_1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100k_sats_to_1m_sats".to_string()), + _1m_sats_to_10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1m_sats_to_10m_sats".to_string()), + _10m_sats_to_1btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10m_sats_to_1btc".to_string()), + _1btc_to_10btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1btc_to_10btc".to_string()), + _10btc_to_100btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10btc_to_100btc".to_string()), + _100btc_to_1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100btc_to_1k_btc".to_string()), + _1k_btc_to_10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_btc_to_10k_btc".to_string()), + _10k_btc_to_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_btc_to_100k_btc".to_string()), + over_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_btc".to_string()), } } } /// Metrics tree node. -pub struct MetricsTree_Distribution_Cohorts_Address_UnderAmount { - pub _10sats: AddressOutputsRealizedSupplyPattern, - pub _100sats: AddressOutputsRealizedSupplyPattern, - pub _1k_sats: AddressOutputsRealizedSupplyPattern, - pub _10k_sats: AddressOutputsRealizedSupplyPattern, - pub _100k_sats: AddressOutputsRealizedSupplyPattern, - pub _1m_sats: AddressOutputsRealizedSupplyPattern, - pub _10m_sats: AddressOutputsRealizedSupplyPattern, - pub _1btc: AddressOutputsRealizedSupplyPattern, - pub _10btc: AddressOutputsRealizedSupplyPattern, - pub _100btc: AddressOutputsRealizedSupplyPattern, - pub _1k_btc: AddressOutputsRealizedSupplyPattern, - pub _10k_btc: AddressOutputsRealizedSupplyPattern, - pub _100k_btc: AddressOutputsRealizedSupplyPattern, +pub struct MetricsTree_Cohorts_Address_UnderAmount { + pub _10sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, + pub _100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, } -impl MetricsTree_Distribution_Cohorts_Address_UnderAmount { +impl MetricsTree_Cohorts_Address_UnderAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10sats".to_string()), - _100sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100sats".to_string()), - _1k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), - _10k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), - _100k_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), - _1m_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), - _10m_sats: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), - _1btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1btc".to_string()), - _10btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10btc".to_string()), - _100btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100btc".to_string()), - _1k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), - _10k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), - _100k_btc: AddressOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Supply { - pub circulating: BtcCentsSatsUsdPattern, - pub burned: MetricsTree_Supply_Burned, - pub inflation_rate: BpsPercentRatioPattern, - pub velocity: MetricsTree_Supply_Velocity, - pub market_cap: MetricsTree_Supply_MarketCap, - pub market_minus_realized_cap_growth_rate: _1m1w1y24hPattern, - pub hodled_or_lost: BtcCentsSatsUsdPattern, -} - -impl MetricsTree_Supply { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - circulating: BtcCentsSatsUsdPattern::new(client.clone(), "circulating_supply".to_string()), - burned: MetricsTree_Supply_Burned::new(client.clone(), format!("{base_path}_burned")), - inflation_rate: BpsPercentRatioPattern::new(client.clone(), "inflation_rate".to_string()), - velocity: MetricsTree_Supply_Velocity::new(client.clone(), format!("{base_path}_velocity")), - market_cap: MetricsTree_Supply_MarketCap::new(client.clone(), format!("{base_path}_market_cap")), - market_minus_realized_cap_growth_rate: _1m1w1y24hPattern::new(client.clone(), "market_minus_realized_cap_growth_rate".to_string()), - hodled_or_lost: BtcCentsSatsUsdPattern::new(client.clone(), "hodled_or_lost_coins".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Supply_Burned { - pub opreturn: BaseCumulativeSumPattern, - pub unspendable: BaseCumulativeSumPattern, -} - -impl MetricsTree_Supply_Burned { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - opreturn: BaseCumulativeSumPattern::new(client.clone(), "opreturn_supply".to_string()), - unspendable: BaseCumulativeSumPattern::new(client.clone(), "unspendable_supply".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Supply_Velocity { - pub btc: MetricPattern1, - pub usd: MetricPattern1, -} - -impl MetricsTree_Supply_Velocity { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - btc: MetricPattern1::new(client.clone(), "velocity_btc".to_string()), - usd: MetricPattern1::new(client.clone(), "velocity_usd".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Supply_MarketCap { - pub cents: MetricPattern1, - pub usd: MetricPattern1, - pub delta: ChangeRatePattern4, -} - -impl MetricsTree_Supply_MarketCap { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - cents: MetricPattern1::new(client.clone(), "market_cap_cents".to_string()), - usd: MetricPattern1::new(client.clone(), "market_cap".to_string()), - delta: ChangeRatePattern4::new(client.clone(), "market_cap_delta".to_string()), + _10sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10sats".to_string()), + _100sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100sats".to_string()), + _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), + _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), + _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), + _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), + _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), + _1btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1btc".to_string()), + _10btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10btc".to_string()), + _100btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100btc".to_string()), + _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), + _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), + _100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), } } } diff --git a/crates/brk_cohort/src/by_address_type.rs b/crates/brk_cohort/src/by_address_type.rs index 71f62ce8d..4b449d20e 100644 --- a/crates/brk_cohort/src/by_address_type.rs +++ b/crates/brk_cohort/src/by_address_type.rs @@ -61,6 +61,19 @@ impl ByAddressType { }) } + pub fn map_with_name(&self, f: impl Fn(&'static str, &T) -> U) -> ByAddressType { + ByAddressType { + p2pk65: f(P2PK65, &self.p2pk65), + p2pk33: f(P2PK33, &self.p2pk33), + p2pkh: f(P2PKH, &self.p2pkh), + p2sh: f(P2SH, &self.p2sh), + p2wpkh: f(P2WPKH, &self.p2wpkh), + p2wsh: f(P2WSH, &self.p2wsh), + p2tr: f(P2TR, &self.p2tr), + p2a: f(P2A, &self.p2a), + } + } + pub fn new_with_index(f: F) -> Result where F: Fn(usize) -> Result, diff --git a/crates/brk_computer/src/blocks/compute.rs b/crates/brk_computer/src/blocks/compute.rs index cfa8a7ae3..65a4bc474 100644 --- a/crates/brk_computer/src/blocks/compute.rs +++ b/crates/brk_computer/src/blocks/compute.rs @@ -21,9 +21,9 @@ impl Vecs { self.lookback .compute(&self.time, starting_indexes, exit)?; self.count - .compute(indexer, &self.lookback, starting_indexes, exit)?; + .compute(indexer, starting_indexes, exit)?; self.interval - .compute(indexer, &self.lookback, starting_indexes, exit)?; + .compute(indexer, starting_indexes, exit)?; self.size .compute(indexer, &self.lookback, starting_indexes, exit)?; self.weight diff --git a/crates/brk_computer/src/blocks/count/compute.rs b/crates/brk_computer/src/blocks/count/compute.rs index 6126327cf..0b5a99dd6 100644 --- a/crates/brk_computer/src/blocks/count/compute.rs +++ b/crates/brk_computer/src/blocks/count/compute.rs @@ -5,13 +5,10 @@ use vecdb::Exit; use super::Vecs; -use crate::blocks::lookback; - impl Vecs { pub(crate) fn compute( &mut self, indexer: &Indexer, - lookback: &lookback::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { @@ -22,20 +19,7 @@ impl Vecs { |h| (h, StoredU32::from(1_u32)), exit, )?; - self.total.cumulative.height.compute_cumulative( - starting_indexes.height, - &self.total.raw.height, - exit, - )?; - - // Rolling window block counts - let ws = lookback.window_starts(); - self.total.sum.compute_rolling_sum( - starting_indexes.height, - &ws, - &self.total.raw.height, - exit, - )?; + self.total.compute_rest(starting_indexes.height, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/blocks/count/import.rs b/crates/brk_computer/src/blocks/count/import.rs index 8dde092b0..6ce2c4a4a 100644 --- a/crates/brk_computer/src/blocks/count/import.rs +++ b/crates/brk_computer/src/blocks/count/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{BlockCountTarget, ComputedPerBlockCumulativeSum, ConstantVecs}, + internal::{BlockCountTarget, CachedWindowStarts, ComputedPerBlockCumulativeWithSums, ConstantVecs}, }; impl Vecs { @@ -13,6 +13,7 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { target: ConstantVecs::new::( @@ -20,11 +21,12 @@ impl Vecs { version, indexes, ), - total: ComputedPerBlockCumulativeSum::forced_import( + total: ComputedPerBlockCumulativeWithSums::forced_import( db, "block_count", version, indexes, + cached_starts, )?, }) } diff --git a/crates/brk_computer/src/blocks/count/vecs.rs b/crates/brk_computer/src/blocks/count/vecs.rs index 3e4606d3a..b3b6a94a9 100644 --- a/crates/brk_computer/src/blocks/count/vecs.rs +++ b/crates/brk_computer/src/blocks/count/vecs.rs @@ -2,10 +2,10 @@ use brk_traversable::Traversable; use brk_types::{StoredU32, StoredU64}; use vecdb::{Rw, StorageMode}; -use crate::internal::{ComputedPerBlockCumulativeSum, ConstantVecs}; +use crate::internal::{ComputedPerBlockCumulativeWithSums, ConstantVecs}; #[derive(Traversable)] pub struct Vecs { pub target: ConstantVecs, - pub total: ComputedPerBlockCumulativeSum, + pub total: ComputedPerBlockCumulativeWithSums, } diff --git a/crates/brk_computer/src/blocks/import.rs b/crates/brk_computer/src/blocks/import.rs index 3d8989fb6..103767fa1 100644 --- a/crates/brk_computer/src/blocks/import.rs +++ b/crates/brk_computer/src/blocks/import.rs @@ -24,11 +24,12 @@ impl Vecs { let db = open_db(parent_path, super::DB_NAME, 50_000_000)?; let version = parent_version; - let count = CountVecs::forced_import(&db, version, indexes)?; let lookback = LookbackVecs::forced_import(&db, version)?; - let interval = IntervalVecs::forced_import(&db, version, indexes)?; - let size = SizeVecs::forced_import(&db, version, indexes)?; - let weight = WeightVecs::forced_import(&db, version, indexes)?; + let cached_starts = &lookback.cached_window_starts; + let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?; + let interval = IntervalVecs::forced_import(&db, version, indexes, cached_starts)?; + let size = SizeVecs::forced_import(&db, version, indexes, cached_starts)?; + let weight = WeightVecs::forced_import(&db, version, indexes, cached_starts)?; let time = TimeVecs::forced_import(&db, version, indexes)?; let difficulty = DifficultyVecs::forced_import(&db, version, indexer, indexes)?; let halving = HalvingVecs::forced_import(&db, version, indexes)?; diff --git a/crates/brk_computer/src/blocks/interval/compute.rs b/crates/brk_computer/src/blocks/interval/compute.rs index 2dcb6f1ab..38eee6f76 100644 --- a/crates/brk_computer/src/blocks/interval/compute.rs +++ b/crates/brk_computer/src/blocks/interval/compute.rs @@ -4,20 +4,17 @@ use brk_types::{CheckedSub, Indexes, Timestamp}; use vecdb::{Exit, ReadableVec}; use super::Vecs; -use crate::blocks; impl Vecs { pub(crate) fn compute( &mut self, indexer: &Indexer, - lookback: &blocks::LookbackVecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { let mut prev_timestamp = None; - let window_starts = lookback.window_starts(); self.0 - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_transform( starting_indexes.height, &indexer.vecs.blocks.timestamp, diff --git a/crates/brk_computer/src/blocks/interval/import.rs b/crates/brk_computer/src/blocks/interval/import.rs index c7e2816df..660efe06c 100644 --- a/crates/brk_computer/src/blocks/interval/import.rs +++ b/crates/brk_computer/src/blocks/interval/import.rs @@ -3,19 +3,21 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::ComputedPerBlockRollingAverage}; +use crate::{indexes, internal::{CachedWindowStarts, ComputedPerBlockRollingAverage}}; impl Vecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let interval = ComputedPerBlockRollingAverage::forced_import( db, "block_interval", version, indexes, + cached_starts, )?; Ok(Self(interval)) diff --git a/crates/brk_computer/src/blocks/lookback.rs b/crates/brk_computer/src/blocks/lookback.rs index e3f37f714..d4c20bc37 100644 --- a/crates/brk_computer/src/blocks/lookback.rs +++ b/crates/brk_computer/src/blocks/lookback.rs @@ -1,14 +1,16 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Indexes, Timestamp, Version}; -use vecdb::{AnyVec, 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::internal::WindowStarts; +use crate::internal::{CachedWindowStarts, Windows, WindowStarts}; use super::time; #[derive(Traversable)] pub struct Vecs { + #[traversable(skip)] + pub cached_window_starts: CachedWindowStarts, pub _1h: M::Stored>>, pub _24h: M::Stored>>, // 1d pub _3d: M::Stored>>, @@ -56,50 +58,63 @@ pub struct Vecs { impl Vecs { pub(crate) fn forced_import(db: &Database, version: Version) -> Result { + let _1h = ImportableVec::forced_import(db, "height_1h_ago", version)?; + let _24h = ImportableVec::forced_import(db, "height_24h_ago", version)?; + let _3d = ImportableVec::forced_import(db, "height_3d_ago", version)?; + let _1w = ImportableVec::forced_import(db, "height_1w_ago", version)?; + let _8d = ImportableVec::forced_import(db, "height_8d_ago", version)?; + let _9d = ImportableVec::forced_import(db, "height_9d_ago", version)?; + let _12d = ImportableVec::forced_import(db, "height_12d_ago", version)?; + let _13d = ImportableVec::forced_import(db, "height_13d_ago", version)?; + let _2w = ImportableVec::forced_import(db, "height_2w_ago", version)?; + let _21d = ImportableVec::forced_import(db, "height_21d_ago", version)?; + let _26d = ImportableVec::forced_import(db, "height_26d_ago", version)?; + let _1m = ImportableVec::forced_import(db, "height_1m_ago", version)?; + let _34d = ImportableVec::forced_import(db, "height_34d_ago", version)?; + let _55d = ImportableVec::forced_import(db, "height_55d_ago", version)?; + let _2m = ImportableVec::forced_import(db, "height_2m_ago", version)?; + let _9w = ImportableVec::forced_import(db, "height_9w_ago", version)?; + let _12w = ImportableVec::forced_import(db, "height_12w_ago", version)?; + let _89d = ImportableVec::forced_import(db, "height_89d_ago", version)?; + let _3m = ImportableVec::forced_import(db, "height_3m_ago", version)?; + let _14w = ImportableVec::forced_import(db, "height_14w_ago", version)?; + let _111d = ImportableVec::forced_import(db, "height_111d_ago", version)?; + let _144d = ImportableVec::forced_import(db, "height_144d_ago", version)?; + let _6m = ImportableVec::forced_import(db, "height_6m_ago", version)?; + let _26w = ImportableVec::forced_import(db, "height_26w_ago", version)?; + let _200d = ImportableVec::forced_import(db, "height_200d_ago", version)?; + let _9m = ImportableVec::forced_import(db, "height_9m_ago", version)?; + let _350d = ImportableVec::forced_import(db, "height_350d_ago", version)?; + let _12m = ImportableVec::forced_import(db, "height_12m_ago", version)?; + let _1y = ImportableVec::forced_import(db, "height_1y_ago", version)?; + let _14m = ImportableVec::forced_import(db, "height_14m_ago", version)?; + let _2y = ImportableVec::forced_import(db, "height_2y_ago", version)?; + let _26m = ImportableVec::forced_import(db, "height_26m_ago", version)?; + let _3y = ImportableVec::forced_import(db, "height_3y_ago", version)?; + let _200w = ImportableVec::forced_import(db, "height_200w_ago", version)?; + let _4y = ImportableVec::forced_import(db, "height_4y_ago", version)?; + let _5y = ImportableVec::forced_import(db, "height_5y_ago", version)?; + let _6y = ImportableVec::forced_import(db, "height_6y_ago", version)?; + let _8y = ImportableVec::forced_import(db, "height_8y_ago", version)?; + let _9y = ImportableVec::forced_import(db, "height_9y_ago", version)?; + let _10y = ImportableVec::forced_import(db, "height_10y_ago", version)?; + let _12y = ImportableVec::forced_import(db, "height_12y_ago", version)?; + let _14y = ImportableVec::forced_import(db, "height_14y_ago", version)?; + let _26y = ImportableVec::forced_import(db, "height_26y_ago", version)?; + + let cached_window_starts = CachedWindowStarts(Windows { + _24h: CachedVec::new(&_24h), + _1w: CachedVec::new(&_1w), + _1m: CachedVec::new(&_1m), + _1y: CachedVec::new(&_1y), + }); + Ok(Self { - _1h: ImportableVec::forced_import(db, "height_1h_ago", version)?, - _24h: ImportableVec::forced_import(db, "height_24h_ago", version)?, - _3d: ImportableVec::forced_import(db, "height_3d_ago", version)?, - _1w: ImportableVec::forced_import(db, "height_1w_ago", version)?, - _8d: ImportableVec::forced_import(db, "height_8d_ago", version)?, - _9d: ImportableVec::forced_import(db, "height_9d_ago", version)?, - _12d: ImportableVec::forced_import(db, "height_12d_ago", version)?, - _13d: ImportableVec::forced_import(db, "height_13d_ago", version)?, - _2w: ImportableVec::forced_import(db, "height_2w_ago", version)?, - _21d: ImportableVec::forced_import(db, "height_21d_ago", version)?, - _26d: ImportableVec::forced_import(db, "height_26d_ago", version)?, - _1m: ImportableVec::forced_import(db, "height_1m_ago", version)?, - _34d: ImportableVec::forced_import(db, "height_34d_ago", version)?, - _55d: ImportableVec::forced_import(db, "height_55d_ago", version)?, - _2m: ImportableVec::forced_import(db, "height_2m_ago", version)?, - _9w: ImportableVec::forced_import(db, "height_9w_ago", version)?, - _12w: ImportableVec::forced_import(db, "height_12w_ago", version)?, - _89d: ImportableVec::forced_import(db, "height_89d_ago", version)?, - _3m: ImportableVec::forced_import(db, "height_3m_ago", version)?, - _14w: ImportableVec::forced_import(db, "height_14w_ago", version)?, - _111d: ImportableVec::forced_import(db, "height_111d_ago", version)?, - _144d: ImportableVec::forced_import(db, "height_144d_ago", version)?, - _6m: ImportableVec::forced_import(db, "height_6m_ago", version)?, - _26w: ImportableVec::forced_import(db, "height_26w_ago", version)?, - _200d: ImportableVec::forced_import(db, "height_200d_ago", version)?, - _9m: ImportableVec::forced_import(db, "height_9m_ago", version)?, - _350d: ImportableVec::forced_import(db, "height_350d_ago", version)?, - _12m: ImportableVec::forced_import(db, "height_12m_ago", version)?, - _1y: ImportableVec::forced_import(db, "height_1y_ago", version)?, - _14m: ImportableVec::forced_import(db, "height_14m_ago", version)?, - _2y: ImportableVec::forced_import(db, "height_2y_ago", version)?, - _26m: ImportableVec::forced_import(db, "height_26m_ago", version)?, - _3y: ImportableVec::forced_import(db, "height_3y_ago", version)?, - _200w: ImportableVec::forced_import(db, "height_200w_ago", version)?, - _4y: ImportableVec::forced_import(db, "height_4y_ago", version)?, - _5y: ImportableVec::forced_import(db, "height_5y_ago", version)?, - _6y: ImportableVec::forced_import(db, "height_6y_ago", version)?, - _8y: ImportableVec::forced_import(db, "height_8y_ago", version)?, - _9y: ImportableVec::forced_import(db, "height_9y_ago", version)?, - _10y: ImportableVec::forced_import(db, "height_10y_ago", version)?, - _12y: ImportableVec::forced_import(db, "height_12y_ago", version)?, - _14y: ImportableVec::forced_import(db, "height_14y_ago", version)?, - _26y: ImportableVec::forced_import(db, "height_26y_ago", version)?, + 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, }) } @@ -112,6 +127,7 @@ impl Vecs { } } + pub fn start_vec(&self, days: usize) -> &EagerVec> { match days { 1 => &self._24h, diff --git a/crates/brk_computer/src/blocks/size/import.rs b/crates/brk_computer/src/blocks/size/import.rs index 6407b1ddb..8b962682b 100644 --- a/crates/brk_computer/src/blocks/size/import.rs +++ b/crates/brk_computer/src/blocks/size/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{ComputedPerBlockFull, ResolutionsFull}, + internal::{CachedWindowStarts, ComputedPerBlockFull, ResolutionsFull}, }; impl Vecs { @@ -13,10 +13,23 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - vbytes: ComputedPerBlockFull::forced_import(db, "block_vbytes", version, indexes)?, - size: ResolutionsFull::forced_import(db, "block_size", version, indexes)?, + vbytes: ComputedPerBlockFull::forced_import( + db, + "block_vbytes", + version, + indexes, + cached_starts, + )?, + size: ResolutionsFull::forced_import( + db, + "block_size", + version, + indexes, + cached_starts, + )?, }) } } diff --git a/crates/brk_computer/src/blocks/weight/compute.rs b/crates/brk_computer/src/blocks/weight/compute.rs index 2741a57e0..87b288521 100644 --- a/crates/brk_computer/src/blocks/weight/compute.rs +++ b/crates/brk_computer/src/blocks/weight/compute.rs @@ -24,7 +24,7 @@ impl Vecs { )?; self.fullness - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_transform( starting_indexes.height, &indexer.vecs.blocks.weight, diff --git a/crates/brk_computer/src/blocks/weight/import.rs b/crates/brk_computer/src/blocks/weight/import.rs index 0ba81ef55..b60d532b0 100644 --- a/crates/brk_computer/src/blocks/weight/import.rs +++ b/crates/brk_computer/src/blocks/weight/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{ResolutionsFull, PercentPerBlockRollingAverage}, + internal::{CachedWindowStarts, ResolutionsFull, PercentPerBlockRollingAverage}, }; impl Vecs { @@ -13,15 +13,17 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let weight = - ResolutionsFull::forced_import(db, "block_weight", version, indexes)?; + ResolutionsFull::forced_import(db, "block_weight", version, indexes, cached_starts)?; let fullness = PercentPerBlockRollingAverage::forced_import( db, "block_fullness", version, indexes, + cached_starts, )?; Ok(Self { weight, fullness }) diff --git a/crates/brk_computer/src/cointime/activity/compute.rs b/crates/brk_computer/src/cointime/activity/compute.rs index 9b20e8a1a..06d22f8c9 100644 --- a/crates/brk_computer/src/cointime/activity/compute.rs +++ b/crates/brk_computer/src/cointime/activity/compute.rs @@ -3,23 +3,20 @@ use brk_types::{Bitcoin, CheckedSub, Indexes, StoredF64}; use vecdb::Exit; use super::Vecs; -use crate::{blocks, distribution}; +use crate::distribution; impl Vecs { pub(crate) fn compute( &mut self, starting_indexes: &Indexes, - blocks: &blocks::Vecs, distribution: &distribution::Vecs, exit: &Exit, ) -> Result<()> { - let window_starts = blocks.lookback.window_starts(); - let all_metrics = &distribution.utxo_cohorts.all.metrics; let circulating_supply = &all_metrics.supply.total.sats.height; self.coinblocks_created - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_transform( starting_indexes.height, circulating_supply, @@ -30,7 +27,7 @@ impl Vecs { })?; self.coinblocks_stored - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_subtract( starting_indexes.height, &self.coinblocks_created.raw.height, diff --git a/crates/brk_computer/src/cointime/activity/import.rs b/crates/brk_computer/src/cointime/activity/import.rs index 483bd3b70..868181f88 100644 --- a/crates/brk_computer/src/cointime/activity/import.rs +++ b/crates/brk_computer/src/cointime/activity/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{ComputedPerBlock, ComputedPerBlockCumulativeSum}, + internal::{CachedWindowStarts, ComputedPerBlock, ComputedPerBlockCumulativeWithSums}, }; impl Vecs { @@ -13,19 +13,22 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - coinblocks_created: ComputedPerBlockCumulativeSum::forced_import( + coinblocks_created: ComputedPerBlockCumulativeWithSums::forced_import( db, "coinblocks_created", version, indexes, + cached_starts, )?, - coinblocks_stored: ComputedPerBlockCumulativeSum::forced_import( + coinblocks_stored: ComputedPerBlockCumulativeWithSums::forced_import( db, "coinblocks_stored", version, indexes, + cached_starts, )?, liveliness: ComputedPerBlock::forced_import(db, "liveliness", version, indexes)?, vaultedness: ComputedPerBlock::forced_import(db, "vaultedness", version, indexes)?, diff --git a/crates/brk_computer/src/cointime/activity/vecs.rs b/crates/brk_computer/src/cointime/activity/vecs.rs index 9dd312213..a04814ba3 100644 --- a/crates/brk_computer/src/cointime/activity/vecs.rs +++ b/crates/brk_computer/src/cointime/activity/vecs.rs @@ -2,12 +2,12 @@ use brk_traversable::Traversable; use brk_types::StoredF64; use vecdb::{Rw, StorageMode}; -use crate::internal::{ComputedPerBlock, ComputedPerBlockCumulativeSum}; +use crate::internal::{ComputedPerBlock, ComputedPerBlockCumulativeWithSums}; #[derive(Traversable)] pub struct Vecs { - pub coinblocks_created: ComputedPerBlockCumulativeSum, - pub coinblocks_stored: ComputedPerBlockCumulativeSum, + pub coinblocks_created: ComputedPerBlockCumulativeWithSums, + pub coinblocks_stored: ComputedPerBlockCumulativeWithSums, pub liveliness: ComputedPerBlock, pub vaultedness: ComputedPerBlock, pub ratio: ComputedPerBlock, diff --git a/crates/brk_computer/src/cointime/compute.rs b/crates/brk_computer/src/cointime/compute.rs index 1b939a53c..9d6ab0ebb 100644 --- a/crates/brk_computer/src/cointime/compute.rs +++ b/crates/brk_computer/src/cointime/compute.rs @@ -19,7 +19,7 @@ impl Vecs { ) -> Result<()> { // Activity computes first (liveliness, vaultedness, etc.) self.activity - .compute(starting_indexes, blocks, distribution, exit)?; + .compute(starting_indexes, distribution, exit)?; // Phase 2: supply, adjusted, value are independent (all depend only on activity) let (r1, r2) = rayon::join( @@ -37,7 +37,6 @@ impl Vecs { self.value.compute( starting_indexes, prices, - blocks, distribution, &self.activity, exit, diff --git a/crates/brk_computer/src/cointime/import.rs b/crates/brk_computer/src/cointime/import.rs index 3f8b1e1bb..2085d9213 100644 --- a/crates/brk_computer/src/cointime/import.rs +++ b/crates/brk_computer/src/cointime/import.rs @@ -13,18 +13,21 @@ use super::{ ValueVecs, Vecs, }; +use crate::internal::CachedWindowStarts; + impl Vecs { pub(crate) fn forced_import( parent_path: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, DB_NAME, 1_000_000)?; let version = parent_version; let v1 = version + Version::ONE; - let activity = ActivityVecs::forced_import(&db, version, indexes)?; + let activity = ActivityVecs::forced_import(&db, version, indexes, cached_starts)?; let supply = SupplyVecs::forced_import(&db, v1, indexes)?; - let value = ValueVecs::forced_import(&db, v1, indexes)?; + let value = ValueVecs::forced_import(&db, v1, indexes, cached_starts)?; let cap = CapVecs::forced_import(&db, v1, indexes)?; let prices = PricesVecs::forced_import(&db, version, indexes)?; let adjusted = AdjustedVecs::forced_import(&db, version, indexes)?; diff --git a/crates/brk_computer/src/cointime/value/compute.rs b/crates/brk_computer/src/cointime/value/compute.rs index 9251ee958..deab3ac17 100644 --- a/crates/brk_computer/src/cointime/value/compute.rs +++ b/crates/brk_computer/src/cointime/value/compute.rs @@ -4,27 +4,24 @@ use vecdb::Exit; use super::super::activity; use super::Vecs; -use crate::{blocks, distribution, prices}; +use crate::{distribution, prices}; impl Vecs { pub(crate) fn compute( &mut self, starting_indexes: &Indexes, prices: &prices::Vecs, - blocks: &blocks::Vecs, distribution: &distribution::Vecs, activity: &activity::Vecs, exit: &Exit, ) -> Result<()> { - let window_starts = blocks.lookback.window_starts(); - let all_metrics = &distribution.utxo_cohorts.all.metrics; let coinblocks_destroyed = &distribution.coinblocks_destroyed; let coindays_destroyed = &all_metrics.activity.coindays_destroyed; let circulating_supply = &all_metrics.supply.total.btc.height; self.destroyed - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_multiply( starting_indexes.height, &prices.spot.usd.height, @@ -35,7 +32,7 @@ impl Vecs { })?; self.created - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_multiply( starting_indexes.height, &prices.spot.usd.height, @@ -46,7 +43,7 @@ impl Vecs { })?; self.stored - .compute(starting_indexes.height, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_multiply( starting_indexes.height, &prices.spot.usd.height, @@ -60,7 +57,7 @@ impl Vecs { // 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, &window_starts, exit, |vec| { + .compute(starting_indexes.height, exit, |vec| { vec.compute_transform3( starting_indexes.height, &prices.spot.usd.height, diff --git a/crates/brk_computer/src/cointime/value/import.rs b/crates/brk_computer/src/cointime/value/import.rs index 9103d51b8..fe933a619 100644 --- a/crates/brk_computer/src/cointime/value/import.rs +++ b/crates/brk_computer/src/cointime/value/import.rs @@ -3,38 +3,46 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::ComputedPerBlockCumulativeSum}; +use crate::{ + indexes, + internal::{CachedWindowStarts, ComputedPerBlockCumulativeWithSums}, +}; impl Vecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - destroyed: ComputedPerBlockCumulativeSum::forced_import( + destroyed: ComputedPerBlockCumulativeWithSums::forced_import( db, "cointime_value_destroyed", version, indexes, + cached_starts, )?, - created: ComputedPerBlockCumulativeSum::forced_import( + created: ComputedPerBlockCumulativeWithSums::forced_import( db, "cointime_value_created", version, indexes, + cached_starts, )?, - stored: ComputedPerBlockCumulativeSum::forced_import( + stored: ComputedPerBlockCumulativeWithSums::forced_import( db, "cointime_value_stored", version, indexes, + cached_starts, )?, - vocdd: ComputedPerBlockCumulativeSum::forced_import( + vocdd: ComputedPerBlockCumulativeWithSums::forced_import( db, "vocdd", version + Version::ONE, indexes, + cached_starts, )?, }) } diff --git a/crates/brk_computer/src/cointime/value/vecs.rs b/crates/brk_computer/src/cointime/value/vecs.rs index ebd602d70..14dda4a39 100644 --- a/crates/brk_computer/src/cointime/value/vecs.rs +++ b/crates/brk_computer/src/cointime/value/vecs.rs @@ -2,12 +2,12 @@ use brk_traversable::Traversable; use brk_types::StoredF64; use vecdb::{Rw, StorageMode}; -use crate::internal::ComputedPerBlockCumulativeSum; +use crate::internal::ComputedPerBlockCumulativeWithSums; #[derive(Traversable)] pub struct Vecs { - pub destroyed: ComputedPerBlockCumulativeSum, - pub created: ComputedPerBlockCumulativeSum, - pub stored: ComputedPerBlockCumulativeSum, - pub vocdd: ComputedPerBlockCumulativeSum, + pub destroyed: ComputedPerBlockCumulativeWithSums, + pub created: ComputedPerBlockCumulativeWithSums, + pub stored: ComputedPerBlockCumulativeWithSums, + pub vocdd: ComputedPerBlockCumulativeWithSums, } diff --git a/crates/brk_computer/src/distribution/address/activity.rs b/crates/brk_computer/src/distribution/address/activity.rs index 12706c14c..8c12ce1e9 100644 --- a/crates/brk_computer/src/distribution/address/activity.rs +++ b/crates/brk_computer/src/distribution/address/activity.rs @@ -19,7 +19,7 @@ use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec}; use crate::{ indexes, - internal::{ComputedPerBlockRollingAverage, WindowStarts}, + internal::{CachedWindowStarts, ComputedPerBlockRollingAverage}, }; /// Per-block activity counts - reset each block. @@ -77,6 +77,7 @@ impl ActivityCountVecs { name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { reactivated: ComputedPerBlockRollingAverage::forced_import( @@ -84,24 +85,28 @@ impl ActivityCountVecs { &format!("{name}_reactivated"), version, indexes, + cached_starts, )?, sending: ComputedPerBlockRollingAverage::forced_import( db, &format!("{name}_sending"), version, indexes, + cached_starts, )?, receiving: ComputedPerBlockRollingAverage::forced_import( db, &format!("{name}_receiving"), version, indexes, + cached_starts, )?, both: ComputedPerBlockRollingAverage::forced_import( db, &format!("{name}_both"), version, indexes, + cached_starts, )?, }) } @@ -156,13 +161,12 @@ impl ActivityCountVecs { pub(crate) fn compute_rest( &mut self, max_from: Height, - windows: &WindowStarts<'_>, exit: &Exit, ) -> Result<()> { - self.reactivated.compute_rest(max_from, windows, exit)?; - self.sending.compute_rest(max_from, windows, exit)?; - self.receiving.compute_rest(max_from, windows, exit)?; - self.both.compute_rest(max_from, windows, exit)?; + self.reactivated.compute_rest(max_from, exit)?; + self.sending.compute_rest(max_from, exit)?; + self.receiving.compute_rest(max_from, exit)?; + self.both.compute_rest(max_from, exit)?; Ok(()) } } @@ -184,6 +188,7 @@ impl AddressTypeToActivityCountVecs { name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self::from( ByAddressType::::new_with_name(|type_name| { @@ -192,6 +197,7 @@ impl AddressTypeToActivityCountVecs { &format!("{type_name}_{name}"), version, indexes, + cached_starts, ) })?, )) @@ -228,11 +234,10 @@ impl AddressTypeToActivityCountVecs { pub(crate) fn compute_rest( &mut self, max_from: Height, - windows: &WindowStarts<'_>, exit: &Exit, ) -> Result<()> { for type_vecs in self.0.values_mut() { - type_vecs.compute_rest(max_from, windows, exit)?; + type_vecs.compute_rest(max_from, exit)?; } Ok(()) } @@ -263,11 +268,12 @@ impl AddressActivityVecs { name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - all: ActivityCountVecs::forced_import(db, name, version, indexes)?, + all: ActivityCountVecs::forced_import(db, name, version, indexes, cached_starts)?, by_addresstype: AddressTypeToActivityCountVecs::forced_import( - db, name, version, indexes, + db, name, version, indexes, cached_starts, )?, }) } @@ -295,11 +301,10 @@ impl AddressActivityVecs { pub(crate) fn compute_rest( &mut self, max_from: Height, - windows: &WindowStarts<'_>, exit: &Exit, ) -> Result<()> { - self.all.compute_rest(max_from, windows, exit)?; - self.by_addresstype.compute_rest(max_from, windows, exit)?; + self.all.compute_rest(max_from, exit)?; + self.by_addresstype.compute_rest(max_from, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/address/delta.rs b/crates/brk_computer/src/distribution/address/delta.rs index b20e2840b..25eb2f965 100644 --- a/crates/brk_computer/src/distribution/address/delta.rs +++ b/crates/brk_computer/src/distribution/address/delta.rs @@ -1,61 +1,53 @@ use brk_cohort::ByAddressType; -use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Height, StoredI64, StoredU64, Version}; -use vecdb::{Database, Exit, Rw, StorageMode}; +use brk_types::{BasisPoints32, StoredI64, StoredU64, Version}; use crate::{ indexes, - internal::{WindowStarts, RollingDelta}, + internal::{CachedWindowStarts, LazyRollingDeltasFromHeight}, }; use super::AddressCountsVecs; -#[derive(Traversable)] -pub struct DeltaVecs { - pub all: RollingDelta, +type AddrDelta = LazyRollingDeltasFromHeight; + +#[derive(Clone, Traversable)] +pub struct DeltaVecs { + pub all: AddrDelta, #[traversable(flatten)] - pub by_addresstype: ByAddressType>, + pub by_addresstype: ByAddressType, } impl DeltaVecs { - pub(crate) fn forced_import( - db: &Database, + pub(crate) fn new( version: Version, + address_count: &AddressCountsVecs, + cached_starts: &CachedWindowStarts, indexes: &indexes::Vecs, - ) -> Result { + ) -> Self { let version = version + Version::TWO; - let all = RollingDelta::forced_import(db, "address_count", version, indexes)?; + let all = LazyRollingDeltasFromHeight::new( + "address_count", + version, + &address_count.all.0.height, + cached_starts, + indexes, + ); - let by_addresstype = ByAddressType::new_with_name(|name| { - RollingDelta::forced_import(db, &format!("{name}_address_count"), version, indexes) - })?; + let by_addresstype = address_count.by_addresstype.map_with_name(|name, addr| { + LazyRollingDeltasFromHeight::new( + &format!("{name}_address_count"), + version, + &addr.0.height, + cached_starts, + indexes, + ) + }); - Ok(Self { + Self { all, by_addresstype, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - address_count: &AddressCountsVecs, - exit: &Exit, - ) -> Result<()> { - self.all - .compute(max_from, windows, &address_count.all.height, exit)?; - - for ((_, growth), (_, addr)) in self - .by_addresstype - .iter_mut() - .zip(address_count.by_addresstype.iter()) - { - growth.compute(max_from, windows, &addr.height, exit)?; } - - Ok(()) } } diff --git a/crates/brk_computer/src/distribution/address/new_address_count.rs b/crates/brk_computer/src/distribution/address/new_address_count.rs index 8dd1e58d5..9f154f8fa 100644 --- a/crates/brk_computer/src/distribution/address/new_address_count.rs +++ b/crates/brk_computer/src/distribution/address/new_address_count.rs @@ -6,7 +6,7 @@ use vecdb::{Database, Exit, Rw, StorageMode}; use crate::{ indexes, - internal::{ComputedPerBlockSum, WindowStarts}, + internal::{CachedWindowStarts, ComputedPerBlockCumulativeWithSums}, }; use super::TotalAddressCountVecs; @@ -14,9 +14,9 @@ use super::TotalAddressCountVecs; /// New address count per block (global + per-type) #[derive(Traversable)] pub struct NewAddressCountVecs { - pub all: ComputedPerBlockSum, + pub all: ComputedPerBlockCumulativeWithSums, #[traversable(flatten)] - pub by_addresstype: ByAddressType>, + pub by_addresstype: ByAddressType>, } impl NewAddressCountVecs { @@ -24,18 +24,25 @@ impl NewAddressCountVecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { - let all = ComputedPerBlockSum::forced_import(db, "new_address_count", version, indexes)?; + let all = ComputedPerBlockCumulativeWithSums::forced_import( + db, + "new_address_count", + version, + indexes, + cached_starts, + )?; - let by_addresstype: ByAddressType> = - ByAddressType::new_with_name(|name| { - ComputedPerBlockSum::forced_import( - db, - &format!("{name}_new_address_count"), - version, - indexes, - ) - })?; + let by_addresstype = ByAddressType::new_with_name(|name| { + ComputedPerBlockCumulativeWithSums::forced_import( + db, + &format!("{name}_new_address_count"), + version, + indexes, + cached_starts, + ) + })?; Ok(Self { all, @@ -46,11 +53,10 @@ impl NewAddressCountVecs { pub(crate) fn compute( &mut self, max_from: Height, - windows: &WindowStarts<'_>, total_address_count: &TotalAddressCountVecs, exit: &Exit, ) -> Result<()> { - self.all.compute(max_from, windows, exit, |height_vec| { + self.all.compute(max_from, exit, |height_vec| { Ok(height_vec.compute_change(max_from, &total_address_count.all.height, 1, exit)?) })?; @@ -59,7 +65,7 @@ impl NewAddressCountVecs { .iter_mut() .zip(total_address_count.by_addresstype.iter()) { - new.compute(max_from, windows, exit, |height_vec| { + new.compute(max_from, exit, |height_vec| { Ok(height_vec.compute_change(max_from, &total.height, 1, exit)?) })?; } diff --git a/crates/brk_computer/src/distribution/cohorts/address/groups.rs b/crates/brk_computer/src/distribution/cohorts/address/groups.rs index d0d489a56..208d8602b 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/address/groups.rs @@ -10,7 +10,7 @@ use derive_more::{Deref, DerefMut}; use rayon::prelude::*; use vecdb::{AnyStoredVec, Database, Exit, Rw, StorageMode}; -use crate::{blocks, distribution::DynCohortVecs, indexes, prices}; +use crate::{distribution::DynCohortVecs, indexes, internal::CachedWindowStarts, prices}; use super::{super::traits::CohortVecs, vecs::AddressCohortVecs}; @@ -27,6 +27,7 @@ impl AddressCohorts { version: Version, indexes: &indexes::Vecs, states_path: &Path, + cached_starts: &CachedWindowStarts, ) -> Result { let v = version + VERSION; @@ -34,7 +35,7 @@ impl AddressCohorts { let create = |filter: Filter, name: &'static str, has_state: bool| -> Result { let sp = if has_state { Some(states_path) } else { None }; - AddressCohortVecs::forced_import(db, filter, name, v, indexes, sp) + AddressCohortVecs::forced_import(db, filter, name, v, indexes, sp, cached_starts) }; let full = |f: Filter, name: &'static str| create(f, name, true); @@ -90,22 +91,12 @@ impl AddressCohorts { /// First phase of post-processing: compute index transforms. pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.par_iter_mut().try_for_each(|v| { - v.address_count_delta.compute( - starting_indexes.height, - &blocks.lookback._1m, - &v.address_count.height, - exit, - ) - })?; - self.par_iter_mut() - .try_for_each(|v| v.compute_rest_part1(blocks, prices, starting_indexes, exit))?; + .try_for_each(|v| v.compute_rest_part1(prices, starting_indexes, exit))?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs index 32f708dcb..a13c1348b 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs @@ -3,15 +3,14 @@ use std::path::Path; use brk_cohort::{CohortContext, Filter, Filtered}; use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Cents, Height, Indexes, StoredI64, StoredU64, Version}; +use brk_types::{BasisPointsSigned32, Cents, Height, Indexes, StoredI64, StoredU64, Version}; use rayon::prelude::*; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{ - blocks, distribution::state::{AddressCohortState, MinimalRealizedState}, indexes, - internal::{ComputedPerBlock, RollingDelta1m}, + internal::{CachedWindowStarts, ComputedPerBlockWithDeltas}, prices, }; @@ -28,9 +27,7 @@ pub struct AddressCohortVecs { #[traversable(flatten)] pub metrics: MinimalCohortMetrics, - pub address_count: ComputedPerBlock, - #[traversable(wrap = "address_count", rename = "delta")] - pub address_count_delta: RollingDelta1m, + pub address_count: ComputedPerBlockWithDeltas, } impl AddressCohortVecs { @@ -41,6 +38,7 @@ impl AddressCohortVecs { version: Version, indexes: &indexes::Vecs, states_path: Option<&Path>, + cached_starts: &CachedWindowStarts, ) -> Result { let full_name = CohortContext::Address.full_name(&filter, name); @@ -50,27 +48,23 @@ impl AddressCohortVecs { full_name: &full_name, version, indexes, + cached_starts, }; + let address_count = ComputedPerBlockWithDeltas::forced_import( + db, + &cfg.name("address_count"), + version, + Version::ONE, + indexes, + cached_starts, + )?; + Ok(Self { starting_height: None, - state: states_path.map(|path| Box::new(AddressCohortState::new(path, &full_name))), - metrics: MinimalCohortMetrics::forced_import(&cfg)?, - - address_count: ComputedPerBlock::forced_import( - db, - &cfg.name("address_count"), - version, - indexes, - )?, - address_count_delta: RollingDelta1m::forced_import( - db, - &cfg.name("address_count_delta"), - version + Version::ONE, - indexes, - )?, + address_count, }) } @@ -189,13 +183,12 @@ impl DynCohortVecs for AddressCohortVecs { fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit) + .compute_rest_part1(prices, starting_indexes, exit) } fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/cohorts/traits.rs b/crates/brk_computer/src/distribution/cohorts/traits.rs index 11f250d39..60d4f6491 100644 --- a/crates/brk_computer/src/distribution/cohorts/traits.rs +++ b/crates/brk_computer/src/distribution/cohorts/traits.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::Exit; -use crate::{blocks, prices}; +use crate::prices; /// Dynamic dispatch trait for cohort vectors. /// @@ -34,7 +34,6 @@ pub trait DynCohortVecs: Send + Sync { /// First phase of post-processing computations. fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs b/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs index e1b89c182..01bf2ae84 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs @@ -19,13 +19,13 @@ use crate::{ metrics::{ AllCohortMetrics, BasicCohortMetrics, CohortMetricsBase, CoreCohortMetrics, ExtendedAdjustedCohortMetrics, ExtendedCohortMetrics, ImportConfig, - MinimalCohortMetrics, ProfitabilityMetrics, RealizedFullAccum, SupplyFull, + MinimalCohortMetrics, ProfitabilityMetrics, RealizedFullAccum, SupplyCore, TypeCohortMetrics, }, state::UTXOCohortState, }, indexes, - internal::AmountPerBlock, + internal::{AmountPerBlock, CachedWindowStarts}, prices, }; @@ -70,6 +70,7 @@ impl UTXOCohorts { version: Version, indexes: &indexes::Vecs, states_path: &Path, + cached_starts: &CachedWindowStarts, ) -> Result { let v = version + VERSION; @@ -81,8 +82,9 @@ impl UTXOCohorts { full_name: &all_full_name, version: v + Version::ONE, indexes, + cached_starts, }; - let all_supply = SupplyFull::forced_import(&all_cfg)?; + let all_supply = SupplyCore::forced_import(&all_cfg)?; // Phase 2: Import separate (stateful) cohorts. @@ -96,6 +98,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; let state = Some(Box::new(UTXOCohortState::new(states_path, &full_name))); Ok(UTXOCohortVecs::new( @@ -115,6 +118,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; let state = Some(Box::new(UTXOCohortState::new(states_path, &full_name))); Ok(UTXOCohortVecs::new( @@ -136,6 +140,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; let state = Some(Box::new(UTXOCohortState::new(states_path, &full_name))); Ok(UTXOCohortVecs::new( @@ -155,6 +160,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; let state = Some(Box::new(UTXOCohortState::new(states_path, &full_name))); Ok(UTXOCohortVecs::new( @@ -186,6 +192,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; UTXOCohortVecs::new(None, ExtendedAdjustedCohortMetrics::forced_import(&cfg)?) }; @@ -200,6 +207,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; UTXOCohortVecs::new(None, ExtendedCohortMetrics::forced_import(&cfg)?) }; @@ -214,6 +222,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; Ok(UTXOCohortVecs::new( None, @@ -236,6 +245,7 @@ impl UTXOCohorts { full_name: &full_name, version: v, indexes, + cached_starts, }; Ok(UTXOCohortVecs::new( None, @@ -459,7 +469,6 @@ impl UTXOCohorts { /// First phase of post-processing: compute index transforms. pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, @@ -497,7 +506,7 @@ impl UTXOCohorts { ); all.extend(self.type_.iter_mut().map(|x| x as &mut dyn DynCohortVecs)); all.into_par_iter() - .try_for_each(|v| v.compute_rest_part1(blocks, prices, starting_indexes, exit))?; + .try_for_each(|v| v.compute_rest_part1(prices, starting_indexes, exit))?; } // Compute matured cents from sats × price @@ -606,19 +615,19 @@ impl UTXOCohorts { Box::new(|| { age_range.par_iter_mut().try_for_each(|v| { v.metrics - .compute_rest_part2(blocks, prices, starting_indexes, ss, exit) + .compute_rest_part2(prices, starting_indexes, ss, exit) }) }), Box::new(|| { under_age.par_iter_mut().try_for_each(|v| { v.metrics - .compute_rest_part2(blocks, prices, starting_indexes, ss, exit) + .compute_rest_part2(prices, starting_indexes, ss, exit) }) }), Box::new(|| { over_age.par_iter_mut().try_for_each(|v| { v.metrics - .compute_rest_part2(blocks, prices, starting_indexes, ss, exit) + .compute_rest_part2(prices, starting_indexes, ss, exit) }) }), Box::new(|| { @@ -629,13 +638,13 @@ impl UTXOCohorts { Box::new(|| { epoch.par_iter_mut().try_for_each(|v| { v.metrics - .compute_rest_part2(blocks, prices, starting_indexes, ss, exit) + .compute_rest_part2(prices, starting_indexes, ss, exit) }) }), Box::new(|| { class.par_iter_mut().try_for_each(|v| { v.metrics - .compute_rest_part2(blocks, prices, starting_indexes, ss, exit) + .compute_rest_part2(prices, starting_indexes, ss, exit) }) }), Box::new(|| { 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 66ab63ec9..bfd1bb28a 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,7 @@ use brk_error::Result; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; -use crate::{blocks, distribution::{cohorts::traits::DynCohortVecs, metrics::CoreCohortMetrics}, prices}; +use crate::{distribution::{cohorts::traits::DynCohortVecs, metrics::CoreCohortMetrics}, prices}; use super::UTXOCohortVecs; @@ -64,13 +64,12 @@ impl DynCohortVecs for UTXOCohortVecs { fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit) + .compute_rest_part1(prices, starting_indexes, exit) } fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs index df61652a5..2197df160 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs @@ -4,7 +4,6 @@ use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; use crate::{ - blocks, distribution::{cohorts::traits::DynCohortVecs, metrics::MinimalCohortMetrics}, prices, }; @@ -57,13 +56,12 @@ impl DynCohortVecs for UTXOCohortVecs { fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit) + .compute_rest_part1(prices, starting_indexes, exit) } fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs index 088ffe5f8..05d1404ed 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs @@ -49,7 +49,6 @@ use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; use crate::{ - blocks, distribution::{ cohorts::traits::DynCohortVecs, metrics::{CohortMetricsBase, CohortMetricsState}, @@ -71,7 +70,10 @@ pub struct UTXOCohortVecs { } impl UTXOCohortVecs { - pub(crate) fn new(state: Option>>, metrics: M) -> Self { + pub(crate) fn new( + state: Option>>, + metrics: M, + ) -> Self { Self { state_starting_height: None, state, @@ -183,24 +185,20 @@ impl DynCohortVecs for UTXOCohortVecs { _is_day_boundary: bool, ) -> Result<()> { if let Some(state) = self.state.as_mut() { - self.metrics.compute_and_push_unrealized( - height, - height_price, - state, - )?; + self.metrics + .compute_and_push_unrealized(height, height_price, state)?; } Ok(()) } fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + .compute_rest_part1(prices, starting_indexes, exit)?; Ok(()) } 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 d24f91adb..8cd82ba5d 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,7 @@ use brk_error::Result; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; -use crate::{blocks, distribution::cohorts::traits::DynCohortVecs, distribution::metrics::TypeCohortMetrics, prices}; +use crate::{distribution::cohorts::traits::DynCohortVecs, distribution::metrics::TypeCohortMetrics, prices}; use super::UTXOCohortVecs; @@ -63,13 +63,12 @@ impl DynCohortVecs for UTXOCohortVecs { fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit) + .compute_rest_part1(prices, starting_indexes, exit) } fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/compute/aggregates.rs b/crates/brk_computer/src/distribution/compute/aggregates.rs deleted file mode 100644 index 506969f59..000000000 --- a/crates/brk_computer/src/distribution/compute/aggregates.rs +++ /dev/null @@ -1,84 +0,0 @@ -use brk_error::Result; -use brk_types::{Dollars, Height, Indexes}; -use tracing::info; -use vecdb::{Exit, ReadableVec}; - -use crate::{blocks, prices}; - -use super::super::cohorts::{AddressCohorts, UTXOCohorts}; - -/// Compute overlapping cohorts from component cohorts. -/// -/// For example: -/// - ">=1d" UTXO cohort is computed from sum of age_range cohorts that match -/// - ">=1 BTC" address cohort is computed from sum of amount_range cohorts that match -pub(crate) fn compute_overlapping( - utxo_cohorts: &mut UTXOCohorts, - address_cohorts: &mut AddressCohorts, - starting_indexes: &Indexes, - exit: &Exit, -) -> Result<()> { - info!("Computing overlapping cohorts..."); - - let (r1, r2) = rayon::join( - || utxo_cohorts.compute_overlapping_vecs(starting_indexes, exit), - || address_cohorts.compute_overlapping_vecs(starting_indexes, exit), - ); - r1?; - r2?; - - Ok(()) -} - -/// First phase of post-processing: compute index transforms. -/// -/// Converts height-indexed data to day1-indexed data and other transforms. -pub(crate) fn compute_rest_part1( - utxo_cohorts: &mut UTXOCohorts, - address_cohorts: &mut AddressCohorts, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - exit: &Exit, -) -> Result<()> { - info!("Computing rest part 1..."); - - let (r1, r2) = rayon::join( - || utxo_cohorts.compute_rest_part1(blocks, prices, starting_indexes, exit), - || address_cohorts.compute_rest_part1(blocks, prices, starting_indexes, exit), - ); - r1?; - r2?; - - Ok(()) -} - -/// Second phase of post-processing: compute relative metrics. -/// -/// Computes supply ratios, market cap ratios, etc. using total references. -pub(crate) fn compute_rest_part2( - utxo_cohorts: &mut UTXOCohorts, - address_cohorts: &mut AddressCohorts, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - height_to_market_cap: &HM, - exit: &Exit, -) -> Result<()> -where - HM: ReadableVec + Sync, -{ - info!("Computing rest part 2..."); - - utxo_cohorts.compute_rest_part2( - blocks, - prices, - starting_indexes, - height_to_market_cap, - exit, - )?; - - address_cohorts.compute_rest_part2(prices, starting_indexes, exit)?; - - Ok(()) -} diff --git a/crates/brk_computer/src/distribution/compute/mod.rs b/crates/brk_computer/src/distribution/compute/mod.rs index 85d7c51e1..fe567f9b8 100644 --- a/crates/brk_computer/src/distribution/compute/mod.rs +++ b/crates/brk_computer/src/distribution/compute/mod.rs @@ -1,4 +1,3 @@ -pub mod aggregates; mod block_loop; mod context; mod readers; diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs index 69b5e5bfd..8413feca6 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/core.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/core.rs @@ -4,20 +4,19 @@ use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; use crate::{ - blocks, distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}, - internal::{AmountPerBlockWithSum24h, PerBlockWithSum24h}, + internal::{AmountPerBlockCumulativeWithSums, ComputedPerBlockCumulativeWithSums}, prices, }; #[derive(Traversable)] pub struct ActivityCore { - pub sent: PerBlockWithSum24h, - pub coindays_destroyed: PerBlockWithSum24h, + pub sent: ComputedPerBlockCumulativeWithSums, + pub coindays_destroyed: ComputedPerBlockCumulativeWithSums, #[traversable(wrap = "sent", rename = "in_profit")] - pub sent_in_profit: AmountPerBlockWithSum24h, + pub sent_in_profit: AmountPerBlockCumulativeWithSums, #[traversable(wrap = "sent", rename = "in_loss")] - pub sent_in_loss: AmountPerBlockWithSum24h, + pub sent_in_loss: AmountPerBlockCumulativeWithSums, } impl ActivityCore { @@ -103,54 +102,26 @@ impl ActivityCore { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.sent.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.sent.raw.height, - exit, - )?; - self.coindays_destroyed.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.coindays_destroyed.raw.height, - exit, - )?; + self.sent + .compute_rest(starting_indexes.height, exit)?; + self.coindays_destroyed + .compute_rest(starting_indexes.height, exit)?; Ok(()) } pub(crate) fn compute_sent_profitability( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.sent_in_profit - .raw - .compute(prices, starting_indexes.height, exit)?; + .compute_rest(starting_indexes.height, prices, exit)?; self.sent_in_loss - .raw - .compute(prices, starting_indexes.height, exit)?; - - self.sent_in_profit.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.sent_in_profit.raw.sats.height, - &self.sent_in_profit.raw.cents.height, - exit, - )?; - self.sent_in_loss.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.sent_in_loss.raw.sats.height, - &self.sent_in_loss.raw.cents.height, - exit, - )?; - + .compute_rest(starting_indexes.height, prices, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index 331ecbee5..35b4081c3 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -4,9 +4,9 @@ use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF32, StoredF64, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; -use crate::internal::{ComputedPerBlock, Identity, LazyPerBlock, RollingWindowsFrom1w}; +use crate::internal::{ComputedPerBlock, Identity, LazyPerBlock}; -use crate::{blocks, distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}}; +use crate::distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}; use super::ActivityCore; @@ -17,18 +17,6 @@ pub struct ActivityFull { #[traversable(flatten)] pub inner: ActivityCore, - #[traversable(wrap = "coindays_destroyed", rename = "cumulative")] - pub coindays_destroyed_cumulative: ComputedPerBlock, - #[traversable(wrap = "coindays_destroyed", rename = "sum")] - pub coindays_destroyed_sum: RollingWindowsFrom1w, - - #[traversable(wrap = "sent", rename = "sum")] - pub sent_sum_extended: RollingWindowsFrom1w, - #[traversable(wrap = "sent/in_profit", rename = "sum")] - pub sent_in_profit_sum_extended: RollingWindowsFrom1w, - #[traversable(wrap = "sent/in_loss", rename = "sum")] - pub sent_in_loss_sum_extended: RollingWindowsFrom1w, - pub coinyears_destroyed: LazyPerBlock, pub dormancy: ComputedPerBlock, @@ -38,23 +26,17 @@ pub struct ActivityFull { impl ActivityFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; - let coindays_destroyed_sum: RollingWindowsFrom1w = - cfg.import("coindays_destroyed", v1)?; + let inner = ActivityCore::forced_import(cfg)?; - let coinyears_destroyed = LazyPerBlock::from_computed::>( + let coinyears_destroyed = LazyPerBlock::from_height_source::>( &cfg.name("coinyears_destroyed"), - v1, - coindays_destroyed_sum._1y.height.read_only_boxed_clone(), - &coindays_destroyed_sum._1y, + cfg.version + v1, + inner.coindays_destroyed.sum._1y.height.read_only_boxed_clone(), + cfg.indexes, ); Ok(Self { - inner: ActivityCore::forced_import(cfg)?, - coindays_destroyed_cumulative: cfg.import("coindays_destroyed_cumulative", v1)?, - coindays_destroyed_sum, - sent_sum_extended: cfg.import("sent", v1)?, - sent_in_profit_sum_extended: cfg.import("sent_in_profit", v1)?, - sent_in_loss_sum_extended: cfg.import("sent_in_loss", v1)?, + inner, coinyears_destroyed, dormancy: cfg.import("dormancy", v1)?, velocity: cfg.import("velocity", v1)?, @@ -92,50 +74,10 @@ impl ActivityFull { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.inner - .compute_rest_part1(blocks, starting_indexes, exit)?; - - self.coindays_destroyed_cumulative - .height - .compute_cumulative( - starting_indexes.height, - &self.inner.coindays_destroyed.raw.height, - exit, - )?; - - let window_starts = blocks.lookback.window_starts(); - self.coindays_destroyed_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.inner.coindays_destroyed.raw.height, - exit, - )?; - - self.sent_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.inner.sent.raw.height, - exit, - )?; - - self.sent_in_profit_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.inner.sent_in_profit.raw.sats.height, - exit, - )?; - self.sent_in_loss_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.inner.sent_in_loss.raw.sats.height, - exit, - )?; - - Ok(()) + self.inner.compute_rest_part1(starting_indexes, exit) } pub(crate) fn compute_rest_part2( diff --git a/crates/brk_computer/src/distribution/metrics/activity/mod.rs b/crates/brk_computer/src/distribution/metrics/activity/mod.rs index 379245b1c..ab0577109 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/mod.rs @@ -8,7 +8,7 @@ use brk_error::Result; use brk_types::{Height, Indexes, Version}; use vecdb::Exit; -use crate::{blocks, distribution::state::{CohortState, CostBasisOps, RealizedOps}}; +use crate::distribution::state::{CohortState, CostBasisOps, RealizedOps}; pub trait ActivityLike: Send + Sync { fn as_core(&self) -> &ActivityCore; @@ -28,7 +28,6 @@ pub trait ActivityLike: Send + Sync { ) -> Result<()>; fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()>; @@ -47,8 +46,8 @@ impl ActivityLike for ActivityCore { 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, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { - self.compute_rest_part1(blocks, starting_indexes, exit) + fn compute_rest_part1(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { + self.compute_rest_part1(starting_indexes, exit) } } @@ -65,7 +64,7 @@ impl ActivityLike for ActivityFull { 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, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { - self.compute_rest_part1(blocks, starting_indexes, exit) + fn compute_rest_part1(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { + self.compute_rest_part1(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 9013d0ecf..a47275d8c 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -2,19 +2,18 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - Cents, Dollars, Height, Indexes, Sats, SatsSigned, StoredI64, StoredU64, - Version, + Cents, Dollars, Height, Indexes, Version, }; use vecdb::AnyStoredVec; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::internal::RollingDeltaExcept1m; - -use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsFull, - AdjustedSopr, RealizedFull, RelativeForAll, SupplyFull, UnrealizedFull, +use crate::{ + blocks, + distribution::metrics::{ + ActivityFull, AdjustedSopr, CohortMetricsBase, CostBasis, ImportConfig, OutputsBase, + RealizedFull, RelativeForAll, SupplyCore, UnrealizedFull, + }, + prices, }; /// All-cohort metrics: extended realized + adjusted (as composable add-on), @@ -24,8 +23,8 @@ use crate::distribution::metrics::{ pub struct AllCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub cost_basis: Box>, @@ -34,11 +33,6 @@ pub struct AllCohortMetrics { pub asopr: Box>, #[traversable(flatten)] pub relative: Box>, - - #[traversable(wrap = "supply", rename = "delta")] - pub supply_delta_extended: RollingDeltaExcept1m, - #[traversable(wrap = "outputs/unspent_count", rename = "delta")] - pub unspent_count_delta_extended: RollingDeltaExcept1m, } impl CohortMetricsBase for AllCohortMetrics { @@ -84,7 +78,7 @@ impl AllCohortMetrics { /// reference for relative metric lazy vecs in other cohorts. pub(crate) fn forced_import_with_supply( cfg: &ImportConfig, - supply: SupplyFull, + supply: SupplyCore, ) -> Result { let unrealized = UnrealizedFull::forced_import(cfg)?; let realized = RealizedFull::forced_import(cfg)?; @@ -95,15 +89,13 @@ impl AllCohortMetrics { Ok(Self { filter: cfg.filter.clone(), supply: Box::new(supply), - outputs: Box::new(OutputsFull::forced_import(cfg)?), + outputs: Box::new(OutputsBase::forced_import(cfg)?), activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasis::forced_import(cfg)?), unrealized: Box::new(unrealized), asopr: Box::new(asopr), relative: Box::new(relative), - supply_delta_extended: cfg.import("supply_delta", Version::ONE)?, - unspent_count_delta_extended: cfg.import("utxo_count_delta", Version::ONE)?, }) } @@ -135,7 +127,6 @@ impl AllCohortMetrics { )?; self.asopr.compute_rest_part2( - blocks, starting_indexes, &self.realized.minimal.sopr.value_created.raw.height, &self.realized.minimal.sopr.value_destroyed.raw.height, @@ -146,26 +137,12 @@ impl AllCohortMetrics { self.relative.compute( starting_indexes.height, - &self.supply.core, + &self.supply, &self.unrealized, height_to_market_cap, exit, )?; - let window_starts = blocks.lookback.window_starts(); - self.supply_delta_extended.compute( - starting_indexes.height, - &window_starts, - &self.supply.total.sats.height, - exit, - )?; - self.unspent_count_delta_extended.compute( - starting_indexes.height, - &window_starts, - &self.outputs.unspent_count.height, - exit, - )?; - self.activity.compute_rest_part2( starting_indexes, &self.supply.total.sats.height, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index c01eeb661..7f454635c 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -4,11 +4,12 @@ use brk_traversable::Traversable; use brk_types::{Height, Indexes, Sats}; use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::distribution::metrics::{ - ActivityCore, CohortMetricsBase, ImportConfig, OutputsFull, RealizedCore, - RelativeToAll, SupplyFull, UnrealizedBase, +use crate::{ + distribution::metrics::{ + ActivityCore, CohortMetricsBase, ImportConfig, OutputsBase, RealizedCore, RelativeToAll, + SupplyCore, UnrealizedBase, + }, + prices, }; /// Basic cohort metrics: no extensions, with relative (rel_to_all). @@ -17,8 +18,8 @@ use crate::distribution::metrics::{ pub struct BasicCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub unrealized: Box>, @@ -46,7 +47,7 @@ impl CohortMetricsBase for BasicCohortMetrics { impl BasicCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let supply = SupplyFull::forced_import(cfg)?; + let supply = SupplyCore::forced_import(cfg)?; let unrealized = UnrealizedBase::forced_import(cfg)?; let realized = RealizedCore::forced_import(cfg)?; @@ -55,7 +56,7 @@ impl BasicCohortMetrics { Ok(Self { filter: cfg.filter.clone(), supply: Box::new(supply), - outputs: Box::new(OutputsFull::forced_import(cfg)?), + outputs: Box::new(OutputsBase::forced_import(cfg)?), activity: Box::new(ActivityCore::forced_import(cfg)?), realized: Box::new(realized), unrealized: Box::new(unrealized), @@ -65,14 +66,12 @@ impl BasicCohortMetrics { pub(crate) fn compute_rest_part2( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, all_supply_sats: &impl ReadableVec, exit: &Exit, ) -> Result<()> { self.realized.compute_rest_part2( - blocks, prices, starting_indexes, &self.supply.total.btc.height, @@ -88,7 +87,7 @@ impl BasicCohortMetrics { self.relative.compute( starting_indexes.height, - &self.supply.core, + &self.supply, all_supply_sats, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index cc36a6f81..fad73ab34 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -4,19 +4,20 @@ use brk_traversable::Traversable; use brk_types::{Height, Indexes, Sats, Version}; use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::distribution::metrics::{ - ActivityCore, CohortMetricsBase, RealizedCore, ImportConfig, OutputsFull, - RelativeToAll, SupplyFull, UnrealizedCore, +use crate::{ + distribution::metrics::{ + ActivityCore, CohortMetricsBase, ImportConfig, OutputsBase, RealizedCore, RelativeToAll, + SupplyCore, UnrealizedCore, + }, + prices, }; #[derive(Traversable)] pub struct CoreCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub unrealized: Box>, @@ -28,8 +29,8 @@ impl CoreCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { filter: cfg.filter.clone(), - supply: Box::new(SupplyFull::forced_import(cfg)?), - outputs: Box::new(OutputsFull::forced_import(cfg)?), + supply: Box::new(SupplyCore::forced_import(cfg)?), + outputs: Box::new(OutputsBase::forced_import(cfg)?), activity: Box::new(ActivityCore::forced_import(cfg)?), realized: Box::new(RealizedCore::forced_import(cfg)?), unrealized: Box::new(UnrealizedCore::forced_import(cfg)?), @@ -100,41 +101,34 @@ impl CoreCohortMetrics { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.supply .compute(prices, starting_indexes.height, exit)?; - self.supply - .compute_rest_part1(blocks, starting_indexes, exit)?; - self.outputs - .compute_rest(blocks, starting_indexes, exit)?; self.activity - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, exit)?; self.activity - .compute_sent_profitability(blocks, prices, starting_indexes, exit)?; + .compute_sent_profitability(prices, starting_indexes, exit)?; self.realized - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, exit)?; - self.unrealized.compute_rest(blocks, starting_indexes, exit)?; + self.unrealized.compute_rest(starting_indexes, exit)?; Ok(()) } pub(crate) fn compute_rest_part2( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, all_supply_sats: &impl ReadableVec, exit: &Exit, ) -> Result<()> { self.realized.compute_rest_part2( - blocks, prices, starting_indexes, &self.supply.total.btc.height, @@ -150,7 +144,7 @@ impl CoreCohortMetrics { self.relative.compute( starting_indexes.height, - &self.supply.core, + &self.supply, all_supply_sats, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index acbb1a0a0..f5add33e9 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -2,18 +2,18 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - Dollars, Height, Indexes, Sats, SatsSigned, StoredI64, StoredU64, Version, + Dollars, Height, Indexes, Sats, Version, }; use vecdb::AnyStoredVec; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::internal::RollingDeltaExcept1m; - -use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsFull, - RealizedFull, RelativeWithExtended, SupplyFull, UnrealizedFull, +use crate::{ + blocks, + distribution::metrics::{ + ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsBase, RealizedFull, + RelativeWithExtended, SupplyCore, UnrealizedFull, + }, + prices, }; /// Cohort metrics with extended realized + extended cost basis (no adjusted). @@ -22,19 +22,14 @@ use crate::distribution::metrics::{ pub struct ExtendedCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, #[traversable(flatten)] pub relative: Box>, - - #[traversable(wrap = "supply", rename = "delta")] - pub supply_delta_extended: RollingDeltaExcept1m, - #[traversable(wrap = "outputs/unspent_count", rename = "delta")] - pub unspent_count_delta_extended: RollingDeltaExcept1m, } impl CohortMetricsBase for ExtendedCohortMetrics { @@ -75,7 +70,7 @@ impl CohortMetricsBase for ExtendedCohortMetrics { impl ExtendedCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let supply = SupplyFull::forced_import(cfg)?; + let supply = SupplyCore::forced_import(cfg)?; let unrealized = UnrealizedFull::forced_import(cfg)?; let realized = RealizedFull::forced_import(cfg)?; @@ -84,14 +79,12 @@ impl ExtendedCohortMetrics { Ok(Self { filter: cfg.filter.clone(), supply: Box::new(supply), - outputs: Box::new(OutputsFull::forced_import(cfg)?), + outputs: Box::new(OutputsBase::forced_import(cfg)?), activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasis::forced_import(cfg)?), unrealized: Box::new(unrealized), relative: Box::new(relative), - supply_delta_extended: cfg.import("supply_delta", Version::ONE)?, - unspent_count_delta_extended: cfg.import("utxo_count_delta", Version::ONE)?, }) } @@ -122,7 +115,7 @@ impl ExtendedCohortMetrics { self.relative.compute( starting_indexes.height, - &self.supply.core, + &self.supply, &self.unrealized, height_to_market_cap, all_supply_sats, @@ -130,20 +123,6 @@ impl ExtendedCohortMetrics { exit, )?; - let window_starts = blocks.lookback.window_starts(); - self.supply_delta_extended.compute( - starting_indexes.height, - &window_starts, - &self.supply.total.sats.height, - exit, - )?; - self.unspent_count_delta_extended.compute( - starting_indexes.height, - &window_starts, - &self.outputs.unspent_count.height, - exit, - )?; - self.activity.compute_rest_part2( starting_indexes, &self.supply.total.sats.height, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs index 1b58f9ca9..df1b120bc 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs @@ -4,11 +4,12 @@ use brk_types::{Cents, Dollars, Height, Indexes, Sats, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, ImportConfig, AdjustedSopr, - RealizedFull, UnrealizedFull, +use crate::{ + blocks, + distribution::metrics::{ + ActivityFull, AdjustedSopr, CohortMetricsBase, ImportConfig, RealizedFull, UnrealizedFull, + }, + prices, }; use super::ExtendedCohortMetrics; @@ -78,7 +79,6 @@ impl ExtendedAdjustedCohortMetrics { )?; self.asopr.compute_rest_part2( - blocks, starting_indexes, &self.inner.realized.minimal.sopr.value_created.raw.height, &self.inner.realized.minimal.sopr.value_destroyed.raw.height, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index 0409e092b..264a9371d 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -4,10 +4,11 @@ use brk_traversable::Traversable; use brk_types::Indexes; use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::distribution::metrics::{ - ImportConfig, OutputsBase, RealizedMinimal, SupplyBase, UnrealizedMinimal, +use crate::{ + distribution::metrics::{ + ImportConfig, OutputsBase, RealizedMinimal, SupplyBase, UnrealizedMinimal, + }, + prices, }; /// MinimalCohortMetrics: supply, outputs, realized cap/price/mvrv/profit/loss + value_created/destroyed. @@ -83,14 +84,13 @@ impl MinimalCohortMetrics { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.supply.compute(prices, starting_indexes.height, exit)?; self.realized - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, 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 6b7267927..c0a546290 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/type.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/type.rs @@ -4,10 +4,11 @@ use brk_traversable::Traversable; use brk_types::Indexes; use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; -use crate::{blocks, prices}; - -use crate::distribution::metrics::{ - ImportConfig, OutputsBase, RealizedMinimal, SupplyCore, UnrealizedBasic, +use crate::{ + distribution::metrics::{ + ImportConfig, OutputsBase, RealizedMinimal, SupplyCore, UnrealizedBasic, + }, + prices, }; /// TypeCohortMetrics: supply(core), outputs(base), realized(minimal), unrealized(basic). @@ -53,16 +54,15 @@ impl TypeCohortMetrics { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.supply.compute(prices, starting_indexes.height, exit)?; self.realized - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, exit)?; self.unrealized - .compute_rest(blocks, starting_indexes.height, exit)?; + .compute_rest(starting_indexes.height, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/config.rs b/crates/brk_computer/src/distribution/metrics/config.rs index 172271b7d..8b487cec3 100644 --- a/crates/brk_computer/src/distribution/metrics/config.rs +++ b/crates/brk_computer/src/distribution/metrics/config.rs @@ -7,13 +7,13 @@ use vecdb::{BytesVec, BytesVecValue, Database, ImportableVec}; use crate::{ indexes, internal::{ - AmountPerBlock, AmountPerBlockCumulative, AmountPerBlockWithSum24h, CentsType, ComputedPerBlock, - ComputedPerBlockCumulative, ComputedPerBlockCumulativeSum, FiatPerBlockWithSum24h, - PerBlockWithSum24h, PriceWithRatioExtendedPerBlock, PriceWithRatioPerBlock, RatioPerBlock, RollingWindow24hAmountPerBlock, - RollingWindow24hFiatPerBlock, RollingWindow24hPerBlock, - FiatPerBlock, FiatRollingDelta1m, FiatRollingDeltaExcept1m, NumericValue, - PercentPerBlock, PercentRollingWindows, Price, RollingDelta1m, RollingDeltaExcept1m, - RollingWindows, RollingWindowsFrom1w, + AmountPerBlock, AmountPerBlockCumulative, AmountPerBlockCumulativeWithSums, + CachedWindowStarts, CentsType, ComputedPerBlock, + ComputedPerBlockCumulative, ComputedPerBlockCumulativeWithSums, + FiatPerBlock, FiatPerBlockCumulativeWithSums, NumericValue, + PercentPerBlock, PercentRollingWindows, Price, + PriceWithRatioExtendedPerBlock, PriceWithRatioPerBlock, RatioPerBlock, + RollingWindow24hPerBlock, RollingWindows, RollingWindowsFrom1w, }, }; @@ -39,7 +39,6 @@ macro_rules! impl_config_import { impl_config_import!( AmountPerBlock, AmountPerBlockCumulative, - RollingWindow24hAmountPerBlock, PriceWithRatioPerBlock, PriceWithRatioExtendedPerBlock, RatioPerBlock, @@ -62,9 +61,19 @@ impl ConfigImport for ComputedPerBlockCumulative ConfigImport for ComputedPerBlockCumulativeSum { +impl ConfigImport for ComputedPerBlockCumulativeWithSums +where + T: NumericValue + JsonSchema + Into, + C: NumericValue + JsonSchema, +{ fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) + Self::forced_import( + cfg.db, + &cfg.name(suffix), + cfg.version + offset, + cfg.indexes, + cfg.cached_starts, + ) } } impl ConfigImport for RollingWindows { @@ -77,33 +86,26 @@ impl ConfigImport for RollingWindow24hPerBlock Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) } } -impl ConfigImport for PerBlockWithSum24h { +impl ConfigImport for AmountPerBlockCumulativeWithSums { fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Ok(Self { - raw: ComputedPerBlock::config_import(cfg, suffix, offset)?, - sum: RollingWindow24hPerBlock::config_import(cfg, suffix, offset)?, - }) + Self::forced_import( + cfg.db, + &cfg.name(suffix), + cfg.version + offset, + cfg.indexes, + cfg.cached_starts, + ) } } -impl ConfigImport for AmountPerBlockWithSum24h { +impl ConfigImport for FiatPerBlockCumulativeWithSums { fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Ok(Self { - raw: AmountPerBlock::config_import(cfg, suffix, offset)?, - sum: RollingWindow24hAmountPerBlock::config_import(cfg, suffix, offset)?, - }) - } -} -impl ConfigImport for RollingWindow24hFiatPerBlock { - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) - } -} -impl ConfigImport for FiatPerBlockWithSum24h { - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Ok(Self { - raw: FiatPerBlock::config_import(cfg, suffix, offset)?, - sum: RollingWindow24hFiatPerBlock::config_import(cfg, suffix, offset)?, - }) + Self::forced_import( + cfg.db, + &cfg.name(suffix), + cfg.version + offset, + cfg.indexes, + cfg.cached_starts, + ) } } impl ConfigImport for RollingWindowsFrom1w { @@ -116,30 +118,6 @@ impl ConfigImport for FiatPerBlock { Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) } } -impl ConfigImport - for RollingDelta1m -{ - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) - } -} -impl ConfigImport - for RollingDeltaExcept1m -{ - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) - } -} -impl ConfigImport for FiatRollingDelta1m { - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) - } -} -impl ConfigImport for FiatRollingDeltaExcept1m { - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) - } -} impl ConfigImport for BytesVec { fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { Ok(Self::forced_import( @@ -157,6 +135,7 @@ pub struct ImportConfig<'a> { pub full_name: &'a str, pub version: Version, pub indexes: &'a indexes::Vecs, + pub cached_starts: &'a CachedWindowStarts, } impl<'a> ImportConfig<'a> { diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index 42b49459a..4de276b52 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -18,17 +18,39 @@ mod activity; /// `ExtendedAdjustedCohortMetrics`, Rust's auto-deref resolves these through `Deref`. macro_rules! impl_cohort_accessors { () => { - fn filter(&self) -> &brk_cohort::Filter { &self.filter } - fn supply(&self) -> &$crate::distribution::metrics::SupplyFull { &self.supply } - fn supply_mut(&mut self) -> &mut $crate::distribution::metrics::SupplyFull { &mut self.supply } - fn outputs(&self) -> &$crate::distribution::metrics::OutputsFull { &self.outputs } - fn outputs_mut(&mut self) -> &mut $crate::distribution::metrics::OutputsFull { &mut self.outputs } - fn activity(&self) -> &Self::ActivityVecs { &self.activity } - fn activity_mut(&mut self) -> &mut Self::ActivityVecs { &mut self.activity } - fn realized(&self) -> &Self::RealizedVecs { &self.realized } - fn realized_mut(&mut self) -> &mut Self::RealizedVecs { &mut self.realized } - fn unrealized(&self) -> &Self::UnrealizedVecs { &self.unrealized } - fn unrealized_mut(&mut self) -> &mut Self::UnrealizedVecs { &mut self.unrealized } + fn filter(&self) -> &brk_cohort::Filter { + &self.filter + } + fn supply(&self) -> &$crate::distribution::metrics::SupplyCore { + &self.supply + } + fn supply_mut(&mut self) -> &mut $crate::distribution::metrics::SupplyCore { + &mut self.supply + } + fn outputs(&self) -> &$crate::distribution::metrics::OutputsBase { + &self.outputs + } + fn outputs_mut(&mut self) -> &mut $crate::distribution::metrics::OutputsBase { + &mut self.outputs + } + fn activity(&self) -> &Self::ActivityVecs { + &self.activity + } + fn activity_mut(&mut self) -> &mut Self::ActivityVecs { + &mut self.activity + } + fn realized(&self) -> &Self::RealizedVecs { + &self.realized + } + fn realized_mut(&mut self) -> &mut Self::RealizedVecs { + &mut self.realized + } + fn unrealized(&self) -> &Self::UnrealizedVecs { + &self.unrealized + } + fn unrealized_mut(&mut self) -> &mut Self::UnrealizedVecs { + &mut self.unrealized + } }; } @@ -44,29 +66,35 @@ mod unrealized; pub use activity::{ActivityCore, ActivityFull, ActivityLike}; pub use cohort::{ - AllCohortMetrics, BasicCohortMetrics, CoreCohortMetrics, - ExtendedAdjustedCohortMetrics, ExtendedCohortMetrics, MinimalCohortMetrics, TypeCohortMetrics, + AllCohortMetrics, BasicCohortMetrics, CoreCohortMetrics, ExtendedAdjustedCohortMetrics, + ExtendedCohortMetrics, MinimalCohortMetrics, TypeCohortMetrics, }; pub use config::ImportConfig; pub use cost_basis::CostBasis; +pub use outputs::OutputsBase; pub use profitability::ProfitabilityMetrics; -pub use outputs::{OutputsBase, OutputsFull}; pub use realized::{ - AdjustedSopr, RealizedCore, RealizedFull, RealizedFullAccum, RealizedLike, - RealizedMinimal, + AdjustedSopr, RealizedCore, RealizedFull, RealizedFullAccum, RealizedLike, RealizedMinimal, }; -pub use relative::{ - RelativeForAll, RelativeToAll, RelativeWithExtended, +pub use relative::{RelativeForAll, RelativeToAll, RelativeWithExtended}; +pub use supply::{SupplyBase, SupplyCore}; +pub use unrealized::{ + UnrealizedBase, UnrealizedBasic, UnrealizedCore, UnrealizedFull, UnrealizedLike, + UnrealizedMinimal, }; -pub use supply::{SupplyBase, SupplyCore, SupplyFull}; -pub use unrealized::{UnrealizedBase, UnrealizedBasic, UnrealizedCore, UnrealizedFull, UnrealizedLike, UnrealizedMinimal}; use brk_cohort::Filter; use brk_error::Result; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{AnyStoredVec, Exit, StorageMode}; -use crate::{blocks, distribution::state::{WithoutCapital, WithCapital, CohortState, CostBasisData, CostBasisOps, CostBasisRaw, CoreRealizedState, MinimalRealizedState, RealizedOps, RealizedState}, prices}; +use crate::{ + distribution::state::{ + CohortState, CoreRealizedState, CostBasisData, CostBasisOps, CostBasisRaw, + MinimalRealizedState, RealizedOps, RealizedState, WithCapital, WithoutCapital, + }, + prices, +}; pub trait CohortMetricsState { type Realized: RealizedOps; @@ -102,16 +130,18 @@ impl CohortMetricsState for AllCohortMetrics { type CostBasis = CostBasisData; } -pub trait CohortMetricsBase: CohortMetricsState> + Send + Sync { +pub trait CohortMetricsBase: + CohortMetricsState> + Send + Sync +{ type ActivityVecs: ActivityLike; type RealizedVecs: RealizedLike; type UnrealizedVecs: UnrealizedLike; fn filter(&self) -> &Filter; - fn supply(&self) -> &SupplyFull; - fn supply_mut(&mut self) -> &mut SupplyFull; - fn outputs(&self) -> &OutputsFull; - fn outputs_mut(&mut self) -> &mut OutputsFull; + fn supply(&self) -> &SupplyCore; + fn supply_mut(&mut self) -> &mut SupplyCore; + fn outputs(&self) -> &OutputsBase; + fn outputs_mut(&mut self) -> &mut OutputsBase; fn activity(&self) -> &Self::ActivityVecs; fn activity_mut(&mut self) -> &mut Self::ActivityVecs; fn realized(&self) -> &Self::RealizedVecs; @@ -120,20 +150,33 @@ pub trait CohortMetricsBase: CohortMetricsState &mut Self::UnrealizedVecs; /// Convenience: access activity as `&ActivityCore` (via `ActivityLike::as_core`). - fn activity_core(&self) -> &ActivityCore { self.activity().as_core() } - fn activity_core_mut(&mut self) -> &mut ActivityCore { self.activity_mut().as_core_mut() } + fn activity_core(&self) -> &ActivityCore { + self.activity().as_core() + } + fn activity_core_mut(&mut self) -> &mut ActivityCore { + self.activity_mut().as_core_mut() + } /// Convenience: access realized as `&RealizedCore` (via `RealizedLike::as_core`). - fn realized_core(&self) -> &RealizedCore { self.realized().as_core() } - fn realized_core_mut(&mut self) -> &mut RealizedCore { self.realized_mut().as_core_mut() } + fn realized_core(&self) -> &RealizedCore { + self.realized().as_core() + } + fn realized_core_mut(&mut self) -> &mut RealizedCore { + self.realized_mut().as_core_mut() + } /// Convenience: access unrealized as `&UnrealizedBase` (via `UnrealizedLike::as_base`). - fn unrealized_base(&self) -> &UnrealizedBase { self.unrealized().as_base() } - fn unrealized_base_mut(&mut self) -> &mut UnrealizedBase { self.unrealized_mut().as_base_mut() } + fn unrealized_base(&self) -> &UnrealizedBase { + self.unrealized().as_base() + } + fn unrealized_base_mut(&mut self) -> &mut UnrealizedBase { + self.unrealized_mut().as_base_mut() + } fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { self.supply_mut().validate_computed_versions(base_version)?; - self.activity_mut().validate_computed_versions(base_version)?; + self.activity_mut() + .validate_computed_versions(base_version)?; Ok(()) } @@ -164,7 +207,11 @@ pub trait CohortMetricsBase: CohortMetricsState>) -> Result<()> { + fn truncate_push( + &mut self, + height: Height, + state: &CohortState>, + ) -> Result<()> { self.supply_mut().truncate_push(height, state)?; self.outputs_mut().truncate_push(height, state)?; self.activity_mut().truncate_push(height, state)?; @@ -175,27 +222,22 @@ pub trait CohortMetricsBase: CohortMetricsState Result<()> { self.supply_mut() .compute(prices, starting_indexes.height, exit)?; - self.supply_mut() - .compute_rest_part1(blocks, starting_indexes, exit)?; - self.outputs_mut() - .compute_rest(blocks, starting_indexes, exit)?; self.activity_mut() - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, exit)?; self.activity_core_mut() - .compute_sent_profitability(blocks, prices, starting_indexes, exit)?; + .compute_sent_profitability(prices, starting_indexes, exit)?; self.realized_mut() - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, exit)?; self.unrealized_mut() - .compute_rest(blocks, prices, starting_indexes, exit)?; + .compute_rest(prices, starting_indexes, exit)?; self.unrealized_mut() .compute_net_sentiment_height(starting_indexes, exit)?; @@ -232,7 +274,10 @@ pub trait CohortMetricsBase: CohortMetricsState>(), + &others + .iter() + .map(|v| v.unrealized_base()) + .collect::>(), exit, )?; Ok(()) diff --git a/crates/brk_computer/src/distribution/metrics/outputs/base.rs b/crates/brk_computer/src/distribution/metrics/outputs/base.rs index 5aba50a36..723831eb0 100644 --- a/crates/brk_computer/src/distribution/metrics/outputs/base.rs +++ b/crates/brk_computer/src/distribution/metrics/outputs/base.rs @@ -1,22 +1,33 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Height, Indexes, StoredU64, Version}; +use brk_types::{BasisPointsSigned32, Height, Indexes, StoredI64, StoredU64, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; -use crate::{distribution::state::{CohortState, CostBasisOps, RealizedOps}, internal::ComputedPerBlock}; +use crate::{ + distribution::{ + metrics::ImportConfig, + state::{CohortState, CostBasisOps, RealizedOps}, + }, + internal::ComputedPerBlockWithDeltas, +}; -use crate::distribution::metrics::ImportConfig; - -/// Base output metrics: utxo_count only (1 stored vec). +/// Base output metrics: utxo_count + delta. #[derive(Traversable)] pub struct OutputsBase { - pub unspent_count: ComputedPerBlock, + pub unspent_count: ComputedPerBlockWithDeltas, } impl OutputsBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - unspent_count: cfg.import("utxo_count", Version::ZERO)?, + unspent_count: ComputedPerBlockWithDeltas::forced_import( + cfg.db, + &cfg.name("utxo_count"), + cfg.version, + Version::ONE, + cfg.indexes, + cfg.cached_starts, + )?, }) } diff --git a/crates/brk_computer/src/distribution/metrics/outputs/full.rs b/crates/brk_computer/src/distribution/metrics/outputs/full.rs deleted file mode 100644 index 47d62700b..000000000 --- a/crates/brk_computer/src/distribution/metrics/outputs/full.rs +++ /dev/null @@ -1,65 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Indexes, StoredI64, StoredU64, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; - -use crate::{blocks, internal::RollingDelta1m}; - -use crate::distribution::metrics::ImportConfig; - -use super::OutputsBase; - -/// Full output metrics: utxo_count + delta (3 stored vecs). -#[derive(Deref, DerefMut, Traversable)] -pub struct OutputsFull { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub base: OutputsBase, - - #[traversable(wrap = "unspent_count", rename = "delta")] - pub unspent_count_delta: RollingDelta1m, -} - -impl OutputsFull { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let base = OutputsBase::forced_import(cfg)?; - let unspent_count_delta = cfg.import("utxo_count_delta", Version::ONE)?; - - Ok(Self { - base, - unspent_count_delta, - }) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - self.base.collect_vecs_mut() - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - let base_refs: Vec<&OutputsBase> = others.iter().map(|o| &o.base).collect(); - self.base.compute_from_stateful(starting_indexes, &base_refs, exit) - } - - pub(crate) fn compute_rest( - &mut self, - blocks: &blocks::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.unspent_count_delta.compute( - starting_indexes.height, - &blocks.lookback._1m, - &self.base.unspent_count.height, - exit, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/outputs/mod.rs b/crates/brk_computer/src/distribution/metrics/outputs/mod.rs index 73441acb9..5972b29bf 100644 --- a/crates/brk_computer/src/distribution/metrics/outputs/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/outputs/mod.rs @@ -1,5 +1,3 @@ mod base; -mod full; pub use base::OutputsBase; -pub use full::OutputsFull; diff --git a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs index 556b6aff0..22f49535f 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs @@ -4,30 +4,22 @@ use brk_types::{Cents, Height, Indexes, StoredF64, Version}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{ - blocks, - internal::{ComputedPerBlock, RatioCents64, RollingWindows}, + distribution::metrics::ImportConfig, + internal::{ComputedPerBlockCumulativeWithSums, RatioCents64, RollingWindows}, }; -use crate::distribution::metrics::ImportConfig; - #[derive(Traversable)] pub struct AdjustedSopr { - pub value_created: ComputedPerBlock, - pub value_destroyed: ComputedPerBlock, - #[traversable(wrap = "value_created", rename = "sum")] - pub value_created_sum: RollingWindows, - #[traversable(wrap = "value_destroyed", rename = "sum")] - pub value_destroyed_sum: RollingWindows, + pub value_created: ComputedPerBlockCumulativeWithSums, + pub value_destroyed: ComputedPerBlockCumulativeWithSums, pub ratio: RollingWindows, } impl AdjustedSopr { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - value_created: cfg.import("adj_value_created", Version::ZERO)?, - value_destroyed: cfg.import("adj_value_destroyed", Version::ZERO)?, - value_created_sum: cfg.import("adj_value_created", Version::ONE)?, - value_destroyed_sum: cfg.import("adj_value_destroyed", Version::ONE)?, + value_created: cfg.import("adj_value_created", Version::ONE)?, + value_destroyed: cfg.import("adj_value_destroyed", Version::ONE)?, ratio: cfg.import("asopr", Version::ONE)?, }) } @@ -35,7 +27,6 @@ impl AdjustedSopr { #[allow(clippy::too_many_arguments)] pub(crate) fn compute_rest_part2( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, base_value_created: &impl ReadableVec, base_value_destroyed: &impl ReadableVec, @@ -44,41 +35,32 @@ impl AdjustedSopr { exit: &Exit, ) -> Result<()> { // Compute value_created = base.value_created - under_1h.value_created - self.value_created.height.compute_subtract( + self.value_created.raw.height.compute_subtract( starting_indexes.height, base_value_created, under_1h_value_created, exit, )?; - self.value_destroyed.height.compute_subtract( + self.value_destroyed.raw.height.compute_subtract( starting_indexes.height, base_value_destroyed, under_1h_value_destroyed, exit, )?; - // Adjusted value created/destroyed rolling sums - let window_starts = blocks.lookback.window_starts(); - self.value_created_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.value_created.height, - exit, - )?; - self.value_destroyed_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.value_destroyed.height, - exit, - )?; + // Cumulatives (rolling sums are lazy) + self.value_created + .compute_rest(starting_indexes.height, exit)?; + self.value_destroyed + .compute_rest(starting_indexes.height, exit)?; - // SOPR ratios from rolling sums + // SOPR ratios from lazy rolling sums for ((sopr, vc), vd) in self .ratio .as_mut_array() .into_iter() - .zip(self.value_created_sum.as_array()) - .zip(self.value_destroyed_sum.as_array()) + .zip(self.value_created.sum.as_array()) + .zip(self.value_destroyed.sum.as_array()) { sopr.compute_binary::( starting_indexes.height, diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs index e4056e04b..d6b77b0fe 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/core.rs @@ -1,18 +1,16 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{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, ReadableCloneableVec, ReadableVec, Rw, StorageMode, }; use crate::{ - blocks, distribution::state::{CohortState, CostBasisOps, RealizedOps}, internal::{ - ComputedPerBlock, FiatRollingDelta1m, LazyPerBlock, - NegCentsUnsignedToDollars, PerBlockWithSum24h, RatioCents64, - RollingWindow24hPerBlock, + FiatPerBlockCumulativeWithSumsAndDeltas, LazyPerBlock, NegCentsUnsignedToDollars, + RatioCents64, RollingWindow24hPerBlock, }, prices, }; @@ -33,23 +31,14 @@ pub struct RealizedCore { #[traversable(flatten)] pub minimal: RealizedMinimal, - #[traversable(wrap = "profit", rename = "cumulative")] - pub profit_cumulative: ComputedPerBlock, - #[traversable(wrap = "loss", rename = "cumulative")] - pub loss_cumulative: ComputedPerBlock, - - #[traversable(wrap = "cap", rename = "delta")] - pub cap_delta: FiatRollingDelta1m, - #[traversable(wrap = "loss", rename = "negative")] pub neg_loss: LazyPerBlock, - pub net_pnl: PerBlockWithSum24h, + pub net_pnl: FiatPerBlockCumulativeWithSumsAndDeltas, pub sopr: RealizedSoprCore, } impl RealizedCore { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; let v1 = Version::ONE; let minimal = RealizedMinimal::forced_import(cfg)?; @@ -61,13 +50,19 @@ impl RealizedCore { cfg.indexes, ); + let net_pnl = FiatPerBlockCumulativeWithSumsAndDeltas::forced_import( + cfg.db, + &cfg.name("net_realized_pnl"), + cfg.version + v1, + Version::new(4), + cfg.indexes, + cfg.cached_starts, + )?; + Ok(Self { minimal, - profit_cumulative: cfg.import("realized_profit_cumulative", v0)?, - loss_cumulative: cfg.import("realized_loss_cumulative", v0)?, - cap_delta: cfg.import("realized_cap_delta", v1)?, neg_loss: neg_realized_loss, - net_pnl: cfg.import("net_realized_pnl", v1)?, + net_pnl, sopr: RealizedSoprCore { ratio: cfg.import("sopr", v1)?, }, @@ -102,25 +97,13 @@ impl RealizedCore { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.minimal - .compute_rest_part1(blocks, starting_indexes, exit)?; + .compute_rest_part1(starting_indexes, exit)?; - self.profit_cumulative.height.compute_cumulative( - starting_indexes.height, - &self.minimal.profit.raw.cents.height, - exit, - )?; - self.loss_cumulative.height.compute_cumulative( - starting_indexes.height, - &self.minimal.loss.raw.cents.height, - exit, - )?; - - self.net_pnl.raw.height.compute_transform2( + self.net_pnl.raw.cents.height.compute_transform2( starting_indexes.height, &self.minimal.profit.raw.cents.height, &self.minimal.loss.raw.cents.height, @@ -138,7 +121,6 @@ impl RealizedCore { pub(crate) fn compute_rest_part2( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, height_to_supply: &impl ReadableVec, @@ -147,19 +129,8 @@ impl RealizedCore { self.minimal .compute_rest_part2(prices, starting_indexes, height_to_supply, exit)?; - self.cap_delta.compute( - starting_indexes.height, - &blocks.lookback._1m, - &self.minimal.cap.cents.height, - exit, - )?; - - self.net_pnl.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.net_pnl.raw.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 5fbb25e68..ade95d0f9 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -14,9 +14,10 @@ use crate::{ blocks, distribution::state::{WithCapital, CohortState, CostBasisData, RealizedState}, internal::{ - CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, FiatPerBlock, - FiatRollingDelta1m, FiatRollingDeltaExcept1m, LazyPerBlock, PercentPerBlock, - PercentRollingWindows, Price, PriceWithRatioExtendedPerBlock, RatioCents64, RatioCentsBp32, + CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, + ComputedPerBlockCumulativeWithSums, FiatPerBlockCumulativeWithSums, + LazyPerBlock, PercentPerBlock, PercentRollingWindows, Price, + PriceWithRatioExtendedPerBlock, RatioCents64, RatioCentsBp32, RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RatioDollarsBp32, RatioPerBlockPercentiles, RatioPerBlockStdDevBands, RatioSma, RollingWindows, RollingWindowsFrom1w, @@ -31,47 +32,22 @@ use super::RealizedCore; #[derive(Traversable)] pub struct RealizedProfit { pub rel_to_rcap: PercentPerBlock, - pub value_created: ComputedPerBlock, - pub value_destroyed: ComputedPerBlock, - #[traversable(wrap = "value_created", rename = "sum")] - pub value_created_sum: RollingWindows, - #[traversable(wrap = "value_destroyed", rename = "sum")] - pub value_destroyed_sum: RollingWindows, + pub value_created: ComputedPerBlockCumulativeWithSums, + pub value_destroyed: ComputedPerBlockCumulativeWithSums, pub distribution_flow: LazyPerBlock, - #[traversable(rename = "sum")] - pub sum_extended: RollingWindowsFrom1w, } #[derive(Traversable)] pub struct RealizedLoss { pub rel_to_rcap: PercentPerBlock, - pub value_created: ComputedPerBlock, - pub value_destroyed: ComputedPerBlock, - #[traversable(wrap = "value_created", rename = "sum")] - pub value_created_sum: RollingWindows, - #[traversable(wrap = "value_destroyed", rename = "sum")] - pub value_destroyed_sum: RollingWindows, + pub value_created: ComputedPerBlockCumulativeWithSums, + pub value_destroyed: ComputedPerBlockCumulativeWithSums, pub capitulation_flow: LazyPerBlock, - #[traversable(rename = "sum")] - pub sum_extended: RollingWindowsFrom1w, -} - -#[derive(Traversable)] -pub struct RealizedGrossPnl { - pub raw: FiatPerBlock, - pub sum: RollingWindows, - pub sell_side_risk_ratio: PercentRollingWindows, } #[derive(Traversable)] pub struct RealizedNetPnl { pub rel_to_rcap: PercentPerBlock, - pub cumulative: ComputedPerBlock, - #[traversable(rename = "sum")] - pub sum_extended: RollingWindowsFrom1w, - pub delta: FiatRollingDelta1m, - #[traversable(rename = "delta")] - pub delta_extended: FiatRollingDeltaExcept1m, #[traversable(wrap = "change_1m", rename = "rel_to_rcap")] pub change_1m_rel_to_rcap: PercentPerBlock, #[traversable(wrap = "change_1m", rename = "rel_to_mcap")] @@ -80,10 +56,6 @@ pub struct RealizedNetPnl { #[derive(Traversable)] pub struct RealizedSopr { - #[traversable(wrap = "value_created", rename = "sum")] - pub value_created_sum_extended: RollingWindowsFrom1w, - #[traversable(wrap = "value_destroyed", rename = "sum")] - pub value_destroyed_sum_extended: RollingWindowsFrom1w, #[traversable(rename = "ratio")] pub ratio_extended: RollingWindowsFrom1w, } @@ -100,7 +72,7 @@ pub struct RealizedInvestor { pub price: PriceWithRatioExtendedPerBlock, pub lower_price_band: Price>, pub upper_price_band: Price>, - #[traversable(wrap = "cap", rename = "raw")] + #[traversable(hidden)] pub cap_raw: M::Stored>, } @@ -113,7 +85,8 @@ pub struct RealizedFull { pub profit: RealizedProfit, pub loss: RealizedLoss, - pub gross_pnl: RealizedGrossPnl, + pub gross_pnl: FiatPerBlockCumulativeWithSums, + pub sell_side_risk_ratio: PercentRollingWindows, pub net_pnl: RealizedNetPnl, pub sopr: RealizedSopr, pub peak_regret: RealizedPeakRegret, @@ -121,10 +94,7 @@ pub struct RealizedFull { pub profit_to_loss_ratio: RollingWindows, - #[traversable(wrap = "cap", rename = "delta")] - pub cap_delta_extended: FiatRollingDeltaExcept1m, - - #[traversable(wrap = "cap", rename = "raw")] + #[traversable(hidden)] pub cap_raw: M::Stored>, #[traversable(wrap = "cap", rename = "rel_to_own_mcap")] pub cap_rel_to_own_mcap: PercentPerBlock, @@ -145,58 +115,46 @@ impl RealizedFull { let core = RealizedCore::forced_import(cfg)?; // Profit - let profit_value_destroyed: ComputedPerBlock = - cfg.import("profit_value_destroyed", v0)?; + let profit_value_destroyed: ComputedPerBlockCumulativeWithSums = + cfg.import("profit_value_destroyed", v1)?; let profit_flow = LazyPerBlock::from_computed::( - &cfg.name("profit_flow"), + &cfg.name("distribution_flow"), cfg.version, - profit_value_destroyed.height.read_only_boxed_clone(), - &profit_value_destroyed, + profit_value_destroyed.raw.height.read_only_boxed_clone(), + &profit_value_destroyed.raw, ); let profit = RealizedProfit { rel_to_rcap: cfg.import("realized_profit_rel_to_rcap", Version::new(2))?, - value_created: cfg.import("profit_value_created", v0)?, + value_created: cfg.import("profit_value_created", v1)?, value_destroyed: profit_value_destroyed, - value_created_sum: cfg.import("profit_value_created", v1)?, - value_destroyed_sum: cfg.import("profit_value_destroyed", v1)?, distribution_flow: profit_flow, - sum_extended: cfg.import("realized_profit", v1)?, }; // Loss - let loss_value_destroyed: ComputedPerBlock = - cfg.import("loss_value_destroyed", v0)?; + let loss_value_destroyed: ComputedPerBlockCumulativeWithSums = + cfg.import("loss_value_destroyed", v1)?; let capitulation_flow = LazyPerBlock::from_computed::( &cfg.name("capitulation_flow"), cfg.version, - loss_value_destroyed.height.read_only_boxed_clone(), - &loss_value_destroyed, + loss_value_destroyed.raw.height.read_only_boxed_clone(), + &loss_value_destroyed.raw, ); let loss = RealizedLoss { rel_to_rcap: cfg.import("realized_loss_rel_to_rcap", Version::new(2))?, - value_created: cfg.import("loss_value_created", v0)?, + value_created: cfg.import("loss_value_created", v1)?, value_destroyed: loss_value_destroyed, - value_created_sum: cfg.import("loss_value_created", v1)?, - value_destroyed_sum: cfg.import("loss_value_destroyed", v1)?, capitulation_flow, - sum_extended: cfg.import("realized_loss", v1)?, }; // Gross PnL - let gross_pnl = RealizedGrossPnl { - raw: cfg.import("realized_gross_pnl", v0)?, - sum: cfg.import("gross_pnl_sum", v1)?, - sell_side_risk_ratio: cfg.import("sell_side_risk_ratio", Version::new(2))?, - }; + let gross_pnl: FiatPerBlockCumulativeWithSums = + cfg.import("realized_gross_pnl", v1)?; + let sell_side_risk_ratio = cfg.import("sell_side_risk_ratio", Version::new(2))?; // Net PnL let net_pnl = RealizedNetPnl { rel_to_rcap: cfg .import("net_realized_pnl_rel_to_rcap", Version::new(2))?, - cumulative: cfg.import("net_realized_pnl_cumulative", v1)?, - sum_extended: cfg.import("net_realized_pnl", v1)?, - delta: cfg.import("net_pnl_delta", Version::new(5))?, - delta_extended: cfg.import("net_pnl_delta", Version::new(5))?, change_1m_rel_to_rcap: cfg .import("net_pnl_change_1m_rel_to_rcap", Version::new(4))?, change_1m_rel_to_mcap: cfg @@ -205,8 +163,6 @@ impl RealizedFull { // SOPR let sopr = RealizedSopr { - value_created_sum_extended: cfg.import("value_created", v1)?, - value_destroyed_sum_extended: cfg.import("value_destroyed", v1)?, ratio_extended: cfg.import("sopr", v1)?, }; @@ -234,12 +190,12 @@ impl RealizedFull { profit, loss, gross_pnl, + sell_side_risk_ratio, net_pnl, sopr, peak_regret, investor, profit_to_loss_ratio: cfg.import("realized_profit_to_loss_ratio", v1)?, - cap_delta_extended: cfg.import("realized_cap_delta", Version::new(5))?, cap_raw: cfg.import("cap_raw", v0)?, cap_rel_to_own_mcap: cfg.import("realized_cap_rel_to_own_mcap", v1)?, price_ratio_percentiles: RatioPerBlockPercentiles::forced_import( @@ -266,11 +222,12 @@ impl RealizedFull { pub(crate) fn min_stateful_len(&self) -> usize { self.profit .value_created + .raw .height .len() - .min(self.profit.value_destroyed.height.len()) - .min(self.loss.value_created.height.len()) - .min(self.loss.value_destroyed.height.len()) + .min(self.profit.value_destroyed.raw.height.len()) + .min(self.loss.value_created.raw.height.len()) + .min(self.loss.value_destroyed.raw.height.len()) .min(self.investor.price.cents.height.len()) .min(self.cap_raw.len()) .min(self.investor.cap_raw.len()) @@ -285,18 +242,22 @@ impl RealizedFull { self.core.truncate_push(height, state)?; self.profit .value_created + .raw .height .truncate_push(height, state.realized.profit_value_created())?; self.profit .value_destroyed + .raw .height .truncate_push(height, state.realized.profit_value_destroyed())?; self.loss .value_created + .raw .height .truncate_push(height, state.realized.loss_value_created())?; self.loss .value_destroyed + .raw .height .truncate_push(height, state.realized.loss_value_destroyed())?; self.investor @@ -320,10 +281,10 @@ impl RealizedFull { pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { let mut vecs = self.core.collect_vecs_mut(); - vecs.push(&mut self.profit.value_created.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.profit.value_destroyed.height); - vecs.push(&mut self.loss.value_created.height); - vecs.push(&mut self.loss.value_destroyed.height); + vecs.push(&mut self.profit.value_created.raw.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.profit.value_destroyed.raw.height); + vecs.push(&mut self.loss.value_created.raw.height); + vecs.push(&mut self.loss.value_destroyed.raw.height); vecs.push(&mut self.investor.price.cents.height); vecs.push(&mut self.cap_raw as &mut dyn AnyStoredVec); vecs.push(&mut self.investor.cap_raw as &mut dyn AnyStoredVec); @@ -350,18 +311,22 @@ impl RealizedFull { ) -> Result<()> { self.profit .value_created + .raw .height .truncate_push(height, accum.profit_value_created)?; self.profit .value_destroyed + .raw .height .truncate_push(height, accum.profit_value_destroyed)?; self.loss .value_created + .raw .height .truncate_push(height, accum.loss_value_created)?; self.loss .value_destroyed + .raw .height .truncate_push(height, accum.loss_value_destroyed)?; self.cap_raw @@ -395,18 +360,11 @@ impl RealizedFull { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.core - .compute_rest_part1(blocks, starting_indexes, exit)?; - - self.net_pnl.cumulative.height.compute_cumulative( - starting_indexes.height, - &self.core.net_pnl.raw.height, - exit, - )?; + .compute_rest_part1(starting_indexes, exit)?; self.peak_regret .value @@ -424,45 +382,20 @@ impl RealizedFull { exit: &Exit, ) -> Result<()> { self.core.compute_rest_part2( - blocks, prices, starting_indexes, height_to_supply, exit, )?; - let window_starts = blocks.lookback.window_starts(); - - // Net PnL rolling sums (1w, 1m, 1y) - self.net_pnl.sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.net_pnl.raw.height, - exit, - )?; - - // SOPR: value created/destroyed rolling sums and ratios - self.sopr.value_created_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.minimal.sopr.value_created.raw.height, - exit, - )?; - self.sopr - .value_destroyed_sum_extended - .compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.minimal.sopr.value_destroyed.raw.height, - exit, - )?; + // SOPR ratios from lazy rolling sums for ((sopr, vc), vd) in self .sopr .ratio_extended .as_mut_array() .into_iter() - .zip(self.sopr.value_created_sum_extended.as_array()) - .zip(self.sopr.value_destroyed_sum_extended.as_array()) + .zip(self.core.minimal.sopr.value_created.sum.as_array()[1..].iter()) + .zip(self.core.minimal.sopr.value_destroyed.sum.as_array()[1..].iter()) { sopr.compute_binary::( starting_indexes.height, @@ -493,36 +426,24 @@ impl RealizedFull { .rel_to_rcap .compute_binary::( starting_indexes.height, - &self.core.net_pnl.raw.height, + &self.core.net_pnl.raw.cents.height, &self.core.minimal.cap.cents.height, exit, )?; - // Profit/loss value created/destroyed rolling sums - self.profit.value_created_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.profit.value_created.height, - exit, - )?; - self.profit.value_destroyed_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.profit.value_destroyed.height, - exit, - )?; - self.loss.value_created_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.loss.value_created.height, - exit, - )?; - self.loss.value_destroyed_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.loss.value_destroyed.height, - exit, - )?; + // Profit/loss value created/destroyed cumulatives (rolling sums are lazy) + self.profit + .value_created + .compute_rest(starting_indexes.height, exit)?; + self.profit + .value_destroyed + .compute_rest(starting_indexes.height, exit)?; + self.loss + .value_created + .compute_rest(starting_indexes.height, exit)?; + self.loss + .value_destroyed + .compute_rest(starting_indexes.height, exit)?; // Gross PnL self.gross_pnl.raw.cents.height.compute_add( @@ -531,32 +452,15 @@ impl RealizedFull { &self.core.minimal.loss.raw.cents.height, exit, )?; + self.gross_pnl + .compute_rest(starting_indexes.height, exit)?; - self.gross_pnl.sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.gross_pnl.raw.cents.height, - exit, - )?; - - // Net PnL delta (1m base + 24h/1w/1y extended) - self.net_pnl.delta.compute( - starting_indexes.height, - &blocks.lookback._1m, - &self.net_pnl.cumulative.height, - exit, - )?; - self.net_pnl.delta_extended.compute( - starting_indexes.height, - &window_starts, - &self.net_pnl.cumulative.height, - exit, - )?; + // Net PnL 1m change relative to rcap and mcap self.net_pnl .change_1m_rel_to_rcap .compute_binary::( starting_indexes.height, - &self.net_pnl.delta.change_1m.cents.height, + &self.core.net_pnl.delta.change._1m.cents.height, &self.core.minimal.cap.cents.height, exit, )?; @@ -564,19 +468,11 @@ impl RealizedFull { .change_1m_rel_to_mcap .compute_binary::( starting_indexes.height, - &self.net_pnl.delta.change_1m.cents.height, + &self.core.net_pnl.delta.change._1m.cents.height, height_to_market_cap, exit, )?; - // Realized cap delta extended (24h/1w/1y — 1m is in RealizedCore) - self.cap_delta_extended.compute( - starting_indexes.height, - &window_starts, - &self.core.minimal.cap.cents.height, - exit, - )?; - // Peak regret rel to rcap self.peak_regret .rel_to_rcap @@ -636,7 +532,6 @@ impl RealizedFull { // Sell-side risk ratios for (ssrr, rv) in self - .gross_pnl .sell_side_risk_ratio .as_mut_array() .into_iter() @@ -644,26 +539,12 @@ impl RealizedFull { { ssrr.compute_binary::( starting_indexes.height, - &rv.height, + &rv.cents.height, &self.core.minimal.cap.cents.height, exit, )?; } - // Profit/loss sum extended (1w, 1m, 1y) - self.profit.sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.minimal.profit.raw.cents.height, - exit, - )?; - self.loss.sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.minimal.loss.raw.cents.height, - exit, - )?; - // Realized cap relative to own market cap self.cap_rel_to_own_mcap .compute_binary::( @@ -674,25 +555,17 @@ impl RealizedFull { )?; // Realized profit to loss ratios - self.profit_to_loss_ratio - ._24h - .compute_binary::( - starting_indexes.height, - &self.core.minimal.profit.sum._24h.cents.height, - &self.core.minimal.loss.sum._24h.cents.height, - exit, - )?; for ((ratio, profit), loss) in self .profit_to_loss_ratio - .as_mut_array_from_1w() + .as_mut_array() .into_iter() - .zip(self.profit.sum_extended.as_array()) - .zip(self.loss.sum_extended.as_array()) + .zip(self.core.minimal.profit.sum.as_array()) + .zip(self.core.minimal.loss.sum.as_array()) { ratio.compute_binary::( starting_indexes.height, - &profit.height, - &loss.height, + &profit.cents.height, + &loss.cents.height, exit, )?; } diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs index 6694deca5..78dce5318 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -1,7 +1,7 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - BasisPoints32, Bitcoin, Cents, Height, Indexes, Sats, StoredF32, + BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Height, Indexes, Sats, StoredF32, Version, }; use vecdb::{ @@ -9,11 +9,10 @@ use vecdb::{ }; use crate::{ - blocks, distribution::state::{CohortState, CostBasisOps, RealizedOps}, internal::{ - FiatPerBlock, FiatPerBlockWithSum24h, Identity, LazyPerBlock, - PerBlockWithSum24h, PriceWithRatioPerBlock, + ComputedPerBlockCumulativeWithSums, FiatPerBlockCumulativeWithSums, + FiatPerBlockWithDeltas, Identity, LazyPerBlock, PriceWithRatioPerBlock, }, prices, }; @@ -22,17 +21,15 @@ use crate::distribution::metrics::ImportConfig; #[derive(Traversable)] pub struct RealizedSoprMinimal { - pub value_created: PerBlockWithSum24h, - pub value_destroyed: PerBlockWithSum24h, + pub value_created: ComputedPerBlockCumulativeWithSums, + pub value_destroyed: ComputedPerBlockCumulativeWithSums, } -/// Minimal realized metrics: cap (fiat), profit/loss (fiat + 24h sum), -/// price, mvrv, sopr (value_created/destroyed with 24h sums). #[derive(Traversable)] pub struct RealizedMinimal { - pub cap: FiatPerBlock, - pub profit: FiatPerBlockWithSum24h, - pub loss: FiatPerBlockWithSum24h, + pub cap: FiatPerBlockWithDeltas, + pub profit: FiatPerBlockCumulativeWithSums, + pub loss: FiatPerBlockCumulativeWithSums, pub price: PriceWithRatioPerBlock, pub mvrv: LazyPerBlock, @@ -43,7 +40,14 @@ impl RealizedMinimal { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; - let cap: FiatPerBlock = cfg.import("realized_cap", Version::ZERO)?; + let cap = FiatPerBlockWithDeltas::forced_import( + cfg.db, + &cfg.name("realized_cap"), + cfg.version, + v1, + cfg.indexes, + cfg.cached_starts, + )?; let price: PriceWithRatioPerBlock = cfg.import("realized_price", v1)?; let mvrv = LazyPerBlock::from_lazy::, BasisPoints32>( @@ -119,34 +123,17 @@ impl RealizedMinimal { pub(crate) fn compute_rest_part1( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.profit.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.profit.raw.cents.height, - exit, - )?; - self.loss.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.loss.raw.cents.height, - exit, - )?; - self.sopr.value_created.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.sopr.value_created.raw.height, - exit, - )?; - self.sopr.value_destroyed.sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._24h, - &self.sopr.value_destroyed.raw.height, - exit, - )?; + self.profit.compute_rest(starting_indexes.height, exit)?; + self.loss.compute_rest(starting_indexes.height, exit)?; + self.sopr + .value_created + .compute_rest(starting_indexes.height, exit)?; + self.sopr + .value_destroyed + .compute_rest(starting_indexes.height, 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 e5711465a..89cb3d868 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/mod.rs @@ -12,19 +12,14 @@ use brk_error::Result; use brk_types::{Height, Indexes}; use vecdb::Exit; -use crate::{blocks, distribution::state::{WithCapital, CohortState, CostBasisData, RealizedState}}; +use crate::distribution::state::{WithCapital, CohortState, CostBasisData, RealizedState}; -/// Polymorphic dispatch for realized metric types. -/// -/// Both `RealizedCore` and `RealizedFull` have the same inherent methods -/// but with different behavior (Full checks/pushes more fields). -/// This trait enables `CohortMetricsBase` to dispatch correctly via associated type. pub trait RealizedLike: Send + Sync { fn as_core(&self) -> &RealizedCore; fn as_core_mut(&mut self) -> &mut RealizedCore; fn min_stateful_len(&self) -> usize; fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()>; - fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()>; + fn compute_rest_part1(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()>; fn compute_from_stateful( &mut self, starting_indexes: &Indexes, @@ -40,8 +35,8 @@ impl RealizedLike for RealizedCore { fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()> { self.truncate_push(height, state) } - fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { - self.compute_rest_part1(blocks, starting_indexes, exit) + 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<()> { self.compute_from_stateful(starting_indexes, others, exit) @@ -55,8 +50,8 @@ impl RealizedLike for RealizedFull { fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()> { self.truncate_push(height, state) } - fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { - self.compute_rest_part1(blocks, starting_indexes, exit) + 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<()> { self.compute_from_stateful(starting_indexes, others, exit) diff --git a/crates/brk_computer/src/distribution/metrics/supply/base.rs b/crates/brk_computer/src/distribution/metrics/supply/base.rs index 8daf66b46..bc46637fb 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/base.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/base.rs @@ -1,13 +1,13 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Height, Indexes, Version}; +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, HalveCents, HalveDollars, HalveSats, HalveSatsToBitcoin, - LazyAmountPerBlock, + LazyAmountPerBlock, LazyRollingDeltasFromHeight, }; use crate::distribution::metrics::ImportConfig; @@ -17,6 +17,7 @@ use crate::distribution::metrics::ImportConfig; pub struct SupplyBase { pub total: AmountPerBlock, pub half: LazyAmountPerBlock, + pub delta: LazyRollingDeltasFromHeight, } impl SupplyBase { @@ -30,9 +31,18 @@ impl SupplyBase { HalveDollars, >(&cfg.name("supply_half"), &supply, cfg.version); + let delta = LazyRollingDeltasFromHeight::new( + &cfg.name("supply_delta"), + cfg.version + Version::ONE, + &supply.sats.height, + cfg.cached_starts, + cfg.indexes, + ); + Ok(Self { total: supply, half: supply_half, + delta, }) } diff --git a/crates/brk_computer/src/distribution/metrics/supply/core.rs b/crates/brk_computer/src/distribution/metrics/supply/core.rs index b05137c07..43f631e26 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/core.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/core.rs @@ -80,6 +80,10 @@ impl SupplyCore { Ok(()) } + pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { + Ok(()) + } + pub(crate) fn compute_from_stateful( &mut self, starting_indexes: &Indexes, diff --git a/crates/brk_computer/src/distribution/metrics/supply/full.rs b/crates/brk_computer/src/distribution/metrics/supply/full.rs deleted file mode 100644 index df040e003..000000000 --- a/crates/brk_computer/src/distribution/metrics/supply/full.rs +++ /dev/null @@ -1,64 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Indexes, Sats, SatsSigned, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; - -use crate::{blocks, internal::RollingDelta1m}; - -use crate::distribution::metrics::ImportConfig; - -use super::SupplyCore; - -/// Full supply metrics: total + in_profit/in_loss + delta (6 stored vecs). -#[derive(Deref, DerefMut, Traversable)] -pub struct SupplyFull { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub core: SupplyCore, - - pub delta: RollingDelta1m, -} - -impl SupplyFull { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let core = SupplyCore::forced_import(cfg)?; - let delta = cfg.import("supply_delta", Version::ONE)?; - - Ok(Self { core, delta }) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - self.core.collect_vecs_mut() - } - - pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { - Ok(()) - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - let core_refs: Vec<&SupplyCore> = others.iter().map(|o| &o.core).collect(); - self.core - .compute_from_stateful(starting_indexes, &core_refs, exit) - } - - pub(crate) fn compute_rest_part1( - &mut self, - blocks: &blocks::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.delta.compute( - starting_indexes.height, - &blocks.lookback._1m, - &self.core.total.sats.height, - exit, - ) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/supply/mod.rs b/crates/brk_computer/src/distribution/metrics/supply/mod.rs index ddf44426f..78e115300 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/mod.rs @@ -1,7 +1,5 @@ mod base; mod core; -mod full; pub use base::SupplyBase; pub use self::core::SupplyCore; -pub use full::SupplyFull; diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs index e6302b442..e448ad49d 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs @@ -4,7 +4,7 @@ use brk_types::{CentsSats, CentsSquaredSats, Height, Indexes, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, BytesVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; -use crate::{blocks, distribution::{metrics::ImportConfig, state::UnrealizedState}}; +use crate::distribution::{metrics::ImportConfig, state::UnrealizedState}; use super::UnrealizedCore; @@ -15,13 +15,13 @@ pub struct UnrealizedBase { #[traversable(flatten)] pub core: UnrealizedCore, - #[traversable(wrap = "invested_capital/in_profit", rename = "raw")] + #[traversable(hidden)] pub invested_capital_in_profit_raw: M::Stored>, - #[traversable(wrap = "invested_capital/in_loss", rename = "raw")] + #[traversable(hidden)] pub invested_capital_in_loss_raw: M::Stored>, - #[traversable(wrap = "investor_cap/in_profit", rename = "raw")] + #[traversable(hidden)] pub investor_cap_in_profit_raw: M::Stored>, - #[traversable(wrap = "investor_cap/in_loss", rename = "raw")] + #[traversable(hidden)] pub investor_cap_in_loss_raw: M::Stored>, } @@ -165,11 +165,10 @@ impl UnrealizedBase { pub(crate) fn compute_rest( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.core.compute_rest(blocks, starting_indexes, exit)?; + self.core.compute_rest(starting_indexes, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs index a17dff805..1e3f590d9 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs @@ -5,22 +5,20 @@ use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; use crate::{ - blocks, distribution::{metrics::ImportConfig, state::UnrealizedState}, - internal::FiatPerBlockWithSum24h, + internal::FiatPerBlockCumulativeWithSums, }; use super::UnrealizedMinimal; -/// Basic unrealized metrics: nupl + unrealized profit/loss (fiat + 24h sums). #[derive(Deref, DerefMut, Traversable)] pub struct UnrealizedBasic { #[deref] #[deref_mut] #[traversable(flatten)] pub minimal: UnrealizedMinimal, - pub profit: FiatPerBlockWithSum24h, - pub loss: FiatPerBlockWithSum24h, + pub profit: FiatPerBlockCumulativeWithSums, + pub loss: FiatPerBlockCumulativeWithSums, } impl UnrealizedBasic { @@ -77,23 +75,11 @@ impl UnrealizedBasic { pub(crate) fn compute_rest( &mut self, - blocks: &blocks::Vecs, max_from: Height, exit: &Exit, ) -> Result<()> { - self.profit.sum.compute_rolling_sum( - max_from, - &blocks.lookback._24h, - &self.profit.raw.cents.height, - exit, - )?; - self.loss.sum.compute_rolling_sum( - max_from, - &blocks.lookback._24h, - &self.loss.raw.cents.height, - exit, - )?; - + self.profit.compute_rest(max_from, exit)?; + self.loss.compute_rest(max_from, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs index afe4d24c8..6c4a87848 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs @@ -5,7 +5,6 @@ use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, Rw, StorageMode}; use crate::{ - blocks, distribution::{ metrics::ImportConfig, state::UnrealizedState, @@ -78,15 +77,13 @@ impl UnrealizedCore { Ok(()) } - /// Compute derived metrics from stored values. pub(crate) fn compute_rest( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.basic - .compute_rest(blocks, starting_indexes.height, exit)?; + .compute_rest(starting_indexes.height, exit)?; self.net_pnl .cents diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs index 370928ca4..04d4c78ee 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs @@ -6,7 +6,7 @@ use vecdb::{AnyStoredVec, Exit, Rw, StorageMode, WritableVec}; use crate::distribution::state::UnrealizedState; use crate::internal::{CentsSubtractToCentsSigned, FiatPerBlock}; -use crate::{blocks, distribution::metrics::ImportConfig, prices}; +use crate::{distribution::metrics::ImportConfig, prices}; use super::UnrealizedBase; @@ -88,12 +88,11 @@ impl UnrealizedFull { pub(crate) fn compute_rest_all( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.inner.compute_rest(blocks, starting_indexes, exit)?; + self.inner.compute_rest(starting_indexes, exit)?; self.gross_pnl.cents.height.compute_add( starting_indexes.height, diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs index 95d57018e..75d9271fe 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs @@ -15,7 +15,12 @@ pub struct UnrealizedMinimal { impl UnrealizedMinimal { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - nupl: cfg.import("nupl", Version::ONE)?, + nupl: RatioPerBlock::forced_import_raw( + cfg.db, + &cfg.name("nupl"), + cfg.version + Version::ONE, + cfg.indexes, + )?, }) } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs index 7f458c747..840ef5ed1 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs @@ -14,7 +14,7 @@ use brk_error::Result; use brk_types::{Height, Indexes}; use vecdb::Exit; -use crate::{blocks, distribution::state::UnrealizedState, prices}; +use crate::{distribution::state::UnrealizedState, prices}; pub trait UnrealizedLike: Send + Sync { fn as_base(&self) -> &UnrealizedBase; @@ -23,7 +23,6 @@ pub trait UnrealizedLike: Send + Sync { fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()>; fn compute_rest( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, @@ -50,12 +49,11 @@ impl UnrealizedLike for UnrealizedBase { } fn compute_rest( &mut self, - blocks: &blocks::Vecs, _prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.compute_rest(blocks, starting_indexes, exit) + self.compute_rest(starting_indexes, exit) } fn compute_net_sentiment_height( &mut self, @@ -81,12 +79,11 @@ impl UnrealizedLike for UnrealizedFull { } fn compute_rest( &mut self, - blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.compute_rest_all(blocks, prices, starting_indexes, exit) + self.compute_rest_all(prices, starting_indexes, exit) } fn compute_net_sentiment_height( &mut self, diff --git a/crates/brk_computer/src/distribution/vecs.rs b/crates/brk_computer/src/distribution/vecs.rs index 0c85e98aa..4403abe93 100644 --- a/crates/brk_computer/src/distribution/vecs.rs +++ b/crates/brk_computer/src/distribution/vecs.rs @@ -23,7 +23,7 @@ use crate::{ state::BlockState, }, indexes, inputs, - internal::{ComputedPerBlockCumulative, finalize_db, open_db}, + internal::{CachedWindowStarts, ComputedPerBlockCumulative, finalize_db, open_db}, outputs, prices, transactions, }; @@ -32,7 +32,6 @@ use super::{ address::{ AddressCountsVecs, AddressActivityVecs, DeltaVecs, NewAddressCountVecs, TotalAddressCountVecs, }, - compute::aggregates, }; const VERSION: Version = Version::new(22); @@ -44,7 +43,7 @@ pub struct AddressMetricsVecs { pub activity: AddressActivityVecs, pub total: TotalAddressCountVecs, pub new: NewAddressCountVecs, - pub delta: DeltaVecs, + pub delta: DeltaVecs, #[traversable(wrap = "indexes", rename = "funded")] pub funded_index: LazyVecFrom1, @@ -100,6 +99,7 @@ impl Vecs { parent: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db_path = parent.join(super::DB_NAME); let states_path = db_path.join("states"); @@ -109,9 +109,9 @@ impl Vecs { let version = parent_version + VERSION; - let utxo_cohorts = UTXOCohorts::forced_import(&db, version, indexes, &states_path)?; + let utxo_cohorts = UTXOCohorts::forced_import(&db, version, indexes, &states_path, cached_starts)?; - let address_cohorts = AddressCohorts::forced_import(&db, version, indexes, &states_path)?; + let address_cohorts = AddressCohorts::forced_import(&db, version, indexes, &states_path, cached_starts)?; // Create address data BytesVecs first so we can also use them for identity mappings let fundedaddressindex_to_fundedaddressdata = BytesVec::forced_import_with( @@ -141,16 +141,17 @@ impl Vecs { let empty_address_count = AddressCountsVecs::forced_import(&db, "empty_address_count", version, indexes)?; let address_activity = - AddressActivityVecs::forced_import(&db, "address_activity", version, indexes)?; + AddressActivityVecs::forced_import(&db, "address_activity", version, indexes, cached_starts)?; // Stored total = address_count + empty_address_count (global + per-type, with all derived indexes) let total_address_count = TotalAddressCountVecs::forced_import(&db, version, indexes)?; // Per-block delta of total (global + per-type) - let new_address_count = NewAddressCountVecs::forced_import(&db, version, indexes)?; + let new_address_count = + NewAddressCountVecs::forced_import(&db, version, indexes, cached_starts)?; - // Growth rate: new / address_count (global + per-type) - let delta = DeltaVecs::forced_import(&db, version, indexes)?; + // Growth rate: delta change + rate (global + per-type) + let delta = DeltaVecs::new(version, &address_count, cached_starts, indexes); let this = Self { supply_state: BytesVec::forced_import_with( @@ -400,26 +401,30 @@ impl Vecs { self.txindex_to_height = txindex_to_height; // 5. Compute aggregates (overlapping cohorts from separate cohorts) - aggregates::compute_overlapping( - &mut self.utxo_cohorts, - &mut self.address_cohorts, - starting_indexes, - exit, - )?; + info!("Computing overlapping cohorts..."); + { + let (r1, r2) = rayon::join( + || self.utxo_cohorts.compute_overlapping_vecs(starting_indexes, exit), + || self.address_cohorts.compute_overlapping_vecs(starting_indexes, exit), + ); + r1?; + r2?; + } // 5b. Compute coinblocks_destroyed cumulative from raw self.coinblocks_destroyed .compute_rest(starting_indexes.height, exit)?; // 6. Compute rest part1 (day1 mappings) - aggregates::compute_rest_part1( - &mut self.utxo_cohorts, - &mut self.address_cohorts, - blocks, - prices, - starting_indexes, - exit, - )?; + info!("Computing rest part 1..."); + { + let (r1, r2) = rayon::join( + || self.utxo_cohorts.compute_rest_part1(prices, starting_indexes, exit), + || self.address_cohorts.compute_rest_part1(prices, starting_indexes, exit), + ); + r1?; + r2?; + } // 6b. Compute address count sum (by addresstype → all) self.addresses.funded.compute_rest(starting_indexes, exit)?; @@ -433,25 +438,15 @@ impl Vecs { exit, )?; - let window_starts = blocks.lookback.window_starts(); - self.addresses .activity - .compute_rest(starting_indexes.height, &window_starts, exit)?; + .compute_rest(starting_indexes.height, exit)?; self.addresses.new.compute( starting_indexes.height, - &window_starts, &self.addresses.total, exit, )?; - self.addresses.delta.compute( - starting_indexes.height, - &window_starts, - &self.addresses.funded, - exit, - )?; - // 7. Compute rest part2 (relative metrics) let height_to_market_cap = self .utxo_cohorts @@ -463,15 +458,16 @@ impl Vecs { .height .read_only_clone(); - aggregates::compute_rest_part2( - &mut self.utxo_cohorts, - &mut self.address_cohorts, + info!("Computing rest part 2..."); + self.utxo_cohorts.compute_rest_part2( blocks, prices, starting_indexes, &height_to_market_cap, exit, )?; + self.address_cohorts + .compute_rest_part2(prices, starting_indexes, exit)?; let _lock = exit.lock(); self.db.compact()?; diff --git a/crates/brk_computer/src/indicators/compute.rs b/crates/brk_computer/src/indicators/compute.rs index ff5a55e0b..701ef2b17 100644 --- a/crates/brk_computer/src/indicators/compute.rs +++ b/crates/brk_computer/src/indicators/compute.rs @@ -69,7 +69,7 @@ impl Vecs { .compute_binary::( starting_indexes.height, market_cap, - &transactions.volume.sent_sum.rolling._24h.usd.height, + &transactions.volume.sent_sum.sum._24h.usd.height, exit, )?; diff --git a/crates/brk_computer/src/inputs/count/import.rs b/crates/brk_computer/src/inputs/count/import.rs index a0aba57de..7ea1d2bc0 100644 --- a/crates/brk_computer/src/inputs/count/import.rs +++ b/crates/brk_computer/src/inputs/count/import.rs @@ -3,19 +3,21 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::ComputedPerBlockAggregated}; +use crate::{indexes, internal::{CachedWindowStarts, ComputedPerBlockAggregated}}; impl Vecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self(ComputedPerBlockAggregated::forced_import( db, "input_count", version, indexes, + cached_starts, )?)) } } diff --git a/crates/brk_computer/src/inputs/import.rs b/crates/brk_computer/src/inputs/import.rs index 39742f882..c01252841 100644 --- a/crates/brk_computer/src/inputs/import.rs +++ b/crates/brk_computer/src/inputs/import.rs @@ -5,7 +5,7 @@ use brk_types::Version; use crate::{ indexes, - internal::{finalize_db, open_db}, + internal::{finalize_db, open_db, CachedWindowStarts}, }; use super::{CountVecs, SpentVecs, Vecs}; @@ -15,12 +15,13 @@ impl Vecs { parent_path: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, super::DB_NAME, 50_000_000)?; let version = parent_version; let spent = SpentVecs::forced_import(&db, version)?; - let count = CountVecs::forced_import(&db, version, indexes)?; + let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?; let this = Self { db, spent, count }; finalize_db(&this.db, &this)?; diff --git a/crates/brk_computer/src/internal/amount/base.rs b/crates/brk_computer/src/internal/amount/base.rs deleted file mode 100644 index 4ace22218..000000000 --- a/crates/brk_computer/src/internal/amount/base.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! Amount type with height-level data only (no period-derived views). -//! -//! Stores sats and cents per index, plus lazy btc and usd transforms. -//! Use when period views are unnecessary (e.g., rolling windows provide windowed data). - -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, VecIndex, -}; - -use crate::{ - internal::{CentsUnsignedToDollars, SatsToBitcoin, SatsToCents}, - prices, -}; - -const VERSION: Version = Version::TWO; // Match AmountPerBlock versioning - -#[derive(Traversable)] -pub struct Amount { - pub sats: M::Stored>>, - pub btc: LazyVecFrom1, - pub cents: M::Stored>>, - pub usd: LazyVecFrom1, -} - -impl Amount { - pub(crate) fn forced_import(db: &Database, name: &str, version: Version) -> Result { - let v = version + VERSION; - - let sats: EagerVec> = - EagerVec::forced_import(db, &format!("{name}_sats"), v)?; - let btc = LazyVecFrom1::transformed::(name, v, sats.read_only_boxed_clone()); - let cents: EagerVec> = - EagerVec::forced_import(db, &format!("{name}_cents"), v)?; - let usd = LazyVecFrom1::transformed::( - &format!("{name}_usd"), - v, - cents.read_only_boxed_clone(), - ); - - Ok(Self { - sats, - btc, - cents, - usd, - }) - } - - /// Eagerly compute cents height values: sats[h] * price_cents[h] / 1e8. - pub(crate) fn compute_cents( - &mut self, - prices: &prices::Vecs, - max_from: Height, - exit: &Exit, - ) -> Result<()> { - self.cents.compute_binary::( - max_from, - &self.sats, - &prices.spot.cents.height, - exit, - )?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/amount/mod.rs b/crates/brk_computer/src/internal/amount/mod.rs index 230d73479..2a1d11a5c 100644 --- a/crates/brk_computer/src/internal/amount/mod.rs +++ b/crates/brk_computer/src/internal/amount/mod.rs @@ -1,5 +1,3 @@ -mod base; mod lazy; -pub use base::*; pub use lazy::*; diff --git a/crates/brk_computer/src/internal/containers/mod.rs b/crates/brk_computer/src/internal/containers/mod.rs index 908e4d47e..a79217bae 100644 --- a/crates/brk_computer/src/internal/containers/mod.rs +++ b/crates/brk_computer/src/internal/containers/mod.rs @@ -2,12 +2,10 @@ mod distribution_stats; mod per_resolution; mod window_24h; mod windows; -mod windows_except_1m; mod windows_from_1w; pub use distribution_stats::*; pub use per_resolution::*; pub use window_24h::*; pub use windows::*; -pub use windows_except_1m::*; pub use windows_from_1w::*; diff --git a/crates/brk_computer/src/internal/containers/windows.rs b/crates/brk_computer/src/internal/containers/windows.rs index cd7204f3d..06286b93c 100644 --- a/crates/brk_computer/src/internal/containers/windows.rs +++ b/crates/brk_computer/src/internal/containers/windows.rs @@ -1,4 +1,11 @@ use brk_traversable::Traversable; +use brk_types::Height; +use vecdb::CachedVec; + +/// Cached window starts for lazy rolling computations. +/// Clone-cheap (all fields are Arc-backed). Shared across all metrics. +#[derive(Clone)] +pub struct CachedWindowStarts(pub Windows>); #[derive(Clone, Traversable)] pub struct Windows { @@ -33,4 +40,32 @@ impl Windows { pub fn as_mut_array_from_1w(&mut self) -> [&mut A; 3] { [&mut self._1w, &mut self._1m, &mut self._1y] } + + pub fn map_with_suffix(&self, mut f: impl FnMut(&str, &A) -> B) -> Windows { + Windows { + _24h: f(Self::SUFFIXES[0], &self._24h), + _1w: f(Self::SUFFIXES[1], &self._1w), + _1m: f(Self::SUFFIXES[2], &self._1m), + _1y: f(Self::SUFFIXES[3], &self._1y), + } + } +} + +impl Windows<(A, B)> { + pub fn unzip(self) -> (Windows, Windows) { + ( + Windows { + _24h: self._24h.0, + _1w: self._1w.0, + _1m: self._1m.0, + _1y: self._1y.0, + }, + Windows { + _24h: self._24h.1, + _1w: self._1w.1, + _1m: self._1m.1, + _1y: self._1y.1, + }, + ) + } } diff --git a/crates/brk_computer/src/internal/containers/windows_except_1m.rs b/crates/brk_computer/src/internal/containers/windows_except_1m.rs deleted file mode 100644 index 8e8549624..000000000 --- a/crates/brk_computer/src/internal/containers/windows_except_1m.rs +++ /dev/null @@ -1,30 +0,0 @@ -use brk_traversable::Traversable; - -#[derive(Clone, Traversable)] -pub struct WindowsExcept1m { - pub _24h: A, - pub _1w: A, - pub _1y: A, -} - -impl WindowsExcept1m { - pub const SUFFIXES: [&'static str; 3] = ["24h", "1w", "1y"]; - - pub fn try_from_fn( - mut f: impl FnMut(&str) -> std::result::Result, - ) -> std::result::Result { - Ok(Self { - _24h: f(Self::SUFFIXES[0])?, - _1w: f(Self::SUFFIXES[1])?, - _1y: f(Self::SUFFIXES[2])?, - }) - } - - pub fn as_array(&self) -> [&A; 3] { - [&self._24h, &self._1w, &self._1y] - } - - pub fn as_mut_array(&mut self) -> [&mut A; 3] { - [&mut self._24h, &mut self._1w, &mut self._1y] - } -} 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 7b3e782c8..7a4589509 100644 --- a/crates/brk_computer/src/internal/per_block/amount/base.rs +++ b/crates/brk_computer/src/internal/per_block/amount/base.rs @@ -1,13 +1,12 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, Version}; -use vecdb::{AnyVec, Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; +use vecdb::{AnyVec, Database, Exit, ReadableCloneableVec, Rw, StorageMode}; use crate::{ indexes, internal::{ CentsUnsignedToDollars, ComputedPerBlock, LazyPerBlock, SatsToBitcoin, SatsToCents, - Windows, }, prices, }; @@ -74,33 +73,5 @@ impl AmountPerBlock { Ok(()) } - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - window_starts: &impl ReadableVec, - sats_source: &impl ReadableVec, - cents_source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.sats - .height - .compute_rolling_sum(max_from, window_starts, sats_source, exit)?; - self.cents - .height - .compute_rolling_sum(max_from, window_starts, cents_source, exit)?; - Ok(()) - } } -impl Windows { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Windows::try_from_fn(|suffix| { - AmountPerBlock::forced_import(db, &format!("{name}_{suffix}"), version, indexes) - }) - } -} diff --git a/crates/brk_computer/src/internal/per_block/amount/cumulative_sum.rs b/crates/brk_computer/src/internal/per_block/amount/cumulative_sum.rs index 284887e3f..1d5039103 100644 --- a/crates/brk_computer/src/internal/per_block/amount/cumulative_sum.rs +++ b/crates/brk_computer/src/internal/per_block/amount/cumulative_sum.rs @@ -5,61 +5,76 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; use crate::{ indexes, - internal::{AmountPerBlock, RollingSumAmountPerBlock, SatsToCents, WindowStarts}, + internal::{AmountPerBlock, CachedWindowStarts, LazyRollingSumsAmountFromHeight, SatsToCents}, prices, }; #[derive(Traversable)] -pub struct AmountPerBlockCumulativeSum { - pub base: AmountPerBlock, +pub struct AmountPerBlockCumulativeWithSums { + pub raw: AmountPerBlock, pub cumulative: AmountPerBlock, - pub sum: RollingSumAmountPerBlock, + pub sum: LazyRollingSumsAmountFromHeight, } const VERSION: Version = Version::TWO; -impl AmountPerBlockCumulativeSum { +impl AmountPerBlockCumulativeWithSums { pub(crate) fn forced_import( db: &Database, name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let v = version + VERSION; + let raw = AmountPerBlock::forced_import(db, name, v, indexes)?; + let cumulative = + AmountPerBlock::forced_import(db, &format!("{name}_cumulative"), v, indexes)?; + let sum = LazyRollingSumsAmountFromHeight::new( + &format!("{name}_sum"), + v, + &cumulative.sats.height, + &cumulative.cents.height, + cached_starts, + indexes, + ); + Ok(Self { - base: AmountPerBlock::forced_import(db, name, v, indexes)?, - cumulative: AmountPerBlock::forced_import( - db, - &format!("{name}_cumulative"), - v, - indexes, - )?, - sum: RollingSumAmountPerBlock::forced_import(db, name, v, indexes)?, + raw, + cumulative, + sum, }) } pub(crate) fn compute( &mut self, max_from: Height, - windows: &WindowStarts<'_>, prices: &prices::Vecs, exit: &Exit, compute_sats: impl FnOnce(&mut EagerVec>) -> Result<()>, ) -> Result<()> { - compute_sats(&mut self.base.sats.height)?; + compute_sats(&mut self.raw.sats.height)?; + self.compute_rest(max_from, prices, exit) + } + pub(crate) fn compute_rest( + &mut self, + max_from: Height, + prices: &prices::Vecs, + exit: &Exit, + ) -> Result<()> { self.cumulative .sats .height - .compute_cumulative(max_from, &self.base.sats.height, exit)?; + .compute_cumulative(max_from, &self.raw.sats.height, exit)?; - self.base + self.raw .cents .height .compute_binary::( max_from, - &self.base.sats.height, + &self.raw.sats.height, &prices.spot.cents.height, exit, )?; @@ -67,15 +82,7 @@ impl AmountPerBlockCumulativeSum { self.cumulative .cents .height - .compute_cumulative(max_from, &self.base.cents.height, exit)?; - - self.sum.compute_rolling_sum( - max_from, - windows, - &self.base.sats.height, - &self.base.cents.height, - exit, - )?; + .compute_cumulative(max_from, &self.raw.cents.height, exit)?; Ok(()) } 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 4f377df01..62201b126 100644 --- a/crates/brk_computer/src/internal/per_block/amount/full.rs +++ b/crates/brk_computer/src/internal/per_block/amount/full.rs @@ -5,7 +5,10 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; use crate::{ indexes, - internal::{AmountPerBlock, RollingFullAmountPerBlock, SatsToCents, WindowStarts}, + internal::{ + AmountPerBlock, CachedWindowStarts, LazyRollingSumsAmountFromHeight, + RollingDistributionAmountPerBlock, SatsToCents, WindowStarts, + }, prices, }; @@ -13,8 +16,9 @@ use crate::{ pub struct AmountPerBlockFull { pub base: AmountPerBlock, pub cumulative: AmountPerBlock, + pub sum: LazyRollingSumsAmountFromHeight, #[traversable(flatten)] - pub rolling: RollingFullAmountPerBlock, + pub rolling: RollingDistributionAmountPerBlock, } const VERSION: Version = Version::TWO; @@ -25,18 +29,33 @@ impl AmountPerBlockFull { name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let v = version + VERSION; + let base = AmountPerBlock::forced_import(db, name, v, indexes)?; + let cumulative = AmountPerBlock::forced_import( + db, + &format!("{name}_cumulative"), + v, + indexes, + )?; + let sum = LazyRollingSumsAmountFromHeight::new( + &format!("{name}_sum"), + v, + &cumulative.sats.height, + &cumulative.cents.height, + cached_starts, + indexes, + ); + let rolling = + RollingDistributionAmountPerBlock::forced_import(db, name, v, indexes)?; + Ok(Self { - base: AmountPerBlock::forced_import(db, name, v, indexes)?, - cumulative: AmountPerBlock::forced_import( - db, - &format!("{name}_cumulative"), - v, - indexes, - )?, - rolling: RollingFullAmountPerBlock::forced_import(db, name, v, indexes)?, + base, + cumulative, + sum, + rolling, }) } diff --git a/crates/brk_computer/src/internal/per_block/amount/lazy_rolling_sum.rs b/crates/brk_computer/src/internal/per_block/amount/lazy_rolling_sum.rs new file mode 100644 index 000000000..b23262ac8 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/amount/lazy_rolling_sum.rs @@ -0,0 +1,124 @@ +use brk_traversable::Traversable; +use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{DeltaSub, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec}; + +use crate::{ + indexes, + internal::{ + CachedWindowStarts, CentsUnsignedToDollars, DerivedResolutions, LazyPerBlock, + LazyRollingSumFromHeight, Resolutions, SatsToBitcoin, Windows, + }, +}; + +/// Single window slot: lazy rolling sum for Amount (sats + btc + cents + usd). +#[derive(Clone, Traversable)] +pub struct LazyRollingSumAmountFromHeight { + pub sats: LazyRollingSumFromHeight, + pub btc: LazyPerBlock, + pub cents: LazyRollingSumFromHeight, + pub usd: LazyPerBlock, +} + +/// Lazy rolling sums for all 4 windows, for Amount (sats + btc + cents + usd). +#[derive(Clone, Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct LazyRollingSumsAmountFromHeight(pub Windows); + +impl LazyRollingSumsAmountFromHeight { + pub fn new( + name: &str, + version: Version, + cumulative_sats: &(impl ReadableCloneableVec + 'static), + cumulative_cents: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, + indexes: &indexes::Vecs, + ) -> Self { + let cum_sats = cumulative_sats.read_only_boxed_clone(); + let cum_cents = cumulative_cents.read_only_boxed_clone(); + + let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec| { + let full_name = format!("{name}_{suffix}"); + let cached = cached_start.clone(); + let starts_version = cached.version(); + + // Sats lazy rolling sum + let sats_sum = LazyDeltaVec::::new( + &format!("{full_name}_sats"), + version, + cum_sats.clone(), + starts_version, + { + let cached = cached.clone(); + move || cached.get() + }, + ); + let sats_resolutions = Resolutions::forced_import( + &format!("{full_name}_sats"), + sats_sum.read_only_boxed_clone(), + version, + indexes, + ); + let sats = LazyRollingSumFromHeight { + height: sats_sum, + resolutions: Box::new(sats_resolutions), + }; + + // Btc lazy from sats + let btc = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &full_name, + version, + sats.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &full_name, + version, + &sats.resolutions, + )), + }; + + // Cents rolling sum + let cents_sum = LazyDeltaVec::::new( + &format!("{full_name}_cents"), + version, + cum_cents.clone(), + starts_version, + move || cached.get(), + ); + let cents_resolutions = Resolutions::forced_import( + &format!("{full_name}_cents"), + cents_sum.read_only_boxed_clone(), + version, + indexes, + ); + let cents = LazyRollingSumFromHeight { + height: cents_sum, + resolutions: Box::new(cents_resolutions), + }; + + // Usd lazy from cents + let usd = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &format!("{full_name}_usd"), + version, + cents.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::< + CentsUnsignedToDollars, + >( + &format!("{full_name}_usd"), version, ¢s.resolutions + )), + }; + + LazyRollingSumAmountFromHeight { + sats, + btc, + cents, + usd, + } + }; + + Self(cached_starts.0.map_with_suffix(make_slot)) + } +} diff --git a/crates/brk_computer/src/internal/per_block/amount/mod.rs b/crates/brk_computer/src/internal/per_block/amount/mod.rs index 9198a4aa4..dc76e8114 100644 --- a/crates/brk_computer/src/internal/per_block/amount/mod.rs +++ b/crates/brk_computer/src/internal/per_block/amount/mod.rs @@ -4,11 +4,8 @@ mod cumulative_sum; mod full; mod lazy; mod lazy_derived_resolutions; -mod rolling; -mod rolling_full; -mod rolling_sum; -mod windows; -mod with_sum_24h; +mod lazy_rolling_sum; +mod rolling_distribution; pub use base::*; pub use cumulative::*; @@ -16,8 +13,5 @@ pub use cumulative_sum::*; pub use full::*; pub use lazy::*; pub use lazy_derived_resolutions::*; -pub use rolling::*; -pub use rolling_full::*; -pub use rolling_sum::*; -pub use windows::*; -pub use with_sum_24h::*; +pub use lazy_rolling_sum::*; +pub use rolling_distribution::*; diff --git a/crates/brk_computer/src/internal/per_block/amount/rolling.rs b/crates/brk_computer/src/internal/per_block/amount/rolling.rs deleted file mode 100644 index 82a2e3b5a..000000000 --- a/crates/brk_computer/src/internal/per_block/amount/rolling.rs +++ /dev/null @@ -1,61 +0,0 @@ -//! Value type for Height + Rolling pattern. -//! -//! Combines Value (sats/btc/usd per height, no period views) with -//! AmountPerBlockWindows (rolling sums across 4 windows). - -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Sats, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; - -use crate::{ - indexes, - internal::{Amount, AmountPerBlockWindows, WindowStarts}, - prices, -}; - -#[derive(Deref, DerefMut, Traversable)] -pub struct AmountPerBlockRolling { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub amount: Amount, - #[traversable(flatten)] - pub rolling: AmountPerBlockWindows, -} - -impl AmountPerBlockRolling { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - amount: Amount::forced_import(db, name, version)?, - rolling: AmountPerBlockWindows::forced_import(db, name, version, indexes)?, - }) - } - - /// Compute sats height via closure, then cents from price, then rolling windows. - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - prices: &prices::Vecs, - exit: &Exit, - compute_sats: impl FnOnce(&mut EagerVec>) -> Result<()>, - ) -> Result<()> { - compute_sats(&mut self.amount.sats)?; - self.amount.compute_cents(prices, max_from, exit)?; - self.rolling.compute_rolling_sum( - max_from, - windows, - &self.amount.sats, - &self.amount.cents, - exit, - )?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/per_block/amount/rolling_full.rs b/crates/brk_computer/src/internal/per_block/amount/rolling_distribution.rs similarity index 73% rename from crates/brk_computer/src/internal/per_block/amount/rolling_full.rs rename to crates/brk_computer/src/internal/per_block/amount/rolling_distribution.rs index cfc1acf57..207be9fcc 100644 --- a/crates/brk_computer/src/internal/per_block/amount/rolling_full.rs +++ b/crates/brk_computer/src/internal/per_block/amount/rolling_distribution.rs @@ -7,21 +7,21 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{ indexes, internal::{ - AmountPerBlock, DistributionStats, WindowStarts, Windows, compute_rolling_distribution_from_starts, + AmountPerBlock, DistributionStats, WindowStarts, Windows, + compute_rolling_distribution_from_starts, }, }; -/// One window slot: sum + 8 distribution stats, each a AmountPerBlock. +/// One window slot: 8 distribution stats, each a AmountPerBlock. /// -/// Tree: `sum.sats.height`, `average.sats.height`, etc. +/// Tree: `average.sats.height`, `min.sats.height`, etc. #[derive(Traversable)] -pub struct RollingFullSlot { - pub sum: AmountPerBlock, +pub struct RollingDistributionSlot { #[traversable(flatten)] pub distribution: DistributionStats>, } -impl RollingFullSlot { +impl RollingDistributionSlot { pub(crate) fn forced_import( db: &Database, name: &str, @@ -29,7 +29,6 @@ impl RollingFullSlot { indexes: &indexes::Vecs, ) -> Result { Ok(Self { - sum: AmountPerBlock::forced_import(db, &format!("{name}_sum"), version, indexes)?, distribution: DistributionStats::try_from_fn(|suffix| { AmountPerBlock::forced_import(db, &format!("{name}_{suffix}"), version, indexes) })?, @@ -44,15 +43,6 @@ impl RollingFullSlot { cents_source: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.sum - .sats - .height - .compute_rolling_sum(max_from, starts, sats_source, exit)?; - self.sum - .cents - .height - .compute_rolling_sum(max_from, starts, cents_source, exit)?; - let d = &mut self.distribution; macro_rules! compute_unit { @@ -80,14 +70,16 @@ impl RollingFullSlot { } } -/// Rolling sum + distribution across 4 windows, window-first. +/// Rolling distribution across 4 windows, window-first. /// -/// Tree: `_24h.sum.sats.height`, `_24h.average.sats.height`, etc. +/// Tree: `_24h.average.sats.height`, `_24h.min.sats.height`, etc. #[derive(Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct RollingFullAmountPerBlock(pub Windows>); +pub struct RollingDistributionAmountPerBlock( + pub Windows>, +); -impl RollingFullAmountPerBlock { +impl RollingDistributionAmountPerBlock { pub(crate) fn forced_import( db: &Database, name: &str, @@ -95,7 +87,12 @@ impl RollingFullAmountPerBlock { indexes: &indexes::Vecs, ) -> Result { Ok(Self(Windows::try_from_fn(|suffix| { - RollingFullSlot::forced_import(db, &format!("{name}_{suffix}"), version, indexes) + RollingDistributionSlot::forced_import( + db, + &format!("{name}_{suffix}"), + version, + indexes, + ) })?)) } diff --git a/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs b/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs deleted file mode 100644 index 3d333f84a..000000000 --- a/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs +++ /dev/null @@ -1,86 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Cents, Height, Sats, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use crate::{ - indexes, - internal::{AmountPerBlock, RollingWindow24h, WindowStarts, Windows}, -}; - -/// Single 24h rolling sum as amount (sats + btc + cents + usd). -/// -/// Tree: `_24h.sats.height`, `_24h.btc.height`, etc. -#[derive(Deref, DerefMut, Traversable)] -#[traversable(transparent)] -pub struct RollingWindow24hAmountPerBlock( - pub RollingWindow24h>, -); - -impl RollingWindow24hAmountPerBlock { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self(RollingWindow24h { - _24h: AmountPerBlock::forced_import(db, &format!("{name}_24h"), version, indexes)?, - })) - } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - height_24h_ago: &impl ReadableVec, - sats_source: &impl ReadableVec, - cents_source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self._24h - .compute_rolling_sum(max_from, height_24h_ago, sats_source, cents_source, exit) - } -} - -/// Rolling sum only, window-first then unit. -/// -/// Tree: `_24h.sats.height`, `_24h.btc.height`, etc. -#[derive(Deref, DerefMut, Traversable)] -#[traversable(transparent)] -pub struct RollingSumAmountPerBlock(pub Windows>); - -impl RollingSumAmountPerBlock { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self(Windows::::forced_import( - db, - &format!("{name}_sum"), - version, - indexes, - )?)) - } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - sats_source: &impl ReadableVec, - cents_source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - for (w, starts) in self.0.as_mut_array().into_iter().zip(windows.as_array()) { - w.sats - .height - .compute_rolling_sum(max_from, *starts, sats_source, exit)?; - w.cents - .height - .compute_rolling_sum(max_from, *starts, cents_source, exit)?; - } - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/per_block/amount/windows.rs b/crates/brk_computer/src/internal/per_block/amount/windows.rs deleted file mode 100644 index 0f555ec5a..000000000 --- a/crates/brk_computer/src/internal/per_block/amount/windows.rs +++ /dev/null @@ -1,52 +0,0 @@ -//! AmountPerBlockWindows - window-first ordering. -//! -//! Access pattern: `coinbase_sum._24h.sats.height` -//! Each window (24h, 7d, 30d, 1y) contains sats (stored) + btc (lazy) + usd (stored). - -use brk_error::Result; - -use brk_traversable::Traversable; -use brk_types::{Height, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use brk_types::{Cents, Sats}; - -use crate::{ - indexes, - internal::{AmountPerBlock, WindowStarts, Windows}, -}; - -/// Value rolling windows — window-first, currency-last. -/// -/// Each window contains `AmountPerBlock` (sats + btc lazy + usd). -#[derive(Deref, DerefMut, Traversable)] -#[traversable(transparent)] -pub struct AmountPerBlockWindows(pub Windows>); - -impl AmountPerBlockWindows { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self(Windows::try_from_fn(|suffix| { - AmountPerBlock::forced_import(db, &format!("{name}_{suffix}"), version, indexes) - })?)) - } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - sats_source: &impl ReadableVec, - cents_source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - for (w, starts) in self.0.as_mut_array().into_iter().zip(windows.as_array()) { - w.compute_rolling_sum(max_from, *starts, sats_source, cents_source, exit)?; - } - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs b/crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs deleted file mode 100644 index c149725fe..000000000 --- a/crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! AmountPerBlockWithSum24h - AmountPerBlock raw + RollingWindow24hAmountPerBlock sum. - -use brk_traversable::Traversable; -use vecdb::{Rw, StorageMode}; - -use crate::internal::{AmountPerBlock, RollingWindow24hAmountPerBlock}; - -/// Amount per-block value (sats + cents) with 24h rolling sum (also amount). -#[derive(Traversable)] -pub struct AmountPerBlockWithSum24h { - pub raw: AmountPerBlock, - pub sum: RollingWindow24hAmountPerBlock, -} diff --git a/crates/brk_computer/src/internal/per_block/computed/aggregated.rs b/crates/brk_computer/src/internal/per_block/computed/aggregated.rs index dd0178ecc..20d4eb7ba 100644 --- a/crates/brk_computer/src/internal/per_block/computed/aggregated.rs +++ b/crates/brk_computer/src/internal/per_block/computed/aggregated.rs @@ -3,8 +3,6 @@ //! For metrics aggregated per-block from finer-grained sources (e.g., per-tx data), //! where we want full per-block stats plus rolling window stats. -use std::ops::SubAssign; - use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Version}; @@ -13,7 +11,7 @@ use vecdb::{Database, Exit, Rw, StorageMode}; use crate::{ indexes, - internal::{Full, NumericValue, RollingFull, WindowStarts}, + internal::{CachedWindowStarts, Full, NumericValue, RollingFull, WindowStarts}, }; #[derive(Traversable)] @@ -35,17 +33,22 @@ where name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { - let height = Full::forced_import(db, name, version)?; - let rolling = RollingFull::forced_import(db, name, version, indexes)?; + let full = Full::forced_import(db, name, version)?; + let rolling = RollingFull::forced_import( + db, + name, + version, + indexes, + &full.cumulative, + cached_starts, + )?; - Ok(Self { - full: height, - rolling, - }) + Ok(Self { full, rolling }) } - /// Compute Full stats via closure, then rolling windows from the per-block sum. + /// Compute Full stats via closure, then rolling distribution from the per-block sum. pub(crate) fn compute( &mut self, max_from: Height, @@ -54,7 +57,7 @@ where compute_full: impl FnOnce(&mut Full) -> Result<()>, ) -> Result<()> where - T: From + Default + SubAssign + Copy + Ord, + T: From + Default + Copy + Ord, f64: From, { compute_full(&mut self.full)?; diff --git a/crates/brk_computer/src/internal/per_block/computed/cumulative.rs b/crates/brk_computer/src/internal/per_block/computed/cumulative.rs index 7db01bf24..dab0f8dee 100644 --- a/crates/brk_computer/src/internal/per_block/computed/cumulative.rs +++ b/crates/brk_computer/src/internal/per_block/computed/cumulative.rs @@ -1,13 +1,13 @@ //! ComputedPerBlockCumulative - raw ComputedPerBlock + cumulative ComputedPerBlock. //! -//! Like ComputedPerBlockCumulativeSum but without RollingWindows. +//! Like ComputedPerBlockCumulativeWithSums but without RollingWindows. //! Used for distribution metrics where rolling is optional per cohort. use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Version}; use schemars::JsonSchema; -use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; +use vecdb::{Database, Exit, Rw, StorageMode}; use crate::{ indexes, @@ -40,20 +40,6 @@ where Ok(Self { raw, cumulative }) } - /// Compute raw data via closure, then cumulative only (no rolling). - pub(crate) fn compute( - &mut self, - max_from: Height, - exit: &Exit, - compute_raw: impl FnOnce(&mut EagerVec>) -> Result<()>, - ) -> Result<()> - where - T: Default, - { - compute_raw(&mut self.raw.height)?; - self.compute_rest(max_from, exit) - } - /// Compute cumulative from already-filled raw vec. pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> where diff --git a/crates/brk_computer/src/internal/per_block/computed/cumulative_sum.rs b/crates/brk_computer/src/internal/per_block/computed/cumulative_sum.rs index 360ad9498..364197f79 100644 --- a/crates/brk_computer/src/internal/per_block/computed/cumulative_sum.rs +++ b/crates/brk_computer/src/internal/per_block/computed/cumulative_sum.rs @@ -1,9 +1,13 @@ -//! ComputedPerBlockCumulativeSum - raw ComputedPerBlock + cumulative ComputedPerBlock + RollingWindows (sum). +//! ComputedPerBlockCumulativeWithSums - raw ComputedPerBlock + cumulative ComputedPerBlock + lazy rolling sums. //! -//! Like ComputedPerBlockFull but with rolling sum only (no distribution). -//! Used for count metrics where distribution stats aren't meaningful. - -use std::ops::SubAssign; +//! Rolling sums are derived lazily from the cumulative vec via LazyDeltaVec. +//! No rolling sum vecs are stored on disk. +//! +//! Type parameters: +//! - `T`: per-block value type (e.g., `StoredU32` for tx counts) +//! - `M`: storage mode (`Rw` or `Ro`) +//! - `C`: cumulative type, defaults to `T`. Use a wider type (e.g., `StoredU64`) +//! when the prefix sum of `T` values could overflow `T`. use brk_error::Result; use brk_traversable::Traversable; @@ -13,33 +17,42 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; use crate::{ indexes, - internal::{ComputedPerBlock, NumericValue, RollingWindows, WindowStarts}, + internal::{CachedWindowStarts, ComputedPerBlock, LazyRollingSumsFromHeight, NumericValue}, }; #[derive(Traversable)] -pub struct ComputedPerBlockCumulativeSum +pub struct ComputedPerBlockCumulativeWithSums where T: NumericValue + JsonSchema, + C: NumericValue + JsonSchema, { pub raw: ComputedPerBlock, - pub cumulative: ComputedPerBlock, - pub sum: RollingWindows, + pub cumulative: ComputedPerBlock, + pub sum: LazyRollingSumsFromHeight, } -impl ComputedPerBlockCumulativeSum +impl ComputedPerBlockCumulativeWithSums where - T: NumericValue + JsonSchema, + T: NumericValue + JsonSchema + Into, + C: NumericValue + JsonSchema, { pub(crate) fn forced_import( db: &Database, name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let raw = ComputedPerBlock::forced_import(db, name, version, indexes)?; let cumulative = ComputedPerBlock::forced_import(db, &format!("{name}_cumulative"), version, indexes)?; - let sum = RollingWindows::forced_import(db, name, version, indexes)?; + let sum = LazyRollingSumsFromHeight::new( + &format!("{name}_sum"), + version, + &cumulative.height, + cached_starts, + indexes, + ); Ok(Self { raw, @@ -48,36 +61,28 @@ where }) } - /// Compute raw data via closure, then cumulative + rolling sum. + /// Compute raw data via closure, then cumulative. Rolling sums are lazy. pub(crate) fn compute( &mut self, max_from: Height, - windows: &WindowStarts<'_>, exit: &Exit, compute_raw: impl FnOnce(&mut EagerVec>) -> Result<()>, ) -> Result<()> where - T: Default + SubAssign, + C: Default, { compute_raw(&mut self.raw.height)?; - self.compute_rest(max_from, windows, exit) + self.compute_rest(max_from, exit) } - /// Compute cumulative + rolling sum from already-populated raw data. - pub(crate) fn compute_rest( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - exit: &Exit, - ) -> Result<()> + /// Compute cumulative from already-populated raw data. Rolling sums are lazy. + pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> where - T: Default + SubAssign, + C: Default, { self.cumulative .height .compute_cumulative(max_from, &self.raw.height, exit)?; - self.sum - .compute_rolling_sum(max_from, windows, &self.raw.height, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/internal/per_block/computed/delta.rs b/crates/brk_computer/src/internal/per_block/computed/delta.rs deleted file mode 100644 index ceb159afd..000000000 --- a/crates/brk_computer/src/internal/per_block/computed/delta.rs +++ /dev/null @@ -1,292 +0,0 @@ -//! RollingDelta - raw change + growth rate (%) across time windows. -//! -//! Three tiers: -//! - `RollingDelta1m` — 1m window only (2 stored vecs: change + rate). Default for all cohorts. -//! - `RollingDeltaExcept1m` — 24h + 1w + 1y windows (6 stored vecs). Extended tier only. -//! - `RollingDelta` — all 4 windows (8 stored vecs). Used for standalone global metrics. -//! -//! For a monotonic source (e.g., cumulative address count): -//! - `change._24h` = count_now - count_24h_ago -//! - `rate._24h` = (count_now - count_24h_ago) / count_24h_ago in BPS - -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{BasisPoints32, BasisPointsSigned32, Height, Version}; -use schemars::JsonSchema; -use vecdb::{AnyVec, Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode, VecIndex}; - -use crate::{ - indexes, - internal::{ - ComputedPerBlock, NumericValue, PercentPerBlock, PercentRollingWindows, - RollingWindows, WindowStarts, WindowsExcept1m, - }, -}; - -/// Pre-collect source data from the earliest needed offset. -/// Returns (source_data, offset) for use in compute_delta_window. -fn collect_source( - source: &impl ReadableVec, - skip: usize, - earliest_starts: &impl ReadableVec, -) -> (Vec, usize) { - let source_len = source.len(); - let offset = if skip > 0 && skip < earliest_starts.len() { - earliest_starts.collect_one_at(skip).unwrap().to_usize() - } else { - 0 - }; - (source.collect_range_at(offset, source_len), offset) -} - -/// Shared computation: change = current - ago, rate = change / ago. -pub(super) fn compute_delta_window( - change_h: &mut EagerVec>, - rate_bps_h: &mut EagerVec>, - max_from: Height, - starts: &impl ReadableVec, - source: &impl ReadableVec, - exit: &Exit, -) -> Result<()> -where - S: NumericValue, - C: NumericValue, - B: NumericValue, -{ - let skip = change_h.len(); - let (mut source_data, mut offset) = collect_source(source, skip, starts); - - change_h.compute_transform( - max_from, - starts, - |(h, ago_h, ..)| { - if h.to_usize() < offset || ago_h.to_usize() < offset { - // Version reset cleared the vec — re-collect from scratch - source_data = source.collect(); - offset = 0; - } - let current: f64 = source_data[h.to_usize() - offset].into(); - let ago: f64 = source_data[ago_h.to_usize() - offset].into(); - (h, C::from(current - ago)) - }, - exit, - )?; - - rate_bps_h.compute_transform( - max_from, - &*change_h, - |(h, change, ..)| { - if h.to_usize() < offset { - // Version reset cleared the vec — re-collect from scratch - source_data = source.collect(); - offset = 0; - } - let current_f: f64 = source_data[h.to_usize() - offset].into(); - let change_f: f64 = change.into(); - let ago = current_f - change_f; - let rate = if ago == 0.0 { 0.0 } else { change_f / ago }; - (h, B::from(rate)) - }, - exit, - )?; - - Ok(()) -} - -#[derive(Traversable)] -pub struct RollingDelta -where - S: NumericValue + JsonSchema, - C: NumericValue + JsonSchema, -{ - pub change: RollingWindows, - pub rate: PercentRollingWindows, - _phantom: std::marker::PhantomData, -} - -impl RollingDelta -where - S: NumericValue + JsonSchema, - C: NumericValue + JsonSchema, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - change: RollingWindows::forced_import( - db, - &format!("{name}_change"), - version, - indexes, - )?, - rate: PercentRollingWindows::forced_import( - db, - &format!("{name}_rate"), - version, - indexes, - )?, - _phantom: std::marker::PhantomData, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - for ((change_w, rate_w), starts) in self - .change - .0 - .as_mut_array() - .into_iter() - .zip(self.rate.0.as_mut_array()) - .zip(windows.as_array()) - { - compute_delta_window( - &mut change_w.height, - &mut rate_w.bps.height, - max_from, - *starts, - source, - exit, - )?; - } - Ok(()) - } -} - -/// 1m-only delta: change + growth rate for the 1-month window. -/// Default tier for all cohorts (2 stored vecs). -#[derive(Traversable)] -pub struct RollingDelta1m -where - S: NumericValue + JsonSchema, - C: NumericValue + JsonSchema, -{ - #[traversable(wrap = "change", rename = "1m")] - pub change_1m: ComputedPerBlock, - #[traversable(wrap = "rate", rename = "1m")] - pub rate_1m: PercentPerBlock, - _phantom: std::marker::PhantomData, -} - -impl RollingDelta1m -where - S: NumericValue + JsonSchema, - C: NumericValue + JsonSchema, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - change_1m: ComputedPerBlock::forced_import( - db, - &format!("{name}_change_1m"), - version, - indexes, - )?, - rate_1m: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_1m"), - version, - indexes, - )?, - _phantom: std::marker::PhantomData, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - height_1m_ago: &impl ReadableVec, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - compute_delta_window( - &mut self.change_1m.height, - &mut self.rate_1m.bps.height, - max_from, - height_1m_ago, - source, - exit, - ) - } -} - -/// Extended delta: 24h + 1w + 1y windows (6 stored vecs). -/// Only for All/LTH/STH cohorts (Extended tier). -#[derive(Traversable)] -pub struct RollingDeltaExcept1m -where - S: NumericValue + JsonSchema, - C: NumericValue + JsonSchema, -{ - pub change: WindowsExcept1m>, - pub rate: WindowsExcept1m>, - _phantom: std::marker::PhantomData, -} - -impl RollingDeltaExcept1m -where - S: NumericValue + JsonSchema, - C: NumericValue + JsonSchema, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - change: WindowsExcept1m::try_from_fn(|suffix| { - ComputedPerBlock::forced_import( - db, - &format!("{name}_change_{suffix}"), - version, - indexes, - ) - })?, - rate: WindowsExcept1m::try_from_fn(|suffix| { - PercentPerBlock::forced_import( - db, - &format!("{name}_rate_{suffix}"), - version, - indexes, - ) - })?, - _phantom: std::marker::PhantomData, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - let changes = self.change.as_mut_array(); - let rates = self.rate.as_mut_array(); - let starts = [windows._24h, windows._1w, windows._1y]; - - for ((change_w, rate_w), starts) in changes.into_iter().zip(rates).zip(starts) { - compute_delta_window( - &mut change_w.height, - &mut rate_w.bps.height, - max_from, - starts, - source, - exit, - )?; - } - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs b/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs deleted file mode 100644 index 5f58e1118..000000000 --- a/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs +++ /dev/null @@ -1,214 +0,0 @@ -//! Fiat delta variants — same as RollingDelta* but change is FiatPerBlock -//! (stored cents + lazy USD) instead of ComputedPerBlock (stored cents only). - -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Height, Version}; -use schemars::JsonSchema; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use crate::{ - indexes, - internal::{ - CentsType, FiatPerBlock, NumericValue, PercentPerBlock, PercentRollingWindows, - Windows, WindowStarts, WindowsExcept1m, - }, -}; - -use super::delta::compute_delta_window; - -/// Fiat 1m-only delta: fiat change (cents + usd) + rate for the 1-month window. -#[derive(Traversable)] -pub struct FiatRollingDelta1m -where - S: NumericValue + JsonSchema, - C: CentsType, -{ - #[traversable(wrap = "change", rename = "1m")] - pub change_1m: FiatPerBlock, - #[traversable(wrap = "rate", rename = "1m")] - pub rate_1m: PercentPerBlock, - _phantom: std::marker::PhantomData, -} - -impl FiatRollingDelta1m -where - S: NumericValue + JsonSchema, - C: CentsType, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - change_1m: FiatPerBlock::forced_import( - db, - &format!("{name}_change_1m"), - version, - indexes, - )?, - rate_1m: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_1m"), - version, - indexes, - )?, - _phantom: std::marker::PhantomData, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - height_1m_ago: &impl ReadableVec, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - compute_delta_window( - &mut self.change_1m.cents.height, - &mut self.rate_1m.bps.height, - max_from, - height_1m_ago, - source, - exit, - ) - } -} - -/// Fiat extended delta: 24h + 1w + 1y windows, fiat change (cents + usd) + rate. -#[derive(Traversable)] -pub struct FiatRollingDeltaExcept1m -where - S: NumericValue + JsonSchema, - C: CentsType, -{ - pub change: WindowsExcept1m>, - pub rate: WindowsExcept1m>, - _phantom: std::marker::PhantomData, -} - -impl FiatRollingDeltaExcept1m -where - S: NumericValue + JsonSchema, - C: CentsType, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - change: WindowsExcept1m::try_from_fn(|suffix| { - FiatPerBlock::forced_import( - db, - &format!("{name}_change_{suffix}"), - version, - indexes, - ) - })?, - rate: WindowsExcept1m::try_from_fn(|suffix| { - PercentPerBlock::forced_import( - db, - &format!("{name}_rate_{suffix}"), - version, - indexes, - ) - })?, - _phantom: std::marker::PhantomData, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - let changes = self.change.as_mut_array(); - let rates = self.rate.as_mut_array(); - let starts = [windows._24h, windows._1w, windows._1y]; - - for ((change_w, rate_w), starts) in changes.into_iter().zip(rates).zip(starts) { - compute_delta_window( - &mut change_w.cents.height, - &mut rate_w.bps.height, - max_from, - starts, - source, - exit, - )?; - } - Ok(()) - } -} - -/// Fiat rolling delta: all 4 windows, fiat change (cents + usd) + rate. -#[derive(Traversable)] -pub struct FiatRollingDelta -where - S: NumericValue + JsonSchema, - C: CentsType, -{ - pub change: Windows>, - pub rate: PercentRollingWindows, - _phantom: std::marker::PhantomData, -} - -impl FiatRollingDelta -where - S: NumericValue + JsonSchema, - C: CentsType, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - change: Windows::try_from_fn(|suffix| { - FiatPerBlock::forced_import( - db, - &format!("{name}_change_{suffix}"), - version, - indexes, - ) - })?, - rate: PercentRollingWindows::forced_import( - db, - &format!("{name}_rate"), - version, - indexes, - )?, - _phantom: std::marker::PhantomData, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - let changes = self.change.as_mut_array(); - let rates = self.rate.0.as_mut_array(); - let starts = windows.as_array(); - - for ((change_w, rate_w), starts) in changes.into_iter().zip(rates).zip(starts) { - compute_delta_window( - &mut change_w.cents.height, - &mut rate_w.bps.height, - max_from, - *starts, - source, - exit, - )?; - } - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/per_block/computed/full.rs b/crates/brk_computer/src/internal/per_block/computed/full.rs index 753b8c33d..523971313 100644 --- a/crates/brk_computer/src/internal/per_block/computed/full.rs +++ b/crates/brk_computer/src/internal/per_block/computed/full.rs @@ -2,8 +2,6 @@ //! //! For metrics with stored per-block data, cumulative sums, and rolling windows. -use std::ops::SubAssign; - use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Version}; @@ -12,7 +10,7 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; use crate::{ indexes, - internal::{ComputedPerBlock, NumericValue, RollingFull, WindowStarts}, + internal::{CachedWindowStarts, ComputedPerBlock, NumericValue, RollingFull, WindowStarts}, }; #[derive(Traversable)] @@ -35,11 +33,19 @@ where name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let raw = ComputedPerBlock::forced_import(db, name, version, indexes)?; let cumulative = ComputedPerBlock::forced_import(db, &format!("{name}_cumulative"), version, indexes)?; - let rolling = RollingFull::forced_import(db, name, version, indexes)?; + let rolling = RollingFull::forced_import( + db, + name, + version, + indexes, + &cumulative.height, + cached_starts, + )?; Ok(Self { raw, @@ -48,7 +54,7 @@ where }) } - /// Compute raw data via closure, then cumulative + rolling. + /// Compute raw data via closure, then cumulative + rolling distribution. pub(crate) fn compute( &mut self, max_from: Height, @@ -57,7 +63,7 @@ where compute_raw: impl FnOnce(&mut EagerVec>) -> Result<()>, ) -> Result<()> where - T: From + Default + SubAssign + Copy + Ord, + T: From + Default + Copy + Ord, f64: From, { compute_raw(&mut self.raw.height)?; diff --git a/crates/brk_computer/src/internal/per_block/computed/mod.rs b/crates/brk_computer/src/internal/per_block/computed/mod.rs index 6e1f16fad..10d47cf5e 100644 --- a/crates/brk_computer/src/internal/per_block/computed/mod.rs +++ b/crates/brk_computer/src/internal/per_block/computed/mod.rs @@ -3,25 +3,19 @@ mod base; mod constant; mod cumulative; mod cumulative_sum; -mod delta; mod resolutions; mod resolutions_full; -mod fiat_delta; mod full; mod rolling_average; -mod sum; -mod with_sum_24h; +mod with_deltas; pub use aggregated::*; pub use base::*; pub use constant::*; pub use cumulative::*; pub use cumulative_sum::*; -pub use delta::*; pub use resolutions::*; pub use resolutions_full::*; -pub use fiat_delta::*; pub use full::*; pub use rolling_average::*; -pub use sum::*; -pub use with_sum_24h::*; +pub use with_deltas::*; diff --git a/crates/brk_computer/src/internal/per_block/computed/resolutions_full.rs b/crates/brk_computer/src/internal/per_block/computed/resolutions_full.rs index 61d3aef17..d14291ebc 100644 --- a/crates/brk_computer/src/internal/per_block/computed/resolutions_full.rs +++ b/crates/brk_computer/src/internal/per_block/computed/resolutions_full.rs @@ -3,8 +3,6 @@ //! For metrics derived from indexer sources (no stored height vec). //! Cumulative gets its own ComputedPerBlock so it has LazyAggVec index views too. -use std::ops::SubAssign; - use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Version}; @@ -13,7 +11,7 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{ComputedPerBlock, NumericValue, RollingFull, WindowStarts}, + internal::{CachedWindowStarts, ComputedPerBlock, NumericValue, RollingFull, WindowStarts}, }; #[derive(Traversable)] @@ -35,10 +33,18 @@ where name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let cumulative = ComputedPerBlock::forced_import(db, &format!("{name}_cumulative"), version, indexes)?; - let rolling = RollingFull::forced_import(db, name, version, indexes)?; + let rolling = RollingFull::forced_import( + db, + name, + version, + indexes, + &cumulative.height, + cached_starts, + )?; Ok(Self { cumulative, @@ -54,7 +60,7 @@ where exit: &Exit, ) -> Result<()> where - T: From + Default + SubAssign + Copy + Ord, + T: From + Default + Copy + Ord, f64: From, { self.cumulative diff --git a/crates/brk_computer/src/internal/per_block/computed/rolling_average.rs b/crates/brk_computer/src/internal/per_block/computed/rolling_average.rs index 4c5b08089..4398d8861 100644 --- a/crates/brk_computer/src/internal/per_block/computed/rolling_average.rs +++ b/crates/brk_computer/src/internal/per_block/computed/rolling_average.rs @@ -1,8 +1,7 @@ //! ComputedPerBlock with rolling average (no distribution stats). //! -//! Stored height data + 4-window rolling averages (24h, 1w, 1m, 1y). -//! Use instead of ComputedPerBlockDistribution when only the average -//! is analytically useful (e.g., block interval, activity counts). +//! Stored height data + f64 cumulative + lazy 4-window rolling averages. +//! Rolling averages are computed on-the-fly from the cumulative via DeltaAvg. use brk_error::Result; @@ -13,7 +12,7 @@ use vecdb::{Database, EagerVec, Exit, ImportableVec, PcoVec, Rw, StorageMode}; use crate::indexes; -use crate::internal::{NumericValue, RollingWindows, WindowStarts}; +use crate::internal::{CachedWindowStarts, LazyRollingAvgsFromHeight, NumericValue}; #[derive(Traversable)] pub struct ComputedPerBlockRollingAverage @@ -21,8 +20,10 @@ where T: NumericValue + JsonSchema, { pub height: M::Stored>>, + #[traversable(hidden)] + pub cumulative: M::Stored>>, #[traversable(flatten)] - pub average: RollingWindows, + pub average: LazyRollingAvgsFromHeight, } impl ComputedPerBlockRollingAverage @@ -34,45 +35,41 @@ where name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let height: EagerVec> = EagerVec::forced_import(db, name, version)?; - let average = - RollingWindows::forced_import(db, &format!("{name}_average"), version + Version::ONE, indexes)?; + let cumulative: EagerVec> = + EagerVec::forced_import(db, &format!("{name}_cumulative"), version)?; + let average = LazyRollingAvgsFromHeight::new( + &format!("{name}_average"), + version + Version::ONE, + &cumulative, + cached_starts, + indexes, + ); - Ok(Self { height, average }) + Ok(Self { + height, + cumulative, + average, + }) } - /// Compute height data via closure, then rolling averages. + /// Compute height data via closure, then cumulative. Rolling averages are lazy. pub(crate) fn compute( &mut self, max_from: Height, - windows: &WindowStarts<'_>, exit: &Exit, compute_height: impl FnOnce(&mut EagerVec>) -> Result<()>, - ) -> Result<()> - where - T: Default, - f64: From, - { + ) -> Result<()> { compute_height(&mut self.height)?; - self.compute_rest(max_from, windows, exit) + self.compute_rest(max_from, exit) } - /// Compute rolling averages from already-populated height data. - pub(crate) fn compute_rest( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - exit: &Exit, - ) -> Result<()> - where - T: Default, - f64: From, - { - for (w, starts) in self.average.0.as_mut_array().into_iter().zip(windows.as_array()) { - w.height - .compute_rolling_average(max_from, *starts, &self.height, exit)?; - } + /// Compute cumulative from already-populated height data. Rolling averages are lazy. + pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> { + self.cumulative + .compute_cumulative(max_from, &self.height, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/internal/per_block/computed/sum.rs b/crates/brk_computer/src/internal/per_block/computed/sum.rs deleted file mode 100644 index cbad21aee..000000000 --- a/crates/brk_computer/src/internal/per_block/computed/sum.rs +++ /dev/null @@ -1,59 +0,0 @@ -//! ComputedPerBlockSum - raw ComputedPerBlock + RollingWindows (sum only). -//! -//! Like ComputedPerBlockCumulativeSum but without the cumulative vec. - -use std::ops::SubAssign; - -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Version}; -use schemars::JsonSchema; -use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; - -use crate::{ - indexes, - internal::{ComputedPerBlock, NumericValue, RollingWindows, WindowStarts}, -}; - -#[derive(Traversable)] -pub struct ComputedPerBlockSum -where - T: NumericValue + JsonSchema, -{ - pub raw: ComputedPerBlock, - pub sum: RollingWindows, -} - -impl ComputedPerBlockSum -where - T: NumericValue + JsonSchema, -{ - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - let raw = ComputedPerBlock::forced_import(db, name, version, indexes)?; - let sum = RollingWindows::forced_import(db, &format!("{name}_sum"), version, indexes)?; - - Ok(Self { raw, sum }) - } - - /// Compute raw data via closure, then rolling sum. - pub(crate) fn compute( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - exit: &Exit, - compute_raw: impl FnOnce(&mut EagerVec>) -> Result<()>, - ) -> Result<()> - where - T: Default + SubAssign, - { - compute_raw(&mut self.raw.height)?; - self.sum - .compute_rolling_sum(max_from, windows, &self.raw.height, exit)?; - Ok(()) - } -} 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 new file mode 100644 index 000000000..3d10ceea9 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs @@ -0,0 +1,55 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::Version; +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use vecdb::{Rw, StorageMode}; + +use crate::{ + indexes, + internal::{ + BpsType, CachedWindowStarts, ComputedPerBlock, LazyRollingDeltasFromHeight, NumericValue, + }, +}; + +#[derive(Deref, DerefMut, Traversable)] +pub struct ComputedPerBlockWithDeltas +where + S: NumericValue + JsonSchema + Into, + C: NumericValue + JsonSchema + From, + B: BpsType + From, +{ + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub inner: ComputedPerBlock, + pub delta: LazyRollingDeltasFromHeight, +} + +impl ComputedPerBlockWithDeltas +where + S: NumericValue + JsonSchema + Into, + C: NumericValue + JsonSchema + From, + B: BpsType + From, +{ + pub(crate) fn forced_import( + db: &vecdb::Database, + name: &str, + version: Version, + delta_version_offset: Version, + indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, + ) -> Result { + let inner = ComputedPerBlock::forced_import(db, name, version, indexes)?; + + let delta = LazyRollingDeltasFromHeight::new( + &format!("{name}_delta"), + version + delta_version_offset, + &inner.height, + cached_starts, + indexes, + ); + + Ok(Self { inner, delta }) + } +} diff --git a/crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs b/crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs deleted file mode 100644 index 6c1ee5355..000000000 --- a/crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! PerBlockWithSum24h - ComputedPerBlock + RollingWindow24hPerBlock rolling sum. -//! -//! Generic building block for metrics that store a per-block value -//! plus its 24h rolling sum. Used across activity and realized metrics. - -use brk_traversable::Traversable; -use schemars::JsonSchema; -use vecdb::{Rw, StorageMode}; - -use crate::internal::{ComputedPerBlock, ComputedVecValue, RollingWindow24hPerBlock}; - -#[derive(Traversable)] -pub struct PerBlockWithSum24h -where - T: ComputedVecValue + PartialOrd + JsonSchema, -{ - pub raw: ComputedPerBlock, - pub sum: RollingWindow24hPerBlock, -} 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 new file mode 100644 index 000000000..b1d2c8512 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum.rs @@ -0,0 +1,53 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{Height, Version}; +use vecdb::{Database, Exit, Rw, StorageMode}; + +use crate::{ + indexes, + internal::{CachedWindowStarts, CentsType, FiatPerBlock, LazyRollingSumsFiatFromHeight}, +}; + +#[derive(Traversable)] +pub struct FiatPerBlockCumulativeWithSums { + pub raw: FiatPerBlock, + pub cumulative: FiatPerBlock, + pub sum: LazyRollingSumsFiatFromHeight, +} + +impl FiatPerBlockCumulativeWithSums { + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, + ) -> Result { + let raw = FiatPerBlock::forced_import(db, name, version, indexes)?; + let cumulative = FiatPerBlock::forced_import( + db, + &format!("{name}_cumulative"), + version, + indexes, + )?; + let sum = LazyRollingSumsFiatFromHeight::new( + &format!("{name}_sum"), + version, + &cumulative.cents.height, + cached_starts, + indexes, + ); + Ok(Self { raw, cumulative, sum }) + } + + pub(crate) fn compute_rest(&mut self, max_from: Height, exit: &Exit) -> Result<()> + where + C: Default, + { + self.cumulative + .cents + .height + .compute_cumulative(max_from, &self.raw.cents.height, exit)?; + Ok(()) + } +} 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 new file mode 100644 index 000000000..31cd8de11 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs @@ -0,0 +1,55 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::Version; +use derive_more::{Deref, DerefMut}; +use vecdb::{Database, Rw, StorageMode}; + +use crate::{ + indexes, + internal::{BpsType, CachedWindowStarts, LazyRollingDeltasFiatFromHeight}, +}; + +use super::{CentsType, FiatPerBlockCumulativeWithSums}; + +#[derive(Deref, DerefMut, Traversable)] +pub struct FiatPerBlockCumulativeWithSumsAndDeltas +where + C: CentsType + Into, + CS: CentsType + From, + B: BpsType + From, +{ + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub inner: FiatPerBlockCumulativeWithSums, + pub delta: LazyRollingDeltasFiatFromHeight, +} + +impl FiatPerBlockCumulativeWithSumsAndDeltas +where + C: CentsType + Into, + CS: CentsType + From, + B: BpsType + From, +{ + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + delta_version_offset: Version, + indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, + ) -> Result { + let inner = + FiatPerBlockCumulativeWithSums::forced_import(db, name, version, indexes, cached_starts)?; + + let delta = LazyRollingDeltasFiatFromHeight::new( + &format!("{name}_delta"), + version + delta_version_offset, + &inner.cumulative.cents.height, + cached_starts, + indexes, + ); + + Ok(Self { inner, delta }) + } +} diff --git a/crates/brk_computer/src/internal/per_block/fiat/lazy_rolling_sum.rs b/crates/brk_computer/src/internal/per_block/fiat/lazy_rolling_sum.rs new file mode 100644 index 000000000..39769dc85 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/fiat/lazy_rolling_sum.rs @@ -0,0 +1,77 @@ +use brk_traversable::Traversable; +use brk_types::{Dollars, Height, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{DeltaSub, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec}; + +use crate::{ + indexes, + internal::{ + CachedWindowStarts, CentsType, DerivedResolutions, LazyPerBlock, LazyRollingSumFromHeight, + Resolutions, Windows, + }, +}; + +#[derive(Clone, Traversable)] +pub struct LazyRollingSumFiatFromHeight { + pub cents: LazyRollingSumFromHeight, + pub usd: LazyPerBlock, +} + +#[derive(Clone, Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct LazyRollingSumsFiatFromHeight( + pub Windows>, +); + +impl LazyRollingSumsFiatFromHeight { + pub fn new( + name: &str, + version: Version, + cumulative_cents: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, + indexes: &indexes::Vecs, + ) -> Self { + let cum_cents = cumulative_cents.read_only_boxed_clone(); + + let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec| { + let full_name = format!("{name}_{suffix}"); + let cached = cached_start.clone(); + let starts_version = cached.version(); + + let cents_sum = LazyDeltaVec::::new( + &format!("{full_name}_cents"), + version, + cum_cents.clone(), + starts_version, + move || cached.get(), + ); + let cents_resolutions = Resolutions::forced_import( + &format!("{full_name}_cents"), + cents_sum.read_only_boxed_clone(), + version, + indexes, + ); + let cents = LazyRollingSumFromHeight { + height: cents_sum, + resolutions: Box::new(cents_resolutions), + }; + + let usd = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &full_name, + version, + cents.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &full_name, + version, + ¢s.resolutions, + )), + }; + + LazyRollingSumFiatFromHeight { cents, usd } + }; + + Self(cached_starts.0.map_with_suffix(make_slot)) + } +} diff --git a/crates/brk_computer/src/internal/per_block/fiat/mod.rs b/crates/brk_computer/src/internal/per_block/fiat/mod.rs index 2a53f64e9..c4b1e7b00 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/mod.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/mod.rs @@ -1,7 +1,12 @@ mod base; +mod cumulative_sum; +mod cumulative_sum_with_deltas; mod lazy; -mod with_sum_24h; - +mod lazy_rolling_sum; +mod with_deltas; pub use base::*; +pub use cumulative_sum::*; +pub use cumulative_sum_with_deltas::*; pub use lazy::*; -pub use with_sum_24h::*; +pub use lazy_rolling_sum::*; +pub use with_deltas::*; diff --git a/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs b/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs new file mode 100644 index 000000000..f85338e08 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs @@ -0,0 +1,55 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::Version; +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use vecdb::{Database, Rw, StorageMode}; + +use crate::{ + indexes, + internal::{BpsType, CachedWindowStarts, LazyRollingDeltasFiatFromHeight}, +}; + +use super::{CentsType, FiatPerBlock}; + +#[derive(Deref, DerefMut, Traversable)] +pub struct FiatPerBlockWithDeltas +where + C: CentsType + Into, + CS: CentsType + From, + B: BpsType + From, +{ + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub inner: FiatPerBlock, + pub delta: LazyRollingDeltasFiatFromHeight, +} + +impl FiatPerBlockWithDeltas +where + C: CentsType + JsonSchema + Into, + CS: CentsType + From, + B: BpsType + From, +{ + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + delta_version_offset: Version, + indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, + ) -> Result { + let inner = FiatPerBlock::forced_import(db, name, version, indexes)?; + + let delta = LazyRollingDeltasFiatFromHeight::new( + &format!("{name}_delta"), + version + delta_version_offset, + &inner.cents.height, + cached_starts, + indexes, + ); + + Ok(Self { inner, delta }) + } +} diff --git a/crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs b/crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs deleted file mode 100644 index 9b9627ea3..000000000 --- a/crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! FiatPerBlockWithSum24h - FiatPerBlock raw + RollingWindow24hFiatPerBlock sum. - -use std::ops::SubAssign; - -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use crate::{ - indexes, - internal::{CentsType, FiatPerBlock, RollingWindow24h}, -}; - -/// Single 24h rolling window backed by FiatPerBlock (cents + lazy usd). -#[derive(Deref, DerefMut, Traversable)] -#[traversable(transparent)] -pub struct RollingWindow24hFiatPerBlock( - pub RollingWindow24h>, -); - -impl RollingWindow24hFiatPerBlock { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self(RollingWindow24h { - _24h: FiatPerBlock::forced_import(db, &format!("{name}_24h"), version, indexes)?, - })) - } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - height_24h_ago: &impl ReadableVec, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> - where - C: Default + SubAssign, - { - self._24h - .cents - .height - .compute_rolling_sum(max_from, height_24h_ago, source, exit)?; - Ok(()) - } -} - -/// Fiat per-block value (cents + usd) with 24h rolling sum (also fiat). -#[derive(Traversable)] -pub struct FiatPerBlockWithSum24h { - pub raw: FiatPerBlock, - pub sum: RollingWindow24hFiatPerBlock, -} diff --git a/crates/brk_computer/src/internal/per_block/percent/rolling_average.rs b/crates/brk_computer/src/internal/per_block/percent/rolling_average.rs index ab1de5cff..0d132ba88 100644 --- a/crates/brk_computer/src/internal/per_block/percent/rolling_average.rs +++ b/crates/brk_computer/src/internal/per_block/percent/rolling_average.rs @@ -5,7 +5,7 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableCloneableVec, Rw, StorageM use crate::{ indexes, - internal::{BpsType, WindowStarts}, + internal::{BpsType, CachedWindowStarts}, }; use crate::internal::{ComputedPerBlockRollingAverage, LazyPerBlock}; @@ -24,12 +24,14 @@ impl PercentPerBlockRollingAverage { name: &str, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let bps = ComputedPerBlockRollingAverage::forced_import( db, &format!("{name}_bps"), version, indexes, + cached_starts, )?; let ratio = LazyPerBlock::from_height_source::( @@ -56,14 +58,9 @@ impl PercentPerBlockRollingAverage { pub(crate) fn compute( &mut self, max_from: Height, - windows: &WindowStarts<'_>, exit: &Exit, compute_height: impl FnOnce(&mut EagerVec>) -> Result<()>, - ) -> Result<()> - where - B: Default, - f64: From, - { - self.bps.compute(max_from, windows, exit, compute_height) + ) -> Result<()> { + self.bps.compute(max_from, exit, compute_height) } } diff --git a/crates/brk_computer/src/internal/per_block/rolling/avg.rs b/crates/brk_computer/src/internal/per_block/rolling/avg.rs new file mode 100644 index 000000000..56111e0a0 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/rolling/avg.rs @@ -0,0 +1,18 @@ +use brk_traversable::Traversable; +use brk_types::Height; +use schemars::JsonSchema; +use vecdb::{DeltaAvg, LazyDeltaVec}; + +use crate::internal::{NumericValue, Resolutions}; + +/// A single lazy rolling-average slot from height: the lazy delta vec + its resolution views. +#[derive(Clone, Traversable)] +#[traversable(merge)] +pub struct LazyRollingAvgFromHeight +where + T: NumericValue + JsonSchema, +{ + pub height: LazyDeltaVec, + #[traversable(flatten)] + pub resolutions: Box>, +} diff --git a/crates/brk_computer/src/internal/per_block/rolling/avgs.rs b/crates/brk_computer/src/internal/per_block/rolling/avgs.rs new file mode 100644 index 000000000..4551671ce --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/rolling/avgs.rs @@ -0,0 +1,61 @@ +use brk_traversable::Traversable; +use brk_types::{Height, Version}; +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use vecdb::{DeltaAvg, LazyDeltaVec, ReadableCloneableVec}; + +use crate::{ + indexes, + internal::{CachedWindowStarts, NumericValue, Resolutions, Windows}, +}; + +use super::LazyRollingAvgFromHeight; + +/// Lazy rolling averages for all 4 window durations (24h, 1w, 1m, 1y), +/// derived from an f64 cumulative vec + cached window starts. +/// +/// Nothing is stored on disk — all values are computed on-the-fly via +/// `LazyDeltaVec`: `(cum[h] - cum[start-1]) / (h - start + 1)`. +#[derive(Clone, Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct LazyRollingAvgsFromHeight(pub Windows>) +where + T: NumericValue + JsonSchema; + +impl LazyRollingAvgsFromHeight +where + T: NumericValue + JsonSchema, +{ + pub fn new( + name: &str, + version: Version, + cumulative: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, + indexes: &indexes::Vecs, + ) -> Self { + let cum_source = cumulative.read_only_boxed_clone(); + + Self(cached_starts.0.map_with_suffix(|suffix, cached_start| { + let full_name = format!("{name}_{suffix}"); + let cached = cached_start.clone(); + let starts_version = cached.version(); + let avg = LazyDeltaVec::::new( + &full_name, + version, + cum_source.clone(), + starts_version, + move || cached.get(), + ); + let resolutions = Resolutions::forced_import( + &full_name, + avg.read_only_boxed_clone(), + version, + indexes, + ); + LazyRollingAvgFromHeight { + height: avg, + resolutions: Box::new(resolutions), + } + })) + } +} diff --git a/crates/brk_computer/src/internal/per_block/rolling/delta.rs b/crates/brk_computer/src/internal/per_block/rolling/delta.rs new file mode 100644 index 000000000..68870b385 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/rolling/delta.rs @@ -0,0 +1,313 @@ +use brk_traversable::Traversable; +use brk_types::{Dollars, Height, StoredF32, Version}; +use schemars::JsonSchema; +use vecdb::{DeltaChange, DeltaRate, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec, VecValue}; + +use crate::{ + indexes, + internal::{ + BpsType, CachedWindowStarts, CentsType, DerivedResolutions, LazyPerBlock, NumericValue, + Resolutions, Windows, + }, +}; + +/// Generic single-slot lazy delta: a `LazyDeltaVec` + resolution views. +/// +/// Used as building block for both change and rate deltas. +/// - Change: `LazyDeltaFromHeight` +/// - Rate BPS: `LazyDeltaFromHeight` +#[derive(Clone, Traversable)] +#[traversable(merge)] +pub struct LazyDeltaFromHeight +where + S: VecValue, + T: NumericValue + JsonSchema, +{ + pub height: LazyDeltaVec, + #[traversable(flatten)] + pub resolutions: Box>, +} + +/// Single-slot lazy delta percent: BPS delta + lazy ratio + lazy percent views. +/// +/// Mirrors `PercentPerBlock` but with lazy delta for the BPS source. +#[derive(Clone, Traversable)] +pub struct LazyDeltaPercentFromHeight +where + S: VecValue, + B: BpsType, +{ + pub bps: LazyDeltaFromHeight, + pub ratio: LazyPerBlock, + pub percent: LazyPerBlock, +} + +/// Lazy rolling deltas for all 4 window durations (24h, 1w, 1m, 1y). +/// +/// Tree shape: `change._24h/...`, `rate._24h/...` — matches old `RollingDelta`. +/// +/// Replaces `RollingDelta`, `RollingDelta1m`, and `RollingDeltaExcept1m` — since +/// there is no storage cost, all 4 windows are always available. +#[derive(Clone, Traversable)] +pub struct LazyRollingDeltasFromHeight +where + S: VecValue, + C: NumericValue + JsonSchema, + B: BpsType, +{ + pub change: Windows>, + pub rate: Windows>, +} + +impl LazyRollingDeltasFromHeight +where + S: VecValue + Into, + C: NumericValue + JsonSchema + From, + B: BpsType + From, +{ + pub fn new( + name: &str, + version: Version, + source: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, + indexes: &indexes::Vecs, + ) -> Self { + let src = source.read_only_boxed_clone(); + + let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec| { + let full_name = format!("{name}_{suffix}"); + let cached = cached_start.clone(); + let starts_version = cached.version(); + + // Change: source[h] - source[ago] as C (via f64) + let change_vec = LazyDeltaVec::::new( + &format!("{full_name}_change"), + version, + src.clone(), + starts_version, + { + let cached = cached.clone(); + move || cached.get() + }, + ); + let change_resolutions = Resolutions::forced_import( + &format!("{full_name}_change"), + change_vec.read_only_boxed_clone(), + version, + indexes, + ); + let change = LazyDeltaFromHeight { + height: change_vec, + resolutions: Box::new(change_resolutions), + }; + + // Rate BPS: (source[h] - source[ago]) / source[ago] as B (via f64) + let rate_vec = LazyDeltaVec::::new( + &format!("{full_name}_rate_bps"), + version, + src.clone(), + starts_version, + move || cached.get(), + ); + let rate_resolutions = Resolutions::forced_import( + &format!("{full_name}_rate_bps"), + rate_vec.read_only_boxed_clone(), + version, + indexes, + ); + let bps = LazyDeltaFromHeight { + height: rate_vec, + resolutions: Box::new(rate_resolutions), + }; + + // Ratio: bps / 10000 + let ratio = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &format!("{full_name}_rate_ratio"), + version, + bps.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &format!("{full_name}_rate_ratio"), + version, + &bps.resolutions, + )), + }; + + // Percent: bps / 100 + let percent = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &format!("{full_name}_rate"), + version, + bps.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &format!("{full_name}_rate"), + version, + &bps.resolutions, + )), + }; + + let rate = LazyDeltaPercentFromHeight { + bps, + ratio, + percent, + }; + + (change, rate) + }; + + let (change, rate) = cached_starts.0.map_with_suffix(make_slot).unzip(); + + Self { change, rate } + } +} + +// --------------------------------------------------------------------------- +// Fiat delta types (cents change + lazy USD + rate) +// --------------------------------------------------------------------------- + +/// Single-slot fiat delta change: cents delta + lazy USD. +#[derive(Clone, Traversable)] +pub struct LazyDeltaFiatFromHeight +where + S: VecValue, + C: CentsType, +{ + pub cents: LazyDeltaFromHeight, + pub usd: LazyPerBlock, +} + +/// Lazy fiat rolling deltas for all 4 windows. +/// +/// Tree shape: `change._24h.{cents,usd}/...`, `rate._24h/...` — matches old `FiatRollingDelta`. +/// +/// Replaces `FiatRollingDelta`, `FiatRollingDelta1m`, and `FiatRollingDeltaExcept1m`. +#[derive(Clone, Traversable)] +pub struct LazyRollingDeltasFiatFromHeight +where + S: VecValue, + C: CentsType, + B: BpsType, +{ + pub change: Windows>, + pub rate: Windows>, +} + +impl LazyRollingDeltasFiatFromHeight +where + S: VecValue + Into, + C: CentsType + From, + B: BpsType + From, +{ + pub fn new( + name: &str, + version: Version, + source: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, + indexes: &indexes::Vecs, + ) -> Self { + let src = source.read_only_boxed_clone(); + + let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec| { + let full_name = format!("{name}_{suffix}"); + let cached = cached_start.clone(); + let starts_version = cached.version(); + + // Change cents: source[h] - source[ago] as C (via f64) + let change_vec = LazyDeltaVec::::new( + &format!("{full_name}_change"), + version, + src.clone(), + starts_version, + { + let cached = cached.clone(); + move || cached.get() + }, + ); + let change_resolutions = Resolutions::forced_import( + &format!("{full_name}_change"), + change_vec.read_only_boxed_clone(), + version, + indexes, + ); + let cents = LazyDeltaFromHeight { + height: change_vec, + resolutions: Box::new(change_resolutions), + }; + + // Change USD: lazy from cents delta + let usd = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &format!("{full_name}_change_usd"), + version, + cents.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &format!("{full_name}_change_usd"), + version, + ¢s.resolutions, + )), + }; + + let change = LazyDeltaFiatFromHeight { cents, usd }; + + // Rate BPS: (source[h] - source[ago]) / source[ago] as B (via f64) + let rate_vec = LazyDeltaVec::::new( + &format!("{full_name}_rate_bps"), + version, + src.clone(), + starts_version, + move || cached.get(), + ); + let rate_resolutions = Resolutions::forced_import( + &format!("{full_name}_rate_bps"), + rate_vec.read_only_boxed_clone(), + version, + indexes, + ); + let bps = LazyDeltaFromHeight { + height: rate_vec, + resolutions: Box::new(rate_resolutions), + }; + + let ratio = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &format!("{full_name}_rate_ratio"), + version, + bps.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &format!("{full_name}_rate_ratio"), + version, + &bps.resolutions, + )), + }; + + let percent = LazyPerBlock { + height: LazyVecFrom1::transformed::( + &format!("{full_name}_rate"), + version, + bps.height.read_only_boxed_clone(), + ), + resolutions: Box::new(DerivedResolutions::from_derived_computed::( + &format!("{full_name}_rate"), + version, + &bps.resolutions, + )), + }; + + let rate = LazyDeltaPercentFromHeight { + bps, + ratio, + percent, + }; + + (change, rate) + }; + + let (change, rate) = cached_starts.0.map_with_suffix(make_slot).unzip(); + + Self { change, rate } + } +} diff --git a/crates/brk_computer/src/internal/per_block/rolling/full.rs b/crates/brk_computer/src/internal/per_block/rolling/full.rs index cfccc6d5a..c0cbd85cb 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/full.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/full.rs @@ -1,28 +1,27 @@ -//! RollingFull - Sum + Distribution per rolling window. -//! -//! 36 stored height vecs per metric (4 sum + 32 distribution), each with 17 index views. - -use std::ops::SubAssign; +//! RollingFull - Lazy rolling sums + stored rolling distribution per window. use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Version}; use schemars::JsonSchema; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; +use vecdb::{Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{ComputedVecValue, NumericValue, RollingDistribution, RollingWindows, WindowStarts}, + internal::{ + CachedWindowStarts, NumericValue, LazyRollingSumsFromHeight, RollingDistribution, + WindowStarts, + }, }; -/// Sum (4 windows) + Distribution (8 stats × 4 windows) = 36 stored height vecs. +/// Lazy rolling sums + stored rolling distribution (8 stats × 4 windows). #[derive(Traversable)] pub struct RollingFull where - T: ComputedVecValue + PartialOrd + JsonSchema, + T: NumericValue + JsonSchema, { - pub sum: RollingWindows, + pub sum: LazyRollingSumsFromHeight, #[traversable(flatten)] pub distribution: RollingDistribution, } @@ -36,14 +35,22 @@ where name: &str, version: Version, indexes: &indexes::Vecs, + cumulative: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, ) -> Result { - Ok(Self { - sum: RollingWindows::forced_import(db, &format!("{name}_sum"), version, indexes)?, - distribution: RollingDistribution::forced_import(db, name, version, indexes)?, - }) + let sum = LazyRollingSumsFromHeight::new( + &format!("{name}_sum"), + version, + cumulative, + cached_starts, + indexes, + ); + let distribution = RollingDistribution::forced_import(db, name, version, indexes)?; + + Ok(Self { sum, distribution }) } - /// Compute rolling sum + all 8 distribution stats across all 4 windows. + /// Compute rolling distribution stats across all 4 windows. pub(crate) fn compute( &mut self, max_from: Height, @@ -52,13 +59,10 @@ where exit: &Exit, ) -> Result<()> where - T: From + Default + SubAssign + Copy + Ord, + T: From + Default + Copy + Ord, f64: From, { - self.sum - .compute_rolling_sum(max_from, windows, source, exit)?; self.distribution - .compute_distribution(max_from, windows, source, exit)?; - Ok(()) + .compute_distribution(max_from, windows, source, exit) } } 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 c00216060..7d6a08e48 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/mod.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/mod.rs @@ -1,7 +1,17 @@ +mod avg; +mod avgs; +mod delta; mod distribution; mod full; +mod sum; +mod sums; mod windows; +pub use avg::*; +pub use avgs::*; +pub use delta::*; pub use distribution::*; pub use full::*; +pub use sum::*; +pub use sums::*; pub use windows::*; diff --git a/crates/brk_computer/src/internal/per_block/rolling/sum.rs b/crates/brk_computer/src/internal/per_block/rolling/sum.rs new file mode 100644 index 000000000..9bff49df3 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/rolling/sum.rs @@ -0,0 +1,18 @@ +use brk_traversable::Traversable; +use brk_types::Height; +use schemars::JsonSchema; +use vecdb::{DeltaSub, LazyDeltaVec}; + +use crate::internal::{NumericValue, Resolutions}; + +/// A single lazy rolling-sum slot from height: the lazy delta vec + its resolution views. +#[derive(Clone, Traversable)] +#[traversable(merge)] +pub struct LazyRollingSumFromHeight +where + T: NumericValue + JsonSchema, +{ + pub height: LazyDeltaVec, + #[traversable(flatten)] + pub resolutions: Box>, +} diff --git a/crates/brk_computer/src/internal/per_block/rolling/sums.rs b/crates/brk_computer/src/internal/per_block/rolling/sums.rs new file mode 100644 index 000000000..376f4f4e9 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/rolling/sums.rs @@ -0,0 +1,64 @@ +use brk_traversable::Traversable; +use brk_types::{Height, Version}; +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use vecdb::{DeltaSub, LazyDeltaVec, ReadableCloneableVec}; + +use crate::{ + indexes, + internal::{CachedWindowStarts, NumericValue, Resolutions, Windows}, +}; + +use super::LazyRollingSumFromHeight; + +/// Lazy rolling sums for all 4 window durations (24h, 1w, 1m, 1y), +/// derived from a cumulative vec + cached window starts. +/// +/// Nothing is stored on disk — all values are computed on-the-fly via +/// `LazyDeltaVec`: `cum[h] - cum[window_start[h]]`. +/// +/// Implements `Traversable` to expose `_24h`, `_1w`, `_1m`, `_1y` with +/// the same tree structure as the old `RollingWindows`. +#[derive(Clone, Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct LazyRollingSumsFromHeight(pub Windows>) +where + T: NumericValue + JsonSchema; + +impl LazyRollingSumsFromHeight +where + T: NumericValue + JsonSchema, +{ + pub fn new( + name: &str, + version: Version, + cumulative: &(impl ReadableCloneableVec + 'static), + cached_starts: &CachedWindowStarts, + indexes: &indexes::Vecs, + ) -> Self { + let cum_source = cumulative.read_only_boxed_clone(); + + Self(cached_starts.0.map_with_suffix(|suffix, cached_start| { + let full_name = format!("{name}_{suffix}"); + let cached = cached_start.clone(); + let starts_version = cached.version(); + let sum = LazyDeltaVec::::new( + &full_name, + version, + cum_source.clone(), + starts_version, + move || cached.get(), + ); + let resolutions = Resolutions::forced_import( + &full_name, + sum.read_only_boxed_clone(), + version, + indexes, + ); + LazyRollingSumFromHeight { + height: sum, + resolutions: Box::new(resolutions), + } + })) + } +} 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 f24139ff2..7eafe7c5b 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/windows.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/windows.rs @@ -3,15 +3,13 @@ //! Each of the 4 windows (24h, 1w, 1m, 1y) contains a height-level stored vec //! plus all 17 LazyAggVec index views. -use std::ops::SubAssign; - use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Version}; use derive_more::{Deref, DerefMut}; use schemars::JsonSchema; -use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode}; +use vecdb::{Database, EagerVec, PcoVec, Rw, StorageMode}; use crate::{ indexes, @@ -42,23 +40,6 @@ where ComputedPerBlock::forced_import(db, &format!("{name}_{suffix}"), version, indexes) })?)) } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> - where - T: Default + SubAssign, - { - for (w, starts) in self.0.as_mut_array().into_iter().zip(windows.as_array()) { - w.height - .compute_rolling_sum(max_from, *starts, source, exit)?; - } - Ok(()) - } } /// Single 24h rolling window backed by ComputedPerBlock (1 stored vec). @@ -89,22 +70,6 @@ where )?, })) } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - height_24h_ago: &impl ReadableVec, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> - where - T: Default + SubAssign, - { - self._24h - .height - .compute_rolling_sum(max_from, height_24h_ago, source, exit)?; - Ok(()) - } } /// Extended rolling windows: 1w + 1m + 1y (3 stored vecs). @@ -128,22 +93,4 @@ where ComputedPerBlock::forced_import(db, &format!("{name}_{suffix}"), version, indexes) })?)) } - - pub(crate) fn compute_rolling_sum( - &mut self, - max_from: Height, - windows: &WindowStarts<'_>, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> - where - T: Default + SubAssign, - { - let starts = [windows._1w, windows._1m, windows._1y]; - for (w, starts) in self.0.as_mut_array().into_iter().zip(starts) { - w.height - .compute_rolling_sum(max_from, starts, source, exit)?; - } - Ok(()) - } } diff --git a/crates/brk_computer/src/internal/traits.rs b/crates/brk_computer/src/internal/traits.rs index df675ed39..bc87836a0 100644 --- a/crates/brk_computer/src/internal/traits.rs +++ b/crates/brk_computer/src/internal/traits.rs @@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div}; use brk_types::{BasisPoints16, BasisPoints32, BasisPointsSigned16, BasisPointsSigned32, StoredF32}; use schemars::JsonSchema; use serde::Serialize; -use vecdb::{Formattable, PcoVecValue, UnaryTransform}; +use vecdb::{CheckedSub, Formattable, PcoVecValue, UnaryTransform}; use crate::internal::{ Bp16ToFloat, Bp16ToPercent, Bp32ToFloat, Bp32ToPercent, Bps16ToFloat, Bps16ToPercent, @@ -34,9 +34,9 @@ impl ComputedVecValue for T where { } -pub trait NumericValue: ComputedVecValue + From + Into {} +pub trait NumericValue: ComputedVecValue + CheckedSub + Default + From + Into {} -impl NumericValue for T where T: ComputedVecValue + From + Into {} +impl NumericValue for T where T: ComputedVecValue + CheckedSub + Default + From + Into {} /// Trait that associates a basis-point type with its transforms to ratio and percent. pub trait BpsType: NumericValue + JsonSchema { diff --git a/crates/brk_computer/src/internal/transform/mod.rs b/crates/brk_computer/src/internal/transform/mod.rs index 11fa8010e..d76f447e8 100644 --- a/crates/brk_computer/src/internal/transform/mod.rs +++ b/crates/brk_computer/src/internal/transform/mod.rs @@ -25,7 +25,6 @@ pub use derived::{ pub use ratio::{ RatioCentsBp32, RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RatioDiffCentsBps32, RatioDiffDollarsBps32, RatioDiffF32Bps32, - RatioDollarsBp16, RatioDollarsBp32, RatioDollarsBps32, RatioSatsBp16, RatioU32Bp16, - RatioU64Bp16, + RatioDollarsBp16, RatioDollarsBp32, RatioDollarsBps32, RatioSatsBp16, RatioU64Bp16, }; pub use specialized::{BlockCountTarget, OhlcCentsToDollars, OhlcCentsToSats}; diff --git a/crates/brk_computer/src/internal/transform/ratio.rs b/crates/brk_computer/src/internal/transform/ratio.rs index 99d9248df..e2cb66190 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, - StoredU32, StoredU64, + StoredU64, }; use vecdb::BinaryTransform; @@ -43,19 +43,6 @@ impl BinaryTransform for RatioCentsBp32 { } } -pub struct RatioU32Bp16; - -impl BinaryTransform for RatioU32Bp16 { - #[inline(always)] - fn apply(numerator: StoredU32, denominator: StoredU32) -> BasisPoints16 { - if *denominator > 0 { - BasisPoints16::from(*numerator as f64 / *denominator as f64) - } else { - BasisPoints16::ZERO - } - } -} - pub struct RatioDollarsBp16; impl BinaryTransform for RatioDollarsBp16 { diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index ce1c5b35f..d8f5947dd 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -34,6 +34,7 @@ pub struct Computer { pub mining: Box>, pub transactions: Box>, pub scripts: Box>, + #[traversable(hidden)] pub positions: Box>, pub cointime: Box>, pub constants: Box, @@ -81,31 +82,6 @@ impl Computer { }) })?; - let (inputs, outputs) = timed("Imported inputs/outputs", || { - thread::scope(|s| -> Result<_> { - let inputs_handle = big_thread().spawn_scoped(s, || -> Result<_> { - Ok(Box::new(inputs::Vecs::forced_import( - &computed_path, - VERSION, - &indexes, - )?)) - })?; - - let outputs_handle = big_thread().spawn_scoped(s, || -> Result<_> { - Ok(Box::new(outputs::Vecs::forced_import( - &computed_path, - VERSION, - &indexes, - )?)) - })?; - - let inputs = inputs_handle.join().unwrap()?; - let outputs = outputs_handle.join().unwrap()?; - - Ok((inputs, outputs)) - }) - })?; - let (constants, prices) = timed("Imported prices/constants", || -> Result<_> { let constants = Box::new(constants::Vecs::new(VERSION, &indexes)); let prices = Box::new(prices::Vecs::forced_import( @@ -116,15 +92,35 @@ impl Computer { Ok((constants, prices)) })?; - let (blocks, mining, transactions, scripts, pools, cointime) = - timed("Imported blocks/mining/tx/scripts/pools/cointime", || { + let blocks = timed("Imported blocks", || -> Result<_> { + Ok(Box::new(blocks::Vecs::forced_import( + &computed_path, + VERSION, + indexer, + &indexes, + )?)) + })?; + + 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", || { thread::scope(|s| -> Result<_> { - let blocks_handle = big_thread().spawn_scoped(s, || -> Result<_> { - Ok(Box::new(blocks::Vecs::forced_import( + let inputs_handle = big_thread().spawn_scoped(s, || -> Result<_> { + Ok(Box::new(inputs::Vecs::forced_import( &computed_path, VERSION, - indexer, &indexes, + cached_starts, + )?)) + })?; + + let outputs_handle = big_thread().spawn_scoped(s, || -> Result<_> { + Ok(Box::new(outputs::Vecs::forced_import( + &computed_path, + VERSION, + &indexes, + cached_starts, )?)) })?; @@ -133,6 +129,7 @@ impl Computer { &computed_path, VERSION, &indexes, + cached_starts, )?)) })?; @@ -142,6 +139,7 @@ impl Computer { VERSION, indexer, &indexes, + cached_starts, )?)) })?; @@ -150,6 +148,7 @@ impl Computer { &computed_path, VERSION, &indexes, + cached_starts, )?)) })?; @@ -158,6 +157,7 @@ impl Computer { &computed_path, VERSION, &indexes, + cached_starts, )?)) })?; @@ -165,15 +165,17 @@ impl Computer { &computed_path, VERSION, &indexes, + cached_starts, )?); - let blocks = blocks_handle.join().unwrap()?; + let inputs = inputs_handle.join().unwrap()?; + let outputs = outputs_handle.join().unwrap()?; let mining = mining_handle.join().unwrap()?; let transactions = transactions_handle.join().unwrap()?; let scripts = scripts_handle.join().unwrap()?; let pools = pools_handle.join().unwrap()?; - Ok((blocks, mining, transactions, scripts, pools, cointime)) + Ok((inputs, outputs, mining, transactions, scripts, pools, cointime)) }) })?; @@ -202,6 +204,7 @@ impl Computer { &computed_path, VERSION, &indexes, + cached_starts, )?); let market = market_handle.join().unwrap()?; @@ -217,6 +220,7 @@ impl Computer { &indexes, &distribution, &cointime, + cached_starts, )?)) })?; @@ -334,7 +338,6 @@ impl Computer { timed("Computed scripts", || { self.scripts.compute( indexer, - &self.blocks, &self.outputs, &self.prices, &starting_indexes, diff --git a/crates/brk_computer/src/mining/import.rs b/crates/brk_computer/src/mining/import.rs index 60a9d8725..281cf814e 100644 --- a/crates/brk_computer/src/mining/import.rs +++ b/crates/brk_computer/src/mining/import.rs @@ -5,7 +5,7 @@ use brk_types::Version; use crate::{ indexes, - internal::{finalize_db, open_db}, + internal::{finalize_db, open_db, CachedWindowStarts}, }; use super::{HashrateVecs, RewardsVecs, Vecs}; @@ -15,11 +15,12 @@ impl Vecs { parent_path: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, super::DB_NAME, 50_000_000)?; let version = parent_version; - let rewards = RewardsVecs::forced_import(&db, version, indexes)?; + let rewards = RewardsVecs::forced_import(&db, version, indexes, cached_starts)?; let hashrate = HashrateVecs::forced_import(&db, version, indexes)?; let this = Self { diff --git a/crates/brk_computer/src/mining/rewards/compute.rs b/crates/brk_computer/src/mining/rewards/compute.rs index 235c3a11f..d213dc4a8 100644 --- a/crates/brk_computer/src/mining/rewards/compute.rs +++ b/crates/brk_computer/src/mining/rewards/compute.rs @@ -18,11 +18,8 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let window_starts = lookback.window_starts(); - self.coinbase.compute( starting_indexes.height, - &window_starts, prices, exit, |vec| { @@ -59,6 +56,8 @@ impl Vecs { )?; // Coinbase fee is 0, so including it in the sum doesn't affect the result + let window_starts = lookback.window_starts(); + self.fees.compute( starting_indexes.height, &window_starts, @@ -78,7 +77,7 @@ impl Vecs { self.subsidy.base.sats.height.compute_transform2( starting_indexes.height, - &self.coinbase.base.sats.height, + &self.coinbase.raw.sats.height, &self.fees.base.sats.height, |(height, coinbase, fees, ..)| { ( @@ -94,7 +93,6 @@ impl Vecs { self.unclaimed.compute( starting_indexes.height, - &window_starts, prices, exit, |vec| { @@ -125,7 +123,7 @@ impl Vecs { self.fee_dominance_rolling .compute_binary::( starting_indexes.height, - self.fees.rolling.as_array().map(|w| &w.sum.sats.height), + self.fees.sum.as_array().map(|w| &w.sats.height), self.coinbase.sum.as_array().map(|w| &w.sats.height), exit, )?; @@ -166,7 +164,7 @@ impl Vecs { .compute_binary::( starting_indexes.height, self.coinbase.sum.as_array().map(|w| &w.usd.height), - self.fees.rolling.as_array().map(|w| &w.sum.usd.height), + self.fees.sum.as_array().map(|w| &w.usd.height), exit, )?; diff --git a/crates/brk_computer/src/mining/rewards/import.rs b/crates/brk_computer/src/mining/rewards/import.rs index cf638cbcc..a1cf68655 100644 --- a/crates/brk_computer/src/mining/rewards/import.rs +++ b/crates/brk_computer/src/mining/rewards/import.rs @@ -6,8 +6,9 @@ use super::Vecs; use crate::{ indexes, internal::{ - AmountPerBlockCumulative, AmountPerBlockCumulativeSum, AmountPerBlockFull, - FiatPerBlock, PercentPerBlock, PercentRollingWindows, RatioRollingWindows, + AmountPerBlockCumulative, AmountPerBlockCumulativeWithSums, AmountPerBlockFull, + CachedWindowStarts, FiatPerBlock, PercentPerBlock, PercentRollingWindows, + RatioRollingWindows, }, }; @@ -16,18 +17,20 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - coinbase: AmountPerBlockCumulativeSum::forced_import( - db, "coinbase", version, indexes, + coinbase: AmountPerBlockCumulativeWithSums::forced_import( + db, "coinbase", version, indexes, cached_starts, )?, subsidy: AmountPerBlockCumulative::forced_import(db, "subsidy", version, indexes)?, - fees: AmountPerBlockFull::forced_import(db, "fees", version, indexes)?, - unclaimed: AmountPerBlockCumulativeSum::forced_import( + fees: AmountPerBlockFull::forced_import(db, "fees", version, indexes, cached_starts)?, + unclaimed: AmountPerBlockCumulativeWithSums::forced_import( db, "unclaimed_rewards", version, indexes, + cached_starts, )?, fee_dominance: PercentPerBlock::forced_import(db, "fee_dominance", version, indexes)?, fee_dominance_rolling: PercentRollingWindows::forced_import( diff --git a/crates/brk_computer/src/mining/rewards/vecs.rs b/crates/brk_computer/src/mining/rewards/vecs.rs index 94da4fb63..e06f48432 100644 --- a/crates/brk_computer/src/mining/rewards/vecs.rs +++ b/crates/brk_computer/src/mining/rewards/vecs.rs @@ -3,16 +3,16 @@ use brk_types::{BasisPoints16, BasisPoints32, Cents}; use vecdb::{Rw, StorageMode}; use crate::internal::{ - AmountPerBlockCumulative, AmountPerBlockCumulativeSum, AmountPerBlockFull, + AmountPerBlockCumulative, AmountPerBlockCumulativeWithSums, AmountPerBlockFull, FiatPerBlock, PercentPerBlock, PercentRollingWindows, RatioRollingWindows, }; #[derive(Traversable)] pub struct Vecs { - pub coinbase: AmountPerBlockCumulativeSum, + pub coinbase: AmountPerBlockCumulativeWithSums, pub subsidy: AmountPerBlockCumulative, pub fees: AmountPerBlockFull, - pub unclaimed: AmountPerBlockCumulativeSum, + pub unclaimed: AmountPerBlockCumulativeWithSums, #[traversable(wrap = "fees", rename = "dominance")] pub fee_dominance: PercentPerBlock, #[traversable(wrap = "fees", rename = "dominance")] diff --git a/crates/brk_computer/src/outputs/count/import.rs b/crates/brk_computer/src/outputs/count/import.rs index 28905529d..78e258acc 100644 --- a/crates/brk_computer/src/outputs/count/import.rs +++ b/crates/brk_computer/src/outputs/count/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{ComputedPerBlock, ComputedPerBlockAggregated}, + internal::{CachedWindowStarts, ComputedPerBlock, ComputedPerBlockAggregated}, }; impl Vecs { @@ -13,6 +13,7 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { total: ComputedPerBlockAggregated::forced_import( @@ -20,6 +21,7 @@ impl Vecs { "output_count", version, indexes, + cached_starts, )?, unspent: ComputedPerBlock::forced_import( db, diff --git a/crates/brk_computer/src/outputs/import.rs b/crates/brk_computer/src/outputs/import.rs index b0acd3f15..d733f7fd1 100644 --- a/crates/brk_computer/src/outputs/import.rs +++ b/crates/brk_computer/src/outputs/import.rs @@ -5,7 +5,7 @@ use brk_types::Version; use crate::{ indexes, - internal::{finalize_db, open_db}, + internal::{finalize_db, open_db, CachedWindowStarts}, }; use super::{CountVecs, SpentVecs, Vecs}; @@ -15,12 +15,13 @@ impl Vecs { parent_path: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, super::DB_NAME, 10_000_000)?; let version = parent_version; let spent = SpentVecs::forced_import(&db, version)?; - let count = CountVecs::forced_import(&db, version, indexes)?; + let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?; let this = Self { db, spent, count }; finalize_db(&this.db, &this)?; diff --git a/crates/brk_computer/src/pools/major.rs b/crates/brk_computer/src/pools/major.rs index 75e3ed678..8ff8e3790 100644 --- a/crates/brk_computer/src/pools/major.rs +++ b/crates/brk_computer/src/pools/major.rs @@ -1,14 +1,14 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU32}; +use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU64}; use derive_more::{Deref, DerefMut}; use vecdb::{BinaryTransform, Database, Exit, ReadableVec, Rw, StorageMode, Version}; use crate::{ blocks, indexes, internal::{ - AmountPerBlockCumulativeSum, MaskSats, PercentRollingWindows, RatioU32Bp16, - RollingWindows, + AmountPerBlockCumulativeWithSums, CachedWindowStarts, MaskSats, PercentRollingWindows, + RatioU64Bp16, }, mining, prices, }; @@ -22,9 +22,7 @@ pub struct Vecs { #[traversable(flatten)] pub base: minor::Vecs, - #[traversable(wrap = "blocks_mined", rename = "sum")] - pub blocks_mined_sum: RollingWindows, - pub rewards: AmountPerBlockCumulativeSum, + pub rewards: AmountPerBlockCumulativeWithSums, #[traversable(rename = "dominance")] pub dominance_rolling: PercentRollingWindows, } @@ -35,23 +33,25 @@ impl Vecs { slug: PoolSlug, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let suffix = |s: &str| format!("{}_{s}", slug); - let base = minor::Vecs::forced_import(db, slug, version, indexes)?; + let base = minor::Vecs::forced_import(db, slug, version, indexes, cached_starts)?; - let blocks_mined_sum = - RollingWindows::forced_import(db, &suffix("blocks_mined"), version, indexes)?; - - let rewards = - AmountPerBlockCumulativeSum::forced_import(db, &suffix("rewards"), version, indexes)?; + let rewards = AmountPerBlockCumulativeWithSums::forced_import( + db, + &suffix("rewards"), + version, + indexes, + cached_starts, + )?; let dominance_rolling = PercentRollingWindows::forced_import(db, &suffix("dominance"), version, indexes)?; Ok(Self { base, - blocks_mined_sum, rewards, dominance_rolling, }) @@ -70,22 +70,15 @@ impl Vecs { self.base .compute(starting_indexes, height_to_pool, blocks, exit)?; - let window_starts = blocks.lookback.window_starts(); - - self.blocks_mined_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.base.blocks_mined.raw.height, - exit, - )?; - for (dom, (mined, total)) in self.dominance_rolling.as_mut_array().into_iter().zip( - self.blocks_mined_sum + self.base + .blocks_mined + .sum .as_array() .into_iter() .zip(blocks.count.total.sum.as_array()), ) { - dom.compute_binary::( + dom.compute_binary::( starting_indexes.height, &mined.height, &total.height, @@ -95,14 +88,13 @@ impl Vecs { self.rewards.compute( starting_indexes.height, - &window_starts, prices, exit, |vec| { Ok(vec.compute_transform2( starting_indexes.height, &self.base.blocks_mined.raw.height, - &mining.rewards.coinbase.base.sats.height, + &mining.rewards.coinbase.raw.sats.height, |(h, mask, val, ..)| (h, MaskSats::apply(mask, val)), exit, )?) diff --git a/crates/brk_computer/src/pools/minor.rs b/crates/brk_computer/src/pools/minor.rs index 237e7c0cf..bf99a13ee 100644 --- a/crates/brk_computer/src/pools/minor.rs +++ b/crates/brk_computer/src/pools/minor.rs @@ -1,13 +1,15 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU32}; +use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU32, StoredU64}; use vecdb::{ Database, Exit, ReadableVec, Rw, StorageMode, Version, }; use crate::{ blocks, indexes, - internal::{ComputedPerBlockCumulative, PercentPerBlock, RatioU32Bp16}, + internal::{ + CachedWindowStarts, ComputedPerBlockCumulativeWithSums, PercentPerBlock, RatioU64Bp16, + }, }; #[derive(Traversable)] @@ -15,7 +17,7 @@ pub struct Vecs { #[traversable(skip)] slug: PoolSlug, - pub blocks_mined: ComputedPerBlockCumulative, + pub blocks_mined: ComputedPerBlockCumulativeWithSums, pub dominance: PercentPerBlock, } @@ -25,14 +27,16 @@ impl Vecs { slug: PoolSlug, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let suffix = |s: &str| format!("{}_{s}", slug); - let blocks_mined = ComputedPerBlockCumulative::forced_import( + let blocks_mined = ComputedPerBlockCumulativeWithSums::forced_import( db, &suffix("blocks_mined"), version, indexes, + cached_starts, )?; let dominance = @@ -73,7 +77,7 @@ impl Vecs { })?; self.dominance - .compute_binary::( + .compute_binary::( starting_indexes.height, &self.blocks_mined.cumulative.height, &blocks.count.total.cumulative.height, diff --git a/crates/brk_computer/src/pools/mod.rs b/crates/brk_computer/src/pools/mod.rs index 6063908a8..3ed11c0cc 100644 --- a/crates/brk_computer/src/pools/mod.rs +++ b/crates/brk_computer/src/pools/mod.rs @@ -18,7 +18,7 @@ pub mod minor; use crate::{ blocks, indexes, - internal::{finalize_db, open_db}, + internal::{finalize_db, open_db, CachedWindowStarts}, mining, prices, }; @@ -39,6 +39,7 @@ impl Vecs { parent_path: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, DB_NAME, 1_000_000)?; let pools = pools(); @@ -52,12 +53,12 @@ impl Vecs { if pool.slug.is_major() { major_map.insert( pool.slug, - major::Vecs::forced_import(&db, pool.slug, version, indexes)?, + major::Vecs::forced_import(&db, pool.slug, version, indexes, cached_starts)?, ); } else { minor_map.insert( pool.slug, - minor::Vecs::forced_import(&db, pool.slug, version, indexes)?, + minor::Vecs::forced_import(&db, pool.slug, version, indexes, cached_starts)?, ); } } diff --git a/crates/brk_computer/src/scripts/compute.rs b/crates/brk_computer/src/scripts/compute.rs index 2a71f94ce..71730d158 100644 --- a/crates/brk_computer/src/scripts/compute.rs +++ b/crates/brk_computer/src/scripts/compute.rs @@ -3,7 +3,7 @@ use brk_indexer::Indexer; use brk_types::Indexes; use vecdb::Exit; -use crate::{blocks, outputs, prices}; +use crate::{outputs, prices}; use super::Vecs; @@ -11,14 +11,13 @@ impl Vecs { pub(crate) fn compute( &mut self, indexer: &Indexer, - blocks: &blocks::Vecs, outputs: &outputs::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.count - .compute(indexer, &blocks.lookback, starting_indexes, exit)?; + .compute(indexer, starting_indexes, exit)?; self.value .compute(indexer, prices, starting_indexes, exit)?; diff --git a/crates/brk_computer/src/scripts/count/compute.rs b/crates/brk_computer/src/scripts/count/compute.rs index e4925d5db..1fe3c9906 100644 --- a/crates/brk_computer/src/scripts/count/compute.rs +++ b/crates/brk_computer/src/scripts/count/compute.rs @@ -4,20 +4,16 @@ use brk_types::{Indexes, StoredU64}; use vecdb::Exit; use super::Vecs; -use crate::blocks; impl Vecs { pub(crate) fn compute( &mut self, indexer: &Indexer, - lookback: &blocks::LookbackVecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let window_starts = lookback.window_starts(); - self.p2a - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2a.first_index, @@ -27,7 +23,7 @@ impl Vecs { })?; self.p2ms - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.scripts.p2ms.first_index, @@ -37,7 +33,7 @@ impl Vecs { })?; self.p2pk33 - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2pk33.first_index, @@ -47,7 +43,7 @@ impl Vecs { })?; self.p2pk65 - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2pk65.first_index, @@ -57,7 +53,7 @@ impl Vecs { })?; self.p2pkh - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2pkh.first_index, @@ -67,7 +63,7 @@ impl Vecs { })?; self.p2sh - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2sh.first_index, @@ -77,7 +73,7 @@ impl Vecs { })?; self.p2tr - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2tr.first_index, @@ -87,7 +83,7 @@ impl Vecs { })?; self.p2wpkh - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2wpkh.first_index, @@ -97,7 +93,7 @@ impl Vecs { })?; self.p2wsh - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.addresses.p2wsh.first_index, @@ -107,7 +103,7 @@ impl Vecs { })?; self.opreturn - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.scripts.opreturn.first_index, @@ -117,7 +113,7 @@ impl Vecs { })?; self.unknownoutput - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.scripts.unknown.first_index, @@ -127,7 +123,7 @@ impl Vecs { })?; self.emptyoutput - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.scripts.empty.first_index, @@ -138,7 +134,7 @@ impl Vecs { // Compute segwit = p2wpkh + p2wsh + p2tr self.segwit - .compute(starting_indexes.height, &window_starts, exit, |v| { + .compute(starting_indexes.height, exit, |v| { Ok(v.compute_transform3( starting_indexes.height, &self.p2wpkh.raw.height, diff --git a/crates/brk_computer/src/scripts/count/import.rs b/crates/brk_computer/src/scripts/count/import.rs index 12514ada8..e31e80d81 100644 --- a/crates/brk_computer/src/scripts/count/import.rs +++ b/crates/brk_computer/src/scripts/count/import.rs @@ -3,34 +3,38 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::ComputedPerBlockCumulativeSum}; +use crate::{ + indexes, + internal::{CachedWindowStarts, ComputedPerBlockCumulativeWithSums}, +}; impl Vecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let p2a = - ComputedPerBlockCumulativeSum::forced_import(db, "p2a_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2a_count", version, indexes, cached_starts)?; let p2ms = - ComputedPerBlockCumulativeSum::forced_import(db, "p2ms_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2ms_count", version, indexes, cached_starts)?; let p2pk33 = - ComputedPerBlockCumulativeSum::forced_import(db, "p2pk33_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2pk33_count", version, indexes, cached_starts)?; let p2pk65 = - ComputedPerBlockCumulativeSum::forced_import(db, "p2pk65_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2pk65_count", version, indexes, cached_starts)?; let p2pkh = - ComputedPerBlockCumulativeSum::forced_import(db, "p2pkh_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2pkh_count", version, indexes, cached_starts)?; let p2sh = - ComputedPerBlockCumulativeSum::forced_import(db, "p2sh_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2sh_count", version, indexes, cached_starts)?; let p2tr = - ComputedPerBlockCumulativeSum::forced_import(db, "p2tr_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2tr_count", version, indexes, cached_starts)?; let p2wpkh = - ComputedPerBlockCumulativeSum::forced_import(db, "p2wpkh_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2wpkh_count", version, indexes, cached_starts)?; let p2wsh = - ComputedPerBlockCumulativeSum::forced_import(db, "p2wsh_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "p2wsh_count", version, indexes, cached_starts)?; let segwit = - ComputedPerBlockCumulativeSum::forced_import(db, "segwit_count", version, indexes)?; + ComputedPerBlockCumulativeWithSums::forced_import(db, "segwit_count", version, indexes, cached_starts)?; Ok(Self { p2a, @@ -42,23 +46,26 @@ impl Vecs { p2tr, p2wpkh, p2wsh, - opreturn: ComputedPerBlockCumulativeSum::forced_import( + opreturn: ComputedPerBlockCumulativeWithSums::forced_import( db, "opreturn_count", version, indexes, + cached_starts, )?, - emptyoutput: ComputedPerBlockCumulativeSum::forced_import( + emptyoutput: ComputedPerBlockCumulativeWithSums::forced_import( db, "emptyoutput_count", version, indexes, + cached_starts, )?, - unknownoutput: ComputedPerBlockCumulativeSum::forced_import( + unknownoutput: ComputedPerBlockCumulativeWithSums::forced_import( db, "unknownoutput_count", version, indexes, + cached_starts, )?, segwit, }) diff --git a/crates/brk_computer/src/scripts/count/vecs.rs b/crates/brk_computer/src/scripts/count/vecs.rs index 3d61e3d71..e40498040 100644 --- a/crates/brk_computer/src/scripts/count/vecs.rs +++ b/crates/brk_computer/src/scripts/count/vecs.rs @@ -2,22 +2,22 @@ use brk_traversable::Traversable; use brk_types::StoredU64; use vecdb::{Rw, StorageMode}; -use crate::internal::ComputedPerBlockCumulativeSum; +use crate::internal::ComputedPerBlockCumulativeWithSums; #[derive(Traversable)] pub struct Vecs { - pub p2a: ComputedPerBlockCumulativeSum, - pub p2ms: ComputedPerBlockCumulativeSum, - pub p2pk33: ComputedPerBlockCumulativeSum, - pub p2pk65: ComputedPerBlockCumulativeSum, - pub p2pkh: ComputedPerBlockCumulativeSum, - pub p2sh: ComputedPerBlockCumulativeSum, - pub p2tr: ComputedPerBlockCumulativeSum, - pub p2wpkh: ComputedPerBlockCumulativeSum, - pub p2wsh: ComputedPerBlockCumulativeSum, - pub opreturn: ComputedPerBlockCumulativeSum, - pub emptyoutput: ComputedPerBlockCumulativeSum, - pub unknownoutput: ComputedPerBlockCumulativeSum, + pub p2a: ComputedPerBlockCumulativeWithSums, + pub p2ms: ComputedPerBlockCumulativeWithSums, + pub p2pk33: ComputedPerBlockCumulativeWithSums, + pub p2pk65: ComputedPerBlockCumulativeWithSums, + pub p2pkh: ComputedPerBlockCumulativeWithSums, + pub p2sh: ComputedPerBlockCumulativeWithSums, + pub p2tr: ComputedPerBlockCumulativeWithSums, + pub p2wpkh: ComputedPerBlockCumulativeWithSums, + pub p2wsh: ComputedPerBlockCumulativeWithSums, + pub opreturn: ComputedPerBlockCumulativeWithSums, + pub emptyoutput: ComputedPerBlockCumulativeWithSums, + pub unknownoutput: ComputedPerBlockCumulativeWithSums, - pub segwit: ComputedPerBlockCumulativeSum, + pub segwit: ComputedPerBlockCumulativeWithSums, } diff --git a/crates/brk_computer/src/scripts/import.rs b/crates/brk_computer/src/scripts/import.rs index 7ac4ad0e6..2a5455b73 100644 --- a/crates/brk_computer/src/scripts/import.rs +++ b/crates/brk_computer/src/scripts/import.rs @@ -9,17 +9,19 @@ use crate::{ }; use super::{AdoptionVecs, CountVecs, ValueVecs, Vecs}; +use crate::internal::CachedWindowStarts; impl Vecs { pub(crate) fn forced_import( parent_path: &Path, parent_version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, super::DB_NAME, 50_000_000)?; let version = parent_version; - let count = CountVecs::forced_import(&db, version, indexes)?; + let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?; let value = ValueVecs::forced_import(&db, version, indexes)?; let adoption = AdoptionVecs::forced_import(&db, version, indexes)?; diff --git a/crates/brk_computer/src/supply/burned/compute.rs b/crates/brk_computer/src/supply/burned/compute.rs index 1c26427c9..f3d335662 100644 --- a/crates/brk_computer/src/supply/burned/compute.rs +++ b/crates/brk_computer/src/supply/burned/compute.rs @@ -3,24 +3,19 @@ use brk_types::{Height, Indexes, Sats}; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, VecIndex, WritableVec}; use super::Vecs; -use crate::{blocks, mining, prices, scripts}; +use crate::{mining, prices, scripts}; impl Vecs { pub(crate) fn compute( &mut self, scripts: &scripts::Vecs, mining: &mining::Vecs, - lookback: &blocks::LookbackVecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let window_starts = lookback.window_starts(); - - // 1. Compute opreturn supply - copy per-block opreturn values from scripts self.opreturn.compute( starting_indexes.height, - &window_starts, prices, exit, |height_vec| { @@ -59,12 +54,11 @@ impl Vecs { // 2. Compute unspendable supply = opreturn + unclaimed_rewards + genesis (at height 0) // Get reference to opreturn height vec for computing unspendable - let opreturn_height = &self.opreturn.base.sats.height; - let unclaimed_height = &mining.rewards.unclaimed.base.sats.height; + let opreturn_height = &self.opreturn.raw.sats.height; + let unclaimed_height = &mining.rewards.unclaimed.raw.sats.height; self.unspendable.compute( starting_indexes.height, - &window_starts, prices, exit, |height_vec| { diff --git a/crates/brk_computer/src/supply/burned/import.rs b/crates/brk_computer/src/supply/burned/import.rs index 47f67143a..8e475dcbb 100644 --- a/crates/brk_computer/src/supply/burned/import.rs +++ b/crates/brk_computer/src/supply/burned/import.rs @@ -3,26 +3,29 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::AmountPerBlockCumulativeSum}; +use crate::{indexes, internal::{AmountPerBlockCumulativeWithSums, CachedWindowStarts}}; impl Vecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - opreturn: AmountPerBlockCumulativeSum::forced_import( + opreturn: AmountPerBlockCumulativeWithSums::forced_import( db, "opreturn_supply", version, indexes, + cached_starts, )?, - unspendable: AmountPerBlockCumulativeSum::forced_import( + unspendable: AmountPerBlockCumulativeWithSums::forced_import( db, "unspendable_supply", version, indexes, + cached_starts, )?, }) } diff --git a/crates/brk_computer/src/supply/burned/vecs.rs b/crates/brk_computer/src/supply/burned/vecs.rs index c0c8d1670..054d7db81 100644 --- a/crates/brk_computer/src/supply/burned/vecs.rs +++ b/crates/brk_computer/src/supply/burned/vecs.rs @@ -1,10 +1,10 @@ use brk_traversable::Traversable; use vecdb::{Rw, StorageMode}; -use crate::internal::AmountPerBlockCumulativeSum; +use crate::internal::AmountPerBlockCumulativeWithSums; #[derive(Traversable)] pub struct Vecs { - pub opreturn: AmountPerBlockCumulativeSum, - pub unspendable: AmountPerBlockCumulativeSum, + pub opreturn: AmountPerBlockCumulativeWithSums, + pub unspendable: AmountPerBlockCumulativeWithSums, } diff --git a/crates/brk_computer/src/supply/compute.rs b/crates/brk_computer/src/supply/compute.rs index 182396a3a..2afc00abb 100644 --- a/crates/brk_computer/src/supply/compute.rs +++ b/crates/brk_computer/src/supply/compute.rs @@ -22,7 +22,6 @@ impl Vecs { self.burned.compute( scripts, mining, - &blocks.lookback, prices, starting_indexes, exit, @@ -44,27 +43,16 @@ impl Vecs { self.velocity .compute(blocks, transactions, distribution, starting_indexes, exit)?; - // 4. Compute market cap delta (change + rate across 4 windows) - let window_starts = blocks.lookback.window_starts(); - - self.market_cap_delta.compute( - starting_indexes.height, - &window_starts, - &self.market_cap.cents.height, - exit, - )?; - - // 5. market_cap_rate - realized_cap_rate per window + // 4. market_cap_rate - realized_cap_rate per window let all_realized = &distribution.utxo_cohorts.all.metrics.realized; - let mcr_arr = self.market_cap_delta.rate.0.as_array(); + let mcr_arr = self.market_cap_delta.rate.as_array(); let diff_arr = self.market_minus_realized_cap_growth_rate.0.as_mut_array(); - // 24h, 1w, 1y from extended; 1m from core delta let rcr_rates = [ - &all_realized.cap_delta_extended.rate._24h.bps.height, - &all_realized.cap_delta_extended.rate._1w.bps.height, - &all_realized.cap_delta.rate_1m.bps.height, - &all_realized.cap_delta_extended.rate._1y.bps.height, + &all_realized.cap.delta.rate._24h.bps.height, + &all_realized.cap.delta.rate._1w.bps.height, + &all_realized.cap.delta.rate._1m.bps.height, + &all_realized.cap.delta.rate._1y.bps.height, ]; for i in 0..4 { diff --git a/crates/brk_computer/src/supply/import.rs b/crates/brk_computer/src/supply/import.rs index a03c205af..ae3fbade2 100644 --- a/crates/brk_computer/src/supply/import.rs +++ b/crates/brk_computer/src/supply/import.rs @@ -6,9 +6,10 @@ use brk_types::Version; use crate::{ cointime, distribution, indexes, internal::{ - FiatRollingDelta, LazyFiatPerBlock, LazyAmountPerBlock, PercentPerBlock, - RollingWindows, finalize_db, open_db, + CachedWindowStarts, LazyAmountPerBlock, LazyFiatPerBlock, + LazyRollingDeltasFiatFromHeight, PercentPerBlock, RollingWindows, finalize_db, open_db, }, + supply::burned, }; use super::Vecs; @@ -22,18 +23,17 @@ impl Vecs { indexes: &indexes::Vecs, distribution: &distribution::Vecs, cointime: &cointime::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent, super::DB_NAME, 10_000_000)?; let version = parent_version + VERSION; let supply_metrics = &distribution.utxo_cohorts.all.metrics.supply; - // Circulating supply - lazy refs to distribution let circulating = LazyAmountPerBlock::identity("circulating_supply", &supply_metrics.total, version); - // Burned/unspendable supply - computed from scripts - let burned = super::burned::Vecs::forced_import(&db, version, indexes)?; + let burned = burned::Vecs::forced_import(&db, version, indexes, cached_starts)?; // Inflation rate let inflation_rate = @@ -47,12 +47,13 @@ impl Vecs { LazyFiatPerBlock::from_computed("market_cap", version, &supply_metrics.total.cents); // Market cap delta (change + rate across 4 windows) - let market_cap_delta = FiatRollingDelta::forced_import( - &db, + let market_cap_delta = LazyRollingDeltasFiatFromHeight::new( "market_cap_delta", version + Version::new(3), + &market_cap.cents.height, + cached_starts, indexes, - )?; + ); let market_minus_realized_cap_growth_rate = RollingWindows::forced_import( &db, @@ -61,11 +62,8 @@ impl Vecs { indexes, )?; - let hodled_or_lost = LazyAmountPerBlock::identity( - "hodled_or_lost_coins", - &cointime.supply.vaulted, - version, - ); + let hodled_or_lost = + LazyAmountPerBlock::identity("hodled_or_lost_coins", &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 e7f6c8a7a..62aee7ea9 100644 --- a/crates/brk_computer/src/supply/vecs.rs +++ b/crates/brk_computer/src/supply/vecs.rs @@ -4,7 +4,8 @@ use vecdb::{Database, Rw, StorageMode}; use super::{burned, velocity}; use crate::internal::{ - FiatRollingDelta, LazyFiatPerBlock, LazyAmountPerBlock, PercentPerBlock, RollingWindows, + LazyFiatPerBlock, LazyAmountPerBlock, LazyRollingDeltasFiatFromHeight, + PercentPerBlock, RollingWindows, }; #[derive(Traversable)] @@ -18,7 +19,7 @@ pub struct Vecs { pub velocity: velocity::Vecs, pub market_cap: LazyFiatPerBlock, #[traversable(wrap = "market_cap", rename = "delta")] - pub market_cap_delta: FiatRollingDelta, + pub market_cap_delta: LazyRollingDeltasFiatFromHeight, pub market_minus_realized_cap_growth_rate: RollingWindows, pub hodled_or_lost: LazyAmountPerBlock, } diff --git a/crates/brk_computer/src/supply/velocity/compute.rs b/crates/brk_computer/src/supply/velocity/compute.rs index 335f72904..73aaeb0f8 100644 --- a/crates/brk_computer/src/supply/velocity/compute.rs +++ b/crates/brk_computer/src/supply/velocity/compute.rs @@ -21,7 +21,7 @@ impl Vecs { self.btc.height.compute_rolling_ratio( starting_indexes.height, &blocks.lookback._1y, - &transactions.volume.sent_sum.sats, + &transactions.volume.sent_sum.raw.sats.height, &circulating_supply.sats.height, exit, )?; @@ -30,7 +30,7 @@ impl Vecs { self.usd.height.compute_rolling_ratio( starting_indexes.height, &blocks.lookback._1y, - &transactions.volume.sent_sum.usd, + &transactions.volume.sent_sum.raw.usd.height, &circulating_supply.usd.height, exit, )?; diff --git a/crates/brk_computer/src/transactions/compute.rs b/crates/brk_computer/src/transactions/compute.rs index de455c4b9..c8c867873 100644 --- a/crates/brk_computer/src/transactions/compute.rs +++ b/crates/brk_computer/src/transactions/compute.rs @@ -26,7 +26,7 @@ impl Vecs { // Versions depends on count self.versions - .compute(indexer, &blocks.lookback, starting_indexes, exit)?; + .compute(indexer, starting_indexes, exit)?; // Size computes next (uses 6-block rolling window) self.size diff --git a/crates/brk_computer/src/transactions/count/import.rs b/crates/brk_computer/src/transactions/count/import.rs index 8e1f00731..c04909cc9 100644 --- a/crates/brk_computer/src/transactions/count/import.rs +++ b/crates/brk_computer/src/transactions/count/import.rs @@ -4,7 +4,7 @@ use brk_types::{StoredBool, TxIndex, Version}; use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec}; use super::Vecs; -use crate::{indexes, internal::ComputedPerBlockFull}; +use crate::{indexes, internal::{CachedWindowStarts, ComputedPerBlockFull}}; impl Vecs { pub(crate) fn forced_import( @@ -12,6 +12,7 @@ impl Vecs { version: Version, indexer: &Indexer, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let txindex_to_is_coinbase = LazyVecFrom2::init( "is_coinbase", @@ -26,7 +27,13 @@ impl Vecs { ); Ok(Self { - total: ComputedPerBlockFull::forced_import(db, "tx_count", version, indexes)?, + total: ComputedPerBlockFull::forced_import( + db, + "tx_count", + version, + indexes, + cached_starts, + )?, is_coinbase: txindex_to_is_coinbase, }) } diff --git a/crates/brk_computer/src/transactions/import.rs b/crates/brk_computer/src/transactions/import.rs index a59656f29..9c026fdb3 100644 --- a/crates/brk_computer/src/transactions/import.rs +++ b/crates/brk_computer/src/transactions/import.rs @@ -6,7 +6,7 @@ use brk_types::Version; use crate::{ indexes, - internal::{finalize_db, open_db}, + internal::{finalize_db, open_db, CachedWindowStarts}, }; use super::{CountVecs, FeesVecs, SizeVecs, Vecs, VersionsVecs, VolumeVecs}; @@ -17,15 +17,16 @@ impl Vecs { parent_version: Version, indexer: &Indexer, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let db = open_db(parent_path, super::DB_NAME, 50_000_000)?; let version = parent_version; - let count = CountVecs::forced_import(&db, version, indexer, indexes)?; + let count = CountVecs::forced_import(&db, version, indexer, indexes, cached_starts)?; let size = SizeVecs::forced_import(&db, version, indexer)?; let fees = FeesVecs::forced_import(&db, version)?; - let versions = VersionsVecs::forced_import(&db, version, indexes)?; - let volume = VolumeVecs::forced_import(&db, version, indexes)?; + let versions = VersionsVecs::forced_import(&db, version, indexes, cached_starts)?; + let volume = VolumeVecs::forced_import(&db, version, indexes, cached_starts)?; let this = Self { db, diff --git a/crates/brk_computer/src/transactions/versions/compute.rs b/crates/brk_computer/src/transactions/versions/compute.rs index 00475f91a..baab5a0ee 100644 --- a/crates/brk_computer/src/transactions/versions/compute.rs +++ b/crates/brk_computer/src/transactions/versions/compute.rs @@ -4,25 +4,22 @@ use brk_types::{Indexes, StoredU64, TxVersion}; use vecdb::{Exit, ReadableVec, VecIndex}; use super::Vecs; -use crate::{blocks, internal::ComputedPerBlockCumulativeSum}; +use crate::internal::ComputedPerBlockCumulativeWithSums; impl Vecs { pub(crate) fn compute( &mut self, indexer: &Indexer, - lookback: &blocks::LookbackVecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let window_starts = lookback.window_starts(); - - let tx_vany = |tx_vany: &mut ComputedPerBlockCumulativeSum, + let tx_vany = |tx_vany: &mut ComputedPerBlockCumulativeWithSums, txversion: TxVersion| { let txversion_vec = &indexer.vecs.transactions.txversion; // Cursor avoids per-transaction PcoVec page decompression. // Txindex values are sequential, so the cursor only advances forward. let mut cursor = txversion_vec.cursor(); - tx_vany.compute(starting_indexes.height, &window_starts, exit, |vec| { + tx_vany.compute(starting_indexes.height, exit, |vec| { vec.compute_filtered_count_from_indexes( starting_indexes.height, &indexer.vecs.transactions.first_txindex, diff --git a/crates/brk_computer/src/transactions/versions/import.rs b/crates/brk_computer/src/transactions/versions/import.rs index 9b34023c3..4b7d8dcbb 100644 --- a/crates/brk_computer/src/transactions/versions/import.rs +++ b/crates/brk_computer/src/transactions/versions/import.rs @@ -3,18 +3,22 @@ use brk_types::Version; use vecdb::Database; use super::Vecs; -use crate::{indexes, internal::ComputedPerBlockCumulativeSum}; +use crate::{ + indexes, + internal::{CachedWindowStarts, ComputedPerBlockCumulativeWithSums}, +}; impl Vecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self { - v1: ComputedPerBlockCumulativeSum::forced_import(db, "tx_v1", version, indexes)?, - v2: ComputedPerBlockCumulativeSum::forced_import(db, "tx_v2", version, indexes)?, - v3: ComputedPerBlockCumulativeSum::forced_import(db, "tx_v3", version, indexes)?, + v1: ComputedPerBlockCumulativeWithSums::forced_import(db, "tx_v1", version, indexes, cached_starts)?, + v2: ComputedPerBlockCumulativeWithSums::forced_import(db, "tx_v2", version, indexes, cached_starts)?, + v3: ComputedPerBlockCumulativeWithSums::forced_import(db, "tx_v3", version, indexes, cached_starts)?, }) } } diff --git a/crates/brk_computer/src/transactions/versions/vecs.rs b/crates/brk_computer/src/transactions/versions/vecs.rs index 58ea16bd6..9b805bee6 100644 --- a/crates/brk_computer/src/transactions/versions/vecs.rs +++ b/crates/brk_computer/src/transactions/versions/vecs.rs @@ -2,11 +2,11 @@ use brk_traversable::Traversable; use brk_types::StoredU64; use vecdb::{Rw, StorageMode}; -use crate::internal::ComputedPerBlockCumulativeSum; +use crate::internal::ComputedPerBlockCumulativeWithSums; #[derive(Traversable)] pub struct Vecs { - pub v1: ComputedPerBlockCumulativeSum, - pub v2: ComputedPerBlockCumulativeSum, - pub v3: ComputedPerBlockCumulativeSum, + pub v1: ComputedPerBlockCumulativeWithSums, + pub v2: ComputedPerBlockCumulativeWithSums, + pub v3: ComputedPerBlockCumulativeWithSums, } diff --git a/crates/brk_computer/src/transactions/volume/compute.rs b/crates/brk_computer/src/transactions/volume/compute.rs index ad7876e2c..5aea6c7d3 100644 --- a/crates/brk_computer/src/transactions/volume/compute.rs +++ b/crates/brk_computer/src/transactions/volume/compute.rs @@ -22,11 +22,8 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let window_starts = blocks.lookback.window_starts(); - self.sent_sum.compute( starting_indexes.height, - &window_starts, prices, exit, |sats_vec| { @@ -43,7 +40,6 @@ impl Vecs { self.received_sum.compute( starting_indexes.height, - &window_starts, prices, exit, |sats_vec| { @@ -57,16 +53,6 @@ impl Vecs { }, )?; - // Annualized volume: rolling 1y sum of per-block sent volume - self.annualized.sats.height.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback._1y, - &self.sent_sum.sats, - exit, - )?; - self.annualized - .compute(prices, starting_indexes.height, exit)?; - self.tx_per_sec .height .compute_binary::<_, Timestamp, PerSec>( diff --git a/crates/brk_computer/src/transactions/volume/import.rs b/crates/brk_computer/src/transactions/volume/import.rs index 328454cfd..858712304 100644 --- a/crates/brk_computer/src/transactions/volume/import.rs +++ b/crates/brk_computer/src/transactions/volume/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{AmountPerBlock, AmountPerBlockRolling, ComputedPerBlock}, + internal::{AmountPerBlockCumulativeWithSums, CachedWindowStarts, ComputedPerBlock}, }; impl Vecs { @@ -13,21 +13,23 @@ impl Vecs { db: &Database, version: Version, indexes: &indexes::Vecs, + cached_starts: &CachedWindowStarts, ) -> Result { let v2 = Version::TWO; Ok(Self { - sent_sum: AmountPerBlockRolling::forced_import(db, "sent_sum", version, indexes)?, - received_sum: AmountPerBlockRolling::forced_import( + sent_sum: AmountPerBlockCumulativeWithSums::forced_import( + db, + "sent_sum", + version, + indexes, + cached_starts, + )?, + received_sum: AmountPerBlockCumulativeWithSums::forced_import( db, "received_sum", version, indexes, - )?, - annualized: AmountPerBlock::forced_import( - db, - "annualized_volume", - version, - indexes, + cached_starts, )?, tx_per_sec: ComputedPerBlock::forced_import(db, "tx_per_sec", version + v2, indexes)?, outputs_per_sec: ComputedPerBlock::forced_import( diff --git a/crates/brk_computer/src/transactions/volume/vecs.rs b/crates/brk_computer/src/transactions/volume/vecs.rs index aa887442e..7e2311878 100644 --- a/crates/brk_computer/src/transactions/volume/vecs.rs +++ b/crates/brk_computer/src/transactions/volume/vecs.rs @@ -2,13 +2,12 @@ use brk_traversable::Traversable; use brk_types::StoredF32; use vecdb::{Rw, StorageMode}; -use crate::internal::{AmountPerBlock, AmountPerBlockRolling, ComputedPerBlock}; +use crate::internal::{AmountPerBlockCumulativeWithSums, ComputedPerBlock}; #[derive(Traversable)] pub struct Vecs { - pub sent_sum: AmountPerBlockRolling, - pub received_sum: AmountPerBlockRolling, - pub annualized: AmountPerBlock, + pub sent_sum: AmountPerBlockCumulativeWithSums, + pub received_sum: AmountPerBlockCumulativeWithSums, pub tx_per_sec: ComputedPerBlock, pub outputs_per_sec: ComputedPerBlock, pub inputs_per_sec: ComputedPerBlock, diff --git a/crates/brk_query/src/impl/mining/block_rewards.rs b/crates/brk_query/src/impl/mining/block_rewards.rs index b87b5b5f5..429a91a08 100644 --- a/crates/brk_query/src/impl/mining/block_rewards.rs +++ b/crates/brk_query/src/impl/mining/block_rewards.rs @@ -11,7 +11,7 @@ impl Query { let current_height = self.height().to_usize(); let start = current_height.saturating_sub(time_period.block_count()); - let coinbase_vec = &computer.mining.rewards.coinbase.base.sats.height; + let coinbase_vec = &computer.mining.rewards.coinbase.raw.sats.height; let timestamp_vec = &indexer.vecs.blocks.timestamp; match time_period { diff --git a/crates/brk_query/src/impl/mining/pools.rs b/crates/brk_query/src/impl/mining/pools.rs index a7a846ba9..d1d28aeb7 100644 --- a/crates/brk_query/src/impl/mining/pools.rs +++ b/crates/brk_query/src/impl/mining/pools.rs @@ -26,7 +26,7 @@ impl Query { let start = end.saturating_sub(time_period.block_count()); let pools = pools(); - let mut pool_data: Vec<(&'static brk_types::Pool, u32)> = Vec::new(); + let mut pool_data: Vec<(&'static brk_types::Pool, u64)> = Vec::new(); // For each pool, get cumulative count at end and start, subtract to get range count for (pool_id, cumulative) in computer @@ -42,9 +42,9 @@ impl Query { .map(|(id, v)| (id, &v.blocks_mined.cumulative.height)), ) { - let count_at_end: u32 = *cumulative.collect_one(current_height).unwrap_or_default(); + let count_at_end: u64 = *cumulative.collect_one(current_height).unwrap_or_default(); - let count_at_start: u32 = if start == 0 { + let count_at_start: u64 = if start == 0 { 0 } else { *cumulative @@ -62,7 +62,7 @@ impl Query { // Sort by block count descending pool_data.sort_by(|a, b| b.1.cmp(&a.1)); - let total_blocks: u32 = pool_data.iter().map(|(_, count)| count).sum(); + let total_blocks: u64 = pool_data.iter().map(|(_, count)| count).sum(); // Build stats with ranks let pool_stats: Vec = pool_data @@ -116,11 +116,11 @@ impl Query { .ok_or_else(|| Error::NotFound("Pool data not found".into()))?; // Get total blocks (all time) - let total_all: u32 = *cumulative.collect_one(current_height).unwrap_or_default(); + let total_all: u64 = *cumulative.collect_one(current_height).unwrap_or_default(); // Get blocks for 24h (144 blocks) let start_24h = end.saturating_sub(144); - let count_before_24h: u32 = if start_24h == 0 { + let count_before_24h: u64 = if start_24h == 0 { 0 } else { *cumulative @@ -131,7 +131,7 @@ impl Query { // Get blocks for 1w (1008 blocks) let start_1w = end.saturating_sub(1008); - let count_before_1w: u32 = if start_1w == 0 { + let count_before_1w: u64 = if start_1w == 0 { 0 } else { *cumulative @@ -141,9 +141,9 @@ impl Query { let total_1w = total_all.saturating_sub(count_before_1w); // Calculate total network blocks for share calculation - let network_blocks_all = (end + 1) as u32; - let network_blocks_24h = (end - start_24h + 1) as u32; - let network_blocks_1w = (end - start_1w + 1) as u32; + let network_blocks_all = (end + 1) as u64; + let network_blocks_24h = (end - start_24h + 1) as u64; + let network_blocks_1w = (end - start_1w + 1) as u64; let share_all = if network_blocks_all > 0 { total_all as f64 / network_blocks_all as f64 diff --git a/crates/brk_query/src/impl/mining/reward_stats.rs b/crates/brk_query/src/impl/mining/reward_stats.rs index a2a552741..7503f7687 100644 --- a/crates/brk_query/src/impl/mining/reward_stats.rs +++ b/crates/brk_query/src/impl/mining/reward_stats.rs @@ -12,7 +12,7 @@ impl Query { let end_block = current_height; let start_block = Height::from(current_height.to_usize().saturating_sub(block_count - 1)); - let coinbase_vec = &computer.mining.rewards.coinbase.base.sats.height; + let coinbase_vec = &computer.mining.rewards.coinbase.raw.sats.height; let fee_vec = &computer.mining.rewards.fees.base.sats.height; let tx_count_vec = &computer.transactions.count.total.raw.height; diff --git a/crates/brk_traversable/src/lib.rs b/crates/brk_traversable/src/lib.rs index 58d4e946f..def482ea4 100644 --- a/crates/brk_traversable/src/lib.rs +++ b/crates/brk_traversable/src/lib.rs @@ -8,9 +8,9 @@ pub use brk_traversable_derive::Traversable; use schemars::JsonSchema; use serde::Serialize; use vecdb::{ - AggFold, AnyExportableVec, AnyVec, BytesVec, BytesVecValue, CompressionStrategy, EagerVec, - Formattable, LazyAggVec, LazyVecFrom1, LazyVecFrom2, LazyVecFrom3, RawStrategy, - ReadOnlyCompressedVec, ReadOnlyRawVec, StoredVec, VecIndex, VecValue, + AggFold, AnyExportableVec, AnyVec, BytesVec, BytesVecValue, CompressionStrategy, DeltaOp, + EagerVec, Formattable, LazyAggVec, LazyDeltaVec, LazyVecFrom1, LazyVecFrom2, LazyVecFrom3, + RawStrategy, ReadOnlyCompressedVec, ReadOnlyRawVec, StoredVec, VecIndex, VecValue, }; pub trait Traversable { @@ -235,6 +235,22 @@ where } } +impl Traversable for LazyDeltaVec +where + I: VecIndex, + S: VecValue, + T: VecValue + Formattable + Serialize + JsonSchema, + Op: DeltaOp, +{ + fn iter_any_exportable(&self) -> impl Iterator { + std::iter::once(self as &dyn AnyExportableVec) + } + + fn to_tree_node(&self) -> TreeNode { + make_leaf::(self) + } +} + impl Traversable for Box { fn to_tree_node(&self) -> TreeNode { (**self).to_tree_node() diff --git a/crates/brk_traversable_derive/src/lib.rs b/crates/brk_traversable_derive/src/lib.rs index cd4efdc7c..ffeede040 100644 --- a/crates/brk_traversable_derive/src/lib.rs +++ b/crates/brk_traversable_derive/src/lib.rs @@ -53,13 +53,17 @@ struct FieldInfo<'a> { attr: FieldAttr, rename: Option, wrap: Option, + hidden: bool, } -/// Returns None for skip, Some((attr, rename, wrap)) for normal/flatten. -fn get_field_attr(field: &syn::Field) -> Option<(FieldAttr, Option, Option)> { +/// Returns None for skip, Some((attr, rename, wrap, hidden)) for normal/flatten/hidden. +fn get_field_attr( + field: &syn::Field, +) -> Option<(FieldAttr, Option, Option, bool)> { let mut attr_type = FieldAttr::Normal; let mut rename = None; let mut wrap = None; + let mut hidden = false; for attr in &field.attrs { if !attr.path().is_ident("traversable") { @@ -70,6 +74,7 @@ fn get_field_attr(field: &syn::Field) -> Option<(FieldAttr, Option, Opti match ident.to_string().as_str() { "skip" => return None, "flatten" => attr_type = FieldAttr::Flatten, + "hidden" => hidden = true, _ => {} } continue; @@ -94,7 +99,7 @@ fn get_field_attr(field: &syn::Field) -> Option<(FieldAttr, Option, Opti } } - Some((attr_type, rename, wrap)) + Some((attr_type, rename, wrap, hidden)) } fn is_field_skipped(field: &syn::Field) -> bool { @@ -316,7 +321,7 @@ fn analyze_fields<'a>( let mut field_traversable_types = Vec::new(); for field in &fields.named { - let Some((attr, rename, wrap)) = get_field_attr(field) else { + let Some((attr, rename, wrap, hidden)) = get_field_attr(field) else { continue; }; @@ -352,6 +357,7 @@ fn analyze_fields<'a>( attr, rename, wrap, + hidden, }); } @@ -390,7 +396,7 @@ fn build_where_clause( fn generate_field_traversals(infos: &[FieldInfo], merge: bool) -> proc_macro2::TokenStream { let normal_entries: Vec<_> = infos .iter() - .filter(|i| matches!(i.attr, FieldAttr::Normal)) + .filter(|i| matches!(i.attr, FieldAttr::Normal) && !i.hidden) .map(|info| { let field_name = info.name; let field_name_str = { @@ -446,7 +452,7 @@ fn generate_field_traversals(infos: &[FieldInfo], merge: bool) -> proc_macro2::T let flatten_entries: Vec<_> = infos .iter() - .filter(|i| matches!(i.attr, FieldAttr::Flatten)) + .filter(|i| matches!(i.attr, FieldAttr::Flatten) && !i.hidden) .map(|info| { let field_name = info.name; let merge_branch = quote! { diff --git a/crates/brk_types/src/feerate.rs b/crates/brk_types/src/feerate.rs index 2a236f7f6..06feb26ee 100644 --- a/crates/brk_types/src/feerate.rs +++ b/crates/brk_types/src/feerate.rs @@ -5,7 +5,7 @@ use std::{ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use vecdb::{Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco}; use super::{Sats, VSize}; @@ -112,6 +112,18 @@ impl Ord for FeeRate { } } +impl CheckedSub for FeeRate { + #[inline] + fn checked_sub(self, rhs: Self) -> Option { + let result = self.0 - rhs.0; + if result.is_nan() { + None + } else { + Some(Self(result)) + } + } +} + impl std::fmt::Display for FeeRate { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut buf = ryu::Buffer::new(); diff --git a/crates/brk_types/src/pooldetail.rs b/crates/brk_types/src/pooldetail.rs index 981025406..1df124153 100644 --- a/crates/brk_types/src/pooldetail.rs +++ b/crates/brk_types/src/pooldetail.rs @@ -67,15 +67,15 @@ impl From<&'static Pool> for PoolDetailInfo { #[derive(Debug, Serialize, Deserialize, JsonSchema)] pub struct PoolBlockCounts { /// Total blocks mined (all time) - pub all: u32, + pub all: u64, /// Blocks mined in last 24 hours #[serde(rename = "24h")] - pub day: u32, + pub day: u64, /// Blocks mined in last week #[serde(rename = "1w")] - pub week: u32, + pub week: u64, } /// Pool's share of total blocks for different time periods diff --git a/crates/brk_types/src/poolssummary.rs b/crates/brk_types/src/poolssummary.rs index bd3fa0180..98509bdef 100644 --- a/crates/brk_types/src/poolssummary.rs +++ b/crates/brk_types/src/poolssummary.rs @@ -11,7 +11,7 @@ pub struct PoolsSummary { /// Total blocks in the time period #[serde(rename = "blockCount")] - pub block_count: u32, + pub block_count: u64, /// Estimated network hashrate (hashes per second) #[serde(rename = "lastEstimatedHashrate")] diff --git a/crates/brk_types/src/poolstats.rs b/crates/brk_types/src/poolstats.rs index 0994104fe..f98b623d8 100644 --- a/crates/brk_types/src/poolstats.rs +++ b/crates/brk_types/src/poolstats.rs @@ -20,14 +20,14 @@ pub struct PoolStats { /// Number of blocks mined in the time period #[serde(rename = "blockCount")] - pub block_count: u32, + pub block_count: u64, /// Pool ranking by block count (1 = most blocks) pub rank: u32, /// Number of empty blocks mined #[serde(rename = "emptyBlocks")] - pub empty_blocks: u32, + pub empty_blocks: u64, /// URL-friendly pool identifier pub slug: PoolSlug, @@ -38,7 +38,7 @@ pub struct PoolStats { impl PoolStats { /// Create a new PoolStats from a Pool reference - pub fn new(pool: &'static Pool, block_count: u32, rank: u32, share: f64) -> Self { + pub fn new(pool: &'static Pool, block_count: u64, rank: u32, share: f64) -> Self { Self { pool_id: pool.unique_id(), name: Cow::Borrowed(pool.name), diff --git a/crates/brk_types/src/stored_u64.rs b/crates/brk_types/src/stored_u64.rs index d13cfa36f..35c3f77c3 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, P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, - P2WPKHAddressIndex, P2WSHAddressIndex, TxInIndex, TxIndex, TxOutIndex, UnknownOutputIndex, - Year1, + P2WPKHAddressIndex, P2WSHAddressIndex, StoredU32, TxInIndex, TxIndex, TxOutIndex, + UnknownOutputIndex, Year1, }; /// Fixed-size 64-bit unsigned integer optimized for on-disk storage @@ -38,6 +38,13 @@ impl StoredU64 { } } +impl From for StoredU64 { + #[inline] + fn from(value: StoredU32) -> Self { + Self(u32::from(value) as u64) + } +} + impl From for StoredU64 { #[inline] fn from(value: u64) -> Self { diff --git a/crates/brk_types/src/vsize.rs b/crates/brk_types/src/vsize.rs index ff339d693..39697f46a 100644 --- a/crates/brk_types/src/vsize.rs +++ b/crates/brk_types/src/vsize.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::{Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco}; use crate::Weight; @@ -109,6 +109,13 @@ impl Div for VSize { } } +impl CheckedSub for VSize { + #[inline] + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + impl std::fmt::Display for VSize { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut buf = itoa::Buffer::new(); diff --git a/crates/brk_types/src/weight.rs b/crates/brk_types/src/weight.rs index a5b41db43..d8d807fc9 100644 --- a/crates/brk_types/src/weight.rs +++ b/crates/brk_types/src/weight.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::{Formattable, Pco}; +use vecdb::{CheckedSub, Formattable, Pco}; /// Transaction or block weight in weight units (WU) #[derive( @@ -128,6 +128,13 @@ impl Div for Weight { } } +impl CheckedSub for Weight { + #[inline] + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + impl std::fmt::Display for Weight { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut buf = itoa::Buffer::new(); diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index f58658fa8..b80d02354 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -99,11 +99,6 @@ * * @typedef {number} Bitcoin */ -/** - * Position within a .blk file, encoding file index and byte offset - * - * @typedef {number} BlkPosition - */ /** * @typedef {Object} BlockCountParam * @property {number} blockCount - Number of recent blocks to include @@ -1786,40 +1781,40 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { } /** - * @typedef {Object} CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern - * @property {CentsDeltaRawRelUsdPattern} cap - * @property {RawSellSumPattern} grossPnl - * @property {CapLowerPriceUpperPattern} investor + * @typedef {Object} CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern + * @property {CentsDeltaRelUsdPattern} cap + * @property {CumulativeRawSumPattern2} grossPnl + * @property {LowerPriceUpperPattern} investor * @property {CapitulationCumulativeNegativeRawRelSumValuePattern} loss * @property {MetricPattern1} mvrv * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl - * @property {BpsRatioPattern} nupl * @property {CumulativeRawRelPattern} peakRegret * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price * @property {CumulativeDistributionRawRelSumValuePattern} profit * @property {_1m1w1y24hPattern} profitToLossRatio + * @property {_1m1w1y24hPattern2} sellSideRiskRatio * @property {AdjustedRatioValuePattern} sopr */ /** - * Create a CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern pattern node + * Create a CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern} + * @returns {CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} */ -function createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(client, acc) { +function createCapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(client, acc) { return { - cap: createCentsDeltaRawRelUsdPattern(client, acc), - grossPnl: createRawSellSumPattern(client, acc), - investor: createCapLowerPriceUpperPattern(client, acc), + cap: createCentsDeltaRelUsdPattern(client, _m(acc, 'realized_cap')), + grossPnl: createCumulativeRawSumPattern2(client, _m(acc, 'realized_gross_pnl')), + investor: createLowerPriceUpperPattern(client, acc), loss: createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc), mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), netPnl: createChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), peakRegret: createCumulativeRawRelPattern(client, _m(acc, 'realized_peak_regret')), price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, _m(acc, 'realized_price')), profit: createCumulativeDistributionRawRelSumValuePattern(client, acc), profitToLossRatio: create_1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')), + sellSideRiskRatio: create_1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')), sopr: createAdjustedRatioValuePattern(client, acc), }; } @@ -1966,39 +1961,6 @@ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, acc) { }; } -/** - * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 - * @property {BtcCentsSatsUsdPattern} average - * @property {BtcCentsSatsUsdPattern} max - * @property {BtcCentsSatsUsdPattern} median - * @property {BtcCentsSatsUsdPattern} min - * @property {BtcCentsSatsUsdPattern} pct10 - * @property {BtcCentsSatsUsdPattern} pct25 - * @property {BtcCentsSatsUsdPattern} pct75 - * @property {BtcCentsSatsUsdPattern} pct90 - * @property {BtcCentsSatsUsdPattern} sum - */ - -/** - * Create a AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2} - */ -function createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(client, acc) { - return { - average: createBtcCentsSatsUsdPattern(client, _m(acc, 'average')), - max: createBtcCentsSatsUsdPattern(client, _m(acc, 'max')), - median: createBtcCentsSatsUsdPattern(client, _m(acc, 'median')), - min: createBtcCentsSatsUsdPattern(client, _m(acc, 'min')), - pct10: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct10')), - pct25: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct25')), - pct75: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct75')), - pct90: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct90')), - sum: createBtcCentsSatsUsdPattern(client, _m(acc, 'sum')), - }; -} - /** * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern * @property {_1m1w1y24hPattern} average @@ -2033,33 +1995,33 @@ function createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, acc) { } /** - * @typedef {Object} _1m1w1y24hBtcCentsSatsUsdPattern - * @property {BtcCentsSatsUsdPattern} _1m - * @property {BtcCentsSatsUsdPattern} _1w - * @property {BtcCentsSatsUsdPattern} _1y - * @property {BtcCentsSatsUsdPattern} _24h - * @property {MetricPattern18} btc - * @property {MetricPattern18} cents - * @property {MetricPattern18} sats - * @property {MetricPattern18} usd + * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern + * @property {BtcCentsSatsUsdPattern} average + * @property {BtcCentsSatsUsdPattern} max + * @property {BtcCentsSatsUsdPattern} median + * @property {BtcCentsSatsUsdPattern} min + * @property {BtcCentsSatsUsdPattern} pct10 + * @property {BtcCentsSatsUsdPattern} pct25 + * @property {BtcCentsSatsUsdPattern} pct75 + * @property {BtcCentsSatsUsdPattern} pct90 */ /** - * Create a _1m1w1y24hBtcCentsSatsUsdPattern pattern node + * Create a AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hBtcCentsSatsUsdPattern} + * @returns {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} */ -function create_1m1w1y24hBtcCentsSatsUsdPattern(client, acc) { +function createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc) { return { - _1m: createBtcCentsSatsUsdPattern(client, _m(acc, '1m')), - _1w: createBtcCentsSatsUsdPattern(client, _m(acc, '1w')), - _1y: createBtcCentsSatsUsdPattern(client, _m(acc, '1y')), - _24h: createBtcCentsSatsUsdPattern(client, _m(acc, '24h')), - btc: createMetricPattern18(client, acc), - cents: createMetricPattern18(client, _m(acc, 'cents')), - sats: createMetricPattern18(client, _m(acc, 'sats')), - usd: createMetricPattern18(client, _m(acc, 'usd')), + average: createBtcCentsSatsUsdPattern(client, _m(acc, 'average')), + max: createBtcCentsSatsUsdPattern(client, _m(acc, 'max')), + median: createBtcCentsSatsUsdPattern(client, _m(acc, 'median')), + min: createBtcCentsSatsUsdPattern(client, _m(acc, 'min')), + pct10: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct10')), + pct25: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct25')), + pct75: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct75')), + pct90: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct90')), }; } @@ -2094,37 +2056,6 @@ function createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, acc) { }; } -/** - * @typedef {Object} CapLossMvrvNetNuplPriceProfitSoprPattern - * @property {CentsDeltaUsdPattern} cap - * @property {CumulativeNegativeRawSumPattern} loss - * @property {MetricPattern1} mvrv - * @property {RawSumPattern3} netPnl - * @property {BpsRatioPattern} nupl - * @property {BpsCentsRatioSatsUsdPattern} price - * @property {CumulativeRawSumPattern2} profit - * @property {RatioValuePattern} sopr - */ - -/** - * Create a CapLossMvrvNetNuplPriceProfitSoprPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CapLossMvrvNetNuplPriceProfitSoprPattern} - */ -function createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) { - return { - cap: createCentsDeltaUsdPattern(client, _m(acc, 'realized_cap')), - loss: createCumulativeNegativeRawSumPattern(client, acc), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - netPnl: createRawSumPattern3(client, _m(acc, 'net_realized_pnl')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), - price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), - profit: createCumulativeRawSumPattern2(client, _m(acc, 'realized_profit')), - sopr: createRatioValuePattern(client, acc), - }; -} - /** * @typedef {Object} CapitulationCumulativeNegativeRawRelSumValuePattern * @property {MetricPattern1} capitulationFlow @@ -2132,9 +2063,9 @@ function createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) { * @property {MetricPattern1} negative * @property {CentsUsdPattern} raw * @property {BpsPercentRatioPattern} relToRcap - * @property {_1m1w1y24hPattern5} sum - * @property {RawSumPattern} valueCreated - * @property {RawSumPattern} valueDestroyed + * @property {_1m1w1y24hPattern3} sum + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** @@ -2150,15 +2081,15 @@ function createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) negative: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), raw: createCentsUsdPattern(client, _m(acc, 'realized_loss')), relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_rcap')), - sum: create_1m1w1y24hPattern5(client, _m(acc, 'realized_loss')), - valueCreated: createRawSumPattern(client, _m(acc, 'loss_value_created')), - valueDestroyed: createRawSumPattern(client, _m(acc, 'loss_value_destroyed')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'realized_loss_sum')), + valueCreated: createCumulativeRawSumPattern(client, _m(acc, 'loss_value_created')), + valueDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'loss_value_destroyed')), }; } /** * @template T - * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern + * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2 * @property {MetricPattern18} average * @property {MetricPattern18} max * @property {MetricPattern18} median @@ -2170,13 +2101,13 @@ function createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) */ /** - * Create a AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern pattern node + * Create a AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2 pattern node * @template T * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} + * @returns {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2} */ -function createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc) { +function createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2(client, acc) { return { average: createMetricPattern18(client, _m(acc, 'average')), max: createMetricPattern18(client, _m(acc, 'max')), @@ -2248,31 +2179,31 @@ function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { } /** - * @typedef {Object} CapLossMvrvNuplPriceProfitSoprPattern - * @property {CentsUsdPattern} cap - * @property {RawSumPattern2} loss + * @typedef {Object} CapLossMvrvNetPriceProfitSoprPattern + * @property {CentsDeltaUsdPattern} cap + * @property {CumulativeNegativeRawSumPattern} loss * @property {MetricPattern1} mvrv - * @property {BpsRatioPattern} nupl + * @property {CumulativeRawSumPattern} netPnl * @property {BpsCentsRatioSatsUsdPattern} price - * @property {RawSumPattern2} profit - * @property {ValuePattern} sopr + * @property {CumulativeRawSumPattern2} profit + * @property {RatioValuePattern} sopr */ /** - * Create a CapLossMvrvNuplPriceProfitSoprPattern pattern node + * Create a CapLossMvrvNetPriceProfitSoprPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CapLossMvrvNuplPriceProfitSoprPattern} + * @returns {CapLossMvrvNetPriceProfitSoprPattern} */ -function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { +function createCapLossMvrvNetPriceProfitSoprPattern(client, acc) { return { - cap: createCentsUsdPattern(client, _m(acc, 'realized_cap')), - loss: createRawSumPattern2(client, _m(acc, 'realized_loss')), + cap: createCentsDeltaUsdPattern(client, _m(acc, 'realized_cap')), + loss: createCumulativeNegativeRawSumPattern(client, acc), mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), + netPnl: createCumulativeRawSumPattern(client, _m(acc, 'net_realized_pnl')), price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), - profit: createRawSumPattern2(client, _m(acc, 'realized_profit')), - sopr: createValuePattern(client, _m(acc, 'value')), + profit: createCumulativeRawSumPattern2(client, _m(acc, 'realized_profit')), + sopr: createRatioValuePattern(client, acc), }; } @@ -2282,9 +2213,9 @@ function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { * @property {MetricPattern1} distributionFlow * @property {CentsUsdPattern} raw * @property {BpsPercentRatioPattern} relToRcap - * @property {_1m1w1y24hPattern5} sum - * @property {RawSumPattern} valueCreated - * @property {RawSumPattern} valueDestroyed + * @property {_1m1w1y24hPattern3} sum + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** @@ -2296,40 +2227,69 @@ function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { function createCumulativeDistributionRawRelSumValuePattern(client, acc) { return { cumulative: createMetricPattern1(client, _m(acc, 'realized_profit_cumulative')), - distributionFlow: createMetricPattern1(client, _m(acc, 'profit_flow')), + distributionFlow: createMetricPattern1(client, _m(acc, 'distribution_flow')), raw: createCentsUsdPattern(client, _m(acc, 'realized_profit')), relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_rcap')), - sum: create_1m1w1y24hPattern5(client, _m(acc, 'realized_profit')), - valueCreated: createRawSumPattern(client, _m(acc, 'profit_value_created')), - valueDestroyed: createRawSumPattern(client, _m(acc, 'profit_value_destroyed')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'realized_profit_sum')), + valueCreated: createCumulativeRawSumPattern(client, _m(acc, 'profit_value_created')), + valueDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'profit_value_destroyed')), }; } /** - * @typedef {Object} GrossInvestedInvestorLossNetProfitSentimentPattern2 + * @typedef {Object} CumulativeNegativeRawRelSumPattern2 + * @property {MetricPattern1} cumulative + * @property {MetricPattern1} negative + * @property {CentsUsdPattern} raw + * @property {BpsPercentRatioPattern} relToMcap + * @property {BpsPercentRatioPattern} relToOwnGross + * @property {BpsPercentRatioPattern} relToOwnMcap + * @property {_1m1w1y24hPattern3} sum + */ + +/** + * Create a CumulativeNegativeRawRelSumPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeNegativeRawRelSumPattern2} + */ +function createCumulativeNegativeRawRelSumPattern2(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'unrealized_loss_cumulative')), + negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), + raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), + relToMcap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_mcap')), + relToOwnGross: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')), + relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_mcap')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'unrealized_loss_sum')), + }; +} + +/** + * @typedef {Object} GrossInvestedLossNetNuplProfitSentimentPattern2 * @property {CentsUsdPattern} grossPnl - * @property {InPattern2} investedCapital - * @property {InPattern} investorCap - * @property {NegativeRawRelSumPattern2} loss + * @property {InPattern} investedCapital + * @property {CumulativeNegativeRawRelSumPattern2} loss * @property {CentsRelUsdPattern2} netPnl - * @property {RawRelSumPattern2} profit + * @property {BpsRatioPattern} nupl + * @property {CumulativeRawRelSumPattern2} profit * @property {GreedNetPainPattern} sentiment */ /** - * Create a GrossInvestedInvestorLossNetProfitSentimentPattern2 pattern node + * Create a GrossInvestedLossNetNuplProfitSentimentPattern2 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {GrossInvestedInvestorLossNetProfitSentimentPattern2} + * @returns {GrossInvestedLossNetNuplProfitSentimentPattern2} */ -function createGrossInvestedInvestorLossNetProfitSentimentPattern2(client, acc) { +function createGrossInvestedLossNetNuplProfitSentimentPattern2(client, acc) { return { grossPnl: createCentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')), - investedCapital: createInPattern2(client, _m(acc, 'invested_capital_in')), - investorCap: createInPattern(client, _m(acc, 'investor_cap_in')), - loss: createNegativeRawRelSumPattern2(client, acc), + investedCapital: createInPattern(client, _m(acc, 'invested_capital_in')), + loss: createCumulativeNegativeRawRelSumPattern2(client, acc), netPnl: createCentsRelUsdPattern2(client, _m(acc, 'net_unrealized_pnl')), - profit: createRawRelSumPattern2(client, _m(acc, 'unrealized_profit')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + profit: createCumulativeRawRelSumPattern2(client, _m(acc, 'unrealized_profit')), sentiment: createGreedNetPainPattern(client, acc), }; } @@ -2415,11 +2375,38 @@ function createBtcCentsRelSatsUsdPattern3(client, acc) { }; } +/** + * @typedef {Object} CapLossMvrvPriceProfitSoprPattern + * @property {CentsUsdPattern} cap + * @property {CumulativeRawSumPattern2} loss + * @property {MetricPattern1} mvrv + * @property {BpsCentsRatioSatsUsdPattern} price + * @property {CumulativeRawSumPattern2} profit + * @property {ValuePattern} sopr + */ + +/** + * Create a CapLossMvrvPriceProfitSoprPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapLossMvrvPriceProfitSoprPattern} + */ +function createCapLossMvrvPriceProfitSoprPattern(client, acc) { + return { + cap: createCentsUsdPattern(client, _m(acc, 'realized_cap')), + loss: createCumulativeRawSumPattern2(client, _m(acc, 'realized_loss')), + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), + profit: createCumulativeRawSumPattern2(client, _m(acc, 'realized_profit')), + sopr: createValuePattern(client, _m(acc, 'value')), + }; +} + /** * @typedef {Object} ChangeCumulativeDeltaRawRelSumPattern * @property {RelPattern} change1m * @property {MetricPattern1} cumulative - * @property {ChangeRatePattern4} delta + * @property {ChangeRatePattern2} delta * @property {MetricPattern1} raw * @property {BpsPercentRatioPattern} relToRcap * @property {_1m1w1y24hPattern} sum @@ -2435,10 +2422,64 @@ function createChangeCumulativeDeltaRawRelSumPattern(client, acc) { return { change1m: createRelPattern(client, _m(acc, 'pnl_change_1m_rel_to')), cumulative: createMetricPattern1(client, _m(acc, 'realized_pnl_cumulative')), - delta: createChangeRatePattern4(client, _m(acc, 'pnl_delta')), + delta: createChangeRatePattern2(client, _m(acc, 'pnl_delta')), raw: createMetricPattern1(client, _m(acc, 'realized_pnl')), relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_pnl_rel_to_rcap')), - sum: create_1m1w1y24hPattern(client, _m(acc, 'realized_pnl')), + sum: create_1m1w1y24hPattern(client, _m(acc, 'realized_pnl_sum')), + }; +} + +/** + * @typedef {Object} CumulativeRawRelSumPattern2 + * @property {MetricPattern1} cumulative + * @property {CentsUsdPattern} raw + * @property {BpsPercentRatioPattern} relToMcap + * @property {BpsPercentRatioPattern} relToOwnGross + * @property {BpsPercentRatioPattern} relToOwnMcap + * @property {_1m1w1y24hPattern3} sum + */ + +/** + * Create a CumulativeRawRelSumPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeRawRelSumPattern2} + */ +function createCumulativeRawRelSumPattern2(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + raw: createCentsUsdPattern(client, acc), + relToMcap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_mcap')), + relToOwnGross: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_gross_pnl')), + relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'sum')), + }; +} + +/** + * @typedef {Object} DeltaHalfInRelTotalPattern + * @property {ChangeRatePattern} delta + * @property {BtcCentsSatsUsdPattern} half + * @property {BtcCentsRelSatsUsdPattern} inLoss + * @property {BtcCentsRelSatsUsdPattern} inProfit + * @property {BpsPercentRatioPattern} relToCirculating + * @property {BtcCentsSatsUsdPattern} total + */ + +/** + * Create a DeltaHalfInRelTotalPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {DeltaHalfInRelTotalPattern} + */ +function createDeltaHalfInRelTotalPattern(client, acc) { + return { + delta: createChangeRatePattern(client, _m(acc, 'delta')), + half: createBtcCentsSatsUsdPattern(client, _m(acc, 'half')), + inLoss: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'in_loss')), + inProfit: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'in_profit')), + relToCirculating: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating')), + total: createBtcCentsSatsUsdPattern(client, acc), }; } @@ -2469,60 +2510,6 @@ function createDeltaHalfInRelTotalPattern2(client, acc) { }; } -/** - * @typedef {Object} DeltaHalfInRelTotalPattern - * @property {ChangeRatePattern2} delta - * @property {BtcCentsSatsUsdPattern} half - * @property {BtcCentsRelSatsUsdPattern} inLoss - * @property {BtcCentsRelSatsUsdPattern} inProfit - * @property {BpsPercentRatioPattern} relToCirculating - * @property {BtcCentsSatsUsdPattern} total - */ - -/** - * Create a DeltaHalfInRelTotalPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {DeltaHalfInRelTotalPattern} - */ -function createDeltaHalfInRelTotalPattern(client, acc) { - return { - delta: createChangeRatePattern2(client, _m(acc, 'delta')), - half: createBtcCentsSatsUsdPattern(client, _m(acc, 'half')), - inLoss: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'in_loss')), - inProfit: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'in_profit')), - relToCirculating: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating')), - total: createBtcCentsSatsUsdPattern(client, acc), - }; -} - -/** - * @typedef {Object} NegativeRawRelSumPattern2 - * @property {MetricPattern1} negative - * @property {CentsUsdPattern} raw - * @property {BpsPercentRatioPattern} relToMcap - * @property {BpsPercentRatioPattern} relToOwnGross - * @property {BpsPercentRatioPattern} relToOwnMcap - * @property {_24hPattern} sum - */ - -/** - * Create a NegativeRawRelSumPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NegativeRawRelSumPattern2} - */ -function createNegativeRawRelSumPattern2(client, acc) { - return { - negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - relToMcap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_mcap')), - relToOwnGross: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')), - relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_mcap')), - sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), - }; -} - /** * @typedef {Object} Pct1Pct2Pct5Pct95Pct98Pct99Pattern * @property {BpsPriceRatioPattern} pct1 @@ -2554,9 +2541,9 @@ function createPct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc) { * @typedef {Object} ActivityOutputsRealizedSupplyUnrealizedPattern * @property {CoindaysSentPattern} activity * @property {UnspentPattern2} outputs - * @property {CapLossMvrvNetNuplPriceProfitSoprPattern} realized + * @property {CapLossMvrvNetPriceProfitSoprPattern} realized * @property {DeltaHalfInRelTotalPattern} supply - * @property {InvestedInvestorLossNetProfitPattern} unrealized + * @property {LossNetNuplProfitPattern} unrealized */ /** @@ -2569,34 +2556,34 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { activity: createCoindaysSentPattern(client, acc), outputs: createUnspentPattern2(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc), + realized: createCapLossMvrvNetPriceProfitSoprPattern(client, acc), supply: createDeltaHalfInRelTotalPattern(client, _m(acc, 'supply')), - unrealized: createInvestedInvestorLossNetProfitPattern(client, acc), + unrealized: createLossNetNuplProfitPattern(client, acc), }; } /** - * @typedef {Object} ActivityOutputsRealizedSupplyUnrealizedPattern2 - * @property {CoindaysSentPattern} activity - * @property {UnspentPattern2} outputs - * @property {CapLossMvrvNetNuplPriceProfitSoprPattern} realized - * @property {DeltaHalfInRelTotalPattern} supply - * @property {LossNetProfitPattern} unrealized + * @typedef {Object} AddressOutputsRealizedSupplyUnrealizedPattern + * @property {DeltaInnerPattern} addressCount + * @property {UnspentPattern} outputs + * @property {CapLossMvrvPriceProfitSoprPattern} realized + * @property {HalfTotalPattern} supply + * @property {NuplPattern} unrealized */ /** - * Create a ActivityOutputsRealizedSupplyUnrealizedPattern2 pattern node + * Create a AddressOutputsRealizedSupplyUnrealizedPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {ActivityOutputsRealizedSupplyUnrealizedPattern2} + * @returns {AddressOutputsRealizedSupplyUnrealizedPattern} */ -function createActivityOutputsRealizedSupplyUnrealizedPattern2(client, acc) { +function createAddressOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { - activity: createCoindaysSentPattern(client, acc), - outputs: createUnspentPattern2(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc), - supply: createDeltaHalfInRelTotalPattern(client, _m(acc, 'supply')), - unrealized: createLossNetProfitPattern(client, acc), + addressCount: createDeltaInnerPattern(client, _m(acc, 'address_count')), + outputs: createUnspentPattern(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvPriceProfitSoprPattern(client, acc), + supply: createHalfTotalPattern(client, _m(acc, 'supply')), + unrealized: createNuplPattern(client, _m(acc, 'nupl')), }; } @@ -2675,37 +2662,12 @@ function createBtcCentsRelSatsUsdPattern2(client, acc) { }; } -/** - * @typedef {Object} CentsDeltaRawRelUsdPattern - * @property {MetricPattern1} cents - * @property {ChangeRatePattern4} delta - * @property {MetricPattern18} raw - * @property {BpsPercentRatioPattern} relToOwnMcap - * @property {MetricPattern1} usd - */ - -/** - * Create a CentsDeltaRawRelUsdPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CentsDeltaRawRelUsdPattern} - */ -function createCentsDeltaRawRelUsdPattern(client, acc) { - return { - cents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - delta: createChangeRatePattern4(client, _m(acc, 'realized_cap_delta')), - raw: createMetricPattern18(client, _m(acc, 'cap_raw')), - relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_cap_rel_to_own_mcap')), - usd: createMetricPattern1(client, _m(acc, 'realized_cap')), - }; -} - /** * @typedef {Object} CoindaysCoinyearsDormancySentVelocityPattern * @property {CumulativeRawSumPattern} coindaysDestroyed * @property {MetricPattern1} coinyearsDestroyed * @property {MetricPattern1} dormancy - * @property {InRawSumPattern2} sent + * @property {CumulativeInRawSumPattern} sent * @property {MetricPattern1} velocity */ @@ -2720,11 +2682,36 @@ function createCoindaysCoinyearsDormancySentVelocityPattern(client, acc) { coindaysDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), - sent: createInRawSumPattern2(client, _m(acc, 'sent')), + sent: createCumulativeInRawSumPattern(client, _m(acc, 'sent')), velocity: createMetricPattern1(client, _m(acc, 'velocity')), }; } +/** + * @typedef {Object} CumulativeInRawSumPattern + * @property {MetricPattern1} cumulative + * @property {CumulativeRawSumPattern3} inLoss + * @property {CumulativeRawSumPattern3} inProfit + * @property {MetricPattern1} raw + * @property {_1m1w1y24hPattern} sum + */ + +/** + * Create a CumulativeInRawSumPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeInRawSumPattern} + */ +function createCumulativeInRawSumPattern(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + inLoss: createCumulativeRawSumPattern3(client, _m(acc, 'in_loss')), + inProfit: createCumulativeRawSumPattern3(client, _m(acc, 'in_profit')), + raw: createMetricPattern1(client, acc), + sum: create_1m1w1y24hPattern(client, _m(acc, 'sum')), + }; +} + /** * @typedef {Object} EmaHistogramLineSignalPattern * @property {MetricPattern1} emaFast @@ -2750,31 +2737,6 @@ function createEmaHistogramLineSignalPattern(client, acc) { }; } -/** - * @typedef {Object} InvestedInvestorLossNetProfitPattern - * @property {InPattern} investedCapital - * @property {InPattern} investorCap - * @property {NegativeRawSumPattern} loss - * @property {CentsUsdPattern} netPnl - * @property {RawSumPattern2} profit - */ - -/** - * Create a InvestedInvestorLossNetProfitPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {InvestedInvestorLossNetProfitPattern} - */ -function createInvestedInvestorLossNetProfitPattern(client, acc) { - return { - investedCapital: createInPattern(client, _m(acc, 'invested_capital_in')), - investorCap: createInPattern(client, _m(acc, 'investor_cap_in')), - loss: createNegativeRawSumPattern(client, acc), - netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - profit: createRawSumPattern2(client, _m(acc, 'unrealized_profit')), - }; -} - /** * @typedef {Object} InvestedMaxMinPercentilesSupplyPattern * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} investedCapital @@ -2825,31 +2787,6 @@ function createPhsReboundThsPattern(client, acc) { }; } -/** - * @typedef {Object} RawRelSumPattern2 - * @property {CentsUsdPattern} raw - * @property {BpsPercentRatioPattern} relToMcap - * @property {BpsPercentRatioPattern} relToOwnGross - * @property {BpsPercentRatioPattern} relToOwnMcap - * @property {_24hPattern} sum - */ - -/** - * Create a RawRelSumPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawRelSumPattern2} - */ -function createRawRelSumPattern2(client, acc) { - return { - raw: createCentsUsdPattern(client, acc), - relToMcap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_mcap')), - relToOwnGross: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_gross_pnl')), - relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')), - sum: create_24hPattern(client, _m(acc, '24h')), - }; -} - /** * @template T * @typedef {Object} _1m1w1y24hHeightPattern @@ -2893,15 +2830,15 @@ function create_1m1w1y24hHeightPattern(client, acc) { */ function create_1m1w1y24hPattern2(client, acc) { return { - _1m: createBpsPercentRatioPattern(client, _m(acc, '1m')), - _1w: createBpsPercentRatioPattern(client, _m(acc, '1w')), - _1y: createBpsPercentRatioPattern(client, _m(acc, '1y')), - _24h: createBpsPercentRatioPattern(client, _m(acc, '24h')), + _1m: createBpsPercentRatioPattern(client, _m(acc, '1m_rate')), + _1w: createBpsPercentRatioPattern(client, _m(acc, '1w_rate')), + _1y: createBpsPercentRatioPattern(client, _m(acc, '1y_rate')), + _24h: createBpsPercentRatioPattern(client, _m(acc, '24h_rate')), }; } /** - * @typedef {Object} _1m1w1y24hPattern8 + * @typedef {Object} _1m1w1y24hPattern4 * @property {BtcCentsSatsUsdPattern} _1m * @property {BtcCentsSatsUsdPattern} _1w * @property {BtcCentsSatsUsdPattern} _1y @@ -2909,12 +2846,12 @@ function create_1m1w1y24hPattern2(client, acc) { */ /** - * Create a _1m1w1y24hPattern8 pattern node + * Create a _1m1w1y24hPattern4 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern8} + * @returns {_1m1w1y24hPattern4} */ -function create_1m1w1y24hPattern8(client, acc) { +function create_1m1w1y24hPattern4(client, acc) { return { _1m: createBtcCentsSatsUsdPattern(client, _m(acc, '1m')), _1w: createBtcCentsSatsUsdPattern(client, _m(acc, '1w')), @@ -2923,29 +2860,6 @@ function create_1m1w1y24hPattern8(client, acc) { }; } -/** - * @typedef {Object} _1m1w1y24hPattern5 - * @property {MetricPattern1} _1m - * @property {MetricPattern1} _1w - * @property {MetricPattern1} _1y - * @property {CentsUsdPattern} _24h - */ - -/** - * Create a _1m1w1y24hPattern5 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern5} - */ -function create_1m1w1y24hPattern5(client, acc) { - return { - _1m: createMetricPattern1(client, _m(acc, '1m')), - _1w: createMetricPattern1(client, _m(acc, '1w')), - _1y: createMetricPattern1(client, _m(acc, '1y')), - _24h: createCentsUsdPattern(client, _m(acc, '24h')), - }; -} - /** * @typedef {Object} _1m1w1y2wPattern * @property {CentsSatsUsdPattern} _1m @@ -2970,36 +2884,13 @@ function create_1m1w1y2wPattern(client, acc) { } /** - * @typedef {Object} _1m1w1y24hPattern4 + * @typedef {Object} _1m1w1y24hPattern3 * @property {CentsUsdPattern} _1m * @property {CentsUsdPattern} _1w * @property {CentsUsdPattern} _1y * @property {CentsUsdPattern} _24h */ -/** - * Create a _1m1w1y24hPattern4 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern4} - */ -function create_1m1w1y24hPattern4(client, acc) { - return { - _1m: createCentsUsdPattern(client, _m(acc, '1m')), - _1w: createCentsUsdPattern(client, _m(acc, '1w')), - _1y: createCentsUsdPattern(client, _m(acc, '1y')), - _24h: createCentsUsdPattern(client, _m(acc, '24h')), - }; -} - -/** - * @typedef {Object} _1m1w1y24hPattern3 - * @property {MetricPattern1} _1m - * @property {MetricPattern1} _1w - * @property {MetricPattern1} _1y - * @property {BtcCentsSatsUsdPattern} _24h - */ - /** * Create a _1m1w1y24hPattern3 pattern node * @param {BrkClientBase} client @@ -3008,10 +2899,10 @@ function create_1m1w1y24hPattern4(client, acc) { */ function create_1m1w1y24hPattern3(client, acc) { return { - _1m: createMetricPattern1(client, _m(acc, '1m')), - _1w: createMetricPattern1(client, _m(acc, '1w')), - _1y: createMetricPattern1(client, _m(acc, '1y')), - _24h: createBtcCentsSatsUsdPattern(client, _m(acc, '24h')), + _1m: createCentsUsdPattern(client, _m(acc, '1m')), + _1w: createCentsUsdPattern(client, _m(acc, '1w')), + _1y: createCentsUsdPattern(client, _m(acc, '1y')), + _24h: createCentsUsdPattern(client, _m(acc, '24h')), }; } @@ -3038,35 +2929,12 @@ function create_1y2y4yAllPattern(client, acc) { }; } -/** - * @typedef {Object} AddressOutputsRealizedSupplyPattern - * @property {DeltaRawPattern} addressCount - * @property {UnspentPattern} outputs - * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized - * @property {HalfTotalPattern} supply - */ - -/** - * Create a AddressOutputsRealizedSupplyPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {AddressOutputsRealizedSupplyPattern} - */ -function createAddressOutputsRealizedSupplyPattern(client, acc) { - return { - addressCount: createDeltaRawPattern(client, _m(acc, 'address_count')), - outputs: createUnspentPattern(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), - supply: createHalfTotalPattern(client, _m(acc, 'supply')), - }; -} - /** * @typedef {Object} AdjustedRatioValuePattern * @property {RatioValuePattern2} adjusted * @property {_1m1w1y24hPattern} ratio - * @property {RawSumPattern} valueCreated - * @property {RawSumPattern} valueDestroyed + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** @@ -3079,8 +2947,8 @@ function createAdjustedRatioValuePattern(client, acc) { return { adjusted: createRatioValuePattern2(client, acc), ratio: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), - valueCreated: createRawSumPattern(client, _m(acc, 'value_created')), - valueDestroyed: createRawSumPattern(client, _m(acc, 'value_destroyed')), + valueCreated: createCumulativeRawSumPattern(client, _m(acc, 'value_created')), + valueDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'value_destroyed')), }; } @@ -3131,25 +2999,25 @@ function createBtcCentsSatsUsdPattern(client, acc) { } /** - * @typedef {Object} CapLowerPriceUpperPattern - * @property {RawPattern2} cap - * @property {CentsSatsUsdPattern} lowerPriceBand - * @property {BpsCentsPercentilesRatioSatsUsdPattern} price - * @property {CentsSatsUsdPattern} upperPriceBand + * @typedef {Object} CentsDeltaRelUsdPattern + * @property {MetricPattern1} cents + * @property {ChangeRatePattern2} delta + * @property {BpsPercentRatioPattern} relToOwnMcap + * @property {MetricPattern1} usd */ /** - * Create a CapLowerPriceUpperPattern pattern node + * Create a CentsDeltaRelUsdPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CapLowerPriceUpperPattern} + * @returns {CentsDeltaRelUsdPattern} */ -function createCapLowerPriceUpperPattern(client, acc) { +function createCentsDeltaRelUsdPattern(client, acc) { return { - cap: createRawPattern2(client, _m(acc, 'investor_cap_raw')), - lowerPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_price_band')), - price: createBpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'investor_price')), - upperPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_price_band')), + cents: createMetricPattern1(client, _m(acc, 'cents')), + delta: createChangeRatePattern2(client, _m(acc, 'delta')), + relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')), + usd: createMetricPattern1(client, acc), }; } @@ -3181,7 +3049,7 @@ function createCentsRelUsdPattern2(client, acc) { * @property {MetricPattern1} cumulative * @property {MetricPattern1} negative * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum + * @property {_1m1w1y24hPattern3} sum */ /** @@ -3192,10 +3060,10 @@ function createCentsRelUsdPattern2(client, acc) { */ function createCumulativeNegativeRawSumPattern(client, acc) { return { - cumulative: createMetricPattern1(client, _m(acc, 'realized_loss_cumulative')), - negative: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - raw: createCentsUsdPattern(client, _m(acc, 'realized_loss')), - sum: create_24hPattern(client, _m(acc, 'realized_loss_24h')), + cumulative: createMetricPattern1(client, _m(acc, 'unrealized_loss_cumulative')), + negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), + raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'unrealized_loss_sum')), }; } @@ -3223,57 +3091,57 @@ function createHalfInTotalPattern(client, acc) { } /** - * @typedef {Object} InRawSumPattern - * @property {RawSumPattern4} inLoss - * @property {RawSumPattern4} inProfit - * @property {MetricPattern1} raw - * @property {_24hPattern2} sum + * @typedef {Object} LossNetNuplProfitPattern + * @property {CumulativeNegativeRawSumPattern} loss + * @property {CentsUsdPattern} netPnl + * @property {BpsRatioPattern} nupl + * @property {CumulativeRawSumPattern2} profit */ /** - * Create a InRawSumPattern pattern node + * Create a LossNetNuplProfitPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {InRawSumPattern} + * @returns {LossNetNuplProfitPattern} */ -function createInRawSumPattern(client, acc) { +function createLossNetNuplProfitPattern(client, acc) { return { - inLoss: createRawSumPattern4(client, _m(acc, 'in_loss')), - inProfit: createRawSumPattern4(client, _m(acc, 'in_profit')), - raw: createMetricPattern1(client, acc), - sum: create_24hPattern2(client, _m(acc, '24h')), + loss: createCumulativeNegativeRawSumPattern(client, acc), + netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + profit: createCumulativeRawSumPattern2(client, _m(acc, 'unrealized_profit')), }; } /** - * @typedef {Object} InRawSumPattern2 - * @property {RawSumPattern5} inLoss - * @property {RawSumPattern5} inProfit - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum + * @typedef {Object} OutputsRealizedSupplyUnrealizedPattern2 + * @property {UnspentPattern} outputs + * @property {CapLossMvrvPriceProfitSoprPattern} realized + * @property {HalfInTotalPattern} supply + * @property {LossNuplProfitPattern} unrealized */ /** - * Create a InRawSumPattern2 pattern node + * Create a OutputsRealizedSupplyUnrealizedPattern2 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {InRawSumPattern2} + * @returns {OutputsRealizedSupplyUnrealizedPattern2} */ -function createInRawSumPattern2(client, acc) { +function createOutputsRealizedSupplyUnrealizedPattern2(client, acc) { return { - inLoss: createRawSumPattern5(client, _m(acc, 'in_loss')), - inProfit: createRawSumPattern5(client, _m(acc, 'in_profit')), - raw: createMetricPattern1(client, acc), - sum: create_1m1w1y24hPattern(client, acc), + outputs: createUnspentPattern(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvPriceProfitSoprPattern(client, acc), + supply: createHalfInTotalPattern(client, _m(acc, 'supply')), + unrealized: createLossNuplProfitPattern(client, acc), }; } /** * @typedef {Object} OutputsRealizedSupplyUnrealizedPattern * @property {UnspentPattern} outputs - * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized - * @property {HalfInTotalPattern} supply - * @property {LossProfitPattern} unrealized + * @property {CapLossMvrvPriceProfitSoprPattern} realized + * @property {HalfTotalPattern} supply + * @property {NuplPattern} unrealized */ /** @@ -3285,9 +3153,9 @@ function createInRawSumPattern2(client, acc) { function createOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { outputs: createUnspentPattern(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), - supply: createHalfInTotalPattern(client, _m(acc, 'supply')), - unrealized: createLossProfitPattern(client, _m(acc, 'unrealized')), + realized: createCapLossMvrvPriceProfitSoprPattern(client, acc), + supply: createHalfTotalPattern(client, _m(acc, 'supply')), + unrealized: createNuplPattern(client, _m(acc, 'nupl')), }; } @@ -3316,32 +3184,11 @@ function create_1m1w1y24hPattern(client, acc) { }; } -/** - * @typedef {Object} BaseCumulativeSumPattern - * @property {BtcCentsSatsUsdPattern} base - * @property {BtcCentsSatsUsdPattern} cumulative - * @property {_1m1w1y24hPattern8} sum - */ - -/** - * Create a BaseCumulativeSumPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {BaseCumulativeSumPattern} - */ -function createBaseCumulativeSumPattern(client, acc) { - return { - base: createBtcCentsSatsUsdPattern(client, acc), - cumulative: createBtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')), - sum: create_1m1w1y24hPattern8(client, _m(acc, 'sum')), - }; -} - /** * @typedef {Object} BlocksDominanceRewardsPattern * @property {CumulativeRawSumPattern} blocksMined * @property {_1m1w1y24hBpsPercentRatioPattern} dominance - * @property {BaseCumulativeSumPattern} rewards + * @property {CumulativeRawSumPattern3} rewards */ /** @@ -3354,7 +3201,7 @@ function createBlocksDominanceRewardsPattern(client, acc) { return { blocksMined: createCumulativeRawSumPattern(client, _m(acc, 'blocks_mined')), dominance: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'dominance')), - rewards: createBaseCumulativeSumPattern(client, _m(acc, 'rewards')), + rewards: createCumulativeRawSumPattern3(client, _m(acc, 'rewards')), }; } @@ -3424,7 +3271,7 @@ function createCentsSatsUsdPattern2(client, acc) { /** * @typedef {Object} CentsDeltaUsdPattern * @property {MetricPattern1} cents - * @property {ChangeRatePattern3} delta + * @property {ChangeRatePattern2} delta * @property {MetricPattern1} usd */ @@ -3437,28 +3284,7 @@ function createCentsSatsUsdPattern2(client, acc) { function createCentsDeltaUsdPattern(client, acc) { return { cents: createMetricPattern1(client, _m(acc, 'cents')), - delta: createChangeRatePattern3(client, _m(acc, 'delta')), - usd: createMetricPattern1(client, acc), - }; -} - -/** - * @typedef {Object} CentsRawUsdPattern - * @property {MetricPattern1} cents - * @property {MetricPattern18} raw - * @property {MetricPattern1} usd - */ - -/** - * Create a CentsRawUsdPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CentsRawUsdPattern} - */ -function createCentsRawUsdPattern(client, acc) { - return { - cents: createMetricPattern1(client, _m(acc, 'cents')), - raw: createMetricPattern18(client, _m(acc, 'raw')), + delta: createChangeRatePattern2(client, _m(acc, 'delta')), usd: createMetricPattern1(client, acc), }; } @@ -3484,6 +3310,27 @@ function createCentsSatsUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CumulativeRawSumPattern3 + * @property {BtcCentsSatsUsdPattern} cumulative + * @property {BtcCentsSatsUsdPattern} raw + * @property {_1m1w1y24hPattern4} sum + */ + +/** + * Create a CumulativeRawSumPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeRawSumPattern3} + */ +function createCumulativeRawSumPattern3(client, acc) { + return { + cumulative: createBtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')), + raw: createBtcCentsSatsUsdPattern(client, acc), + sum: create_1m1w1y24hPattern4(client, _m(acc, 'sum')), + }; +} + /** * @typedef {Object} CumulativeRawRelPattern * @property {MetricPattern1} cumulative @@ -3509,7 +3356,7 @@ function createCumulativeRawRelPattern(client, acc) { * @typedef {Object} CumulativeRawSumPattern2 * @property {MetricPattern1} cumulative * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum + * @property {_1m1w1y24hPattern3} sum */ /** @@ -3522,7 +3369,7 @@ function createCumulativeRawSumPattern2(client, acc) { return { cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), raw: createCentsUsdPattern(client, acc), - sum: create_24hPattern(client, _m(acc, '24h')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'sum')), }; } @@ -3548,73 +3395,52 @@ function createGreedNetPainPattern(client, acc) { } /** - * @typedef {Object} LossNetProfitPattern - * @property {NegativeRawSumPattern} loss - * @property {CentsUsdPattern} netPnl - * @property {RawSumPattern2} profit + * @typedef {Object} LossNuplProfitPattern + * @property {CumulativeRawSumPattern2} loss + * @property {BpsRatioPattern} nupl + * @property {CumulativeRawSumPattern2} profit */ /** - * Create a LossNetProfitPattern pattern node + * Create a LossNuplProfitPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {LossNetProfitPattern} + * @returns {LossNuplProfitPattern} */ -function createLossNetProfitPattern(client, acc) { +function createLossNuplProfitPattern(client, acc) { return { - loss: createNegativeRawSumPattern(client, acc), - netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - profit: createRawSumPattern2(client, _m(acc, 'unrealized_profit')), + loss: createCumulativeRawSumPattern2(client, _m(acc, 'unrealized_loss')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + profit: createCumulativeRawSumPattern2(client, _m(acc, 'unrealized_profit')), }; } /** - * @typedef {Object} NegativeRawSumPattern - * @property {MetricPattern1} negative - * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum + * @typedef {Object} LowerPriceUpperPattern + * @property {CentsSatsUsdPattern} lowerPriceBand + * @property {BpsCentsPercentilesRatioSatsUsdPattern} price + * @property {CentsSatsUsdPattern} upperPriceBand */ /** - * Create a NegativeRawSumPattern pattern node + * Create a LowerPriceUpperPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {NegativeRawSumPattern} + * @returns {LowerPriceUpperPattern} */ -function createNegativeRawSumPattern(client, acc) { +function createLowerPriceUpperPattern(client, acc) { return { - negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), - }; -} - -/** - * @typedef {Object} OutputsRealizedSupplyPattern - * @property {UnspentPattern} outputs - * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized - * @property {HalfTotalPattern} supply - */ - -/** - * Create a OutputsRealizedSupplyPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {OutputsRealizedSupplyPattern} - */ -function createOutputsRealizedSupplyPattern(client, acc) { - return { - outputs: createUnspentPattern(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), - supply: createHalfTotalPattern(client, _m(acc, 'supply')), + lowerPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_price_band')), + price: createBpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'investor_price')), + upperPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_price_band')), }; } /** * @typedef {Object} RatioValuePattern2 * @property {_1m1w1y24hPattern} ratio - * @property {RawSumPattern} valueCreated - * @property {RawSumPattern} valueDestroyed + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** @@ -3626,16 +3452,16 @@ function createOutputsRealizedSupplyPattern(client, acc) { function createRatioValuePattern2(client, acc) { return { ratio: create_1m1w1y24hPattern(client, _m(acc, 'asopr')), - valueCreated: createRawSumPattern(client, _m(acc, 'adj_value_created')), - valueDestroyed: createRawSumPattern(client, _m(acc, 'adj_value_destroyed')), + valueCreated: createCumulativeRawSumPattern(client, _m(acc, 'adj_value_created')), + valueDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'adj_value_destroyed')), }; } /** * @typedef {Object} RatioValuePattern - * @property {_24hPattern2} ratio - * @property {RawSumPattern3} valueCreated - * @property {RawSumPattern3} valueDestroyed + * @property {_24hPattern} ratio + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** @@ -3646,38 +3472,17 @@ function createRatioValuePattern2(client, acc) { */ function createRatioValuePattern(client, acc) { return { - ratio: create_24hPattern2(client, _m(acc, 'sopr_24h')), - valueCreated: createRawSumPattern3(client, _m(acc, 'value_created')), - valueDestroyed: createRawSumPattern3(client, _m(acc, 'value_destroyed')), - }; -} - -/** - * @typedef {Object} RawSellSumPattern - * @property {CentsUsdPattern} raw - * @property {_1m1w1y24hPattern2} sellSideRiskRatio - * @property {_1m1w1y24hPattern} sum - */ - -/** - * Create a RawSellSumPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSellSumPattern} - */ -function createRawSellSumPattern(client, acc) { - return { - raw: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), - sellSideRiskRatio: create_1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')), - sum: create_1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')), + ratio: create_24hPattern(client, _m(acc, 'sopr_24h')), + valueCreated: createCumulativeRawSumPattern(client, _m(acc, 'value_created')), + valueDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'value_destroyed')), }; } /** * @template T * @typedef {Object} _6bBlockTxindexPattern - * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} _6b - * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} block + * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2} _6b + * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2} block * @property {MetricPattern19} txindex */ @@ -3690,8 +3495,8 @@ function createRawSellSumPattern(client, acc) { */ function create_6bBlockTxindexPattern(client, acc) { return { - _6b: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, _m(acc, '6b')), - block: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc), + _6b: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2(client, _m(acc, '6b')), + block: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2(client, acc), txindex: createMetricPattern19(client, acc), }; } @@ -3715,13 +3520,13 @@ function createCumulativeRawSumPattern(client, acc) { return { cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), raw: createMetricPattern1(client, acc), - sum: create_1m1w1y24hPattern(client, acc), + sum: create_1m1w1y24hPattern(client, _m(acc, 'sum')), }; } /** * @typedef {Object} BlocksDominancePattern - * @property {CumulativeRawPattern} blocksMined + * @property {CumulativeRawSumPattern} blocksMined * @property {BpsPercentRatioPattern} dominance */ @@ -3733,7 +3538,7 @@ function createCumulativeRawSumPattern(client, acc) { */ function createBlocksDominancePattern(client, acc) { return { - blocksMined: createCumulativeRawPattern(client, _m(acc, 'blocks_mined')), + blocksMined: createCumulativeRawSumPattern(client, _m(acc, 'blocks_mined')), dominance: createBpsPercentRatioPattern(client, _m(acc, 'dominance')), }; } @@ -3790,34 +3595,15 @@ function createCentsUsdPattern(client, acc) { */ function createChangeRatePattern(client, acc) { return { - change: create_1m1w1y24hPattern(client, _m(acc, 'change')), - rate: create_1m1w1y24hPattern2(client, _m(acc, 'rate')), - }; -} - -/** - * @typedef {Object} ChangeRatePattern4 - * @property {_1m1w1y24hPattern4} change - * @property {_1m1w1y24hPattern2} rate - */ - -/** - * Create a ChangeRatePattern4 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {ChangeRatePattern4} - */ -function createChangeRatePattern4(client, acc) { - return { - change: create_1m1w1y24hPattern4(client, _m(acc, 'change')), - rate: create_1m1w1y24hPattern2(client, _m(acc, 'rate')), + change: create_1m1w1y24hPattern(client, acc), + rate: create_1m1w1y24hPattern2(client, acc), }; } /** * @typedef {Object} ChangeRatePattern2 - * @property {_1mPattern} change - * @property {_1mPattern2} rate + * @property {_1m1w1y24hPattern3} change + * @property {_1m1w1y24hPattern2} rate */ /** @@ -3828,34 +3614,15 @@ function createChangeRatePattern4(client, acc) { */ function createChangeRatePattern2(client, acc) { return { - change: create_1mPattern(client, _m(acc, 'change_1m')), - rate: create_1mPattern2(client, _m(acc, 'rate_1m')), - }; -} - -/** - * @typedef {Object} ChangeRatePattern3 - * @property {_1mPattern3} change - * @property {_1mPattern2} rate - */ - -/** - * Create a ChangeRatePattern3 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {ChangeRatePattern3} - */ -function createChangeRatePattern3(client, acc) { - return { - change: create_1mPattern3(client, _m(acc, 'change_1m')), - rate: create_1mPattern2(client, _m(acc, 'rate_1m')), + change: create_1m1w1y24hPattern3(client, acc), + rate: create_1m1w1y24hPattern2(client, acc), }; } /** * @typedef {Object} CoindaysSentPattern - * @property {RawSumPattern3} coindaysDestroyed - * @property {InRawSumPattern} sent + * @property {CumulativeRawSumPattern} coindaysDestroyed + * @property {CumulativeInRawSumPattern} sent */ /** @@ -3866,33 +3633,33 @@ function createChangeRatePattern3(client, acc) { */ function createCoindaysSentPattern(client, acc) { return { - coindaysDestroyed: createRawSumPattern3(client, _m(acc, 'coindays_destroyed')), - sent: createInRawSumPattern(client, _m(acc, 'sent')), + coindaysDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), + sent: createCumulativeInRawSumPattern(client, _m(acc, 'sent')), }; } /** - * @typedef {Object} DeltaRawPattern2 + * @typedef {Object} DeltaInnerPattern * @property {ChangeRatePattern} delta - * @property {MetricPattern1} raw + * @property {MetricPattern1} inner */ /** - * Create a DeltaRawPattern2 pattern node + * Create a DeltaInnerPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {DeltaRawPattern2} + * @returns {DeltaInnerPattern} */ -function createDeltaRawPattern2(client, acc) { +function createDeltaInnerPattern(client, acc) { return { delta: createChangeRatePattern(client, _m(acc, 'delta')), - raw: createMetricPattern1(client, acc), + inner: createMetricPattern1(client, acc), }; } /** * @typedef {Object} DeltaRawPattern - * @property {ChangeRatePattern2} delta + * @property {ChangeRatePattern} delta * @property {MetricPattern1} raw */ @@ -3904,7 +3671,7 @@ function createDeltaRawPattern2(client, acc) { */ function createDeltaRawPattern(client, acc) { return { - delta: createChangeRatePattern2(client, _m(acc, 'delta')), + delta: createChangeRatePattern(client, _m(acc, 'delta')), raw: createMetricPattern1(client, acc), }; } @@ -3928,29 +3695,10 @@ function createHalfTotalPattern(client, acc) { }; } -/** - * @typedef {Object} InPattern2 - * @property {CentsRawUsdPattern} inLoss - * @property {CentsRawUsdPattern} inProfit - */ - -/** - * Create a InPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {InPattern2} - */ -function createInPattern2(client, acc) { - return { - inLoss: createCentsRawUsdPattern(client, _m(acc, 'loss')), - inProfit: createCentsRawUsdPattern(client, _m(acc, 'profit')), - }; -} - /** * @typedef {Object} InPattern - * @property {RawPattern2} inLoss - * @property {RawPattern2} inProfit + * @property {CentsUsdPattern} inLoss + * @property {CentsUsdPattern} inProfit */ /** @@ -3961,27 +3709,8 @@ function createInPattern2(client, acc) { */ function createInPattern(client, acc) { return { - inLoss: createRawPattern2(client, _m(acc, 'loss_raw')), - inProfit: createRawPattern2(client, _m(acc, 'profit_raw')), - }; -} - -/** - * @typedef {Object} LossProfitPattern - * @property {RawSumPattern2} loss - * @property {RawSumPattern2} profit - */ - -/** - * Create a LossProfitPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {LossProfitPattern} - */ -function createLossProfitPattern(client, acc) { - return { - loss: createRawSumPattern2(client, _m(acc, 'loss')), - profit: createRawSumPattern2(client, _m(acc, 'profit')), + inLoss: createCentsUsdPattern(client, _m(acc, 'loss')), + inProfit: createCentsUsdPattern(client, _m(acc, 'profit')), }; } @@ -4004,63 +3733,6 @@ function createPriceValuePattern(client, acc) { }; } -/** - * @typedef {Object} RawSumPattern5 - * @property {BtcCentsSatsUsdPattern} raw - * @property {_1m1w1y24hPattern3} sum - */ - -/** - * Create a RawSumPattern5 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumPattern5} - */ -function createRawSumPattern5(client, acc) { - return { - raw: createBtcCentsSatsUsdPattern(client, acc), - sum: create_1m1w1y24hPattern3(client, acc), - }; -} - -/** - * @typedef {Object} RawSumPattern4 - * @property {BtcCentsSatsUsdPattern} raw - * @property {_24hPattern3} sum - */ - -/** - * Create a RawSumPattern4 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumPattern4} - */ -function createRawSumPattern4(client, acc) { - return { - raw: createBtcCentsSatsUsdPattern(client, acc), - sum: create_24hPattern3(client, _m(acc, '24h')), - }; -} - -/** - * @typedef {Object} RawSumPattern2 - * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum - */ - -/** - * Create a RawSumPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumPattern2} - */ -function createRawSumPattern2(client, acc) { - return { - raw: createCentsUsdPattern(client, acc), - sum: create_24hPattern(client, _m(acc, '24h')), - }; -} - /** * @typedef {Object} RealizedSupplyPattern * @property {MetricPattern1} realizedCap @@ -4120,8 +3792,8 @@ function createSdSmaPattern(client, acc) { /** * @typedef {Object} ValuePattern - * @property {RawSumPattern3} valueCreated - * @property {RawSumPattern3} valueDestroyed + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** @@ -4132,128 +3804,14 @@ function createSdSmaPattern(client, acc) { */ function createValuePattern(client, acc) { return { - valueCreated: createRawSumPattern3(client, _m(acc, 'created')), - valueDestroyed: createRawSumPattern3(client, _m(acc, 'destroyed')), - }; -} - -/** - * @template T - * @typedef {Object} CumulativeRawPattern - * @property {MetricPattern1} cumulative - * @property {MetricPattern1} raw - */ - -/** - * Create a CumulativeRawPattern pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CumulativeRawPattern} - */ -function createCumulativeRawPattern(client, acc) { - return { - cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), - raw: createMetricPattern1(client, acc), - }; -} - -/** - * @template T - * @typedef {Object} RawSumPattern - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * Create a RawSumPattern pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumPattern} - */ -function createRawSumPattern(client, acc) { - return { - raw: createMetricPattern1(client, acc), - sum: create_1m1w1y24hPattern(client, acc), - }; -} - -/** - * @template T - * @typedef {Object} RawSumPattern3 - * @property {MetricPattern1} raw - * @property {_24hPattern2} sum - */ - -/** - * Create a RawSumPattern3 pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumPattern3} - */ -function createRawSumPattern3(client, acc) { - return { - raw: createMetricPattern1(client, acc), - sum: create_24hPattern2(client, _m(acc, '24h')), - }; -} - -/** - * @typedef {Object} _1mPattern2 - * @property {BpsPercentRatioPattern} _1m - */ - -/** - * Create a _1mPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1mPattern2} - */ -function create_1mPattern2(client, acc) { - return { - _1m: createBpsPercentRatioPattern(client, acc), - }; -} - -/** - * @typedef {Object} _1mPattern3 - * @property {CentsUsdPattern} _1m - */ - -/** - * Create a _1mPattern3 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1mPattern3} - */ -function create_1mPattern3(client, acc) { - return { - _1m: createCentsUsdPattern(client, acc), - }; -} - -/** - * @typedef {Object} _24hPattern3 - * @property {BtcCentsSatsUsdPattern} _24h - */ - -/** - * Create a _24hPattern3 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_24hPattern3} - */ -function create_24hPattern3(client, acc) { - return { - _24h: createBtcCentsSatsUsdPattern(client, acc), + valueCreated: createCumulativeRawSumPattern(client, _m(acc, 'created')), + valueDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'destroyed')), }; } /** * @typedef {Object} _24hPattern - * @property {CentsUsdPattern} _24h + * @property {MetricPattern1} _24h */ /** @@ -4264,7 +3822,24 @@ function create_24hPattern3(client, acc) { */ function create_24hPattern(client, acc) { return { - _24h: createCentsUsdPattern(client, acc), + _24h: createMetricPattern1(client, acc), + }; +} + +/** + * @typedef {Object} NuplPattern + * @property {BpsRatioPattern} nupl + */ + +/** + * Create a NuplPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {NuplPattern} + */ +function createNuplPattern(client, acc) { + return { + nupl: createBpsRatioPattern(client, acc), }; } @@ -4285,23 +3860,6 @@ function createUnspentPattern2(client, acc) { }; } -/** - * @typedef {Object} UnspentPattern3 - * @property {DeltaRawPattern2} unspentCount - */ - -/** - * Create a UnspentPattern3 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {UnspentPattern3} - */ -function createUnspentPattern3(client, acc) { - return { - unspentCount: createDeltaRawPattern2(client, acc), - }; -} - /** * @typedef {Object} UnspentPattern * @property {MetricPattern1} unspentCount @@ -4319,63 +3877,6 @@ function createUnspentPattern(client, acc) { }; } -/** - * @template T - * @typedef {Object} _1mPattern - * @property {MetricPattern1} _1m - */ - -/** - * Create a _1mPattern pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1mPattern} - */ -function create_1mPattern(client, acc) { - return { - _1m: createMetricPattern1(client, acc), - }; -} - -/** - * @template T - * @typedef {Object} _24hPattern2 - * @property {MetricPattern1} _24h - */ - -/** - * Create a _24hPattern2 pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_24hPattern2} - */ -function create_24hPattern2(client, acc) { - return { - _24h: createMetricPattern1(client, acc), - }; -} - -/** - * @template T - * @typedef {Object} RawPattern2 - * @property {MetricPattern18} raw - */ - -/** - * Create a RawPattern2 pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawPattern2} - */ -function createRawPattern2(client, acc) { - return { - raw: createMetricPattern18(client, acc), - }; -} - // Catalog tree typedefs /** @@ -4387,7 +3888,6 @@ function createRawPattern2(client, acc) { * @property {MetricsTree_Addresses} addresses * @property {MetricsTree_Scripts} scripts * @property {MetricsTree_Mining} mining - * @property {MetricsTree_Positions} positions * @property {MetricsTree_Cointime} cointime * @property {MetricsTree_Constants} constants * @property {MetricsTree_Indexes} indexes @@ -4395,8 +3895,8 @@ function createRawPattern2(client, acc) { * @property {MetricsTree_Market} market * @property {MetricsTree_Pools} pools * @property {MetricsTree_Prices} prices - * @property {MetricsTree_Distribution} distribution * @property {MetricsTree_Supply} supply + * @property {MetricsTree_Cohorts} cohorts */ /** @@ -4581,9 +4081,8 @@ function createRawPattern2(client, acc) { /** * @typedef {Object} MetricsTree_Transactions_Volume - * @property {_1m1w1y24hBtcCentsSatsUsdPattern} sentSum - * @property {_1m1w1y24hBtcCentsSatsUsdPattern} receivedSum - * @property {BtcCentsSatsUsdPattern} annualized + * @property {CumulativeRawSumPattern3} sentSum + * @property {CumulativeRawSumPattern3} receivedSum * @property {MetricPattern1} txPerSec * @property {MetricPattern1} outputsPerSec * @property {MetricPattern1} inputsPerSec @@ -4641,6 +4140,14 @@ function createRawPattern2(client, acc) { /** * @typedef {Object} MetricsTree_Addresses * @property {MetricsTree_Addresses_Raw} raw + * @property {MetricsTree_Addresses_Indexes} indexes + * @property {MetricsTree_Addresses_Data} data + * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} funded + * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} empty + * @property {MetricsTree_Addresses_Activity} activity + * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} total + * @property {MetricsTree_Addresses_New} new + * @property {MetricsTree_Addresses_Delta} delta */ /** @@ -4703,6 +4210,65 @@ function createRawPattern2(client, acc) { * @property {MetricPattern24} bytes */ +/** + * @typedef {Object} MetricsTree_Addresses_Indexes + * @property {MetricPattern24} p2a + * @property {MetricPattern26} p2pk33 + * @property {MetricPattern27} p2pk65 + * @property {MetricPattern28} p2pkh + * @property {MetricPattern29} p2sh + * @property {MetricPattern30} p2tr + * @property {MetricPattern31} p2wpkh + * @property {MetricPattern32} p2wsh + * @property {MetricPattern34} funded + * @property {MetricPattern35} empty + */ + +/** + * @typedef {Object} MetricsTree_Addresses_Data + * @property {MetricPattern34} funded + * @property {MetricPattern35} empty + */ + +/** + * @typedef {Object} MetricsTree_Addresses_Activity + * @property {BothReactivatedReceivingSendingPattern} all + * @property {BothReactivatedReceivingSendingPattern} p2pk65 + * @property {BothReactivatedReceivingSendingPattern} p2pk33 + * @property {BothReactivatedReceivingSendingPattern} p2pkh + * @property {BothReactivatedReceivingSendingPattern} p2sh + * @property {BothReactivatedReceivingSendingPattern} p2wpkh + * @property {BothReactivatedReceivingSendingPattern} p2wsh + * @property {BothReactivatedReceivingSendingPattern} p2tr + * @property {BothReactivatedReceivingSendingPattern} p2a + */ + +/** + * @typedef {Object} MetricsTree_Addresses_New + * @property {CumulativeRawSumPattern} all + * @property {CumulativeRawSumPattern} p2pk65 + * @property {CumulativeRawSumPattern} p2pk33 + * @property {CumulativeRawSumPattern} p2pkh + * @property {CumulativeRawSumPattern} p2sh + * @property {CumulativeRawSumPattern} p2wpkh + * @property {CumulativeRawSumPattern} p2wsh + * @property {CumulativeRawSumPattern} p2tr + * @property {CumulativeRawSumPattern} p2a + */ + +/** + * @typedef {Object} MetricsTree_Addresses_Delta + * @property {ChangeRatePattern} all + * @property {ChangeRatePattern} p2pk65 + * @property {ChangeRatePattern} p2pk33 + * @property {ChangeRatePattern} p2pkh + * @property {ChangeRatePattern} p2sh + * @property {ChangeRatePattern} p2wpkh + * @property {ChangeRatePattern} p2wsh + * @property {ChangeRatePattern} p2tr + * @property {ChangeRatePattern} p2a + */ + /** * @typedef {Object} MetricsTree_Scripts * @property {MetricsTree_Scripts_Raw} raw @@ -4785,10 +4351,10 @@ function createRawPattern2(client, acc) { /** * @typedef {Object} MetricsTree_Mining_Rewards - * @property {BaseCumulativeSumPattern} coinbase + * @property {CumulativeRawSumPattern3} coinbase * @property {MetricsTree_Mining_Rewards_Subsidy} subsidy * @property {MetricsTree_Mining_Rewards_Fees} fees - * @property {BaseCumulativeSumPattern} unclaimed + * @property {CumulativeRawSumPattern3} unclaimed */ /** @@ -4803,10 +4369,11 @@ function createRawPattern2(client, acc) { * @typedef {Object} MetricsTree_Mining_Rewards_Fees * @property {BtcCentsSatsUsdPattern} base * @property {BtcCentsSatsUsdPattern} cumulative - * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2} _24h - * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2} _1w - * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2} _1m - * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2} _1y + * @property {_1m1w1y24hPattern4} sum + * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} _24h + * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} _1w + * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} _1m + * @property {AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} _1y * @property {_1m1w1y24hBpsPercentRatioPattern} dominance * @property {MetricsTree_Mining_Rewards_Fees_RatioMultiple} ratioMultiple */ @@ -4842,12 +4409,6 @@ function createRawPattern2(client, acc) { * @property {MetricPattern1} _1y */ -/** - * @typedef {Object} MetricsTree_Positions - * @property {MetricPattern18} block - * @property {MetricPattern19} tx - */ - /** * @typedef {Object} MetricsTree_Cointime * @property {MetricsTree_Cointime_Activity} activity @@ -4857,6 +4418,7 @@ function createRawPattern2(client, acc) { * @property {MetricsTree_Cointime_Prices} prices * @property {MetricsTree_Cointime_Adjusted} adjusted * @property {MetricsTree_Cointime_ReserveRisk} reserveRisk + * @property {MetricsTree_Cointime_CoinblocksDestroyed} coinblocksDestroyed */ /** @@ -4919,6 +4481,12 @@ function createRawPattern2(client, acc) { * @property {MetricPattern18} hodlBank */ +/** + * @typedef {Object} MetricsTree_Cointime_CoinblocksDestroyed + * @property {MetricPattern1} raw + * @property {MetricPattern1} cumulative + */ + /** * @typedef {Object} MetricsTree_Constants * @property {MetricPattern1} _0 @@ -5773,174 +5341,65 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution - * @property {MetricPattern18} supplyState - * @property {MetricsTree_Distribution_Addresses} addresses - * @property {MetricsTree_Distribution_Cohorts} cohorts - * @property {CumulativeRawPattern} coinblocksDestroyed + * @typedef {Object} MetricsTree_Supply + * @property {BtcCentsSatsUsdPattern} circulating + * @property {MetricsTree_Supply_Burned} burned + * @property {BpsPercentRatioPattern} inflationRate + * @property {MetricsTree_Supply_Velocity} velocity + * @property {CentsDeltaUsdPattern} marketCap + * @property {_1m1w1y24hPattern} marketMinusRealizedCapGrowthRate + * @property {BtcCentsSatsUsdPattern} hodledOrLost + * @property {MetricPattern18} state */ /** - * @typedef {Object} MetricsTree_Distribution_Addresses - * @property {MetricsTree_Distribution_Addresses_Indexes} indexes - * @property {MetricsTree_Distribution_Addresses_Data} data - * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} funded - * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} empty - * @property {MetricsTree_Distribution_Addresses_Activity} activity - * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} total - * @property {MetricsTree_Distribution_Addresses_New} new - * @property {MetricsTree_Distribution_Addresses_Delta} delta + * @typedef {Object} MetricsTree_Supply_Burned + * @property {CumulativeRawSumPattern3} opreturn + * @property {CumulativeRawSumPattern3} unspendable */ /** - * @typedef {Object} MetricsTree_Distribution_Addresses_Indexes - * @property {MetricPattern24} p2a - * @property {MetricPattern26} p2pk33 - * @property {MetricPattern27} p2pk65 - * @property {MetricPattern28} p2pkh - * @property {MetricPattern29} p2sh - * @property {MetricPattern30} p2tr - * @property {MetricPattern31} p2wpkh - * @property {MetricPattern32} p2wsh - * @property {MetricPattern34} funded - * @property {MetricPattern35} empty + * @typedef {Object} MetricsTree_Supply_Velocity + * @property {MetricPattern1} btc + * @property {MetricPattern1} usd */ /** - * @typedef {Object} MetricsTree_Distribution_Addresses_Data - * @property {MetricPattern34} funded - * @property {MetricPattern35} empty + * @typedef {Object} MetricsTree_Cohorts + * @property {MetricsTree_Cohorts_Utxo} utxo + * @property {MetricsTree_Cohorts_Address} address */ /** - * @typedef {Object} MetricsTree_Distribution_Addresses_Activity - * @property {BothReactivatedReceivingSendingPattern} all - * @property {BothReactivatedReceivingSendingPattern} p2pk65 - * @property {BothReactivatedReceivingSendingPattern} p2pk33 - * @property {BothReactivatedReceivingSendingPattern} p2pkh - * @property {BothReactivatedReceivingSendingPattern} p2sh - * @property {BothReactivatedReceivingSendingPattern} p2wpkh - * @property {BothReactivatedReceivingSendingPattern} p2wsh - * @property {BothReactivatedReceivingSendingPattern} p2tr - * @property {BothReactivatedReceivingSendingPattern} p2a + * @typedef {Object} MetricsTree_Cohorts_Utxo + * @property {MetricsTree_Cohorts_Utxo_All} all + * @property {MetricsTree_Cohorts_Utxo_Sth} sth + * @property {MetricsTree_Cohorts_Utxo_Lth} lth + * @property {MetricsTree_Cohorts_Utxo_AgeRange} ageRange + * @property {MetricsTree_Cohorts_Utxo_UnderAge} underAge + * @property {MetricsTree_Cohorts_Utxo_OverAge} overAge + * @property {MetricsTree_Cohorts_Utxo_Epoch} epoch + * @property {MetricsTree_Cohorts_Utxo_Class} class + * @property {MetricsTree_Cohorts_Utxo_OverAmount} overAmount + * @property {MetricsTree_Cohorts_Utxo_AmountRange} amountRange + * @property {MetricsTree_Cohorts_Utxo_UnderAmount} underAmount + * @property {MetricsTree_Cohorts_Utxo_Type} type + * @property {MetricsTree_Cohorts_Utxo_Profitability} profitability + * @property {MetricsTree_Cohorts_Utxo_Matured} matured */ /** - * @typedef {Object} MetricsTree_Distribution_Addresses_New - * @property {MetricsTree_Distribution_Addresses_New_All} all - * @property {MetricsTree_Distribution_Addresses_New_P2pk65} p2pk65 - * @property {MetricsTree_Distribution_Addresses_New_P2pk33} p2pk33 - * @property {MetricsTree_Distribution_Addresses_New_P2pkh} p2pkh - * @property {MetricsTree_Distribution_Addresses_New_P2sh} p2sh - * @property {MetricsTree_Distribution_Addresses_New_P2wpkh} p2wpkh - * @property {MetricsTree_Distribution_Addresses_New_P2wsh} p2wsh - * @property {MetricsTree_Distribution_Addresses_New_P2tr} p2tr - * @property {MetricsTree_Distribution_Addresses_New_P2a} p2a - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_All - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2pk65 - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2pk33 - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2pkh - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2sh - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2wpkh - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2wsh - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2tr - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_New_P2a - * @property {MetricPattern1} raw - * @property {_1m1w1y24hPattern} sum - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Addresses_Delta - * @property {ChangeRatePattern} all - * @property {ChangeRatePattern} p2pk65 - * @property {ChangeRatePattern} p2pk33 - * @property {ChangeRatePattern} p2pkh - * @property {ChangeRatePattern} p2sh - * @property {ChangeRatePattern} p2wpkh - * @property {ChangeRatePattern} p2wsh - * @property {ChangeRatePattern} p2tr - * @property {ChangeRatePattern} p2a - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Cohorts - * @property {MetricsTree_Distribution_Cohorts_Utxo} utxo - * @property {MetricsTree_Distribution_Cohorts_Address} address - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo - * @property {MetricsTree_Distribution_Cohorts_Utxo_All} all - * @property {MetricsTree_Distribution_Cohorts_Utxo_Sth} sth - * @property {MetricsTree_Distribution_Cohorts_Utxo_Lth} lth - * @property {MetricsTree_Distribution_Cohorts_Utxo_AgeRange} ageRange - * @property {MetricsTree_Distribution_Cohorts_Utxo_UnderAge} underAge - * @property {MetricsTree_Distribution_Cohorts_Utxo_OverAge} overAge - * @property {MetricsTree_Distribution_Cohorts_Utxo_Epoch} epoch - * @property {MetricsTree_Distribution_Cohorts_Utxo_Class} class - * @property {MetricsTree_Distribution_Cohorts_Utxo_OverAmount} overAmount - * @property {MetricsTree_Distribution_Cohorts_Utxo_AmountRange} amountRange - * @property {MetricsTree_Distribution_Cohorts_Utxo_UnderAmount} underAmount - * @property {MetricsTree_Distribution_Cohorts_Utxo_Type} type - * @property {MetricsTree_Distribution_Cohorts_Utxo_Profitability} profitability - * @property {MetricsTree_Distribution_Cohorts_Utxo_Matured} matured - */ - -/** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_All - * @property {MetricsTree_Distribution_Cohorts_Utxo_All_Supply} supply - * @property {UnspentPattern3} outputs + * @typedef {Object} MetricsTree_Cohorts_Utxo_All + * @property {MetricsTree_Cohorts_Utxo_All_Supply} supply + * @property {UnspentPattern2} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity - * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern} realized + * @property {CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} realized * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis - * @property {MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized} unrealized + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized} unrealized */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_All_Supply + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Supply * @property {ChangeRatePattern} delta * @property {BtcCentsRelSatsUsdPattern2} inProfit * @property {BtcCentsRelSatsUsdPattern2} inLoss @@ -5949,85 +5408,95 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized * @property {CentsUsdPattern} grossPnl - * @property {InPattern2} investedCapital + * @property {InPattern} investedCapital * @property {GreedNetPainPattern} sentiment - * @property {InPattern} investorCap - * @property {MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss} loss - * @property {MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl} netPnl - * @property {MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit} profit + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_Loss} loss + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl} netPnl + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_Profit} profit + * @property {BpsRatioPattern} nupl */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_Loss * @property {MetricPattern1} negative * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum + * @property {MetricPattern1} cumulative + * @property {_1m1w1y24hPattern3} sum * @property {BpsPercentRatioPattern} relToMcap * @property {BpsPercentRatioPattern} relToOwnGross */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl * @property {MetricPattern1} cents * @property {MetricPattern1} usd * @property {BpsPercentRatioPattern} relToOwnGross */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_Profit * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum + * @property {MetricPattern1} cumulative + * @property {_1m1w1y24hPattern3} sum * @property {BpsPercentRatioPattern} relToMcap * @property {BpsPercentRatioPattern} relToOwnGross */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Sth - * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern} realized + * @typedef {Object} MetricsTree_Cohorts_Utxo_Sth + * @property {CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} realized * @property {DeltaHalfInRelTotalPattern2} supply - * @property {UnspentPattern3} outputs + * @property {UnspentPattern2} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis - * @property {GrossInvestedInvestorLossNetProfitSentimentPattern2} unrealized + * @property {GrossInvestedLossNetNuplProfitSentimentPattern2} unrealized */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Lth + * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth * @property {DeltaHalfInRelTotalPattern2} supply - * @property {UnspentPattern3} outputs + * @property {UnspentPattern2} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity - * @property {MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized} realized + * @property {MetricsTree_Cohorts_Utxo_Lth_Realized} realized * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis - * @property {GrossInvestedInvestorLossNetProfitSentimentPattern2} unrealized + * @property {GrossInvestedLossNetNuplProfitSentimentPattern2} unrealized */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized + * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth_Realized * @property {CumulativeDistributionRawRelSumValuePattern} profit * @property {CapitulationCumulativeNegativeRawRelSumValuePattern} loss - * @property {RawSellSumPattern} grossPnl + * @property {CumulativeRawSumPattern2} grossPnl + * @property {MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio} sellSideRiskRatio * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl - * @property {MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr} sopr + * @property {MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr} sopr * @property {CumulativeRawRelPattern} peakRegret - * @property {CapLowerPriceUpperPattern} investor + * @property {LowerPriceUpperPattern} investor * @property {_1m1w1y24hPattern} profitToLossRatio - * @property {CentsDeltaRawRelUsdPattern} cap + * @property {CentsDeltaRelUsdPattern} cap * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price * @property {MetricPattern1} mvrv - * @property {BpsRatioPattern} nupl */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr - * @property {RawSumPattern} valueCreated - * @property {RawSumPattern} valueDestroyed + * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio + * @property {BpsPercentRatioPattern} _24h + * @property {BpsPercentRatioPattern} _1w + * @property {BpsPercentRatioPattern} _1m + * @property {BpsPercentRatioPattern} _1y + */ + +/** + * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr * @property {_1m1w1y24hPattern} ratio + * @property {CumulativeRawSumPattern} valueCreated + * @property {CumulativeRawSumPattern} valueDestroyed */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_AgeRange + * @typedef {Object} MetricsTree_Cohorts_Utxo_AgeRange * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} under1h * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1hTo1d * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1dTo1w @@ -6052,157 +5521,157 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_UnderAge - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1w - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _3m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _4m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _5m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _6m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _3y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _4y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _5y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _6y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _7y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _8y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _10y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _12y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _15y + * @typedef {Object} MetricsTree_Cohorts_Utxo_UnderAge + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1w + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _3m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _4m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _5m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _6m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _3y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _4y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _5y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _6y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _7y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _8y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _12y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _15y */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_OverAge - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1d - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1w - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _3m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _4m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _5m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _6m - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _3y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _4y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _5y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _6y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _7y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _8y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _10y - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _12y + * @typedef {Object} MetricsTree_Cohorts_Utxo_OverAge + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1d + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1w + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _3m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _4m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _5m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _6m + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _3y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _4y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _5y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _6y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _7y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _8y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10y + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _12y */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Epoch - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _0 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _1 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _3 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _4 + * @typedef {Object} MetricsTree_Cohorts_Utxo_Epoch + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _0 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _3 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _4 */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Class - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2009 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2010 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2011 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2012 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2013 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2014 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2015 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2016 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2017 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2018 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2019 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2020 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2021 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2022 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2023 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2024 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2025 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern2} _2026 + * @typedef {Object} MetricsTree_Cohorts_Utxo_Class + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2009 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2010 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2011 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2012 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2013 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2014 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2015 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2016 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2017 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2018 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2019 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2020 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2021 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2022 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2023 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2024 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2025 + * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _2026 */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_OverAmount - * @property {OutputsRealizedSupplyPattern} _1sat - * @property {OutputsRealizedSupplyPattern} _10sats - * @property {OutputsRealizedSupplyPattern} _100sats - * @property {OutputsRealizedSupplyPattern} _1kSats - * @property {OutputsRealizedSupplyPattern} _10kSats - * @property {OutputsRealizedSupplyPattern} _100kSats - * @property {OutputsRealizedSupplyPattern} _1mSats - * @property {OutputsRealizedSupplyPattern} _10mSats - * @property {OutputsRealizedSupplyPattern} _1btc - * @property {OutputsRealizedSupplyPattern} _10btc - * @property {OutputsRealizedSupplyPattern} _100btc - * @property {OutputsRealizedSupplyPattern} _1kBtc - * @property {OutputsRealizedSupplyPattern} _10kBtc + * @typedef {Object} MetricsTree_Cohorts_Utxo_OverAmount + * @property {OutputsRealizedSupplyUnrealizedPattern} _1sat + * @property {OutputsRealizedSupplyUnrealizedPattern} _10sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _100sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _100kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1mSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10mSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _10btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _100btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _1kBtc + * @property {OutputsRealizedSupplyUnrealizedPattern} _10kBtc */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_AmountRange - * @property {OutputsRealizedSupplyPattern} _0sats - * @property {OutputsRealizedSupplyPattern} _1satTo10sats - * @property {OutputsRealizedSupplyPattern} _10satsTo100sats - * @property {OutputsRealizedSupplyPattern} _100satsTo1kSats - * @property {OutputsRealizedSupplyPattern} _1kSatsTo10kSats - * @property {OutputsRealizedSupplyPattern} _10kSatsTo100kSats - * @property {OutputsRealizedSupplyPattern} _100kSatsTo1mSats - * @property {OutputsRealizedSupplyPattern} _1mSatsTo10mSats - * @property {OutputsRealizedSupplyPattern} _10mSatsTo1btc - * @property {OutputsRealizedSupplyPattern} _1btcTo10btc - * @property {OutputsRealizedSupplyPattern} _10btcTo100btc - * @property {OutputsRealizedSupplyPattern} _100btcTo1kBtc - * @property {OutputsRealizedSupplyPattern} _1kBtcTo10kBtc - * @property {OutputsRealizedSupplyPattern} _10kBtcTo100kBtc - * @property {OutputsRealizedSupplyPattern} over100kBtc + * @typedef {Object} MetricsTree_Cohorts_Utxo_AmountRange + * @property {OutputsRealizedSupplyUnrealizedPattern} _0sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1satTo10sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10satsTo100sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _100satsTo1kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1kSatsTo10kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10kSatsTo100kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _100kSatsTo1mSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1mSatsTo10mSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10mSatsTo1btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _1btcTo10btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _10btcTo100btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _100btcTo1kBtc + * @property {OutputsRealizedSupplyUnrealizedPattern} _1kBtcTo10kBtc + * @property {OutputsRealizedSupplyUnrealizedPattern} _10kBtcTo100kBtc + * @property {OutputsRealizedSupplyUnrealizedPattern} over100kBtc */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_UnderAmount - * @property {OutputsRealizedSupplyPattern} _10sats - * @property {OutputsRealizedSupplyPattern} _100sats - * @property {OutputsRealizedSupplyPattern} _1kSats - * @property {OutputsRealizedSupplyPattern} _10kSats - * @property {OutputsRealizedSupplyPattern} _100kSats - * @property {OutputsRealizedSupplyPattern} _1mSats - * @property {OutputsRealizedSupplyPattern} _10mSats - * @property {OutputsRealizedSupplyPattern} _1btc - * @property {OutputsRealizedSupplyPattern} _10btc - * @property {OutputsRealizedSupplyPattern} _100btc - * @property {OutputsRealizedSupplyPattern} _1kBtc - * @property {OutputsRealizedSupplyPattern} _10kBtc - * @property {OutputsRealizedSupplyPattern} _100kBtc + * @typedef {Object} MetricsTree_Cohorts_Utxo_UnderAmount + * @property {OutputsRealizedSupplyUnrealizedPattern} _10sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _100sats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _100kSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1mSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _10mSats + * @property {OutputsRealizedSupplyUnrealizedPattern} _1btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _10btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _100btc + * @property {OutputsRealizedSupplyUnrealizedPattern} _1kBtc + * @property {OutputsRealizedSupplyUnrealizedPattern} _10kBtc + * @property {OutputsRealizedSupplyUnrealizedPattern} _100kBtc */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Type - * @property {OutputsRealizedSupplyUnrealizedPattern} p2pk65 - * @property {OutputsRealizedSupplyUnrealizedPattern} p2pk33 - * @property {OutputsRealizedSupplyUnrealizedPattern} p2pkh - * @property {OutputsRealizedSupplyUnrealizedPattern} p2ms - * @property {OutputsRealizedSupplyUnrealizedPattern} p2sh - * @property {OutputsRealizedSupplyUnrealizedPattern} p2wpkh - * @property {OutputsRealizedSupplyUnrealizedPattern} p2wsh - * @property {OutputsRealizedSupplyUnrealizedPattern} p2tr - * @property {OutputsRealizedSupplyUnrealizedPattern} p2a - * @property {OutputsRealizedSupplyUnrealizedPattern} unknown - * @property {OutputsRealizedSupplyUnrealizedPattern} empty + * @typedef {Object} MetricsTree_Cohorts_Utxo_Type + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2pk65 + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2pk33 + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2pkh + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2ms + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2sh + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2wpkh + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2wsh + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2tr + * @property {OutputsRealizedSupplyUnrealizedPattern2} p2a + * @property {OutputsRealizedSupplyUnrealizedPattern2} unknown + * @property {OutputsRealizedSupplyUnrealizedPattern2} empty */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Profitability - * @property {MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range} range - * @property {MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit} profit - * @property {MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss} loss + * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability + * @property {MetricsTree_Cohorts_Utxo_Profitability_Range} range + * @property {MetricsTree_Cohorts_Utxo_Profitability_Profit} profit + * @property {MetricsTree_Cohorts_Utxo_Profitability_Loss} loss */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range + * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability_Range * @property {RealizedSupplyPattern} over1000pctInProfit * @property {RealizedSupplyPattern} _500pctTo1000pctInProfit * @property {RealizedSupplyPattern} _300pctTo500pctInProfit @@ -6231,7 +5700,7 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit + * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability_Profit * @property {RealizedSupplyPattern} breakeven * @property {RealizedSupplyPattern} _10pct * @property {RealizedSupplyPattern} _20pct @@ -6249,7 +5718,7 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss + * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability_Loss * @property {RealizedSupplyPattern} breakeven * @property {RealizedSupplyPattern} _10pct * @property {RealizedSupplyPattern} _20pct @@ -6262,7 +5731,7 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Utxo_Matured + * @typedef {Object} MetricsTree_Cohorts_Utxo_Matured * @property {BtcCentsSatsUsdPattern} under1h * @property {BtcCentsSatsUsdPattern} _1hTo1d * @property {BtcCentsSatsUsdPattern} _1dTo1w @@ -6287,93 +5756,63 @@ function createRawPattern2(client, acc) { */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Address - * @property {MetricsTree_Distribution_Cohorts_Address_OverAmount} overAmount - * @property {MetricsTree_Distribution_Cohorts_Address_AmountRange} amountRange - * @property {MetricsTree_Distribution_Cohorts_Address_UnderAmount} underAmount + * @typedef {Object} MetricsTree_Cohorts_Address + * @property {MetricsTree_Cohorts_Address_OverAmount} overAmount + * @property {MetricsTree_Cohorts_Address_AmountRange} amountRange + * @property {MetricsTree_Cohorts_Address_UnderAmount} underAmount */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Address_OverAmount - * @property {AddressOutputsRealizedSupplyPattern} _1sat - * @property {AddressOutputsRealizedSupplyPattern} _10sats - * @property {AddressOutputsRealizedSupplyPattern} _100sats - * @property {AddressOutputsRealizedSupplyPattern} _1kSats - * @property {AddressOutputsRealizedSupplyPattern} _10kSats - * @property {AddressOutputsRealizedSupplyPattern} _100kSats - * @property {AddressOutputsRealizedSupplyPattern} _1mSats - * @property {AddressOutputsRealizedSupplyPattern} _10mSats - * @property {AddressOutputsRealizedSupplyPattern} _1btc - * @property {AddressOutputsRealizedSupplyPattern} _10btc - * @property {AddressOutputsRealizedSupplyPattern} _100btc - * @property {AddressOutputsRealizedSupplyPattern} _1kBtc - * @property {AddressOutputsRealizedSupplyPattern} _10kBtc + * @typedef {Object} MetricsTree_Cohorts_Address_OverAmount + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1sat + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1mSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10mSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kBtc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kBtc */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Address_AmountRange - * @property {AddressOutputsRealizedSupplyPattern} _0sats - * @property {AddressOutputsRealizedSupplyPattern} _1satTo10sats - * @property {AddressOutputsRealizedSupplyPattern} _10satsTo100sats - * @property {AddressOutputsRealizedSupplyPattern} _100satsTo1kSats - * @property {AddressOutputsRealizedSupplyPattern} _1kSatsTo10kSats - * @property {AddressOutputsRealizedSupplyPattern} _10kSatsTo100kSats - * @property {AddressOutputsRealizedSupplyPattern} _100kSatsTo1mSats - * @property {AddressOutputsRealizedSupplyPattern} _1mSatsTo10mSats - * @property {AddressOutputsRealizedSupplyPattern} _10mSatsTo1btc - * @property {AddressOutputsRealizedSupplyPattern} _1btcTo10btc - * @property {AddressOutputsRealizedSupplyPattern} _10btcTo100btc - * @property {AddressOutputsRealizedSupplyPattern} _100btcTo1kBtc - * @property {AddressOutputsRealizedSupplyPattern} _1kBtcTo10kBtc - * @property {AddressOutputsRealizedSupplyPattern} _10kBtcTo100kBtc - * @property {AddressOutputsRealizedSupplyPattern} over100kBtc + * @typedef {Object} MetricsTree_Cohorts_Address_AmountRange + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _0sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1satTo10sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10satsTo100sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100satsTo1kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kSatsTo10kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kSatsTo100kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kSatsTo1mSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1mSatsTo10mSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10mSatsTo1btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1btcTo10btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10btcTo100btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100btcTo1kBtc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kBtcTo10kBtc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kBtcTo100kBtc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} over100kBtc */ /** - * @typedef {Object} MetricsTree_Distribution_Cohorts_Address_UnderAmount - * @property {AddressOutputsRealizedSupplyPattern} _10sats - * @property {AddressOutputsRealizedSupplyPattern} _100sats - * @property {AddressOutputsRealizedSupplyPattern} _1kSats - * @property {AddressOutputsRealizedSupplyPattern} _10kSats - * @property {AddressOutputsRealizedSupplyPattern} _100kSats - * @property {AddressOutputsRealizedSupplyPattern} _1mSats - * @property {AddressOutputsRealizedSupplyPattern} _10mSats - * @property {AddressOutputsRealizedSupplyPattern} _1btc - * @property {AddressOutputsRealizedSupplyPattern} _10btc - * @property {AddressOutputsRealizedSupplyPattern} _100btc - * @property {AddressOutputsRealizedSupplyPattern} _1kBtc - * @property {AddressOutputsRealizedSupplyPattern} _10kBtc - * @property {AddressOutputsRealizedSupplyPattern} _100kBtc - */ - -/** - * @typedef {Object} MetricsTree_Supply - * @property {BtcCentsSatsUsdPattern} circulating - * @property {MetricsTree_Supply_Burned} burned - * @property {BpsPercentRatioPattern} inflationRate - * @property {MetricsTree_Supply_Velocity} velocity - * @property {MetricsTree_Supply_MarketCap} marketCap - * @property {_1m1w1y24hPattern} marketMinusRealizedCapGrowthRate - * @property {BtcCentsSatsUsdPattern} hodledOrLost - */ - -/** - * @typedef {Object} MetricsTree_Supply_Burned - * @property {BaseCumulativeSumPattern} opreturn - * @property {BaseCumulativeSumPattern} unspendable - */ - -/** - * @typedef {Object} MetricsTree_Supply_Velocity - * @property {MetricPattern1} btc - * @property {MetricPattern1} usd - */ - -/** - * @typedef {Object} MetricsTree_Supply_MarketCap - * @property {MetricPattern1} cents - * @property {MetricPattern1} usd - * @property {ChangeRatePattern4} delta + * @typedef {Object} MetricsTree_Cohorts_Address_UnderAmount + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100sats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1mSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10mSats + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100btc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kBtc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kBtc + * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kBtc */ /** @@ -7458,9 +6897,8 @@ class BrkClient extends BrkClientBase { v3: createCumulativeRawSumPattern(this, 'tx_v3'), }, volume: { - sentSum: create_1m1w1y24hBtcCentsSatsUsdPattern(this, 'sent_sum'), - receivedSum: create_1m1w1y24hBtcCentsSatsUsdPattern(this, 'received_sum'), - annualized: createBtcCentsSatsUsdPattern(this, 'annualized_volume'), + sentSum: createCumulativeRawSumPattern3(this, 'sent_sum'), + receivedSum: createCumulativeRawSumPattern3(this, 'received_sum'), txPerSec: createMetricPattern1(this, 'tx_per_sec'), outputsPerSec: createMetricPattern1(this, 'outputs_per_sec'), inputsPerSec: createMetricPattern1(this, 'inputs_per_sec'), @@ -7531,6 +6969,58 @@ class BrkClient extends BrkClientBase { bytes: createMetricPattern24(this, 'p2abytes'), }, }, + indexes: { + p2a: createMetricPattern24(this, 'anyaddressindex'), + p2pk33: createMetricPattern26(this, 'anyaddressindex'), + p2pk65: createMetricPattern27(this, 'anyaddressindex'), + p2pkh: createMetricPattern28(this, 'anyaddressindex'), + p2sh: createMetricPattern29(this, 'anyaddressindex'), + p2tr: createMetricPattern30(this, 'anyaddressindex'), + p2wpkh: createMetricPattern31(this, 'anyaddressindex'), + p2wsh: createMetricPattern32(this, 'anyaddressindex'), + funded: createMetricPattern34(this, 'funded_address_index'), + empty: createMetricPattern35(this, 'empty_address_index'), + }, + data: { + funded: createMetricPattern34(this, 'fundedaddressdata'), + empty: createMetricPattern35(this, 'emptyaddressdata'), + }, + funded: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'address_count'), + empty: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'empty_address_count'), + activity: { + all: createBothReactivatedReceivingSendingPattern(this, 'address_activity'), + p2pk65: createBothReactivatedReceivingSendingPattern(this, 'p2pk65_address_activity'), + p2pk33: createBothReactivatedReceivingSendingPattern(this, 'p2pk33_address_activity'), + p2pkh: createBothReactivatedReceivingSendingPattern(this, 'p2pkh_address_activity'), + p2sh: createBothReactivatedReceivingSendingPattern(this, 'p2sh_address_activity'), + p2wpkh: createBothReactivatedReceivingSendingPattern(this, 'p2wpkh_address_activity'), + p2wsh: createBothReactivatedReceivingSendingPattern(this, 'p2wsh_address_activity'), + p2tr: createBothReactivatedReceivingSendingPattern(this, 'p2tr_address_activity'), + p2a: createBothReactivatedReceivingSendingPattern(this, 'p2a_address_activity'), + }, + total: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'total_address_count'), + new: { + all: createCumulativeRawSumPattern(this, 'new_address_count'), + p2pk65: createCumulativeRawSumPattern(this, 'p2pk65_new_address_count'), + p2pk33: createCumulativeRawSumPattern(this, 'p2pk33_new_address_count'), + p2pkh: createCumulativeRawSumPattern(this, 'p2pkh_new_address_count'), + p2sh: createCumulativeRawSumPattern(this, 'p2sh_new_address_count'), + p2wpkh: createCumulativeRawSumPattern(this, 'p2wpkh_new_address_count'), + p2wsh: createCumulativeRawSumPattern(this, 'p2wsh_new_address_count'), + p2tr: createCumulativeRawSumPattern(this, 'p2tr_new_address_count'), + p2a: createCumulativeRawSumPattern(this, 'p2a_new_address_count'), + }, + delta: { + all: createChangeRatePattern(this, 'address_count'), + p2pk65: createChangeRatePattern(this, 'p2pk65_address_count'), + p2pk33: createChangeRatePattern(this, 'p2pk33_address_count'), + p2pkh: createChangeRatePattern(this, 'p2pkh_address_count'), + p2sh: createChangeRatePattern(this, 'p2sh_address_count'), + p2wpkh: createChangeRatePattern(this, 'p2wpkh_address_count'), + p2wsh: createChangeRatePattern(this, 'p2wsh_address_count'), + p2tr: createChangeRatePattern(this, 'p2tr_address_count'), + p2a: createChangeRatePattern(this, 'p2a_address_count'), + }, }, scripts: { raw: { @@ -7579,7 +7069,7 @@ class BrkClient extends BrkClientBase { }, mining: { rewards: { - coinbase: createBaseCumulativeSumPattern(this, 'coinbase'), + coinbase: createCumulativeRawSumPattern3(this, 'coinbase'), subsidy: { base: createBtcCentsSatsUsdPattern(this, 'subsidy'), cumulative: createBtcCentsSatsUsdPattern(this, 'subsidy_cumulative'), @@ -7589,10 +7079,11 @@ class BrkClient extends BrkClientBase { fees: { base: createBtcCentsSatsUsdPattern(this, 'fees'), cumulative: createBtcCentsSatsUsdPattern(this, 'fees_cumulative'), - _24h: createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(this, 'fees_24h'), - _1w: createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(this, 'fees_1w'), - _1m: createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(this, 'fees_1m'), - _1y: createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(this, 'fees_1y'), + sum: create_1m1w1y24hPattern4(this, 'fees_sum'), + _24h: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(this, 'fees_24h'), + _1w: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(this, 'fees_1w'), + _1m: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(this, 'fees_1m'), + _1y: createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(this, 'fees_1y'), dominance: create_1m1w1y24hBpsPercentRatioPattern(this, 'fee_dominance'), ratioMultiple: { _24h: createBpsRatioPattern(this, 'fee_ratio_multiple_24h'), @@ -7601,7 +7092,7 @@ class BrkClient extends BrkClientBase { _1y: createBpsRatioPattern(this, 'fee_ratio_multiple_1y'), }, }, - unclaimed: createBaseCumulativeSumPattern(this, 'unclaimed_rewards'), + unclaimed: createCumulativeRawSumPattern3(this, 'unclaimed_rewards'), }, hashrate: { rate: { @@ -7619,10 +7110,6 @@ class BrkClient extends BrkClientBase { value: createPhsReboundThsPattern(this, 'hash_value'), }, }, - positions: { - block: createMetricPattern18(this, 'position'), - tx: createMetricPattern19(this, 'position'), - }, cointime: { activity: { coinblocksCreated: createCumulativeRawSumPattern(this, 'coinblocks_created'), @@ -7670,6 +7157,10 @@ class BrkClient extends BrkClientBase { vocddMedian1y: createMetricPattern18(this, 'vocdd_median_1y'), hodlBank: createMetricPattern18(this, 'hodl_bank'), }, + coinblocksDestroyed: { + raw: createMetricPattern1(this, 'coinblocks_destroyed'), + cumulative: createMetricPattern1(this, 'coinblocks_destroyed_cumulative'), + }, }, constants: { _0: createMetricPattern1(this, 'constant_0'), @@ -8299,461 +7790,380 @@ class BrkClient extends BrkClientBase { sats: createMetricPattern1(this, 'price_sats'), }, }, - distribution: { - supplyState: createMetricPattern18(this, 'supply_state'), - addresses: { - indexes: { - p2a: createMetricPattern24(this, 'anyaddressindex'), - p2pk33: createMetricPattern26(this, 'anyaddressindex'), - p2pk65: createMetricPattern27(this, 'anyaddressindex'), - p2pkh: createMetricPattern28(this, 'anyaddressindex'), - p2sh: createMetricPattern29(this, 'anyaddressindex'), - p2tr: createMetricPattern30(this, 'anyaddressindex'), - p2wpkh: createMetricPattern31(this, 'anyaddressindex'), - p2wsh: createMetricPattern32(this, 'anyaddressindex'), - funded: createMetricPattern34(this, 'funded_address_index'), - empty: createMetricPattern35(this, 'empty_address_index'), - }, - data: { - funded: createMetricPattern34(this, 'fundedaddressdata'), - empty: createMetricPattern35(this, 'emptyaddressdata'), - }, - funded: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'address_count'), - empty: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'empty_address_count'), - activity: { - all: createBothReactivatedReceivingSendingPattern(this, 'address_activity'), - p2pk65: createBothReactivatedReceivingSendingPattern(this, 'p2pk65_address_activity'), - p2pk33: createBothReactivatedReceivingSendingPattern(this, 'p2pk33_address_activity'), - p2pkh: createBothReactivatedReceivingSendingPattern(this, 'p2pkh_address_activity'), - p2sh: createBothReactivatedReceivingSendingPattern(this, 'p2sh_address_activity'), - p2wpkh: createBothReactivatedReceivingSendingPattern(this, 'p2wpkh_address_activity'), - p2wsh: createBothReactivatedReceivingSendingPattern(this, 'p2wsh_address_activity'), - p2tr: createBothReactivatedReceivingSendingPattern(this, 'p2tr_address_activity'), - p2a: createBothReactivatedReceivingSendingPattern(this, 'p2a_address_activity'), - }, - total: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'total_address_count'), - new: { - all: { - raw: createMetricPattern1(this, 'new_address_count'), - sum: create_1m1w1y24hPattern(this, 'new_address_count_sum'), - }, - p2pk65: { - raw: createMetricPattern1(this, 'p2pk65_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2pk65_new_address_count_sum'), - }, - p2pk33: { - raw: createMetricPattern1(this, 'p2pk33_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2pk33_new_address_count_sum'), - }, - p2pkh: { - raw: createMetricPattern1(this, 'p2pkh_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2pkh_new_address_count_sum'), - }, - p2sh: { - raw: createMetricPattern1(this, 'p2sh_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2sh_new_address_count_sum'), - }, - p2wpkh: { - raw: createMetricPattern1(this, 'p2wpkh_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2wpkh_new_address_count_sum'), - }, - p2wsh: { - raw: createMetricPattern1(this, 'p2wsh_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2wsh_new_address_count_sum'), - }, - p2tr: { - raw: createMetricPattern1(this, 'p2tr_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2tr_new_address_count_sum'), - }, - p2a: { - raw: createMetricPattern1(this, 'p2a_new_address_count'), - sum: create_1m1w1y24hPattern(this, 'p2a_new_address_count_sum'), - }, - }, - delta: { - all: createChangeRatePattern(this, 'address_count'), - p2pk65: createChangeRatePattern(this, 'p2pk65_address_count'), - p2pk33: createChangeRatePattern(this, 'p2pk33_address_count'), - p2pkh: createChangeRatePattern(this, 'p2pkh_address_count'), - p2sh: createChangeRatePattern(this, 'p2sh_address_count'), - p2wpkh: createChangeRatePattern(this, 'p2wpkh_address_count'), - p2wsh: createChangeRatePattern(this, 'p2wsh_address_count'), - p2tr: createChangeRatePattern(this, 'p2tr_address_count'), - p2a: createChangeRatePattern(this, 'p2a_address_count'), - }, - }, - cohorts: { - utxo: { - all: { - supply: { - delta: createChangeRatePattern(this, 'supply_delta'), - inProfit: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_profit'), - inLoss: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_loss'), - total: createBtcCentsSatsUsdPattern(this, 'supply'), - half: createBtcCentsSatsUsdPattern(this, 'supply_half'), - }, - outputs: createUnspentPattern3(this, 'utxo_count'), - activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, ''), - realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(this, ''), - costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, ''), - unrealized: { - grossPnl: createCentsUsdPattern(this, 'unrealized_gross_pnl'), - investedCapital: createInPattern2(this, 'invested_capital_in'), - sentiment: createGreedNetPainPattern(this, ''), - investorCap: createInPattern(this, 'investor_cap_in'), - loss: { - negative: createMetricPattern1(this, 'neg_unrealized_loss'), - raw: createCentsUsdPattern(this, 'unrealized_loss'), - sum: create_24hPattern(this, 'unrealized_loss_24h'), - relToMcap: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_mcap'), - relToOwnGross: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'), - }, - netPnl: { - cents: createMetricPattern1(this, 'net_unrealized_pnl_cents'), - usd: createMetricPattern1(this, 'net_unrealized_pnl'), - relToOwnGross: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), - }, - profit: { - raw: createCentsUsdPattern(this, 'unrealized_profit'), - sum: create_24hPattern(this, 'unrealized_profit_24h'), - relToMcap: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_mcap'), - relToOwnGross: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'), - }, - }, - }, - sth: { - realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(this, 'sth'), - supply: createDeltaHalfInRelTotalPattern2(this, 'sth_supply'), - outputs: createUnspentPattern3(this, 'sth_utxo_count'), - activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'sth'), - costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'sth'), - unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern2(this, 'sth'), - }, - lth: { - supply: createDeltaHalfInRelTotalPattern2(this, 'lth_supply'), - outputs: createUnspentPattern3(this, 'lth_utxo_count'), - activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'lth'), - realized: { - profit: createCumulativeDistributionRawRelSumValuePattern(this, 'lth'), - loss: createCapitulationCumulativeNegativeRawRelSumValuePattern(this, 'lth'), - grossPnl: createRawSellSumPattern(this, 'lth'), - netPnl: createChangeCumulativeDeltaRawRelSumPattern(this, 'lth_net'), - sopr: { - valueCreated: createRawSumPattern(this, 'lth_value_created'), - valueDestroyed: createRawSumPattern(this, 'lth_value_destroyed'), - ratio: create_1m1w1y24hPattern(this, 'lth_sopr'), - }, - peakRegret: createCumulativeRawRelPattern(this, 'lth_realized_peak_regret'), - investor: createCapLowerPriceUpperPattern(this, 'lth'), - profitToLossRatio: create_1m1w1y24hPattern(this, 'lth_realized_profit_to_loss_ratio'), - cap: createCentsDeltaRawRelUsdPattern(this, 'lth'), - price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(this, 'lth_realized_price'), - mvrv: createMetricPattern1(this, 'lth_mvrv'), - nupl: createBpsRatioPattern(this, 'lth_nupl_ratio'), - }, - costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'lth'), - unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern2(this, 'lth'), - }, - ageRange: { - under1h: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1h_old'), - _1hTo1d: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1h_to_1d_old'), - _1dTo1w: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1d_to_1w_old'), - _1wTo1m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1w_to_1m_old'), - _1mTo2m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1m_to_2m_old'), - _2mTo3m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_2m_to_3m_old'), - _3mTo4m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_3m_to_4m_old'), - _4mTo5m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_4m_to_5m_old'), - _5mTo6m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_5m_to_6m_old'), - _6mTo1y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_6m_to_1y_old'), - _1yTo2y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1y_to_2y_old'), - _2yTo3y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_2y_to_3y_old'), - _3yTo4y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_3y_to_4y_old'), - _4yTo5y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_4y_to_5y_old'), - _5yTo6y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_5y_to_6y_old'), - _6yTo7y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_6y_to_7y_old'), - _7yTo8y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_7y_to_8y_old'), - _8yTo10y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_8y_to_10y_old'), - _10yTo12y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10y_to_12y_old'), - _12yTo15y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_12y_to_15y_old'), - over15y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_15y_old'), - }, - underAge: { - _1w: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_1w_old'), - _1m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_1m_old'), - _2m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_2m_old'), - _3m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_3m_old'), - _4m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_4m_old'), - _5m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_5m_old'), - _6m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_6m_old'), - _1y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_1y_old'), - _2y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_2y_old'), - _3y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_3y_old'), - _4y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_4y_old'), - _5y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_5y_old'), - _6y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_6y_old'), - _7y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_7y_old'), - _8y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_8y_old'), - _10y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_10y_old'), - _12y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_12y_old'), - _15y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_under_15y_old'), - }, - overAge: { - _1d: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_1d_old'), - _1w: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_1w_old'), - _1m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_1m_old'), - _2m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_2m_old'), - _3m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_3m_old'), - _4m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_4m_old'), - _5m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_5m_old'), - _6m: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_6m_old'), - _1y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_1y_old'), - _2y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_2y_old'), - _3y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_3y_old'), - _4y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_4y_old'), - _5y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_5y_old'), - _6y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_6y_old'), - _7y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_7y_old'), - _8y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_8y_old'), - _10y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_10y_old'), - _12y: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'utxos_over_12y_old'), - }, - epoch: { - _0: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'epoch_0'), - _1: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'epoch_1'), - _2: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'epoch_2'), - _3: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'epoch_3'), - _4: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'epoch_4'), - }, - class: { - _2009: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2009'), - _2010: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2010'), - _2011: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2011'), - _2012: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2012'), - _2013: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2013'), - _2014: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2014'), - _2015: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2015'), - _2016: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2016'), - _2017: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2017'), - _2018: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2018'), - _2019: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2019'), - _2020: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2020'), - _2021: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2021'), - _2022: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2022'), - _2023: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2023'), - _2024: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2024'), - _2025: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2025'), - _2026: createActivityOutputsRealizedSupplyUnrealizedPattern2(this, 'class_2026'), - }, - overAmount: { - _1sat: createOutputsRealizedSupplyPattern(this, 'utxos_over_1sat'), - _10sats: createOutputsRealizedSupplyPattern(this, 'utxos_over_10sats'), - _100sats: createOutputsRealizedSupplyPattern(this, 'utxos_over_100sats'), - _1kSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_1k_sats'), - _10kSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_10k_sats'), - _100kSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_100k_sats'), - _1mSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_1m_sats'), - _10mSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_10m_sats'), - _1btc: createOutputsRealizedSupplyPattern(this, 'utxos_over_1btc'), - _10btc: createOutputsRealizedSupplyPattern(this, 'utxos_over_10btc'), - _100btc: createOutputsRealizedSupplyPattern(this, 'utxos_over_100btc'), - _1kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_over_1k_btc'), - _10kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_over_10k_btc'), - }, - amountRange: { - _0sats: createOutputsRealizedSupplyPattern(this, 'utxos_0sats'), - _1satTo10sats: createOutputsRealizedSupplyPattern(this, 'utxos_1sat_to_10sats'), - _10satsTo100sats: createOutputsRealizedSupplyPattern(this, 'utxos_10sats_to_100sats'), - _100satsTo1kSats: createOutputsRealizedSupplyPattern(this, 'utxos_100sats_to_1k_sats'), - _1kSatsTo10kSats: createOutputsRealizedSupplyPattern(this, 'utxos_1k_sats_to_10k_sats'), - _10kSatsTo100kSats: createOutputsRealizedSupplyPattern(this, 'utxos_10k_sats_to_100k_sats'), - _100kSatsTo1mSats: createOutputsRealizedSupplyPattern(this, 'utxos_100k_sats_to_1m_sats'), - _1mSatsTo10mSats: createOutputsRealizedSupplyPattern(this, 'utxos_1m_sats_to_10m_sats'), - _10mSatsTo1btc: createOutputsRealizedSupplyPattern(this, 'utxos_10m_sats_to_1btc'), - _1btcTo10btc: createOutputsRealizedSupplyPattern(this, 'utxos_1btc_to_10btc'), - _10btcTo100btc: createOutputsRealizedSupplyPattern(this, 'utxos_10btc_to_100btc'), - _100btcTo1kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_100btc_to_1k_btc'), - _1kBtcTo10kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_1k_btc_to_10k_btc'), - _10kBtcTo100kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_10k_btc_to_100k_btc'), - over100kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_over_100k_btc'), - }, - underAmount: { - _10sats: createOutputsRealizedSupplyPattern(this, 'utxos_under_10sats'), - _100sats: createOutputsRealizedSupplyPattern(this, 'utxos_under_100sats'), - _1kSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_1k_sats'), - _10kSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_10k_sats'), - _100kSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_100k_sats'), - _1mSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_1m_sats'), - _10mSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_10m_sats'), - _1btc: createOutputsRealizedSupplyPattern(this, 'utxos_under_1btc'), - _10btc: createOutputsRealizedSupplyPattern(this, 'utxos_under_10btc'), - _100btc: createOutputsRealizedSupplyPattern(this, 'utxos_under_100btc'), - _1kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_under_1k_btc'), - _10kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_under_10k_btc'), - _100kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_under_100k_btc'), - }, - type: { - p2pk65: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2pk65'), - p2pk33: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2pk33'), - p2pkh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2pkh'), - p2ms: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2ms'), - p2sh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2sh'), - p2wpkh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2wpkh'), - p2wsh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2wsh'), - p2tr: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2tr'), - p2a: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2a'), - unknown: createOutputsRealizedSupplyUnrealizedPattern(this, 'unknown_outputs'), - empty: createOutputsRealizedSupplyUnrealizedPattern(this, 'empty_outputs'), - }, - profitability: { - range: { - over1000pctInProfit: createRealizedSupplyPattern(this, 'utxos_over_1000pct_in_profit'), - _500pctTo1000pctInProfit: createRealizedSupplyPattern(this, 'utxos_500pct_to_1000pct_in_profit'), - _300pctTo500pctInProfit: createRealizedSupplyPattern(this, 'utxos_300pct_to_500pct_in_profit'), - _200pctTo300pctInProfit: createRealizedSupplyPattern(this, 'utxos_200pct_to_300pct_in_profit'), - _100pctTo200pctInProfit: createRealizedSupplyPattern(this, 'utxos_100pct_to_200pct_in_profit'), - _90pctTo100pctInProfit: createRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_profit'), - _80pctTo90pctInProfit: createRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_profit'), - _70pctTo80pctInProfit: createRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_profit'), - _60pctTo70pctInProfit: createRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_profit'), - _50pctTo60pctInProfit: createRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_profit'), - _40pctTo50pctInProfit: createRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_profit'), - _30pctTo40pctInProfit: createRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_profit'), - _20pctTo30pctInProfit: createRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_profit'), - _10pctTo20pctInProfit: createRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_profit'), - _0pctTo10pctInProfit: createRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_profit'), - _0pctTo10pctInLoss: createRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_loss'), - _10pctTo20pctInLoss: createRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_loss'), - _20pctTo30pctInLoss: createRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_loss'), - _30pctTo40pctInLoss: createRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_loss'), - _40pctTo50pctInLoss: createRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_loss'), - _50pctTo60pctInLoss: createRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_loss'), - _60pctTo70pctInLoss: createRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_loss'), - _70pctTo80pctInLoss: createRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_loss'), - _80pctTo90pctInLoss: createRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_loss'), - _90pctTo100pctInLoss: createRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_loss'), - }, - profit: { - breakeven: createRealizedSupplyPattern(this, 'utxos_in_profit'), - _10pct: createRealizedSupplyPattern(this, 'utxos_over_10pct_in_profit'), - _20pct: createRealizedSupplyPattern(this, 'utxos_over_20pct_in_profit'), - _30pct: createRealizedSupplyPattern(this, 'utxos_over_30pct_in_profit'), - _40pct: createRealizedSupplyPattern(this, 'utxos_over_40pct_in_profit'), - _50pct: createRealizedSupplyPattern(this, 'utxos_over_50pct_in_profit'), - _60pct: createRealizedSupplyPattern(this, 'utxos_over_60pct_in_profit'), - _70pct: createRealizedSupplyPattern(this, 'utxos_over_70pct_in_profit'), - _80pct: createRealizedSupplyPattern(this, 'utxos_over_80pct_in_profit'), - _90pct: createRealizedSupplyPattern(this, 'utxos_over_90pct_in_profit'), - _100pct: createRealizedSupplyPattern(this, 'utxos_over_100pct_in_profit'), - _200pct: createRealizedSupplyPattern(this, 'utxos_over_200pct_in_profit'), - _300pct: createRealizedSupplyPattern(this, 'utxos_over_300pct_in_profit'), - _500pct: createRealizedSupplyPattern(this, 'utxos_over_500pct_in_profit'), - }, - loss: { - breakeven: createRealizedSupplyPattern(this, 'utxos_in_loss'), - _10pct: createRealizedSupplyPattern(this, 'utxos_over_10pct_in_loss'), - _20pct: createRealizedSupplyPattern(this, 'utxos_over_20pct_in_loss'), - _30pct: createRealizedSupplyPattern(this, 'utxos_over_30pct_in_loss'), - _40pct: createRealizedSupplyPattern(this, 'utxos_over_40pct_in_loss'), - _50pct: createRealizedSupplyPattern(this, 'utxos_over_50pct_in_loss'), - _60pct: createRealizedSupplyPattern(this, 'utxos_over_60pct_in_loss'), - _70pct: createRealizedSupplyPattern(this, 'utxos_over_70pct_in_loss'), - _80pct: createRealizedSupplyPattern(this, 'utxos_over_80pct_in_loss'), - }, - }, - matured: { - under1h: createBtcCentsSatsUsdPattern(this, 'utxo_under_1h_old_matured'), - _1hTo1d: createBtcCentsSatsUsdPattern(this, 'utxo_1h_to_1d_old_matured'), - _1dTo1w: createBtcCentsSatsUsdPattern(this, 'utxo_1d_to_1w_old_matured'), - _1wTo1m: createBtcCentsSatsUsdPattern(this, 'utxo_1w_to_1m_old_matured'), - _1mTo2m: createBtcCentsSatsUsdPattern(this, 'utxo_1m_to_2m_old_matured'), - _2mTo3m: createBtcCentsSatsUsdPattern(this, 'utxo_2m_to_3m_old_matured'), - _3mTo4m: createBtcCentsSatsUsdPattern(this, 'utxo_3m_to_4m_old_matured'), - _4mTo5m: createBtcCentsSatsUsdPattern(this, 'utxo_4m_to_5m_old_matured'), - _5mTo6m: createBtcCentsSatsUsdPattern(this, 'utxo_5m_to_6m_old_matured'), - _6mTo1y: createBtcCentsSatsUsdPattern(this, 'utxo_6m_to_1y_old_matured'), - _1yTo2y: createBtcCentsSatsUsdPattern(this, 'utxo_1y_to_2y_old_matured'), - _2yTo3y: createBtcCentsSatsUsdPattern(this, 'utxo_2y_to_3y_old_matured'), - _3yTo4y: createBtcCentsSatsUsdPattern(this, 'utxo_3y_to_4y_old_matured'), - _4yTo5y: createBtcCentsSatsUsdPattern(this, 'utxo_4y_to_5y_old_matured'), - _5yTo6y: createBtcCentsSatsUsdPattern(this, 'utxo_5y_to_6y_old_matured'), - _6yTo7y: createBtcCentsSatsUsdPattern(this, 'utxo_6y_to_7y_old_matured'), - _7yTo8y: createBtcCentsSatsUsdPattern(this, 'utxo_7y_to_8y_old_matured'), - _8yTo10y: createBtcCentsSatsUsdPattern(this, 'utxo_8y_to_10y_old_matured'), - _10yTo12y: createBtcCentsSatsUsdPattern(this, 'utxo_10y_to_12y_old_matured'), - _12yTo15y: createBtcCentsSatsUsdPattern(this, 'utxo_12y_to_15y_old_matured'), - over15y: createBtcCentsSatsUsdPattern(this, 'utxo_over_15y_old_matured'), - }, - }, - address: { - overAmount: { - _1sat: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_1sat'), - _10sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_10sats'), - _100sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_100sats'), - _1kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_1k_sats'), - _10kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_10k_sats'), - _100kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_100k_sats'), - _1mSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_1m_sats'), - _10mSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_10m_sats'), - _1btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_1btc'), - _10btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_10btc'), - _100btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_100btc'), - _1kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_1k_btc'), - _10kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_10k_btc'), - }, - amountRange: { - _0sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_0sats'), - _1satTo10sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_1sat_to_10sats'), - _10satsTo100sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_10sats_to_100sats'), - _100satsTo1kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_100sats_to_1k_sats'), - _1kSatsTo10kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_1k_sats_to_10k_sats'), - _10kSatsTo100kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_10k_sats_to_100k_sats'), - _100kSatsTo1mSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_100k_sats_to_1m_sats'), - _1mSatsTo10mSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_1m_sats_to_10m_sats'), - _10mSatsTo1btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_10m_sats_to_1btc'), - _1btcTo10btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_1btc_to_10btc'), - _10btcTo100btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_10btc_to_100btc'), - _100btcTo1kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_100btc_to_1k_btc'), - _1kBtcTo10kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_1k_btc_to_10k_btc'), - _10kBtcTo100kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_10k_btc_to_100k_btc'), - over100kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_over_100k_btc'), - }, - underAmount: { - _10sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_10sats'), - _100sats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_100sats'), - _1kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_1k_sats'), - _10kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_10k_sats'), - _100kSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_100k_sats'), - _1mSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_1m_sats'), - _10mSats: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_10m_sats'), - _1btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_1btc'), - _10btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_10btc'), - _100btc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_100btc'), - _1kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_1k_btc'), - _10kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_10k_btc'), - _100kBtc: createAddressOutputsRealizedSupplyPattern(this, 'addrs_under_100k_btc'), - }, - }, - }, - coinblocksDestroyed: createCumulativeRawPattern(this, 'coinblocks_destroyed'), - }, supply: { circulating: createBtcCentsSatsUsdPattern(this, 'circulating_supply'), burned: { - opreturn: createBaseCumulativeSumPattern(this, 'opreturn_supply'), - unspendable: createBaseCumulativeSumPattern(this, 'unspendable_supply'), + opreturn: createCumulativeRawSumPattern3(this, 'opreturn_supply'), + unspendable: createCumulativeRawSumPattern3(this, 'unspendable_supply'), }, inflationRate: createBpsPercentRatioPattern(this, 'inflation_rate'), velocity: { btc: createMetricPattern1(this, 'velocity_btc'), usd: createMetricPattern1(this, 'velocity_usd'), }, - marketCap: { - cents: createMetricPattern1(this, 'market_cap_cents'), - usd: createMetricPattern1(this, 'market_cap'), - delta: createChangeRatePattern4(this, 'market_cap_delta'), - }, + marketCap: createCentsDeltaUsdPattern(this, 'market_cap'), marketMinusRealizedCapGrowthRate: create_1m1w1y24hPattern(this, 'market_minus_realized_cap_growth_rate'), hodledOrLost: createBtcCentsSatsUsdPattern(this, 'hodled_or_lost_coins'), + state: createMetricPattern18(this, 'supply_state'), + }, + cohorts: { + utxo: { + all: { + supply: { + delta: createChangeRatePattern(this, 'supply_delta'), + inProfit: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_profit'), + inLoss: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_loss'), + total: createBtcCentsSatsUsdPattern(this, 'supply'), + half: createBtcCentsSatsUsdPattern(this, 'supply_half'), + }, + outputs: createUnspentPattern2(this, 'utxo_count'), + activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, ''), + realized: createCapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(this, ''), + costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, ''), + unrealized: { + grossPnl: createCentsUsdPattern(this, 'unrealized_gross_pnl'), + investedCapital: createInPattern(this, 'invested_capital_in'), + sentiment: createGreedNetPainPattern(this, ''), + loss: { + negative: createMetricPattern1(this, 'neg_unrealized_loss'), + raw: createCentsUsdPattern(this, 'unrealized_loss'), + cumulative: createMetricPattern1(this, 'unrealized_loss_cumulative'), + sum: create_1m1w1y24hPattern3(this, 'unrealized_loss_sum'), + relToMcap: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_mcap'), + relToOwnGross: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'), + }, + netPnl: { + cents: createMetricPattern1(this, 'net_unrealized_pnl_cents'), + usd: createMetricPattern1(this, 'net_unrealized_pnl'), + relToOwnGross: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), + }, + profit: { + raw: createCentsUsdPattern(this, 'unrealized_profit'), + cumulative: createMetricPattern1(this, 'unrealized_profit_cumulative'), + sum: create_1m1w1y24hPattern3(this, 'unrealized_profit_sum'), + relToMcap: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_mcap'), + relToOwnGross: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'), + }, + nupl: createBpsRatioPattern(this, 'nupl'), + }, + }, + sth: { + realized: createCapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(this, 'sth'), + supply: createDeltaHalfInRelTotalPattern2(this, 'sth_supply'), + outputs: createUnspentPattern2(this, 'sth_utxo_count'), + activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'sth'), + costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'sth'), + unrealized: createGrossInvestedLossNetNuplProfitSentimentPattern2(this, 'sth'), + }, + lth: { + supply: createDeltaHalfInRelTotalPattern2(this, 'lth_supply'), + outputs: createUnspentPattern2(this, 'lth_utxo_count'), + activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'lth'), + realized: { + profit: createCumulativeDistributionRawRelSumValuePattern(this, 'lth'), + loss: createCapitulationCumulativeNegativeRawRelSumValuePattern(this, 'lth'), + grossPnl: createCumulativeRawSumPattern2(this, 'lth_realized_gross_pnl'), + sellSideRiskRatio: { + _24h: createBpsPercentRatioPattern(this, 'lth_sell_side_risk_ratio_24h'), + _1w: createBpsPercentRatioPattern(this, 'lth_sell_side_risk_ratio_1w'), + _1m: createBpsPercentRatioPattern(this, 'lth_sell_side_risk_ratio_1m'), + _1y: createBpsPercentRatioPattern(this, 'lth_sell_side_risk_ratio_1y'), + }, + netPnl: createChangeCumulativeDeltaRawRelSumPattern(this, 'lth_net'), + sopr: { + ratio: create_1m1w1y24hPattern(this, 'lth_sopr'), + valueCreated: createCumulativeRawSumPattern(this, 'lth_value_created'), + valueDestroyed: createCumulativeRawSumPattern(this, 'lth_value_destroyed'), + }, + peakRegret: createCumulativeRawRelPattern(this, 'lth_realized_peak_regret'), + investor: createLowerPriceUpperPattern(this, 'lth'), + profitToLossRatio: create_1m1w1y24hPattern(this, 'lth_realized_profit_to_loss_ratio'), + cap: createCentsDeltaRelUsdPattern(this, 'lth_realized_cap'), + price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(this, 'lth_realized_price'), + mvrv: createMetricPattern1(this, 'lth_mvrv'), + }, + costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'lth'), + unrealized: createGrossInvestedLossNetNuplProfitSentimentPattern2(this, 'lth'), + }, + ageRange: { + under1h: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1h_old'), + _1hTo1d: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1h_to_1d_old'), + _1dTo1w: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1d_to_1w_old'), + _1wTo1m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1w_to_1m_old'), + _1mTo2m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1m_to_2m_old'), + _2mTo3m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_2m_to_3m_old'), + _3mTo4m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_3m_to_4m_old'), + _4mTo5m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_4m_to_5m_old'), + _5mTo6m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_5m_to_6m_old'), + _6mTo1y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_6m_to_1y_old'), + _1yTo2y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1y_to_2y_old'), + _2yTo3y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_2y_to_3y_old'), + _3yTo4y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_3y_to_4y_old'), + _4yTo5y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_4y_to_5y_old'), + _5yTo6y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_5y_to_6y_old'), + _6yTo7y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_6y_to_7y_old'), + _7yTo8y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_7y_to_8y_old'), + _8yTo10y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_8y_to_10y_old'), + _10yTo12y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10y_to_12y_old'), + _12yTo15y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_12y_to_15y_old'), + over15y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_15y_old'), + }, + underAge: { + _1w: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1w_old'), + _1m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1m_old'), + _2m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_2m_old'), + _3m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_3m_old'), + _4m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_4m_old'), + _5m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_5m_old'), + _6m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_6m_old'), + _1y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1y_old'), + _2y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_2y_old'), + _3y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_3y_old'), + _4y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_4y_old'), + _5y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_5y_old'), + _6y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_6y_old'), + _7y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_7y_old'), + _8y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_8y_old'), + _10y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10y_old'), + _12y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_12y_old'), + _15y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_15y_old'), + }, + overAge: { + _1d: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1d_old'), + _1w: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1w_old'), + _1m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1m_old'), + _2m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_2m_old'), + _3m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_3m_old'), + _4m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_4m_old'), + _5m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_5m_old'), + _6m: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_6m_old'), + _1y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1y_old'), + _2y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_2y_old'), + _3y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_3y_old'), + _4y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_4y_old'), + _5y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_5y_old'), + _6y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_6y_old'), + _7y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_7y_old'), + _8y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_8y_old'), + _10y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10y_old'), + _12y: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_12y_old'), + }, + epoch: { + _0: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'epoch_0'), + _1: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'epoch_1'), + _2: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'epoch_2'), + _3: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'epoch_3'), + _4: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'epoch_4'), + }, + class: { + _2009: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2009'), + _2010: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2010'), + _2011: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2011'), + _2012: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2012'), + _2013: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2013'), + _2014: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2014'), + _2015: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2015'), + _2016: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2016'), + _2017: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2017'), + _2018: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2018'), + _2019: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2019'), + _2020: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2020'), + _2021: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2021'), + _2022: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2022'), + _2023: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2023'), + _2024: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2024'), + _2025: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2025'), + _2026: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'class_2026'), + }, + overAmount: { + _1sat: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1sat'), + _10sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10sats'), + _100sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100sats'), + _1kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1k_sats'), + _10kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10k_sats'), + _100kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100k_sats'), + _1mSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1m_sats'), + _10mSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10m_sats'), + _1btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1btc'), + _10btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10btc'), + _100btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100btc'), + _1kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1k_btc'), + _10kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10k_btc'), + }, + amountRange: { + _0sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_0sats'), + _1satTo10sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1sat_to_10sats'), + _10satsTo100sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10sats_to_100sats'), + _100satsTo1kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_100sats_to_1k_sats'), + _1kSatsTo10kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1k_sats_to_10k_sats'), + _10kSatsTo100kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10k_sats_to_100k_sats'), + _100kSatsTo1mSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_100k_sats_to_1m_sats'), + _1mSatsTo10mSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1m_sats_to_10m_sats'), + _10mSatsTo1btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10m_sats_to_1btc'), + _1btcTo10btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1btc_to_10btc'), + _10btcTo100btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10btc_to_100btc'), + _100btcTo1kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_100btc_to_1k_btc'), + _1kBtcTo10kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_1k_btc_to_10k_btc'), + _10kBtcTo100kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_10k_btc_to_100k_btc'), + over100kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100k_btc'), + }, + underAmount: { + _10sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10sats'), + _100sats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100sats'), + _1kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1k_sats'), + _10kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10k_sats'), + _100kSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100k_sats'), + _1mSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1m_sats'), + _10mSats: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10m_sats'), + _1btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1btc'), + _10btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10btc'), + _100btc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100btc'), + _1kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1k_btc'), + _10kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10k_btc'), + _100kBtc: createOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100k_btc'), + }, + type: { + p2pk65: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2pk65'), + p2pk33: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2pk33'), + p2pkh: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2pkh'), + p2ms: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2ms'), + p2sh: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2sh'), + p2wpkh: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2wpkh'), + p2wsh: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2wsh'), + p2tr: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2tr'), + p2a: createOutputsRealizedSupplyUnrealizedPattern2(this, 'p2a'), + unknown: createOutputsRealizedSupplyUnrealizedPattern2(this, 'unknown_outputs'), + empty: createOutputsRealizedSupplyUnrealizedPattern2(this, 'empty_outputs'), + }, + profitability: { + range: { + over1000pctInProfit: createRealizedSupplyPattern(this, 'utxos_over_1000pct_in_profit'), + _500pctTo1000pctInProfit: createRealizedSupplyPattern(this, 'utxos_500pct_to_1000pct_in_profit'), + _300pctTo500pctInProfit: createRealizedSupplyPattern(this, 'utxos_300pct_to_500pct_in_profit'), + _200pctTo300pctInProfit: createRealizedSupplyPattern(this, 'utxos_200pct_to_300pct_in_profit'), + _100pctTo200pctInProfit: createRealizedSupplyPattern(this, 'utxos_100pct_to_200pct_in_profit'), + _90pctTo100pctInProfit: createRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_profit'), + _80pctTo90pctInProfit: createRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_profit'), + _70pctTo80pctInProfit: createRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_profit'), + _60pctTo70pctInProfit: createRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_profit'), + _50pctTo60pctInProfit: createRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_profit'), + _40pctTo50pctInProfit: createRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_profit'), + _30pctTo40pctInProfit: createRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_profit'), + _20pctTo30pctInProfit: createRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_profit'), + _10pctTo20pctInProfit: createRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_profit'), + _0pctTo10pctInProfit: createRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_profit'), + _0pctTo10pctInLoss: createRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_loss'), + _10pctTo20pctInLoss: createRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_loss'), + _20pctTo30pctInLoss: createRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_loss'), + _30pctTo40pctInLoss: createRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_loss'), + _40pctTo50pctInLoss: createRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_loss'), + _50pctTo60pctInLoss: createRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_loss'), + _60pctTo70pctInLoss: createRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_loss'), + _70pctTo80pctInLoss: createRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_loss'), + _80pctTo90pctInLoss: createRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_loss'), + _90pctTo100pctInLoss: createRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_loss'), + }, + profit: { + breakeven: createRealizedSupplyPattern(this, 'utxos_in_profit'), + _10pct: createRealizedSupplyPattern(this, 'utxos_over_10pct_in_profit'), + _20pct: createRealizedSupplyPattern(this, 'utxos_over_20pct_in_profit'), + _30pct: createRealizedSupplyPattern(this, 'utxos_over_30pct_in_profit'), + _40pct: createRealizedSupplyPattern(this, 'utxos_over_40pct_in_profit'), + _50pct: createRealizedSupplyPattern(this, 'utxos_over_50pct_in_profit'), + _60pct: createRealizedSupplyPattern(this, 'utxos_over_60pct_in_profit'), + _70pct: createRealizedSupplyPattern(this, 'utxos_over_70pct_in_profit'), + _80pct: createRealizedSupplyPattern(this, 'utxos_over_80pct_in_profit'), + _90pct: createRealizedSupplyPattern(this, 'utxos_over_90pct_in_profit'), + _100pct: createRealizedSupplyPattern(this, 'utxos_over_100pct_in_profit'), + _200pct: createRealizedSupplyPattern(this, 'utxos_over_200pct_in_profit'), + _300pct: createRealizedSupplyPattern(this, 'utxos_over_300pct_in_profit'), + _500pct: createRealizedSupplyPattern(this, 'utxos_over_500pct_in_profit'), + }, + loss: { + breakeven: createRealizedSupplyPattern(this, 'utxos_in_loss'), + _10pct: createRealizedSupplyPattern(this, 'utxos_over_10pct_in_loss'), + _20pct: createRealizedSupplyPattern(this, 'utxos_over_20pct_in_loss'), + _30pct: createRealizedSupplyPattern(this, 'utxos_over_30pct_in_loss'), + _40pct: createRealizedSupplyPattern(this, 'utxos_over_40pct_in_loss'), + _50pct: createRealizedSupplyPattern(this, 'utxos_over_50pct_in_loss'), + _60pct: createRealizedSupplyPattern(this, 'utxos_over_60pct_in_loss'), + _70pct: createRealizedSupplyPattern(this, 'utxos_over_70pct_in_loss'), + _80pct: createRealizedSupplyPattern(this, 'utxos_over_80pct_in_loss'), + }, + }, + matured: { + under1h: createBtcCentsSatsUsdPattern(this, 'utxo_under_1h_old_matured'), + _1hTo1d: createBtcCentsSatsUsdPattern(this, 'utxo_1h_to_1d_old_matured'), + _1dTo1w: createBtcCentsSatsUsdPattern(this, 'utxo_1d_to_1w_old_matured'), + _1wTo1m: createBtcCentsSatsUsdPattern(this, 'utxo_1w_to_1m_old_matured'), + _1mTo2m: createBtcCentsSatsUsdPattern(this, 'utxo_1m_to_2m_old_matured'), + _2mTo3m: createBtcCentsSatsUsdPattern(this, 'utxo_2m_to_3m_old_matured'), + _3mTo4m: createBtcCentsSatsUsdPattern(this, 'utxo_3m_to_4m_old_matured'), + _4mTo5m: createBtcCentsSatsUsdPattern(this, 'utxo_4m_to_5m_old_matured'), + _5mTo6m: createBtcCentsSatsUsdPattern(this, 'utxo_5m_to_6m_old_matured'), + _6mTo1y: createBtcCentsSatsUsdPattern(this, 'utxo_6m_to_1y_old_matured'), + _1yTo2y: createBtcCentsSatsUsdPattern(this, 'utxo_1y_to_2y_old_matured'), + _2yTo3y: createBtcCentsSatsUsdPattern(this, 'utxo_2y_to_3y_old_matured'), + _3yTo4y: createBtcCentsSatsUsdPattern(this, 'utxo_3y_to_4y_old_matured'), + _4yTo5y: createBtcCentsSatsUsdPattern(this, 'utxo_4y_to_5y_old_matured'), + _5yTo6y: createBtcCentsSatsUsdPattern(this, 'utxo_5y_to_6y_old_matured'), + _6yTo7y: createBtcCentsSatsUsdPattern(this, 'utxo_6y_to_7y_old_matured'), + _7yTo8y: createBtcCentsSatsUsdPattern(this, 'utxo_7y_to_8y_old_matured'), + _8yTo10y: createBtcCentsSatsUsdPattern(this, 'utxo_8y_to_10y_old_matured'), + _10yTo12y: createBtcCentsSatsUsdPattern(this, 'utxo_10y_to_12y_old_matured'), + _12yTo15y: createBtcCentsSatsUsdPattern(this, 'utxo_12y_to_15y_old_matured'), + over15y: createBtcCentsSatsUsdPattern(this, 'utxo_over_15y_old_matured'), + }, + }, + address: { + overAmount: { + _1sat: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1sat'), + _10sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10sats'), + _100sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100sats'), + _1kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_sats'), + _10kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_sats'), + _100kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_sats'), + _1mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1m_sats'), + _10mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10m_sats'), + _1btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1btc'), + _10btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10btc'), + _100btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100btc'), + _1kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_btc'), + _10kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_btc'), + }, + amountRange: { + _0sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_0sats'), + _1satTo10sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1sat_to_10sats'), + _10satsTo100sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10sats_to_100sats'), + _100satsTo1kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100sats_to_1k_sats'), + _1kSatsTo10kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1k_sats_to_10k_sats'), + _10kSatsTo100kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10k_sats_to_100k_sats'), + _100kSatsTo1mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100k_sats_to_1m_sats'), + _1mSatsTo10mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1m_sats_to_10m_sats'), + _10mSatsTo1btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10m_sats_to_1btc'), + _1btcTo10btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1btc_to_10btc'), + _10btcTo100btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10btc_to_100btc'), + _100btcTo1kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100btc_to_1k_btc'), + _1kBtcTo10kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1k_btc_to_10k_btc'), + _10kBtcTo100kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10k_btc_to_100k_btc'), + over100kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_btc'), + }, + underAmount: { + _10sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10sats'), + _100sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100sats'), + _1kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_sats'), + _10kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_sats'), + _100kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_sats'), + _1mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1m_sats'), + _10mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10m_sats'), + _1btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1btc'), + _10btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10btc'), + _100btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100btc'), + _1kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_btc'), + _10kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_btc'), + _100kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_btc'), + }, + }, }, }; } diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index c70dd9e94..b26c9a354 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -45,8 +45,6 @@ BasisPointsSigned16 = int BasisPointsSigned32 = int # Bitcoin amount as floating point (1 BTC = 100,000,000 satoshis) Bitcoin = float -# Position within a .blk file, encoding file index and byte offset -BlkPosition = int # Block height Height = int # UNIX timestamp in seconds @@ -2204,22 +2202,22 @@ class _10y1m1w1y2y3m3y4y5y6m6y8yPattern3: self._6y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '6y')) self._8y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '8y')) -class CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern: +class CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.cap: CentsDeltaRawRelUsdPattern = CentsDeltaRawRelUsdPattern(client, acc) - self.gross_pnl: RawSellSumPattern = RawSellSumPattern(client, acc) - self.investor: CapLowerPriceUpperPattern = CapLowerPriceUpperPattern(client, acc) + self.cap: CentsDeltaRelUsdPattern = CentsDeltaRelUsdPattern(client, _m(acc, 'realized_cap')) + self.gross_pnl: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_gross_pnl')) + self.investor: LowerPriceUpperPattern = LowerPriceUpperPattern(client, acc) self.loss: CapitulationCumulativeNegativeRawRelSumValuePattern = CapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) self.net_pnl: ChangeCumulativeDeltaRawRelSumPattern = ChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) self.peak_regret: CumulativeRawRelPattern = CumulativeRawRelPattern(client, _m(acc, 'realized_peak_regret')) self.price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern = BpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, _m(acc, 'realized_price')) self.profit: CumulativeDistributionRawRelSumValuePattern = CumulativeDistributionRawRelSumValuePattern(client, acc) self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')) + self.sell_side_risk_ratio: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')) self.sopr: AdjustedRatioValuePattern = AdjustedRatioValuePattern(client, acc) class AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern: @@ -2287,21 +2285,6 @@ class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3: self.p2wpkh: MetricPattern1[StoredU64] = MetricPattern1(client, _p('p2wpkh', acc)) self.p2wsh: MetricPattern1[StoredU64] = MetricPattern1(client, _p('p2wsh', acc)) -class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.average: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'average')) - self.max: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'max')) - self.median: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'median')) - self.min: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'min')) - self.pct10: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct10')) - self.pct25: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct25')) - self.pct75: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct75')) - self.pct90: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct90')) - self.sum: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'sum')) - class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern: """Pattern struct for repeated tree structure.""" @@ -2317,19 +2300,19 @@ class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern: self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct90')) self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'sum')) -class _1m1w1y24hBtcCentsSatsUsdPattern: +class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self._1m: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1m')) - self._1w: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1w')) - self._1y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1y')) - self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) - self.btc: MetricPattern18[Bitcoin] = MetricPattern18(client, acc) - self.cents: MetricPattern18[Cents] = MetricPattern18(client, _m(acc, 'cents')) - self.sats: MetricPattern18[Sats] = MetricPattern18(client, _m(acc, 'sats')) - self.usd: MetricPattern18[Dollars] = MetricPattern18(client, _m(acc, 'usd')) + self.average: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'average')) + self.max: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'max')) + self.median: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'median')) + self.min: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'min')) + self.pct10: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct10')) + self.pct25: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct25')) + self.pct75: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct75')) + self.pct90: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct90')) class BpsCentsPercentilesRatioSatsSmaStdUsdPattern: """Pattern struct for repeated tree structure.""" @@ -2345,20 +2328,6 @@ class BpsCentsPercentilesRatioSatsSmaStdUsdPattern: self.std_dev: _1y2y4yAllPattern = _1y2y4yAllPattern(client, _m(acc, 'ratio')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) -class CapLossMvrvNetNuplPriceProfitSoprPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, _m(acc, 'realized_cap')) - self.loss: CumulativeNegativeRawSumPattern = CumulativeNegativeRawSumPattern(client, acc) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.net_pnl: RawSumPattern3[CentsSigned] = RawSumPattern3(client, _m(acc, 'net_realized_pnl')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) - self.price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) - self.profit: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_profit')) - self.sopr: RatioValuePattern = RatioValuePattern(client, acc) - class CapitulationCumulativeNegativeRawRelSumValuePattern: """Pattern struct for repeated tree structure.""" @@ -2369,11 +2338,11 @@ class CapitulationCumulativeNegativeRawRelSumValuePattern: self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_loss')) self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_rcap')) - self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'realized_loss')) - self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'loss_value_created')) - self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'loss_value_destroyed')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'realized_loss_sum')) + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'loss_value_created')) + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'loss_value_destroyed')) -class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(Generic[T]): +class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2(Generic[T]): """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2413,18 +2382,18 @@ class _1m1w1y24hBpsPercentRatioPattern: self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, acc) self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) -class CapLossMvrvNuplPriceProfitSoprPattern: +class CapLossMvrvNetPriceProfitSoprPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.cap: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_cap')) - self.loss: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'realized_loss')) + self.cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, _m(acc, 'realized_cap')) + self.loss: CumulativeNegativeRawSumPattern = CumulativeNegativeRawSumPattern(client, acc) self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) + self.net_pnl: CumulativeRawSumPattern[CentsSigned] = CumulativeRawSumPattern(client, _m(acc, 'net_realized_pnl')) self.price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) - self.profit: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'realized_profit')) - self.sopr: ValuePattern = ValuePattern(client, _m(acc, 'value')) + self.profit: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_profit')) + self.sopr: RatioValuePattern = RatioValuePattern(client, acc) class CumulativeDistributionRawRelSumValuePattern: """Pattern struct for repeated tree structure.""" @@ -2432,24 +2401,37 @@ class CumulativeDistributionRawRelSumValuePattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_cumulative')) - self.distribution_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'profit_flow')) + self.distribution_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'distribution_flow')) self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_profit')) self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_rcap')) - self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'realized_profit')) - self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'profit_value_created')) - self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'profit_value_destroyed')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'realized_profit_sum')) + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'profit_value_created')) + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'profit_value_destroyed')) -class GrossInvestedInvestorLossNetProfitSentimentPattern2: +class CumulativeNegativeRawRelSumPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'unrealized_loss_cumulative')) + self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) + self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) + self.rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_mcap')) + self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')) + self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_mcap')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'unrealized_loss_sum')) + +class GrossInvestedLossNetNuplProfitSentimentPattern2: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')) - self.invested_capital: InPattern2 = InPattern2(client, _m(acc, 'invested_capital_in')) - self.investor_cap: InPattern = InPattern(client, _m(acc, 'investor_cap_in')) - self.loss: NegativeRawRelSumPattern2 = NegativeRawRelSumPattern2(client, acc) + self.invested_capital: InPattern = InPattern(client, _m(acc, 'invested_capital_in')) + self.loss: CumulativeNegativeRawRelSumPattern2 = CumulativeNegativeRawRelSumPattern2(client, acc) self.net_pnl: CentsRelUsdPattern2 = CentsRelUsdPattern2(client, _m(acc, 'net_unrealized_pnl')) - self.profit: RawRelSumPattern2 = RawRelSumPattern2(client, _m(acc, 'unrealized_profit')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.profit: CumulativeRawRelSumPattern2 = CumulativeRawRelSumPattern2(client, _m(acc, 'unrealized_profit')) self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, acc) class _1m1w1y2y4yAllPattern: @@ -2488,6 +2470,18 @@ class BtcCentsRelSatsUsdPattern3: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) +class CapLossMvrvPriceProfitSoprPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cap: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_cap')) + self.loss: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_loss')) + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) + self.profit: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_profit')) + self.sopr: ValuePattern = ValuePattern(client, _m(acc, 'value')) + class ChangeCumulativeDeltaRawRelSumPattern: """Pattern struct for repeated tree structure.""" @@ -2495,10 +2489,34 @@ class ChangeCumulativeDeltaRawRelSumPattern: """Create pattern node with accumulated metric name.""" self.change_1m: RelPattern = RelPattern(client, _m(acc, 'pnl_change_1m_rel_to')) self.cumulative: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_pnl_cumulative')) - self.delta: ChangeRatePattern4 = ChangeRatePattern4(client, _m(acc, 'pnl_delta')) + self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'pnl_delta')) self.raw: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_pnl')) self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_pnl_rel_to_rcap')) - self.sum: _1m1w1y24hPattern[CentsSigned] = _1m1w1y24hPattern(client, _m(acc, 'realized_pnl')) + self.sum: _1m1w1y24hPattern[CentsSigned] = _1m1w1y24hPattern(client, _m(acc, 'realized_pnl_sum')) + +class CumulativeRawRelSumPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cumulative')) + self.raw: CentsUsdPattern = CentsUsdPattern(client, acc) + self.rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_mcap')) + self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_gross_pnl')) + self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'sum')) + +class DeltaHalfInRelTotalPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) + self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'half')) + self.in_loss: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'in_loss')) + self.in_profit: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'in_profit')) + self.rel_to_circulating: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating')) + self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) class DeltaHalfInRelTotalPattern2: """Pattern struct for repeated tree structure.""" @@ -2512,30 +2530,6 @@ class DeltaHalfInRelTotalPattern2: self.rel_to_circulating: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) -class DeltaHalfInRelTotalPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) - self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'half')) - self.in_loss: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'in_loss')) - self.in_profit: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'in_profit')) - self.rel_to_circulating: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating')) - self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - -class NegativeRawRelSumPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_mcap')) - self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')) - self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_mcap')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) - class Pct1Pct2Pct5Pct95Pct98Pct99Pattern: """Pattern struct for repeated tree structure.""" @@ -2555,20 +2549,20 @@ class ActivityOutputsRealizedSupplyUnrealizedPattern: """Create pattern node with accumulated metric name.""" self.activity: CoindaysSentPattern = CoindaysSentPattern(client, acc) self.outputs: UnspentPattern2 = UnspentPattern2(client, _m(acc, 'utxo_count')) - self.realized: CapLossMvrvNetNuplPriceProfitSoprPattern = CapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) + self.realized: CapLossMvrvNetPriceProfitSoprPattern = CapLossMvrvNetPriceProfitSoprPattern(client, acc) self.supply: DeltaHalfInRelTotalPattern = DeltaHalfInRelTotalPattern(client, _m(acc, 'supply')) - self.unrealized: InvestedInvestorLossNetProfitPattern = InvestedInvestorLossNetProfitPattern(client, acc) + self.unrealized: LossNetNuplProfitPattern = LossNetNuplProfitPattern(client, acc) -class ActivityOutputsRealizedSupplyUnrealizedPattern2: +class AddressOutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.activity: CoindaysSentPattern = CoindaysSentPattern(client, acc) - self.outputs: UnspentPattern2 = UnspentPattern2(client, _m(acc, 'utxo_count')) - self.realized: CapLossMvrvNetNuplPriceProfitSoprPattern = CapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) - self.supply: DeltaHalfInRelTotalPattern = DeltaHalfInRelTotalPattern(client, _m(acc, 'supply')) - self.unrealized: LossNetProfitPattern = LossNetProfitPattern(client, acc) + self.address_count: DeltaInnerPattern = DeltaInnerPattern(client, _m(acc, 'address_count')) + self.outputs: UnspentPattern = UnspentPattern(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvPriceProfitSoprPattern = CapLossMvrvPriceProfitSoprPattern(client, acc) + self.supply: HalfTotalPattern = HalfTotalPattern(client, _m(acc, 'supply')) + self.unrealized: NuplPattern = NuplPattern(client, _m(acc, 'nupl')) class BpsCentsRatioSatsUsdPattern: """Pattern struct for repeated tree structure.""" @@ -2603,17 +2597,6 @@ class BtcCentsRelSatsUsdPattern2: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) -class CentsDeltaRawRelUsdPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.delta: ChangeRatePattern4 = ChangeRatePattern4(client, _m(acc, 'realized_cap_delta')) - self.raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'cap_raw')) - self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_cap_rel_to_own_mcap')) - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - class CoindaysCoinyearsDormancySentVelocityPattern: """Pattern struct for repeated tree structure.""" @@ -2622,9 +2605,20 @@ class CoindaysCoinyearsDormancySentVelocityPattern: self.coindays_destroyed: CumulativeRawSumPattern[StoredF64] = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) - self.sent: InRawSumPattern2 = InRawSumPattern2(client, _m(acc, 'sent')) + self.sent: CumulativeInRawSumPattern = CumulativeInRawSumPattern(client, _m(acc, 'sent')) self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) +class CumulativeInRawSumPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'cumulative')) + self.in_loss: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, _m(acc, 'in_loss')) + self.in_profit: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, _m(acc, 'in_profit')) + self.raw: MetricPattern1[Sats] = MetricPattern1(client, acc) + self.sum: _1m1w1y24hPattern[Sats] = _1m1w1y24hPattern(client, _m(acc, 'sum')) + class EmaHistogramLineSignalPattern: """Pattern struct for repeated tree structure.""" @@ -2636,17 +2630,6 @@ class EmaHistogramLineSignalPattern: self.line: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'line_24h')) self.signal: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'signal_24h')) -class InvestedInvestorLossNetProfitPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.invested_capital: InPattern = InPattern(client, _m(acc, 'invested_capital_in')) - self.investor_cap: InPattern = InPattern(client, _m(acc, 'investor_cap_in')) - self.loss: NegativeRawSumPattern = NegativeRawSumPattern(client, acc) - self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.profit: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'unrealized_profit')) - class InvestedMaxMinPercentilesSupplyPattern: """Pattern struct for repeated tree structure.""" @@ -2669,17 +2652,6 @@ class PhsReboundThsPattern: self.ths: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ths')) self.ths_min: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ths_min')) -class RawRelSumPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: CentsUsdPattern = CentsUsdPattern(client, acc) - self.rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_mcap')) - self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_gross_pnl')) - self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, '24h')) - class _1m1w1y24hHeightPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2696,12 +2668,12 @@ class _1m1w1y24hPattern2: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1m')) - self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1w')) - self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1y')) - self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '24h')) + self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1m_rate')) + self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1w_rate')) + self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1y_rate')) + self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '24h_rate')) -class _1m1w1y24hPattern8: +class _1m1w1y24hPattern4: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2711,16 +2683,6 @@ class _1m1w1y24hPattern8: self._1y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1y')) self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) -class _1m1w1y24hPattern5: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, '1m')) - self._1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, '1w')) - self._1y: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, '1y')) - self._24h: CentsUsdPattern = CentsUsdPattern(client, _m(acc, '24h')) - class _1m1w1y2wPattern: """Pattern struct for repeated tree structure.""" @@ -2731,7 +2693,7 @@ class _1m1w1y2wPattern: self._1y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '1y')) self._2w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '2w')) -class _1m1w1y24hPattern4: +class _1m1w1y24hPattern3: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2741,16 +2703,6 @@ class _1m1w1y24hPattern4: self._1y: CentsUsdPattern = CentsUsdPattern(client, _m(acc, '1y')) self._24h: CentsUsdPattern = CentsUsdPattern(client, _m(acc, '24h')) -class _1m1w1y24hPattern3: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, '1m')) - self._1w: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, '1w')) - self._1y: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, '1y')) - self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) - class _1y2y4yAllPattern: """Pattern struct for repeated tree structure.""" @@ -2761,16 +2713,6 @@ class _1y2y4yAllPattern: self._4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) self.all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) -class AddressOutputsRealizedSupplyPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.address_count: DeltaRawPattern = DeltaRawPattern(client, _m(acc, 'address_count')) - self.outputs: UnspentPattern = UnspentPattern(client, _m(acc, 'utxo_count')) - self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) - self.supply: HalfTotalPattern = HalfTotalPattern(client, _m(acc, 'supply')) - class AdjustedRatioValuePattern: """Pattern struct for repeated tree structure.""" @@ -2778,8 +2720,8 @@ class AdjustedRatioValuePattern: """Create pattern node with accumulated metric name.""" self.adjusted: RatioValuePattern2 = RatioValuePattern2(client, acc) self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) - self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'value_created')) - self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'value_destroyed')) + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'value_created')) + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'value_destroyed')) class BothReactivatedReceivingSendingPattern: """Pattern struct for repeated tree structure.""" @@ -2801,15 +2743,15 @@ class BtcCentsSatsUsdPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) -class CapLowerPriceUpperPattern: +class CentsDeltaRelUsdPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.cap: RawPattern2[CentsSquaredSats] = RawPattern2(client, _m(acc, 'investor_cap_raw')) - self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_price_band')) - self.price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'investor_price')) - self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_price_band')) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) + self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) class CentsRelUsdPattern2: """Pattern struct for repeated tree structure.""" @@ -2826,10 +2768,10 @@ class CumulativeNegativeRawSumPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_cumulative')) - self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_loss')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'realized_loss_24h')) + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'unrealized_loss_cumulative')) + self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) + self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'unrealized_loss_sum')) class HalfInTotalPattern: """Pattern struct for repeated tree structure.""" @@ -2841,25 +2783,25 @@ class HalfInTotalPattern: self.in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'in_profit')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) -class InRawSumPattern: +class LossNetNuplProfitPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.in_loss: RawSumPattern4 = RawSumPattern4(client, _m(acc, 'in_loss')) - self.in_profit: RawSumPattern4 = RawSumPattern4(client, _m(acc, 'in_profit')) - self.raw: MetricPattern1[Sats] = MetricPattern1(client, acc) - self.sum: _24hPattern2[Sats] = _24hPattern2(client, _m(acc, '24h')) + self.loss: CumulativeNegativeRawSumPattern = CumulativeNegativeRawSumPattern(client, acc) + self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.profit: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'unrealized_profit')) -class InRawSumPattern2: +class OutputsRealizedSupplyUnrealizedPattern2: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.in_loss: RawSumPattern5 = RawSumPattern5(client, _m(acc, 'in_loss')) - self.in_profit: RawSumPattern5 = RawSumPattern5(client, _m(acc, 'in_profit')) - self.raw: MetricPattern1[Sats] = MetricPattern1(client, acc) - self.sum: _1m1w1y24hPattern[Sats] = _1m1w1y24hPattern(client, acc) + self.outputs: UnspentPattern = UnspentPattern(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvPriceProfitSoprPattern = CapLossMvrvPriceProfitSoprPattern(client, acc) + self.supply: HalfInTotalPattern = HalfInTotalPattern(client, _m(acc, 'supply')) + self.unrealized: LossNuplProfitPattern = LossNuplProfitPattern(client, acc) class OutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -2867,9 +2809,9 @@ class OutputsRealizedSupplyUnrealizedPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.outputs: UnspentPattern = UnspentPattern(client, _m(acc, 'utxo_count')) - self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) - self.supply: HalfInTotalPattern = HalfInTotalPattern(client, _m(acc, 'supply')) - self.unrealized: LossProfitPattern = LossProfitPattern(client, _m(acc, 'unrealized')) + self.realized: CapLossMvrvPriceProfitSoprPattern = CapLossMvrvPriceProfitSoprPattern(client, acc) + self.supply: HalfTotalPattern = HalfTotalPattern(client, _m(acc, 'supply')) + self.unrealized: NuplPattern = NuplPattern(client, _m(acc, 'nupl')) class _1m1w1y24hPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2881,15 +2823,6 @@ class _1m1w1y24hPattern(Generic[T]): self._1y: MetricPattern1[T] = MetricPattern1(client, _m(acc, '1y')) self._24h: MetricPattern1[T] = MetricPattern1(client, _m(acc, '24h')) -class BaseCumulativeSumPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')) - self.sum: _1m1w1y24hPattern8 = _1m1w1y24hPattern8(client, _m(acc, 'sum')) - class BlocksDominanceRewardsPattern: """Pattern struct for repeated tree structure.""" @@ -2897,7 +2830,7 @@ class BlocksDominanceRewardsPattern: """Create pattern node with accumulated metric name.""" self.blocks_mined: CumulativeRawSumPattern[StoredU32] = CumulativeRawSumPattern(client, _m(acc, 'blocks_mined')) self.dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'dominance')) - self.rewards: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, _m(acc, 'rewards')) + self.rewards: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, _m(acc, 'rewards')) class BpsPercentRatioPattern: """Pattern struct for repeated tree structure.""" @@ -2932,16 +2865,7 @@ class CentsDeltaUsdPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) - self.delta: ChangeRatePattern3 = ChangeRatePattern3(client, _m(acc, 'delta')) - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) - -class CentsRawUsdPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) - self.raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'raw')) + self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) class CentsSatsUsdPattern: @@ -2953,6 +2877,15 @@ class CentsSatsUsdPattern: self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) +class CumulativeRawSumPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')) + self.raw: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, _m(acc, 'sum')) + class CumulativeRawRelPattern: """Pattern struct for repeated tree structure.""" @@ -2969,7 +2902,7 @@ class CumulativeRawSumPattern2: """Create pattern node with accumulated metric name.""" self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cumulative')) self.raw: CentsUsdPattern = CentsUsdPattern(client, acc) - self.sum: _24hPattern = _24hPattern(client, _m(acc, '24h')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'sum')) class GreedNetPainPattern: """Pattern struct for repeated tree structure.""" @@ -2980,32 +2913,23 @@ class GreedNetPainPattern: self.net: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_sentiment')) self.pain_index: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'pain_index')) -class LossNetProfitPattern: +class LossNuplProfitPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.loss: NegativeRawSumPattern = NegativeRawSumPattern(client, acc) - self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.profit: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'unrealized_profit')) + self.loss: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'unrealized_loss')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.profit: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'unrealized_profit')) -class NegativeRawSumPattern: +class LowerPriceUpperPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) - -class OutputsRealizedSupplyPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.outputs: UnspentPattern = UnspentPattern(client, _m(acc, 'utxo_count')) - self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) - self.supply: HalfTotalPattern = HalfTotalPattern(client, _m(acc, 'supply')) + self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_price_band')) + self.price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'investor_price')) + self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_price_band')) class RatioValuePattern2: """Pattern struct for repeated tree structure.""" @@ -3013,34 +2937,25 @@ class RatioValuePattern2: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'asopr')) - self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'adj_value_created')) - self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'adj_value_destroyed')) + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'adj_value_created')) + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'adj_value_destroyed')) class RatioValuePattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.ratio: _24hPattern2[StoredF64] = _24hPattern2(client, _m(acc, 'sopr_24h')) - self.value_created: RawSumPattern3[Cents] = RawSumPattern3(client, _m(acc, 'value_created')) - self.value_destroyed: RawSumPattern3[Cents] = RawSumPattern3(client, _m(acc, 'value_destroyed')) - -class RawSellSumPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) - self.sell_side_risk_ratio: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')) - self.sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')) + self.ratio: _24hPattern = _24hPattern(client, _m(acc, 'sopr_24h')) + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'value_created')) + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'value_destroyed')) class _6bBlockTxindexPattern(Generic[T]): """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self._6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern[T] = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, _m(acc, '6b')) - self.block: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern[T] = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc) + self._6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2[T] = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2(client, _m(acc, '6b')) + self.block: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2[T] = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern2(client, acc) self.txindex: MetricPattern19[T] = MetricPattern19(client, acc) class CumulativeRawSumPattern(Generic[T]): @@ -3050,14 +2965,14 @@ class CumulativeRawSumPattern(Generic[T]): """Create pattern node with accumulated metric name.""" self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) self.raw: MetricPattern1[T] = MetricPattern1(client, acc) - self.sum: _1m1w1y24hPattern[T] = _1m1w1y24hPattern(client, acc) + self.sum: _1m1w1y24hPattern[T] = _1m1w1y24hPattern(client, _m(acc, 'sum')) class BlocksDominancePattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.blocks_mined: CumulativeRawPattern[StoredU32] = CumulativeRawPattern(client, _m(acc, 'blocks_mined')) + self.blocks_mined: CumulativeRawSumPattern[StoredU32] = CumulativeRawSumPattern(client, _m(acc, 'blocks_mined')) self.dominance: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'dominance')) class BpsRatioPattern: @@ -3081,55 +2996,39 @@ class ChangeRatePattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.change: _1m1w1y24hPattern[StoredI64] = _1m1w1y24hPattern(client, _m(acc, 'change')) - self.rate: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'rate')) - -class ChangeRatePattern4: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.change: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, _m(acc, 'change')) - self.rate: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'rate')) + self.change: _1m1w1y24hPattern[StoredI64] = _1m1w1y24hPattern(client, acc) + self.rate: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, acc) class ChangeRatePattern2: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.change: _1mPattern[StoredI64] = _1mPattern(client, _m(acc, 'change_1m')) - self.rate: _1mPattern2 = _1mPattern2(client, _m(acc, 'rate_1m')) - -class ChangeRatePattern3: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.change: _1mPattern3 = _1mPattern3(client, _m(acc, 'change_1m')) - self.rate: _1mPattern2 = _1mPattern2(client, _m(acc, 'rate_1m')) + self.change: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, acc) + self.rate: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, acc) class CoindaysSentPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.coindays_destroyed: RawSumPattern3[StoredF64] = RawSumPattern3(client, _m(acc, 'coindays_destroyed')) - self.sent: InRawSumPattern = InRawSumPattern(client, _m(acc, 'sent')) + self.coindays_destroyed: CumulativeRawSumPattern[StoredF64] = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) + self.sent: CumulativeInRawSumPattern = CumulativeInRawSumPattern(client, _m(acc, 'sent')) -class DeltaRawPattern2: +class DeltaInnerPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + self.inner: MetricPattern1[StoredU64] = MetricPattern1(client, acc) class DeltaRawPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) + self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, acc) class HalfTotalPattern: @@ -3140,29 +3039,13 @@ class HalfTotalPattern: self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'half')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) -class InPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.in_loss: CentsRawUsdPattern = CentsRawUsdPattern(client, _m(acc, 'loss')) - self.in_profit: CentsRawUsdPattern = CentsRawUsdPattern(client, _m(acc, 'profit')) - class InPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.in_loss: RawPattern2[CentsSats] = RawPattern2(client, _m(acc, 'loss_raw')) - self.in_profit: RawPattern2[CentsSats] = RawPattern2(client, _m(acc, 'profit_raw')) - -class LossProfitPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.loss: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'loss')) - self.profit: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'profit')) + self.in_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'loss')) + self.in_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'profit')) class PriceValuePattern: """Pattern struct for repeated tree structure.""" @@ -3172,30 +3055,6 @@ class PriceValuePattern: self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p3sd_4y')) self.value: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio_p3sd_4y')) -class RawSumPattern5: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, acc) - -class RawSumPattern4: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - self.sum: _24hPattern3 = _24hPattern3(client, _m(acc, '24h')) - -class RawSumPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: CentsUsdPattern = CentsUsdPattern(client, acc) - self.sum: _24hPattern = _24hPattern(client, _m(acc, '24h')) - class RealizedSupplyPattern: """Pattern struct for repeated tree structure.""" @@ -3225,60 +3084,22 @@ class ValuePattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.value_created: RawSumPattern3[Cents] = RawSumPattern3(client, _m(acc, 'created')) - self.value_destroyed: RawSumPattern3[Cents] = RawSumPattern3(client, _m(acc, 'destroyed')) - -class CumulativeRawPattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) - self.raw: MetricPattern1[T] = MetricPattern1(client, acc) - -class RawSumPattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: MetricPattern1[T] = MetricPattern1(client, acc) - self.sum: _1m1w1y24hPattern[T] = _1m1w1y24hPattern(client, acc) - -class RawSumPattern3(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: MetricPattern1[T] = MetricPattern1(client, acc) - self.sum: _24hPattern2[T] = _24hPattern2(client, _m(acc, '24h')) - -class _1mPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, acc) - -class _1mPattern3: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: CentsUsdPattern = CentsUsdPattern(client, acc) - -class _24hPattern3: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'created')) + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, _m(acc, 'destroyed')) class _24hPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self._24h: CentsUsdPattern = CentsUsdPattern(client, acc) + self._24h: MetricPattern1[StoredF64] = MetricPattern1(client, acc) + +class NuplPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.nupl: BpsRatioPattern = BpsRatioPattern(client, acc) class UnspentPattern2: """Pattern struct for repeated tree structure.""" @@ -3287,13 +3108,6 @@ class UnspentPattern2: """Create pattern node with accumulated metric name.""" self.unspent_count: DeltaRawPattern = DeltaRawPattern(client, acc) -class UnspentPattern3: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.unspent_count: DeltaRawPattern2 = DeltaRawPattern2(client, acc) - class UnspentPattern: """Pattern struct for repeated tree structure.""" @@ -3301,27 +3115,6 @@ class UnspentPattern: """Create pattern node with accumulated metric name.""" self.unspent_count: MetricPattern1[StoredU64] = MetricPattern1(client, acc) -class _1mPattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: MetricPattern1[T] = MetricPattern1(client, acc) - -class _24hPattern2(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._24h: MetricPattern1[T] = MetricPattern1(client, acc) - -class RawPattern2(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: MetricPattern18[T] = MetricPattern18(client, acc) - # Metrics tree classes class MetricsTree_Blocks_Difficulty: @@ -3512,9 +3305,8 @@ class MetricsTree_Transactions_Volume: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.sent_sum: _1m1w1y24hBtcCentsSatsUsdPattern = _1m1w1y24hBtcCentsSatsUsdPattern(client, 'sent_sum') - self.received_sum: _1m1w1y24hBtcCentsSatsUsdPattern = _1m1w1y24hBtcCentsSatsUsdPattern(client, 'received_sum') - self.annualized: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'annualized_volume') + self.sent_sum: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, 'sent_sum') + self.received_sum: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, 'received_sum') self.tx_per_sec: MetricPattern1[StoredF32] = MetricPattern1(client, 'tx_per_sec') self.outputs_per_sec: MetricPattern1[StoredF32] = MetricPattern1(client, 'outputs_per_sec') self.inputs_per_sec: MetricPattern1[StoredF32] = MetricPattern1(client, 'inputs_per_sec') @@ -3655,11 +3447,83 @@ class MetricsTree_Addresses_Raw: self.p2tr: MetricsTree_Addresses_Raw_P2tr = MetricsTree_Addresses_Raw_P2tr(client) self.p2a: MetricsTree_Addresses_Raw_P2a = MetricsTree_Addresses_Raw_P2a(client) +class MetricsTree_Addresses_Indexes: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.p2a: MetricPattern24[AnyAddressIndex] = MetricPattern24(client, 'anyaddressindex') + self.p2pk33: MetricPattern26[AnyAddressIndex] = MetricPattern26(client, 'anyaddressindex') + self.p2pk65: MetricPattern27[AnyAddressIndex] = MetricPattern27(client, 'anyaddressindex') + self.p2pkh: MetricPattern28[AnyAddressIndex] = MetricPattern28(client, 'anyaddressindex') + self.p2sh: MetricPattern29[AnyAddressIndex] = MetricPattern29(client, 'anyaddressindex') + self.p2tr: MetricPattern30[AnyAddressIndex] = MetricPattern30(client, 'anyaddressindex') + self.p2wpkh: MetricPattern31[AnyAddressIndex] = MetricPattern31(client, 'anyaddressindex') + self.p2wsh: MetricPattern32[AnyAddressIndex] = MetricPattern32(client, 'anyaddressindex') + self.funded: MetricPattern34[FundedAddressIndex] = MetricPattern34(client, 'funded_address_index') + self.empty: MetricPattern35[EmptyAddressIndex] = MetricPattern35(client, 'empty_address_index') + +class MetricsTree_Addresses_Data: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.funded: MetricPattern34[FundedAddressData] = MetricPattern34(client, 'fundedaddressdata') + self.empty: MetricPattern35[EmptyAddressData] = MetricPattern35(client, 'emptyaddressdata') + +class MetricsTree_Addresses_Activity: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.all: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'address_activity') + self.p2pk65: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk65_address_activity') + self.p2pk33: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk33_address_activity') + self.p2pkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pkh_address_activity') + self.p2sh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2sh_address_activity') + self.p2wpkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wpkh_address_activity') + self.p2wsh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wsh_address_activity') + self.p2tr: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2tr_address_activity') + self.p2a: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2a_address_activity') + +class MetricsTree_Addresses_New: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.all: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'new_address_count') + self.p2pk65: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2pk65_new_address_count') + self.p2pk33: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2pk33_new_address_count') + self.p2pkh: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2pkh_new_address_count') + self.p2sh: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2sh_new_address_count') + self.p2wpkh: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2wpkh_new_address_count') + self.p2wsh: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2wsh_new_address_count') + self.p2tr: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2tr_new_address_count') + self.p2a: CumulativeRawSumPattern[StoredU64] = CumulativeRawSumPattern(client, 'p2a_new_address_count') + +class MetricsTree_Addresses_Delta: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.all: ChangeRatePattern = ChangeRatePattern(client, 'address_count') + self.p2pk65: ChangeRatePattern = ChangeRatePattern(client, 'p2pk65_address_count') + self.p2pk33: ChangeRatePattern = ChangeRatePattern(client, 'p2pk33_address_count') + self.p2pkh: ChangeRatePattern = ChangeRatePattern(client, 'p2pkh_address_count') + self.p2sh: ChangeRatePattern = ChangeRatePattern(client, 'p2sh_address_count') + self.p2wpkh: ChangeRatePattern = ChangeRatePattern(client, 'p2wpkh_address_count') + self.p2wsh: ChangeRatePattern = ChangeRatePattern(client, 'p2wsh_address_count') + self.p2tr: ChangeRatePattern = ChangeRatePattern(client, 'p2tr_address_count') + self.p2a: ChangeRatePattern = ChangeRatePattern(client, 'p2a_address_count') + class MetricsTree_Addresses: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.raw: MetricsTree_Addresses_Raw = MetricsTree_Addresses_Raw(client) + self.indexes: MetricsTree_Addresses_Indexes = MetricsTree_Addresses_Indexes(client) + self.data: MetricsTree_Addresses_Data = MetricsTree_Addresses_Data(client) + self.funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'address_count') + self.empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'empty_address_count') + self.activity: MetricsTree_Addresses_Activity = MetricsTree_Addresses_Activity(client) + self.total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'total_address_count') + self.new: MetricsTree_Addresses_New = MetricsTree_Addresses_New(client) + self.delta: MetricsTree_Addresses_Delta = MetricsTree_Addresses_Delta(client) class MetricsTree_Scripts_Raw_Empty: """Metrics tree node.""" @@ -3769,10 +3633,11 @@ class MetricsTree_Mining_Rewards_Fees: def __init__(self, client: BrkClientBase, base_path: str = ''): self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'fees') self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'fees_cumulative') - self._24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 = AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(client, 'fees_24h') - self._1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 = AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(client, 'fees_1w') - self._1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 = AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(client, 'fees_1m') - self._1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 = AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(client, 'fees_1y') + self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'fees_sum') + self._24h: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, 'fees_24h') + self._1w: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, 'fees_1w') + self._1m: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, 'fees_1m') + self._1y: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern = AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, 'fees_1y') self.dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'fee_dominance') self.ratio_multiple: MetricsTree_Mining_Rewards_Fees_RatioMultiple = MetricsTree_Mining_Rewards_Fees_RatioMultiple(client) @@ -3780,10 +3645,10 @@ class MetricsTree_Mining_Rewards: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.coinbase: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, 'coinbase') + self.coinbase: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, 'coinbase') self.subsidy: MetricsTree_Mining_Rewards_Subsidy = MetricsTree_Mining_Rewards_Subsidy(client) self.fees: MetricsTree_Mining_Rewards_Fees = MetricsTree_Mining_Rewards_Fees(client) - self.unclaimed: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, 'unclaimed_rewards') + self.unclaimed: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, 'unclaimed_rewards') class MetricsTree_Mining_Hashrate_Rate_Sma: """Metrics tree node.""" @@ -3818,13 +3683,6 @@ class MetricsTree_Mining: self.rewards: MetricsTree_Mining_Rewards = MetricsTree_Mining_Rewards(client) self.hashrate: MetricsTree_Mining_Hashrate = MetricsTree_Mining_Hashrate(client) -class MetricsTree_Positions: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.block: MetricPattern18[BlkPosition] = MetricPattern18(client, 'position') - self.tx: MetricPattern19[BlkPosition] = MetricPattern19(client, 'position') - class MetricsTree_Cointime_Activity: """Metrics tree node.""" @@ -3892,6 +3750,13 @@ class MetricsTree_Cointime_ReserveRisk: self.vocdd_median_1y: MetricPattern18[StoredF64] = MetricPattern18(client, 'vocdd_median_1y') self.hodl_bank: MetricPattern18[StoredF64] = MetricPattern18(client, 'hodl_bank') +class MetricsTree_Cointime_CoinblocksDestroyed: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.raw: MetricPattern1[StoredF64] = MetricPattern1(client, 'coinblocks_destroyed') + self.cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, 'coinblocks_destroyed_cumulative') + class MetricsTree_Cointime: """Metrics tree node.""" @@ -3903,6 +3768,7 @@ class MetricsTree_Cointime: self.prices: MetricsTree_Cointime_Prices = MetricsTree_Cointime_Prices(client) self.adjusted: MetricsTree_Cointime_Adjusted = MetricsTree_Cointime_Adjusted(client) self.reserve_risk: MetricsTree_Cointime_ReserveRisk = MetricsTree_Cointime_ReserveRisk(client) + self.coinblocks_destroyed: MetricsTree_Cointime_CoinblocksDestroyed = MetricsTree_Cointime_CoinblocksDestroyed(client) class MetricsTree_Constants: """Metrics tree node.""" @@ -4834,147 +4700,34 @@ class MetricsTree_Prices: self.ohlc: MetricsTree_Prices_Ohlc = MetricsTree_Prices_Ohlc(client) self.spot: MetricsTree_Prices_Spot = MetricsTree_Prices_Spot(client) -class MetricsTree_Distribution_Addresses_Indexes: +class MetricsTree_Supply_Burned: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2a: MetricPattern24[AnyAddressIndex] = MetricPattern24(client, 'anyaddressindex') - self.p2pk33: MetricPattern26[AnyAddressIndex] = MetricPattern26(client, 'anyaddressindex') - self.p2pk65: MetricPattern27[AnyAddressIndex] = MetricPattern27(client, 'anyaddressindex') - self.p2pkh: MetricPattern28[AnyAddressIndex] = MetricPattern28(client, 'anyaddressindex') - self.p2sh: MetricPattern29[AnyAddressIndex] = MetricPattern29(client, 'anyaddressindex') - self.p2tr: MetricPattern30[AnyAddressIndex] = MetricPattern30(client, 'anyaddressindex') - self.p2wpkh: MetricPattern31[AnyAddressIndex] = MetricPattern31(client, 'anyaddressindex') - self.p2wsh: MetricPattern32[AnyAddressIndex] = MetricPattern32(client, 'anyaddressindex') - self.funded: MetricPattern34[FundedAddressIndex] = MetricPattern34(client, 'funded_address_index') - self.empty: MetricPattern35[EmptyAddressIndex] = MetricPattern35(client, 'empty_address_index') + self.opreturn: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, 'opreturn_supply') + self.unspendable: CumulativeRawSumPattern3 = CumulativeRawSumPattern3(client, 'unspendable_supply') -class MetricsTree_Distribution_Addresses_Data: +class MetricsTree_Supply_Velocity: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.funded: MetricPattern34[FundedAddressData] = MetricPattern34(client, 'fundedaddressdata') - self.empty: MetricPattern35[EmptyAddressData] = MetricPattern35(client, 'emptyaddressdata') + self.btc: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_btc') + self.usd: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_usd') -class MetricsTree_Distribution_Addresses_Activity: +class MetricsTree_Supply: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'address_activity') - self.p2pk65: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk65_address_activity') - self.p2pk33: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk33_address_activity') - self.p2pkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pkh_address_activity') - self.p2sh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2sh_address_activity') - self.p2wpkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wpkh_address_activity') - self.p2wsh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wsh_address_activity') - self.p2tr: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2tr_address_activity') - self.p2a: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2a_address_activity') + self.circulating: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'circulating_supply') + self.burned: MetricsTree_Supply_Burned = MetricsTree_Supply_Burned(client) + self.inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'inflation_rate') + self.velocity: MetricsTree_Supply_Velocity = MetricsTree_Supply_Velocity(client) + self.market_cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, 'market_cap') + self.market_minus_realized_cap_growth_rate: _1m1w1y24hPattern[BasisPointsSigned32] = _1m1w1y24hPattern(client, 'market_minus_realized_cap_growth_rate') + self.hodled_or_lost: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'hodled_or_lost_coins') + self.state: MetricPattern18[SupplyState] = MetricPattern18(client, 'supply_state') -class MetricsTree_Distribution_Addresses_New_All: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2pk65: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2pk65_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2pk65_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2pk33: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2pk33_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2pk33_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2pkh: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2pkh_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2pkh_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2sh: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2sh_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2sh_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2wpkh: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2wpkh_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2wpkh_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2wsh: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2wsh_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2wsh_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2tr: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2tr_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2tr_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New_P2a: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: MetricPattern1[StoredU64] = MetricPattern1(client, 'p2a_new_address_count') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'p2a_new_address_count_sum') - -class MetricsTree_Distribution_Addresses_New: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: MetricsTree_Distribution_Addresses_New_All = MetricsTree_Distribution_Addresses_New_All(client) - self.p2pk65: MetricsTree_Distribution_Addresses_New_P2pk65 = MetricsTree_Distribution_Addresses_New_P2pk65(client) - self.p2pk33: MetricsTree_Distribution_Addresses_New_P2pk33 = MetricsTree_Distribution_Addresses_New_P2pk33(client) - self.p2pkh: MetricsTree_Distribution_Addresses_New_P2pkh = MetricsTree_Distribution_Addresses_New_P2pkh(client) - self.p2sh: MetricsTree_Distribution_Addresses_New_P2sh = MetricsTree_Distribution_Addresses_New_P2sh(client) - self.p2wpkh: MetricsTree_Distribution_Addresses_New_P2wpkh = MetricsTree_Distribution_Addresses_New_P2wpkh(client) - self.p2wsh: MetricsTree_Distribution_Addresses_New_P2wsh = MetricsTree_Distribution_Addresses_New_P2wsh(client) - self.p2tr: MetricsTree_Distribution_Addresses_New_P2tr = MetricsTree_Distribution_Addresses_New_P2tr(client) - self.p2a: MetricsTree_Distribution_Addresses_New_P2a = MetricsTree_Distribution_Addresses_New_P2a(client) - -class MetricsTree_Distribution_Addresses_Delta: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: ChangeRatePattern = ChangeRatePattern(client, 'address_count') - self.p2pk65: ChangeRatePattern = ChangeRatePattern(client, 'p2pk65_address_count') - self.p2pk33: ChangeRatePattern = ChangeRatePattern(client, 'p2pk33_address_count') - self.p2pkh: ChangeRatePattern = ChangeRatePattern(client, 'p2pkh_address_count') - self.p2sh: ChangeRatePattern = ChangeRatePattern(client, 'p2sh_address_count') - self.p2wpkh: ChangeRatePattern = ChangeRatePattern(client, 'p2wpkh_address_count') - self.p2wsh: ChangeRatePattern = ChangeRatePattern(client, 'p2wsh_address_count') - self.p2tr: ChangeRatePattern = ChangeRatePattern(client, 'p2tr_address_count') - self.p2a: ChangeRatePattern = ChangeRatePattern(client, 'p2a_address_count') - -class MetricsTree_Distribution_Addresses: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.indexes: MetricsTree_Distribution_Addresses_Indexes = MetricsTree_Distribution_Addresses_Indexes(client) - self.data: MetricsTree_Distribution_Addresses_Data = MetricsTree_Distribution_Addresses_Data(client) - self.funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'address_count') - self.empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'empty_address_count') - self.activity: MetricsTree_Distribution_Addresses_Activity = MetricsTree_Distribution_Addresses_Activity(client) - self.total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'total_address_count') - self.new: MetricsTree_Distribution_Addresses_New = MetricsTree_Distribution_Addresses_New(client) - self.delta: MetricsTree_Distribution_Addresses_Delta = MetricsTree_Distribution_Addresses_Delta(client) - -class MetricsTree_Distribution_Cohorts_Utxo_All_Supply: +class MetricsTree_Cohorts_Utxo_All_Supply: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -4984,17 +4737,18 @@ class MetricsTree_Distribution_Cohorts_Utxo_All_Supply: self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'supply') self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'supply_half') -class MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss: +class MetricsTree_Cohorts_Utxo_All_Unrealized_Loss: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.negative: MetricPattern1[Dollars] = MetricPattern1(client, 'neg_unrealized_loss') self.raw: CentsUsdPattern = CentsUsdPattern(client, 'unrealized_loss') - self.sum: _24hPattern = _24hPattern(client, 'unrealized_loss_24h') + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, 'unrealized_loss_cumulative') + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, 'unrealized_loss_sum') self.rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_mcap') self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_own_gross_pnl') -class MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl: +class MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -5002,86 +4756,96 @@ class MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl: self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'net_unrealized_pnl') self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl') -class MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit: +class MetricsTree_Cohorts_Utxo_All_Unrealized_Profit: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.raw: CentsUsdPattern = CentsUsdPattern(client, 'unrealized_profit') - self.sum: _24hPattern = _24hPattern(client, 'unrealized_profit_24h') + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, 'unrealized_profit_cumulative') + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, 'unrealized_profit_sum') self.rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_mcap') self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_own_gross_pnl') -class MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized: +class MetricsTree_Cohorts_Utxo_All_Unrealized: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, 'unrealized_gross_pnl') - self.invested_capital: InPattern2 = InPattern2(client, 'invested_capital_in') + self.invested_capital: InPattern = InPattern(client, 'invested_capital_in') self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, '') - self.investor_cap: InPattern = InPattern(client, 'investor_cap_in') - self.loss: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss = MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Loss(client) - self.net_pnl: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl = MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_NetPnl(client) - self.profit: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit = MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized_Profit(client) + self.loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss = MetricsTree_Cohorts_Utxo_All_Unrealized_Loss(client) + self.net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl = MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl(client) + self.profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit = MetricsTree_Cohorts_Utxo_All_Unrealized_Profit(client) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'nupl') -class MetricsTree_Distribution_Cohorts_Utxo_All: +class MetricsTree_Cohorts_Utxo_All: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply: MetricsTree_Distribution_Cohorts_Utxo_All_Supply = MetricsTree_Distribution_Cohorts_Utxo_All_Supply(client) - self.outputs: UnspentPattern3 = UnspentPattern3(client, 'utxo_count') + self.supply: MetricsTree_Cohorts_Utxo_All_Supply = MetricsTree_Cohorts_Utxo_All_Supply(client) + self.outputs: UnspentPattern2 = UnspentPattern2(client, 'utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, '') - self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(client, '') + self.realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern = CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(client, '') self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, '') - self.unrealized: MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized = MetricsTree_Distribution_Cohorts_Utxo_All_Unrealized(client) + self.unrealized: MetricsTree_Cohorts_Utxo_All_Unrealized = MetricsTree_Cohorts_Utxo_All_Unrealized(client) -class MetricsTree_Distribution_Cohorts_Utxo_Sth: +class MetricsTree_Cohorts_Utxo_Sth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(client, 'sth') + self.realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern = CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(client, 'sth') self.supply: DeltaHalfInRelTotalPattern2 = DeltaHalfInRelTotalPattern2(client, 'sth_supply') - self.outputs: UnspentPattern3 = UnspentPattern3(client, 'sth_utxo_count') + self.outputs: UnspentPattern2 = UnspentPattern2(client, 'sth_utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'sth') self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, 'sth') - self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2 = GrossInvestedInvestorLossNetProfitSentimentPattern2(client, 'sth') + self.unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2 = GrossInvestedLossNetNuplProfitSentimentPattern2(client, 'sth') -class MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr: +class MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.value_created: RawSumPattern[Cents] = RawSumPattern(client, 'lth_value_created') - self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, 'lth_value_destroyed') - self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_sopr') + self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_sell_side_risk_ratio_24h') + self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_sell_side_risk_ratio_1w') + self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_sell_side_risk_ratio_1m') + self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_sell_side_risk_ratio_1y') -class MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized: +class MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_sopr') + self.value_created: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, 'lth_value_created') + self.value_destroyed: CumulativeRawSumPattern[Cents] = CumulativeRawSumPattern(client, 'lth_value_destroyed') + +class MetricsTree_Cohorts_Utxo_Lth_Realized: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.profit: CumulativeDistributionRawRelSumValuePattern = CumulativeDistributionRawRelSumValuePattern(client, 'lth') self.loss: CapitulationCumulativeNegativeRawRelSumValuePattern = CapitulationCumulativeNegativeRawRelSumValuePattern(client, 'lth') - self.gross_pnl: RawSellSumPattern = RawSellSumPattern(client, 'lth') + self.gross_pnl: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, 'lth_realized_gross_pnl') + self.sell_side_risk_ratio: MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio = MetricsTree_Cohorts_Utxo_Lth_Realized_SellSideRiskRatio(client) self.net_pnl: ChangeCumulativeDeltaRawRelSumPattern = ChangeCumulativeDeltaRawRelSumPattern(client, 'lth_net') - self.sopr: MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr = MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized_Sopr(client) + self.sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr = MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr(client) self.peak_regret: CumulativeRawRelPattern = CumulativeRawRelPattern(client, 'lth_realized_peak_regret') - self.investor: CapLowerPriceUpperPattern = CapLowerPriceUpperPattern(client, 'lth') + self.investor: LowerPriceUpperPattern = LowerPriceUpperPattern(client, 'lth') self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_realized_profit_to_loss_ratio') - self.cap: CentsDeltaRawRelUsdPattern = CentsDeltaRawRelUsdPattern(client, 'lth') + self.cap: CentsDeltaRelUsdPattern = CentsDeltaRelUsdPattern(client, 'lth_realized_cap') self.price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern = BpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, 'lth_realized_price') self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_mvrv') - self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'lth_nupl_ratio') -class MetricsTree_Distribution_Cohorts_Utxo_Lth: +class MetricsTree_Cohorts_Utxo_Lth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.supply: DeltaHalfInRelTotalPattern2 = DeltaHalfInRelTotalPattern2(client, 'lth_supply') - self.outputs: UnspentPattern3 = UnspentPattern3(client, 'lth_utxo_count') + self.outputs: UnspentPattern2 = UnspentPattern2(client, 'lth_utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'lth') - self.realized: MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized = MetricsTree_Distribution_Cohorts_Utxo_Lth_Realized(client) + self.realized: MetricsTree_Cohorts_Utxo_Lth_Realized = MetricsTree_Cohorts_Utxo_Lth_Realized(client) self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, 'lth') - self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2 = GrossInvestedInvestorLossNetProfitSentimentPattern2(client, 'lth') + self.unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2 = GrossInvestedLossNetNuplProfitSentimentPattern2(client, 'lth') -class MetricsTree_Distribution_Cohorts_Utxo_AgeRange: +class MetricsTree_Cohorts_Utxo_AgeRange: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -5107,158 +4871,158 @@ class MetricsTree_Distribution_Cohorts_Utxo_AgeRange: self._12y_to_15y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_12y_to_15y_old') self.over_15y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_15y_old') -class MetricsTree_Distribution_Cohorts_Utxo_UnderAge: +class MetricsTree_Cohorts_Utxo_UnderAge: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1w: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_1w_old') - self._1m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_1m_old') - self._2m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_2m_old') - self._3m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_3m_old') - self._4m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_4m_old') - self._5m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_5m_old') - self._6m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_6m_old') - self._1y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_1y_old') - self._2y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_2y_old') - self._3y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_3y_old') - self._4y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_4y_old') - self._5y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_5y_old') - self._6y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_6y_old') - self._7y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_7y_old') - self._8y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_8y_old') - self._10y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_10y_old') - self._12y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_12y_old') - self._15y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_under_15y_old') + self._1w: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1w_old') + self._1m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1m_old') + self._2m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_2m_old') + self._3m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_3m_old') + self._4m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_4m_old') + self._5m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_5m_old') + self._6m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_6m_old') + self._1y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1y_old') + self._2y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_2y_old') + self._3y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_3y_old') + self._4y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_4y_old') + self._5y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_5y_old') + self._6y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_6y_old') + self._7y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_7y_old') + self._8y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_8y_old') + self._10y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10y_old') + self._12y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_12y_old') + self._15y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_15y_old') -class MetricsTree_Distribution_Cohorts_Utxo_OverAge: +class MetricsTree_Cohorts_Utxo_OverAge: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1d: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_1d_old') - self._1w: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_1w_old') - self._1m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_1m_old') - self._2m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_2m_old') - self._3m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_3m_old') - self._4m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_4m_old') - self._5m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_5m_old') - self._6m: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_6m_old') - self._1y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_1y_old') - self._2y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_2y_old') - self._3y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_3y_old') - self._4y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_4y_old') - self._5y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_5y_old') - self._6y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_6y_old') - self._7y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_7y_old') - self._8y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_8y_old') - self._10y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_10y_old') - self._12y: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'utxos_over_12y_old') + self._1d: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1d_old') + self._1w: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1w_old') + self._1m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1m_old') + self._2m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_2m_old') + self._3m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_3m_old') + self._4m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_4m_old') + self._5m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_5m_old') + self._6m: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_6m_old') + self._1y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1y_old') + self._2y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_2y_old') + self._3y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_3y_old') + self._4y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_4y_old') + self._5y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_5y_old') + self._6y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_6y_old') + self._7y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_7y_old') + self._8y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_8y_old') + self._10y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10y_old') + self._12y: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_12y_old') -class MetricsTree_Distribution_Cohorts_Utxo_Epoch: +class MetricsTree_Cohorts_Utxo_Epoch: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'epoch_0') - self._1: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'epoch_1') - self._2: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'epoch_2') - self._3: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'epoch_3') - self._4: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'epoch_4') + self._0: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'epoch_0') + self._1: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'epoch_1') + self._2: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'epoch_2') + self._3: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'epoch_3') + self._4: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'epoch_4') -class MetricsTree_Distribution_Cohorts_Utxo_Class: +class MetricsTree_Cohorts_Utxo_Class: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._2009: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2009') - self._2010: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2010') - self._2011: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2011') - self._2012: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2012') - self._2013: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2013') - self._2014: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2014') - self._2015: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2015') - self._2016: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2016') - self._2017: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2017') - self._2018: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2018') - self._2019: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2019') - self._2020: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2020') - self._2021: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2021') - self._2022: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2022') - self._2023: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2023') - self._2024: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2024') - self._2025: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2025') - self._2026: ActivityOutputsRealizedSupplyUnrealizedPattern2 = ActivityOutputsRealizedSupplyUnrealizedPattern2(client, 'class_2026') + self._2009: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2009') + self._2010: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2010') + self._2011: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2011') + self._2012: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2012') + self._2013: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2013') + self._2014: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2014') + self._2015: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2015') + self._2016: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2016') + self._2017: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2017') + self._2018: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2018') + self._2019: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2019') + self._2020: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2020') + self._2021: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2021') + self._2022: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2022') + self._2023: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2023') + self._2024: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2024') + self._2025: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2025') + self._2026: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'class_2026') -class MetricsTree_Distribution_Cohorts_Utxo_OverAmount: +class MetricsTree_Cohorts_Utxo_OverAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1sat: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1sat') - self._10sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10sats') - self._100sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100sats') - self._1k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1k_sats') - self._10k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10k_sats') - self._100k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100k_sats') - self._1m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1m_sats') - self._10m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10m_sats') - self._1btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1btc') - self._10btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10btc') - self._100btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100btc') - self._1k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1k_btc') - self._10k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10k_btc') + self._1sat: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1sat') + self._10sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10sats') + self._100sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100sats') + self._1k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1k_sats') + self._10k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10k_sats') + self._100k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100k_sats') + self._1m_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1m_sats') + self._10m_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10m_sats') + self._1btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1btc') + self._10btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10btc') + self._100btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100btc') + self._1k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1k_btc') + self._10k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10k_btc') -class MetricsTree_Distribution_Cohorts_Utxo_AmountRange: +class MetricsTree_Cohorts_Utxo_AmountRange: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_0sats') - self._1sat_to_10sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_1sat_to_10sats') - self._10sats_to_100sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_10sats_to_100sats') - self._100sats_to_1k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_100sats_to_1k_sats') - self._1k_sats_to_10k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_1k_sats_to_10k_sats') - self._10k_sats_to_100k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_10k_sats_to_100k_sats') - self._100k_sats_to_1m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_100k_sats_to_1m_sats') - self._1m_sats_to_10m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_1m_sats_to_10m_sats') - self._10m_sats_to_1btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_10m_sats_to_1btc') - self._1btc_to_10btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_1btc_to_10btc') - self._10btc_to_100btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_10btc_to_100btc') - self._100btc_to_1k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_100btc_to_1k_btc') - self._1k_btc_to_10k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_1k_btc_to_10k_btc') - self._10k_btc_to_100k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_10k_btc_to_100k_btc') - self.over_100k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100k_btc') + self._0sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_0sats') + self._1sat_to_10sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_1sat_to_10sats') + self._10sats_to_100sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_10sats_to_100sats') + self._100sats_to_1k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_100sats_to_1k_sats') + self._1k_sats_to_10k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_1k_sats_to_10k_sats') + self._10k_sats_to_100k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_10k_sats_to_100k_sats') + self._100k_sats_to_1m_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_100k_sats_to_1m_sats') + self._1m_sats_to_10m_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_1m_sats_to_10m_sats') + self._10m_sats_to_1btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_10m_sats_to_1btc') + self._1btc_to_10btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_1btc_to_10btc') + self._10btc_to_100btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_10btc_to_100btc') + self._100btc_to_1k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_100btc_to_1k_btc') + self._1k_btc_to_10k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_1k_btc_to_10k_btc') + self._10k_btc_to_100k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_10k_btc_to_100k_btc') + self.over_100k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100k_btc') -class MetricsTree_Distribution_Cohorts_Utxo_UnderAmount: +class MetricsTree_Cohorts_Utxo_UnderAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._10sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10sats') - self._100sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100sats') - self._1k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1k_sats') - self._10k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10k_sats') - self._100k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100k_sats') - self._1m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1m_sats') - self._10m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10m_sats') - self._1btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1btc') - self._10btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10btc') - self._100btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100btc') - self._1k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1k_btc') - self._10k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10k_btc') - self._100k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100k_btc') + self._10sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10sats') + self._100sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100sats') + self._1k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1k_sats') + self._10k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10k_sats') + self._100k_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100k_sats') + self._1m_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1m_sats') + self._10m_sats: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10m_sats') + self._1btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1btc') + self._10btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10btc') + self._100btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100btc') + self._1k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1k_btc') + self._10k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10k_btc') + self._100k_btc: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100k_btc') -class MetricsTree_Distribution_Cohorts_Utxo_Type: +class MetricsTree_Cohorts_Utxo_Type: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2pk65: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2pk65') - self.p2pk33: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2pk33') - self.p2pkh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2pkh') - self.p2ms: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2ms') - self.p2sh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2sh') - self.p2wpkh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2wpkh') - self.p2wsh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2wsh') - self.p2tr: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2tr') - self.p2a: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2a') - self.unknown: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'unknown_outputs') - self.empty: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'empty_outputs') + self.p2pk65: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2pk65') + self.p2pk33: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2pk33') + self.p2pkh: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2pkh') + self.p2ms: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2ms') + self.p2sh: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2sh') + self.p2wpkh: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2wpkh') + self.p2wsh: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2wsh') + self.p2tr: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2tr') + self.p2a: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'p2a') + self.unknown: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'unknown_outputs') + self.empty: OutputsRealizedSupplyUnrealizedPattern2 = OutputsRealizedSupplyUnrealizedPattern2(client, 'empty_outputs') -class MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range: +class MetricsTree_Cohorts_Utxo_Profitability_Range: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -5288,7 +5052,7 @@ class MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range: self._80pct_to_90pct_in_loss: RealizedSupplyPattern = RealizedSupplyPattern(client, 'utxos_80pct_to_90pct_in_loss') self._90pct_to_100pct_in_loss: RealizedSupplyPattern = RealizedSupplyPattern(client, 'utxos_90pct_to_100pct_in_loss') -class MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit: +class MetricsTree_Cohorts_Utxo_Profitability_Profit: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -5307,7 +5071,7 @@ class MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit: self._300pct: RealizedSupplyPattern = RealizedSupplyPattern(client, 'utxos_over_300pct_in_profit') self._500pct: RealizedSupplyPattern = RealizedSupplyPattern(client, 'utxos_over_500pct_in_profit') -class MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss: +class MetricsTree_Cohorts_Utxo_Profitability_Loss: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -5321,15 +5085,15 @@ class MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss: self._70pct: RealizedSupplyPattern = RealizedSupplyPattern(client, 'utxos_over_70pct_in_loss') self._80pct: RealizedSupplyPattern = RealizedSupplyPattern(client, 'utxos_over_80pct_in_loss') -class MetricsTree_Distribution_Cohorts_Utxo_Profitability: +class MetricsTree_Cohorts_Utxo_Profitability: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.range: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range = MetricsTree_Distribution_Cohorts_Utxo_Profitability_Range(client) - self.profit: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit = MetricsTree_Distribution_Cohorts_Utxo_Profitability_Profit(client) - self.loss: MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss = MetricsTree_Distribution_Cohorts_Utxo_Profitability_Loss(client) + self.range: MetricsTree_Cohorts_Utxo_Profitability_Range = MetricsTree_Cohorts_Utxo_Profitability_Range(client) + self.profit: MetricsTree_Cohorts_Utxo_Profitability_Profit = MetricsTree_Cohorts_Utxo_Profitability_Profit(client) + self.loss: MetricsTree_Cohorts_Utxo_Profitability_Loss = MetricsTree_Cohorts_Utxo_Profitability_Loss(client) -class MetricsTree_Distribution_Cohorts_Utxo_Matured: +class MetricsTree_Cohorts_Utxo_Matured: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -5355,138 +5119,95 @@ class MetricsTree_Distribution_Cohorts_Utxo_Matured: self._12y_to_15y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'utxo_12y_to_15y_old_matured') self.over_15y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'utxo_over_15y_old_matured') -class MetricsTree_Distribution_Cohorts_Utxo: +class MetricsTree_Cohorts_Utxo: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: MetricsTree_Distribution_Cohorts_Utxo_All = MetricsTree_Distribution_Cohorts_Utxo_All(client) - self.sth: MetricsTree_Distribution_Cohorts_Utxo_Sth = MetricsTree_Distribution_Cohorts_Utxo_Sth(client) - self.lth: MetricsTree_Distribution_Cohorts_Utxo_Lth = MetricsTree_Distribution_Cohorts_Utxo_Lth(client) - self.age_range: MetricsTree_Distribution_Cohorts_Utxo_AgeRange = MetricsTree_Distribution_Cohorts_Utxo_AgeRange(client) - self.under_age: MetricsTree_Distribution_Cohorts_Utxo_UnderAge = MetricsTree_Distribution_Cohorts_Utxo_UnderAge(client) - self.over_age: MetricsTree_Distribution_Cohorts_Utxo_OverAge = MetricsTree_Distribution_Cohorts_Utxo_OverAge(client) - self.epoch: MetricsTree_Distribution_Cohorts_Utxo_Epoch = MetricsTree_Distribution_Cohorts_Utxo_Epoch(client) - self.class_: MetricsTree_Distribution_Cohorts_Utxo_Class = MetricsTree_Distribution_Cohorts_Utxo_Class(client) - self.over_amount: MetricsTree_Distribution_Cohorts_Utxo_OverAmount = MetricsTree_Distribution_Cohorts_Utxo_OverAmount(client) - self.amount_range: MetricsTree_Distribution_Cohorts_Utxo_AmountRange = MetricsTree_Distribution_Cohorts_Utxo_AmountRange(client) - self.under_amount: MetricsTree_Distribution_Cohorts_Utxo_UnderAmount = MetricsTree_Distribution_Cohorts_Utxo_UnderAmount(client) - self.r#type: MetricsTree_Distribution_Cohorts_Utxo_Type = MetricsTree_Distribution_Cohorts_Utxo_Type(client) - self.profitability: MetricsTree_Distribution_Cohorts_Utxo_Profitability = MetricsTree_Distribution_Cohorts_Utxo_Profitability(client) - self.matured: MetricsTree_Distribution_Cohorts_Utxo_Matured = MetricsTree_Distribution_Cohorts_Utxo_Matured(client) + self.all: MetricsTree_Cohorts_Utxo_All = MetricsTree_Cohorts_Utxo_All(client) + self.sth: MetricsTree_Cohorts_Utxo_Sth = MetricsTree_Cohorts_Utxo_Sth(client) + self.lth: MetricsTree_Cohorts_Utxo_Lth = MetricsTree_Cohorts_Utxo_Lth(client) + self.age_range: MetricsTree_Cohorts_Utxo_AgeRange = MetricsTree_Cohorts_Utxo_AgeRange(client) + self.under_age: MetricsTree_Cohorts_Utxo_UnderAge = MetricsTree_Cohorts_Utxo_UnderAge(client) + self.over_age: MetricsTree_Cohorts_Utxo_OverAge = MetricsTree_Cohorts_Utxo_OverAge(client) + self.epoch: MetricsTree_Cohorts_Utxo_Epoch = MetricsTree_Cohorts_Utxo_Epoch(client) + self.class_: MetricsTree_Cohorts_Utxo_Class = MetricsTree_Cohorts_Utxo_Class(client) + self.over_amount: MetricsTree_Cohorts_Utxo_OverAmount = MetricsTree_Cohorts_Utxo_OverAmount(client) + self.amount_range: MetricsTree_Cohorts_Utxo_AmountRange = MetricsTree_Cohorts_Utxo_AmountRange(client) + self.under_amount: MetricsTree_Cohorts_Utxo_UnderAmount = MetricsTree_Cohorts_Utxo_UnderAmount(client) + self.r#type: MetricsTree_Cohorts_Utxo_Type = MetricsTree_Cohorts_Utxo_Type(client) + self.profitability: MetricsTree_Cohorts_Utxo_Profitability = MetricsTree_Cohorts_Utxo_Profitability(client) + self.matured: MetricsTree_Cohorts_Utxo_Matured = MetricsTree_Cohorts_Utxo_Matured(client) -class MetricsTree_Distribution_Cohorts_Address_OverAmount: +class MetricsTree_Cohorts_Address_OverAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1sat: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_1sat') - self._10sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_10sats') - self._100sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_100sats') - self._1k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_1k_sats') - self._10k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_10k_sats') - self._100k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_100k_sats') - self._1m_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_1m_sats') - self._10m_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_10m_sats') - self._1btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_1btc') - self._10btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_10btc') - self._100btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_100btc') - self._1k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_1k_btc') - self._10k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_10k_btc') + self._1sat: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1sat') + self._10sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10sats') + self._100sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100sats') + self._1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_sats') + self._10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_sats') + self._100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_sats') + self._1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1m_sats') + self._10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10m_sats') + self._1btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1btc') + self._10btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10btc') + self._100btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100btc') + self._1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_btc') + self._10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_btc') -class MetricsTree_Distribution_Cohorts_Address_AmountRange: +class MetricsTree_Cohorts_Address_AmountRange: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_0sats') - self._1sat_to_10sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_1sat_to_10sats') - self._10sats_to_100sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_10sats_to_100sats') - self._100sats_to_1k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_100sats_to_1k_sats') - self._1k_sats_to_10k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_1k_sats_to_10k_sats') - self._10k_sats_to_100k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_10k_sats_to_100k_sats') - self._100k_sats_to_1m_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_100k_sats_to_1m_sats') - self._1m_sats_to_10m_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_1m_sats_to_10m_sats') - self._10m_sats_to_1btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_10m_sats_to_1btc') - self._1btc_to_10btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_1btc_to_10btc') - self._10btc_to_100btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_10btc_to_100btc') - self._100btc_to_1k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_100btc_to_1k_btc') - self._1k_btc_to_10k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_1k_btc_to_10k_btc') - self._10k_btc_to_100k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_10k_btc_to_100k_btc') - self.over_100k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_over_100k_btc') + self._0sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_0sats') + self._1sat_to_10sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1sat_to_10sats') + self._10sats_to_100sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10sats_to_100sats') + self._100sats_to_1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100sats_to_1k_sats') + self._1k_sats_to_10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1k_sats_to_10k_sats') + self._10k_sats_to_100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10k_sats_to_100k_sats') + self._100k_sats_to_1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100k_sats_to_1m_sats') + self._1m_sats_to_10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1m_sats_to_10m_sats') + self._10m_sats_to_1btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10m_sats_to_1btc') + self._1btc_to_10btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1btc_to_10btc') + self._10btc_to_100btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10btc_to_100btc') + self._100btc_to_1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100btc_to_1k_btc') + self._1k_btc_to_10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1k_btc_to_10k_btc') + self._10k_btc_to_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10k_btc_to_100k_btc') + self.over_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_btc') -class MetricsTree_Distribution_Cohorts_Address_UnderAmount: +class MetricsTree_Cohorts_Address_UnderAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._10sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_10sats') - self._100sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_100sats') - self._1k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_1k_sats') - self._10k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_10k_sats') - self._100k_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_100k_sats') - self._1m_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_1m_sats') - self._10m_sats: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_10m_sats') - self._1btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_1btc') - self._10btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_10btc') - self._100btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_100btc') - self._1k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_1k_btc') - self._10k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_10k_btc') - self._100k_btc: AddressOutputsRealizedSupplyPattern = AddressOutputsRealizedSupplyPattern(client, 'addrs_under_100k_btc') + self._10sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10sats') + self._100sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100sats') + self._1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_sats') + self._10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_sats') + self._100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_sats') + self._1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1m_sats') + self._10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10m_sats') + self._1btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1btc') + self._10btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10btc') + self._100btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100btc') + self._1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_btc') + self._10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_btc') + self._100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_btc') -class MetricsTree_Distribution_Cohorts_Address: +class MetricsTree_Cohorts_Address: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.over_amount: MetricsTree_Distribution_Cohorts_Address_OverAmount = MetricsTree_Distribution_Cohorts_Address_OverAmount(client) - self.amount_range: MetricsTree_Distribution_Cohorts_Address_AmountRange = MetricsTree_Distribution_Cohorts_Address_AmountRange(client) - self.under_amount: MetricsTree_Distribution_Cohorts_Address_UnderAmount = MetricsTree_Distribution_Cohorts_Address_UnderAmount(client) + self.over_amount: MetricsTree_Cohorts_Address_OverAmount = MetricsTree_Cohorts_Address_OverAmount(client) + self.amount_range: MetricsTree_Cohorts_Address_AmountRange = MetricsTree_Cohorts_Address_AmountRange(client) + self.under_amount: MetricsTree_Cohorts_Address_UnderAmount = MetricsTree_Cohorts_Address_UnderAmount(client) -class MetricsTree_Distribution_Cohorts: +class MetricsTree_Cohorts: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.utxo: MetricsTree_Distribution_Cohorts_Utxo = MetricsTree_Distribution_Cohorts_Utxo(client) - self.address: MetricsTree_Distribution_Cohorts_Address = MetricsTree_Distribution_Cohorts_Address(client) - -class MetricsTree_Distribution: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply_state: MetricPattern18[SupplyState] = MetricPattern18(client, 'supply_state') - self.addresses: MetricsTree_Distribution_Addresses = MetricsTree_Distribution_Addresses(client) - self.cohorts: MetricsTree_Distribution_Cohorts = MetricsTree_Distribution_Cohorts(client) - self.coinblocks_destroyed: CumulativeRawPattern[StoredF64] = CumulativeRawPattern(client, 'coinblocks_destroyed') - -class MetricsTree_Supply_Burned: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.opreturn: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, 'opreturn_supply') - self.unspendable: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, 'unspendable_supply') - -class MetricsTree_Supply_Velocity: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.btc: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_btc') - self.usd: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_usd') - -class MetricsTree_Supply_MarketCap: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.cents: MetricPattern1[Cents] = MetricPattern1(client, 'market_cap_cents') - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'market_cap') - self.delta: ChangeRatePattern4 = ChangeRatePattern4(client, 'market_cap_delta') - -class MetricsTree_Supply: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.circulating: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'circulating_supply') - self.burned: MetricsTree_Supply_Burned = MetricsTree_Supply_Burned(client) - self.inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'inflation_rate') - self.velocity: MetricsTree_Supply_Velocity = MetricsTree_Supply_Velocity(client) - self.market_cap: MetricsTree_Supply_MarketCap = MetricsTree_Supply_MarketCap(client) - self.market_minus_realized_cap_growth_rate: _1m1w1y24hPattern[BasisPointsSigned32] = _1m1w1y24hPattern(client, 'market_minus_realized_cap_growth_rate') - self.hodled_or_lost: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'hodled_or_lost_coins') + self.utxo: MetricsTree_Cohorts_Utxo = MetricsTree_Cohorts_Utxo(client) + self.address: MetricsTree_Cohorts_Address = MetricsTree_Cohorts_Address(client) class MetricsTree: """Metrics tree node.""" @@ -5499,7 +5220,6 @@ class MetricsTree: self.addresses: MetricsTree_Addresses = MetricsTree_Addresses(client) self.scripts: MetricsTree_Scripts = MetricsTree_Scripts(client) self.mining: MetricsTree_Mining = MetricsTree_Mining(client) - self.positions: MetricsTree_Positions = MetricsTree_Positions(client) self.cointime: MetricsTree_Cointime = MetricsTree_Cointime(client) self.constants: MetricsTree_Constants = MetricsTree_Constants(client) self.indexes: MetricsTree_Indexes = MetricsTree_Indexes(client) @@ -5507,8 +5227,8 @@ class MetricsTree: self.market: MetricsTree_Market = MetricsTree_Market(client) self.pools: MetricsTree_Pools = MetricsTree_Pools(client) self.prices: MetricsTree_Prices = MetricsTree_Prices(client) - self.distribution: MetricsTree_Distribution = MetricsTree_Distribution(client) self.supply: MetricsTree_Supply = MetricsTree_Supply(client) + self.cohorts: MetricsTree_Cohorts = MetricsTree_Cohorts(client) class BrkClient(BrkClientBase): """Main BRK client with metrics tree and API methods."""