next: ai part 11

This commit is contained in:
nym21
2026-07-29 10:50:14 +02:00
parent eccbda34ee
commit 1cdee36f2e
56 changed files with 2269 additions and 1037 deletions
+10 -8
View File
@@ -1,6 +1,7 @@
import { colors } from "../../utils/colors.js";
import { entries } from "../../utils/array.js";
import { brk } from "../../utils/client.js";
import { ageRanges } from "../age-ranges.js";
/** @type {readonly AddressableType[]} */
const ADDRESSABLE_TYPES = [
@@ -14,9 +15,13 @@ const ADDRESSABLE_TYPES = [
"p2pk65",
];
/** @type {(key: SpendableType) => key is AddressableType} */
const isAddressable = (key) =>
/** @type {readonly string[]} */ (ADDRESSABLE_TYPES).includes(key);
/**
* @param {SpendableType} key
* @returns {key is AddressableType}
*/
function isAddressable(key) {
return /** @type {readonly string[]} */ (ADDRESSABLE_TYPES).includes(key);
}
export function buildCohortData() {
const utxoCohorts = brk.series.cohorts.utxo;
@@ -27,7 +32,6 @@ export function buildCohortData() {
EPOCH_NAMES,
UNDER_AGE_NAMES,
OVER_AGE_NAMES,
AGE_RANGE_NAMES,
OVER_AMOUNT_NAMES,
UNDER_AMOUNT_NAMES,
AMOUNT_RANGE_NAMES,
@@ -83,10 +87,8 @@ export function buildCohortData() {
tree: utxoCohorts.overAge[key],
}));
const ageRange = entries(AGE_RANGE_NAMES).map(([key, names], i, arr) => ({
name: names.short,
title: `UTXOs ${names.long}`,
color: colors.at(i, arr.length),
const ageRange = ageRanges.map(({ key, ...range }) => ({
...range,
tree: utxoCohorts.ageRange[key],
matured: utxoCohorts.matured[key],
}));
@@ -77,10 +77,15 @@ function groupedOutputsFolder(list, all, title) {
}),
},
{
name: "Spending Rate",
title: title("Spending Rate"),
name: "1Y Turnover",
title: title("1 Year UTXO Turnover"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
line({ series: tree.outputs.spendingRate, name, color, unit: Unit.ratio }),
line({
series: tree.outputs.utxoTurnover1y,
name,
color,
unit: Unit.ratio,
}),
),
},
],
@@ -308,10 +313,15 @@ function outputsFolder(outputs, color, title) {
tree: chartsFromCount({ pattern: outputs.spentCount, title, metric: "Spent UTXO Count", unit: Unit.count, color }),
},
{
name: "Spending Rate",
title: title("Spending Rate"),
name: "1Y Turnover",
title: title("1 Year UTXO Turnover"),
bottom: [
line({ series: outputs.spendingRate, name: "Rate", color, unit: Unit.ratio }),
line({
series: outputs.utxoTurnover1y,
name: "Turnover",
color,
unit: Unit.ratio,
}),
],
},
],
@@ -501,7 +501,7 @@ function realizedOverviewFolder({
/**
* Full realized subfolder (All/STH/LTH)
* @param {RealizedPattern | LthRealizedPattern} r
* @param {FullRealizedProfitabilityPattern} r
* @param {(name: string) => string} title
* @returns {PartialOptionsGroup}
*/
@@ -809,7 +809,8 @@ export function createProfitabilitySectionAll({ cohort, title }) {
/**
* Section for cohorts with full realized and unrealized profitability data.
* @param {{ cohort: { tree: { unrealized: FullRelativePattern, realized: RealizedPattern } }, title: (name: string) => string }} args
* This section does not use SOPR, whose shape differs between STH and Entry.
* @param {{ cohort: { tree: { unrealized: FullRelativePattern, realized: FullRealizedProfitabilityPattern } }, title: (name: string) => string }} args
* @returns {PartialOptionsGroup}
*/
export function createProfitabilitySectionFull({ cohort, title }) {