// @ts_check /** * @typedef {Object} BaseSeriesBlueprint * @property {string} title * @property {boolean} [defaultActive] * * @typedef {Object} BaselineSeriesBlueprintSpecific * @property {"Baseline"} type * @property {Color} [color] * @property {[Color, Color]} [colors] * @property {BaselineSeriesPartialOptions} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & BaselineSeriesBlueprintSpecific} BaselineSeriesBlueprint * * @typedef {Object} CandlestickSeriesBlueprintSpecific * @property {"Candlestick"} type * @property {Color} [color] * @property {CandlestickSeriesPartialOptions} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & CandlestickSeriesBlueprintSpecific} CandlestickSeriesBlueprint * * @typedef {Object} LineSeriesBlueprintSpecific * @property {"Line"} [type] * @property {Color} [color] * @property {LineSeriesPartialOptions} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & LineSeriesBlueprintSpecific} LineSeriesBlueprint * * @typedef {Object} HistogramSeriesBlueprintSpecific * @property {"Histogram"} type * @property {Color} color * @property {HistogramSeriesPartialOptions} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & HistogramSeriesBlueprintSpecific} HistogramSeriesBlueprint * * @typedef {BaselineSeriesBlueprint | CandlestickSeriesBlueprint | LineSeriesBlueprint | HistogramSeriesBlueprint} AnySeriesBlueprint * * @typedef {AnySeriesBlueprint["type"]} SeriesType * * @typedef {{ key: VecId, unit?: Unit }} FetchedAnySeriesOptions * * @typedef {BaselineSeriesBlueprint & FetchedAnySeriesOptions} FetchedBaselineSeriesBlueprint * @typedef {CandlestickSeriesBlueprint & FetchedAnySeriesOptions} FetchedCandlestickSeriesBlueprint * @typedef {LineSeriesBlueprint & FetchedAnySeriesOptions} FetchedLineSeriesBlueprint * @typedef {HistogramSeriesBlueprint & FetchedAnySeriesOptions} FetchedHistogramSeriesBlueprint * @typedef {AnySeriesBlueprint & FetchedAnySeriesOptions} AnyFetchedSeriesBlueprint * * @typedef {Object} PartialOption * @property {string} name * * @typedef {Object} ProcessedOptionAddons * @property {string} id * @property {string} title * @property {string[]} path * * @typedef {Object} PartialExplorerOptionSpecific * @property {"explorer"} kind * @property {string} title * * @typedef {PartialOption & PartialExplorerOptionSpecific} PartialExplorerOption * * @typedef {Required & ProcessedOptionAddons} ExplorerOption * * @typedef {Object} PartialChartOptionSpecific * @property {"chart"} [kind] * @property {string} title * @property {AnyFetchedSeriesBlueprint[]} [top] * @property {AnyFetchedSeriesBlueprint[]} [bottom] * * @typedef {PartialOption & PartialChartOptionSpecific} PartialChartOption * * @typedef {Object} ProcessedChartOptionAddons * @property {Record} top * @property {Record} bottom * * @typedef {Required> & ProcessedChartOptionAddons & ProcessedOptionAddons} ChartOption * * @typedef {Object} PartialTableOptionSpecific * @property {"table"} kind * @property {string} title * * @typedef {PartialOption & PartialTableOptionSpecific} PartialTableOption * * @typedef {Required & ProcessedOptionAddons} TableOption * * @typedef {Object} PartialSimulationOptionSpecific * @property {"simulation"} kind * @property {string} title * * @typedef {PartialOption & PartialSimulationOptionSpecific} PartialSimulationOption * * @typedef {Required & ProcessedOptionAddons} SimulationOption * * @typedef {Object} PartialUrlOptionSpecific * @property {"url"} [kind] * @property {() => string} url * @property {boolean} [qrcode] * * @typedef {PartialOption & PartialUrlOptionSpecific} PartialUrlOption * * @typedef {Required & ProcessedOptionAddons} UrlOption * * @typedef {PartialExplorerOption | PartialChartOption | PartialTableOption | PartialSimulationOption | PartialUrlOption} AnyPartialOption * * @typedef {ExplorerOption | ChartOption | TableOption | SimulationOption | UrlOption} Option * * @typedef {Object} PartialOptionsGroup * @property {string} name * @property {PartialOptionsTree} tree * * @typedef {Object} OptionsGroup * @property {string} id * @property {string} name * @property {OptionsTree} tree * * @typedef {(AnyPartialOption | PartialOptionsGroup)[]} PartialOptionsTree * * @typedef {(Option | OptionsGroup)[]} OptionsTree * */ /** * @param {Object} args * @param {Env} args.env * @param {Colors} args.colors * @param {VecIdToIndexes} args.vecIdToIndexes * @returns {PartialOptionsTree} */ function createPartialOptions({ env, colors, vecIdToIndexes }) { /** * @template {string} S * @typedef {Extract} StartsWith */ /** * @template {string} S * @typedef {Extract} EndsWith */ /** * @template {string} K * @template {string} S * @typedef {K extends `${S}${infer Rest}` ? Rest : never} WithoutPrefix */ /** * @template {string} K * @template {string} S * @typedef {K extends `${infer Rest}${S}` ? Rest : never} WithoutSuffix */ /** * @template {string} K * @template {string} S * @typedef {K extends `${infer _Prefix}${S}${infer _Suffix}` ? never : K} ExcludeSubstring */ /** * @typedef {"cumulative_"} CumulativePrefix * @typedef {"_30d_change"} _30DChageSubString * @typedef {StartsWith} CumulativeVecId * @typedef {ExcludeSubstring, _30DChageSubString>} CumulativeVecIdBase * @typedef {"_average"} AverageSuffix * @typedef {EndsWith} VecIdAverage * @typedef {WithoutSuffix} VecIdAverageBase * @typedef {"_median"} MedianSuffix * @typedef {EndsWith} VecIdMedian * @typedef {WithoutSuffix} VecIdMedianBase * @typedef {"_90p"} _90pSuffix * @typedef {EndsWith<_90pSuffix>} VecId90p * @typedef {WithoutSuffix} VecId90pBase * @typedef {"_75p"} _75pSuffix * @typedef {EndsWith<_75pSuffix>} VecId75p * @typedef {WithoutSuffix} VecId75pBase * @typedef {"_25p"} _25pSuffix * @typedef {EndsWith<_25pSuffix>} VecId25p * @typedef {WithoutSuffix} VecId25pBase * @typedef {"_10p"} _10pSuffix * @typedef {EndsWith<_10pSuffix>} VecId10p * @typedef {WithoutSuffix} VecId10pBase * @typedef {"_max"} MaxSuffix * @typedef {EndsWith} VecIdMax * @typedef {WithoutSuffix} VecIdMaxBase * @typedef {"_min"} MinSuffix * @typedef {EndsWith} VecIdMin * @typedef {WithoutSuffix} VecIdMinBase */ const averages = /** @type {const} */ ([ { name: "1 Week", key: "1w", days: 7, color: colors.red }, { name: "8 Day", key: "8d", days: 8, color: colors.orange }, { name: "13 Day", key: "13d", days: 13, color: colors.amber }, { name: "21 Day", key: "21d", days: 21, color: colors.yellow }, { name: "1 Month", key: "1m", days: 30, color: colors.lime }, { name: "34 Day", key: "34d", days: 34, color: colors.green }, { name: "55 Day", key: "55d", days: 55, color: colors.emerald }, { name: "89 Day", key: "89d", days: 89, color: colors.teal }, { name: "144 Day", key: "144d", days: 144, color: colors.cyan }, { name: "200 Day", key: "200d", days: 200, color: colors.sky }, { name: "1 Year", key: "1y", days: 365, color: colors.blue }, { name: "2 Year", key: "2y", days: 2 * 365, color: colors.indigo }, { name: "200 Week", key: "200w", days: 200 * 7, color: colors.violet }, { name: "4 Year", key: "4y", days: 4 * 365, color: colors.purple }, ]); const dcaClasses = /** @type {const} */ ([ { year: 2015, color: colors.pink, defaultActive: false }, { year: 2016, color: colors.red, defaultActive: false }, { year: 2017, color: colors.orange, defaultActive: true }, { year: 2018, color: colors.yellow, defaultActive: true }, { year: 2019, color: colors.green, defaultActive: true }, { year: 2020, color: colors.teal, defaultActive: true }, { year: 2021, color: colors.sky, defaultActive: true }, { year: 2022, color: colors.blue, defaultActive: true }, { year: 2023, color: colors.purple, defaultActive: true }, { year: 2024, color: colors.fuchsia, defaultActive: true }, { year: 2025, color: colors.pink, defaultActive: true }, ]); const terms = /** @type {const} */ ([ { key: "short_term_holders", name: "short", title: "Short Term Holders", color: colors.yellow, }, { key: "long_term_holders", name: "long", title: "Long Term Holders", color: colors.fuchsia, }, ]); const upToDate = /** @type {const} */ ([ { key: "utxos_up_to_1d_old", name: "1d", title: "UTXOs Up to 1 Day old", color: colors.pink, }, { key: "utxos_up_to_1w_old", name: "1w", title: "UTXOs Up to 1 Week old", color: colors.red, }, { key: "utxos_up_to_1m_old", name: "1m", title: "UTXOs Up to 1 Month old", color: colors.orange, }, { key: "utxos_up_to_2m_old", name: "2m", title: "UTXOs Up to 2 Months old", color: colors.amber, }, { key: "utxos_up_to_3m_old", name: "3m", title: "UTXOs Up to 3 Months old", color: colors.yellow, }, { key: "utxos_up_to_4m_old", name: "4m", title: "UTXOs Up to 4 Months old", color: colors.lime, }, { key: "utxos_up_to_5m_old", name: "5m", title: "UTXOs Up to 5 Months old", color: colors.green, }, { key: "utxos_up_to_6m_old", name: "6m", title: "UTXOs Up to 6 Months old", color: colors.teal, }, { key: "utxos_up_to_1y_old", name: "1y", title: "UTXOs Up to 1 Year old", color: colors.sky, }, { key: "utxos_up_to_2y_old", name: "2y", title: "UTXOs Up to 2 Years old", color: colors.indigo, }, { key: "utxos_up_to_3y_old", name: "3y", title: "UTXOs Up to 3 Years old", color: colors.violet, }, { key: "utxos_up_to_4y_old", name: "4y", title: "UTXOs Up to 4 Years old", color: colors.purple, }, { key: "utxos_up_to_5y_old", name: "5y", title: "UTXOs Up to 5 Years old", color: colors.fuchsia, }, { key: "utxos_up_to_6y_old", name: "6y", title: "UTXOs Up to 6 Years old", color: colors.pink, }, { key: "utxos_up_to_7y_old", name: "7y", title: "UTXOs Up to 7 Years old", color: colors.red, }, { key: "utxos_up_to_8y_old", name: "8y", title: "UTXOs Up to 8 Years old", color: colors.orange, }, { key: "utxos_up_to_10y_old", name: "10y", title: "UTXOs Up to 10 Years old", color: colors.amber, }, { key: "utxos_up_to_12y_old", name: "12y", title: "UTXOs Up to 12 Years old", color: colors.yellow, }, { key: "utxos_up_to_15y_old", name: "15y", title: "UTXOs Up to 15 Years old", color: colors.lime, }, ]); const fromDate = /** @type {const} */ ([ { key: "utxos_at_least_1d_old", name: "1d", title: "UTXOs at least 1 Day old", color: colors.red, }, { key: "utxos_at_least_1w_old", name: "1w", title: "UTXOs at least 1 Week old", color: colors.orange, }, { key: "utxos_at_least_1m_old", name: "1m", title: "UTXOs at least 1 Month old", color: colors.yellow, }, { key: "utxos_at_least_2m_old", name: "2m", title: "UTXOs at least 2 Months old", color: colors.lime, }, { key: "utxos_at_least_3m_old", name: "3m", title: "UTXOs at least 3 Months old", color: colors.green, }, { key: "utxos_at_least_4m_old", name: "4m", title: "UTXOs at least 4 Months old", color: colors.teal, }, { key: "utxos_at_least_5m_old", name: "5m", title: "UTXOs at least 5 Months old", color: colors.cyan, }, { key: "utxos_at_least_6m_old", name: "6m", title: "UTXOs at least 6 Months old", color: colors.blue, }, { key: "utxos_at_least_1y_old", name: "1y", title: "UTXOs at least 1 Year old", color: colors.indigo, }, { key: "utxos_at_least_2y_old", name: "2y", title: "UTXOs at least 2 Years old", color: colors.violet, }, { key: "utxos_at_least_3y_old", name: "3y", title: "UTXOs at least 3 Years old", color: colors.purple, }, { key: "utxos_at_least_4y_old", name: "4y", title: "UTXOs at least 4 Years old", color: colors.fuchsia, }, { key: "utxos_at_least_5y_old", name: "5y", title: "UTXOs at least 5 Years old", color: colors.pink, }, { key: "utxos_at_least_6y_old", name: "6y", title: "UTXOs at least 6 Years old", color: colors.rose, }, { key: "utxos_at_least_7y_old", name: "7y", title: "UTXOs at least 7 Years old", color: colors.red, }, { key: "utxos_at_least_8y_old", name: "8y", title: "UTXOs at least 8 Years old", color: colors.orange, }, { key: "utxos_at_least_10y_old", name: "10y", title: "UTXOs at least 10 Years old", color: colors.yellow, }, { key: "utxos_at_least_12y_old", name: "12y", title: "UTXOs at least 12 Years old", color: colors.lime, }, { key: "utxos_at_least_15y_old", name: "15y", title: "UTXOs at least 15 Years old", color: colors.green, }, ]); const dateRange = /** @type {const} */ ([ { key: "utxos_up_to_1d_old", name: "1d", title: "UTXOs New Up to 1 Day old", color: colors.pink, }, { key: "utxos_at_least_1d_up_to_1w_old", name: "1d..1w", title: "UTXOs At least 1 Day ago Up to 1 Week old", color: colors.red, }, { key: "utxos_at_least_1w_up_to_1m_old", name: "1w..1m", title: "UTXOs At least 1 Week ago Up to 1 Month old", color: colors.orange, }, { key: "utxos_at_least_1m_up_to_2m_old", name: "1m..2m", title: "UTXOs At least 1 Month ago Up to 2 Months old", color: colors.yellow, }, { key: "utxos_at_least_2m_up_to_3m_old", name: "2m..3m", title: "UTXOs At least 2 Month ago Up to 3 Months old", color: colors.yellow, }, { key: "utxos_at_least_3m_up_to_4m_old", name: "3m..4m", title: "UTXOs At least 3 Month ago Up to 4 Months old", color: colors.lime, }, { key: "utxos_at_least_4m_up_to_5m_old", name: "4m..5m", title: "UTXOs At least 4 Month ago Up to 5 Months old", color: colors.lime, }, { key: "utxos_at_least_5m_up_to_6m_old", name: "5m..6m", title: "UTXOs At least 5 Month ago Up to 6 Months old", color: colors.lime, }, { key: "utxos_at_least_6m_up_to_1y_old", name: "6m..1y", title: "UTXOs At least 6 Months ago Up to 1 Year old", color: colors.green, }, { key: "utxos_at_least_1y_up_to_2y_old", name: "1y..2y", title: "UTXOs At least 1 Year ago Up to 2 Years old", color: colors.cyan, }, { key: "utxos_at_least_2y_up_to_3y_old", name: "2y..3y", title: "UTXOs At least 2 Years ago Up to 3 Years old", color: colors.blue, }, { key: "utxos_at_least_3y_up_to_4y_old", name: "3y..4y", title: "UTXOs At least 3 Years ago Up to 4 Years old", color: colors.indigo, }, { key: "utxos_at_least_4y_up_to_5y_old", name: "4y..5y", title: "UTXOs At least 4 Years ago Up to 5 Years old", color: colors.violet, }, { key: "utxos_at_least_5y_up_to_6y_old", name: "5y..6y", title: "UTXOs At least 5 Years ago Up to 6 Years old", color: colors.purple, }, { key: "utxos_at_least_6y_up_to_7y_old", name: "6y..7y", title: "UTXOs At least 6 Years ago Up to 7 Years old", color: colors.purple, }, { key: "utxos_at_least_7y_up_to_8y_old", name: "7y..8y", title: "UTXOs At least 7 Years ago Up to 8 Years old", color: colors.fuchsia, }, { key: "utxos_at_least_8y_up_to_10y_old", name: "8y..10y", title: "UTXOs At least 8 Years ago Up to 10 Years old", color: colors.fuchsia, }, { key: "utxos_at_least_10y_up_to_12y_old", name: "10y..12y", title: "UTXOs At least 10 Years ago Up to 12 Years old", color: colors.pink, }, { key: "utxos_at_least_12y_up_to_15y_old", name: "12y..15y", title: "UTXOs At least 12 Years ago Up to 15 Years old", color: colors.red, }, { key: "utxos_at_least_15y_old", name: "15y+", title: "UTXOs At least 15 Years old up to genesis", color: colors.orange, }, ]); const epoch = /** @type {const} */ ([ { key: "epoch_0", name: "0", title: "Epoch 0", color: colors.red, }, { key: "epoch_1", name: "1", title: "Epoch 1", color: colors.yellow, }, { key: "epoch_2", name: "2", title: "Epoch 2", color: colors.orange, }, { key: "epoch_3", name: "3", title: "Epoch 3", color: colors.lime, }, { key: "epoch_4", name: "4", title: "Epoch 4", color: colors.green, }, ]); const aboveAmount = /** @type {const} */ ([ { key: "above_1sat", name: ">=1 sat", title: "Above 1 sat", color: colors.orange, }, { key: "above_10sats", name: ">=10 sats", title: "Above 10 sats", color: colors.orange, }, { key: "above_100sats", name: ">=100 sats", title: "Above 100 sats", color: colors.yellow, }, { key: "above_1k_sats", name: ">=1K sats", title: "Above 1K sats", color: colors.lime, }, { key: "above_10k_sats", name: ">=10K sats", title: "Above 10K sats", color: colors.green, }, { key: "above_100k_sats", name: ">=100K sats", title: "Above 100K sats", color: colors.cyan, }, { key: "above_1m_sats", name: ">=1M sats", title: "Above 1M sats", color: colors.blue, }, { key: "above_10m_sats", name: ">=10M sats", title: "Above 10M sats", color: colors.indigo, }, { key: "above_1btc", name: ">=1 btc", title: "Above 1 BTC", color: colors.purple, }, { key: "above_10btc", name: ">=10 btc", title: "Above 10 BTC", color: colors.violet, }, { key: "above_100btc", name: ">=100 btc", title: "Above 100 BTC", color: colors.fuchsia, }, { key: "above_1k_btc", name: ">=1K btc", title: "Above 1K BTC", color: colors.pink, }, { key: "above_10k_btc", name: ">=10K btc", title: "Above 10K BTC", color: colors.red, }, ]); const utxosAboveAmount = aboveAmount.map( ({ key, name, title, color }) => /** @type {const} */ ({ key: `utxos_${key}`, name, title: `UTXOs ${title}`, color, }), ); const addressesAboveAmount = aboveAmount.map( ({ key, name, title, color }) => /** @type {const} */ ({ key: `addrs_${key}`, name, title: `Addresses ${title}`, color, }), ); const underAmount = /** @type {const} */ ([ { key: "under_10sats", name: "<10 sats", title: "under 10 sats", color: colors.orange, }, { key: "under_100sats", name: "<100 sats", title: "under 100 sats", color: colors.yellow, }, { key: "under_1k_sats", name: "<1k sats", title: "under 1k sats", color: colors.lime, }, { key: "under_10k_sats", name: "<10k sats", title: "under 10k sats", color: colors.green, }, { key: "under_100k_sats", name: "<100k sats", title: "under 100k sats", color: colors.cyan, }, { key: "under_1m_sats", name: "<1m sats", title: "under 1m sats", color: colors.blue, }, { key: "under_10m_sats", name: "<10m sats", title: "under 10m sats", color: colors.indigo, }, { key: "under_1btc", name: "<1 btc", title: "under 1 btc", color: colors.purple, }, { key: "under_10btc", name: "<10 btc", title: "under 10 btc", color: colors.violet, }, { key: "under_100btc", name: "<100 btc", title: "under 100 btc", color: colors.fuchsia, }, { key: "under_1k_btc", name: "<1k btc", title: "under 1k btc", color: colors.pink, }, { key: "under_10k_btc", name: "<10k btc", title: "under 10k btc", color: colors.red, }, { key: "under_100k_btc", name: "<100k btc", title: "under 100k btc", color: colors.orange, }, ]); const utxosUnderAmount = underAmount.map( ({ key, name, title, color }) => /** @type {const} */ ({ key: `utxos_${key}`, name, title: `UTXOs ${title}`, color, }), ); const addressesUnderAmount = underAmount.map( ({ key, name, title, color }) => /** @type {const} */ ({ key: `addrs_${key}`, name, title: `Addresses ${title}`, color, }), ); const amountRanges = /** @type {const} */ ([ { key: "with_0sats", name: "0 sats", title: "valued 0 sats", color: colors.red, }, { key: "above_1sat_under_10sats", name: "1 sat..10 sats", title: "Above 1 sat Under 10 sats", color: colors.orange, }, { key: "above_10sats_under_100sats", name: "10 sats..100 sats", title: "Above 10 sats Under 100 sats", color: colors.yellow, }, { key: "above_100sats_under_1k_sats", name: "100 sats..1K sats", title: "Above 100 sats Under 1K sats", color: colors.lime, }, { key: "above_1k_sats_under_10k_sats", name: "1K sats..10K sats", title: "Above 1K sats Under 10K sats", color: colors.green, }, { key: "above_10k_sats_under_100k_sats", name: "10K sats..100K sats", title: "Above 10K sats Under 100K sats", color: colors.cyan, }, { key: "above_100k_sats_under_1m_sats", name: "100K sats .. 1M sats", title: "Above 100K sats Under 1M sats", color: colors.blue, }, { key: "above_1m_sats_under_10m_sats", name: "1M sats..10M sats", title: "Above 1M sats Under 10M sats", color: colors.indigo, }, { key: "above_10m_sats_under_1btc", name: "10M sats..1 btc", title: "Above 10M sats Under 1 BTC", color: colors.purple, }, { key: "above_1btc_under_10btc", name: "1 btc..10 btc", title: "Above 1 BTC Under 10 BTC", color: colors.violet, }, { key: "above_10btc_under_100btc", name: "10 btc..100 btc", title: "Above 10 BTC Under 100 BTC", color: colors.fuchsia, }, { key: "above_100btc_under_1k_btc", name: "100 btc..1K btc", title: "Above 100 BTC Under 1K BTC", color: colors.pink, }, { key: "above_1k_btc_under_10k_btc", name: "1K btc..10K btc", title: "Above 1K BTC Under 10K BTC", color: colors.red, }, { key: "above_10k_btc_under_100k_btc", name: "10K btc..100K btc", title: "Above 10K BTC Under 100K BTC", color: colors.orange, }, { key: "above_100k_btc", name: "100K+ btc", title: "Above 100K BTC", color: colors.yellow, }, ]); const utxosAmountRanges = amountRanges.map( ({ key, name, title, color }) => /** @type {const} */ ({ key: `utxos_${key}`, name, title: `UTXOs ${title}`, color, }), ); const addressesAmountRanges = amountRanges.map( ({ key, name, title, color }) => /** @type {const} */ ({ key: `addrs_${key}`, name, title: `Addresses ${title}`, color, }), ); const type = /** @type {const} */ ([ { key: "p2pk65", name: "p2pk65", title: "Pay To Long Public Key", color: colors.red, }, { key: "p2pk33", name: "p2pk33", title: "Pay To Short Public Key", color: colors.orange, }, { key: "p2pkh", name: "p2pkh", title: "Pay To Public Key Hash", color: colors.yellow, }, { key: "p2ms_outputs", name: "p2ms", title: "Pay To Bare Multisig", color: colors.lime, }, { key: "p2sh", name: "p2sh", title: "Pay To Script Hash", color: colors.green, }, { key: "p2wpkh", name: "p2wpkh", title: "Pay To Witness Public Key Hash", color: colors.teal, }, { key: "p2wsh", name: "p2wsh", title: "Pay To Witness Script Hash", color: colors.blue, }, { key: "p2tr", name: "p2tr", title: "Pay To Taproot", color: colors.indigo, }, { key: "p2a", name: "p2a", title: "Pay To Anchor", color: colors.purple, }, { key: "unknown_outputs", name: "unknown", title: "Pay To Unknown", color: colors.violet, }, { key: "empty_outputs", name: "empty", title: "Pay To Empty", color: colors.fuchsia, }, ]); const cointimePrices = /** @type {const} */ ([ { key: `true_market_mean`, name: "True market mean", title: "True market mean", color: colors.blue, }, { key: `vaulted_price`, name: "Vaulted", title: "Vaulted Price", color: colors.lime, }, { key: `active_price`, name: "Active", title: "Active Price", color: colors.rose, }, { key: `cointime_price`, name: "cointime", title: "Cointime Price", color: colors.yellow, }, ]); const cointimeCapitalizations = /** @type {const} */ ([ { key: `vaulted_cap`, name: "Vaulted", title: "Vaulted Capitalization", color: colors.lime, }, { key: `active_cap`, name: "Active", title: "Active Capitalization", color: colors.rose, }, { key: `cointime_cap`, name: "Cointime", title: "Cointime Capitalization", color: colors.yellow, }, { key: `investor_cap`, name: "Investor", title: "Investor Capitalization", color: colors.fuchsia, }, { key: `thermo_cap`, name: "Thermo", title: "Thermo Capitalization", color: colors.emerald, }, ]); /** * @param {Object} args * @param {number} [args.number] * @param {string} [args.name] * @param {boolean} [args.defaultActive] * @param {Unit} args.unit */ function createPriceLine({ number = 0, unit, defaultActive, name }) { return /** @satisfies {FetchedLineSeriesBlueprint} */ ({ key: `constant_${number >= 0 ? number : `minus_${Math.abs(number)}`}`, title: name ?? `${number}`, unit, defaultActive, color: colors.gray, options: { lineStyle: 4, lastValueVisible: false, crosshairMarkerVisible: false, }, }); } /** * @param {Object} args * @param {number[]} args.numbers * @param {boolean} [args.defaultActive] * @param {Unit} args.unit */ function createPriceLines({ numbers, unit }) { return numbers.map( (number) => /** @satisfies {FetchedLineSeriesBlueprint} */ ({ key: `constant_${number >= 0 ? number : `minus_${Math.abs(number)}`}`, title: `${number}`, unit, defaultActive: !number, color: colors.gray, options: { lineStyle: 4, lastValueVisible: false, crosshairMarkerVisible: false, }, }), ); } /** * @param {Object} args * @param {VecId} args.key * @param {string} args.name * @param {Color} [args.color] * @param {Unit} [args.unit] * @param {boolean} [args.defaultActive] * @param {LineSeriesPartialOptions} [args.options] */ function createBaseSeries({ key, name, color, defaultActive, unit, options, }) { return /** @satisfies {AnyFetchedSeriesBlueprint} */ ({ key, title: name, color, unit, defaultActive, options, }); } /** * @param {Object} args * @param {VecIdAverageBase} args.concat * @param {string} [args.title] */ function createAverageSeries({ concat, title = "" }) { return /** @satisfies {AnyFetchedSeriesBlueprint} */ ({ key: `${concat}_average`, title: `Average ${title}`, }); } /** * @param {Object} args * @param {CumulativeVecIdBase} args.concat * @param {Color} [args.sumColor] * @param {Color} [args.cumulativeColor] * @param {string} [args.common] */ function createSumCumulativeSeries({ concat, common, sumColor, cumulativeColor, }) { return /** @satisfies {AnyFetchedSeriesBlueprint[]} */ ([ createSumSeries({ key: concat, title: common, color: sumColor, }), createCumulativeSeries({ concat, title: common, color: cumulativeColor, }), ]); } /** * @param {Object} args * @param {CumulativeVecIdBase} args.key * @param {string} [args.title] * @param {Color} [args.color] */ function createSumSeries({ key, title = "", color }) { return /** @satisfies {AnyFetchedSeriesBlueprint} */ ({ key, title: `Sum ${title}`, color: color ?? colors.orange, }); } /** * @param {Object} args * @param {CumulativeVecIdBase} args.concat * @param {string} [args.title] * @param {Color} [args.color] */ function createCumulativeSeries({ concat, title = "", color }) { return /** @satisfies {AnyFetchedSeriesBlueprint} */ ({ key: `${concat}_cumulative`, title: `Cumulative ${title}`, color: color ?? colors.red, defaultActive: false, }); } /** * @param {Object} args * @param {VecIdMinBase & VecIdMaxBase & VecId90pBase & VecId75pBase & VecIdMedianBase & VecId25pBase & VecId10pBase} args.concat * @param {string} [args.title] */ function createMinMaxPercentilesSeries({ concat, title = "" }) { return /** @satisfies {AnyFetchedSeriesBlueprint[]} */ ([ { key: `${concat}_max`, title: `Max ${title}`, color: colors.pink, defaultActive: false, }, { key: `${concat}_min`, title: `Min ${title}`, color: colors.green, defaultActive: false, }, { key: `${concat}_median`, title: `Median ${title}`, color: colors.amber, defaultActive: false, }, { key: `${concat}_75p`, title: `75p ${title}`, color: colors.red, defaultActive: false, }, { key: `${concat}_25p`, title: `25p ${title}`, color: colors.yellow, defaultActive: false, }, { key: `${concat}_90p`, title: `90p ${title}`, color: colors.rose, defaultActive: false, }, { key: `${concat}_10p`, title: `10p ${title}`, color: colors.lime, defaultActive: false, }, ]); } /** * @param {VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecId90pBase & VecId75pBase & VecIdMedianBase & VecId25pBase & VecId10pBase} key */ function createAverageSumCumulativeMinMaxPercentilesSeries(key) { return [ createAverageSeries({ concat: key }), ...createSumCumulativeSeries({ concat: key }), ...createMinMaxPercentilesSeries({ concat: key }), ]; } /** * @param {Object} args * @param {VecId & VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecId90pBase & VecId75pBase & VecIdMedianBase & VecId25pBase & VecId10pBase} args.key * @param {string} args.name */ function createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key, name, }) { return [ createBaseSeries({ key, name, }), ...createAverageSumCumulativeMinMaxPercentilesSeries(key), ]; } /** * @param {Object} args * @param {VecId & CumulativeVecIdBase} args.key * @param {string} args.name */ function createBaseSumCumulativeSeries({ key, name }) { return [ createBaseSeries({ key, name, }), ...createSumCumulativeSeries({ concat: key, }), ]; } /** * @typedef {"_ratio_zscore"} RatioZScoreCapSuffix * @typedef {EndsWith} VecIdRatioZScoreCap * @typedef {WithoutSuffix} VecIdRatioZScoreCapBase */ /** * * @param {Object} args * @param {string} args.name * @param {string} args.legend * @param {string} args.title * @param {VecIdRatioZScoreCapBase} args.key * @param {Color} [args.color] */ function createPriceWithRatioOptions({ name, title, legend, key, color }) { const percentiles = [ { name: "p1", color: colors.indigo, }, { name: "p2", color: colors.violet, }, { name: "p5", color: colors.purple, }, { name: "p95", color: colors.amber, }, { name: "p98", color: colors.orange, }, { name: "p99", color: colors.red, }, ]; const ratioAverages = /** @type {const} */ ([ { name: "1w sma", key: "1w_sma", color: colors.lime, }, { name: "1m sma", key: "1m_sma", color: colors.teal, }, { name: "1y sma", key: "1y_sma", color: colors.sky, }, { name: "2y sma", key: "2y_sma", color: colors.indigo, }, { name: "4y sma", key: "4y_sma", color: colors.purple, }, { name: "all sma", key: "sma", color: colors.rose, }, ]); return [ { name: "price", title, top: [ createBaseSeries({ key, name: legend, color, }), ], }, { name: "Ratio", title: `${title} Ratio`, top: [ createBaseSeries({ key, name: legend, color, }), ...(`${key}_ratio_p1sd_as_price` in vecIdToIndexes ? percentiles.map(({ name, color }) => createBaseSeries({ key: `${key}_ratio_${name}_as_price`, name, color, defaultActive: false, options: { lineStyle: 1, }, }), ) : []), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_ratio`, title: "Ratio", type: "Baseline", options: { baseValue: { price: 1 }, }, }), ...(`${key}_ratio_p1sd` in vecIdToIndexes ? percentiles.map(({ name, color }) => createBaseSeries({ key: `${key}_ratio_${name}`, name, color, defaultActive: false, options: { lineStyle: 1, }, }), ) : []), ...(`${key}_ratio_sma` in vecIdToIndexes ? ratioAverages.map(({ name, key: keyAddon, color }) => createBaseSeries({ key: `${key}_ratio_${keyAddon}`, name, color, defaultActive: false, options: { lineStyle: 1, }, }), ) : []), createPriceLine({ number: 1, unit: "Ratio", }), ], }, ...(`${key}_ratio_zscore` in vecIdToIndexes ? [ { name: "ZScores", tree: [ { name: "compare", title: `Compare ${title} ZScores`, top: [ createBaseSeries({ key, name: legend, color, }), createBaseSeries({ key: `${key}_ratio_1y_0sd_as_price`, name: "1y 0sd", color: colors.fuchsia, defaultActive: false, }), createBaseSeries({ key: `${key}_ratio_2y_0sd_as_price`, name: "2y 0sd", color: colors.purple, defaultActive: false, }), createBaseSeries({ key: `${key}_ratio_4y_0sd_as_price`, name: "4y 0sd", color: colors.violet, defaultActive: false, }), createBaseSeries({ key: `${key}_ratio_0sd_as_price`, name: "0sd", color: colors.indigo, defaultActive: false, }), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_ratio_zscore`, title: "All", type: "Baseline", }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_ratio_4y_zscore`, colors: [colors.lime, colors.rose], title: "4y", type: "Baseline", }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_ratio_2y_zscore`, colors: [colors.avocado, colors.pink], title: "2y", type: "Baseline", }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_ratio_1y_zscore`, colors: [colors.yellow, colors.fuchsia], title: "1Y", type: "Baseline", }), ...createPriceLines({ numbers: [0, 1, 2, 3, 4, -1, -2, -3, -4], unit: "Ratio", }), ], }, ...[ { nameAddon: "all", titleAddon: "", keyAddon: "", }, { nameAddon: "4y", titleAddon: "4y", keyAddon: "4y_", }, { nameAddon: "2y", titleAddon: "2y", keyAddon: "2y_", }, { nameAddon: "1y", titleAddon: "1y", keyAddon: "1y_", }, ].flatMap(({ nameAddon, titleAddon, keyAddon }) => ({ name: nameAddon, title: `${title} ${titleAddon} ZScore`, top: [ createBaseSeries({ key, name: legend, color, }), ...[ { sdKey: "0sd", name: "0σ", color: colors.lime }, { sdKey: `p0_5sd`, name: "+0.5σ", color: colors.yellow, }, { sdKey: `p1sd`, name: "+1σ", color: colors.amber, }, { sdKey: `p1_5sd`, name: "+1.5σ", color: colors.orange, }, { sdKey: `p2sd`, name: "+2σ", color: colors.red, }, { sdKey: `p2_5sd`, name: "+2.5σ", color: colors.rose, }, { sdKey: `p3sd`, name: "+3σ", color: colors.pink, }, { sdKey: `m0_5sd`, name: "−0.5σ", color: colors.teal, }, { sdKey: `m1sd`, name: "−1σ", color: colors.cyan, }, { sdKey: `m1_5sd`, name: "−1.5σ", color: colors.sky, }, { sdKey: `m2sd`, name: "−2σ", color: colors.blue, }, { sdKey: `m2_5sd`, name: "−2.5σ", color: colors.indigo, }, { sdKey: `m3sd`, name: "−3σ", color: colors.violet, }, ].map(({ sdKey, name, color }) => createBaseSeries({ key: `${key}_ratio_${keyAddon}${sdKey}_as_price`, name, color, defaultActive: false, options: { lineStyle: 1, }, }), ), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_ratio_${keyAddon}zscore`, title: "score", type: "Baseline", }), ...createPriceLines({ numbers: [0, 1, 2, 3, 4, -1, -2, -3, -4], unit: "Ratio", }), ], })), ], }, ] : []), ]; } /** * @typedef {"_supply_in_profit"} SupplyInProfitSuffix * @typedef {EndsWith} VecIdSupplyInProfit * @typedef {WithoutSuffix} CohortId */ /** * @typedef {Object} UTXOGroupObject * @property {string} args.name * @property {string} args.title * @property {Color} args.color * @property {"" | CohortId} args.key */ /** * @typedef {Object} UTXOGroupsObject * @property {string} args.name * @property {string} args.title * @property {readonly UTXOGroupObject[]} args.list */ /** * @template {"" | CohortId} T * @param {T} _key */ const fixKey = (_key) => _key !== "" ? /** @type {Exclude<"" | `${T}_`, "_">} */ (`${_key}_`) : /** @type {const} */ (""); /** * @param {UTXOGroupObject | UTXOGroupsObject} args */ function createCohortGroupFolder(args) { const list = "list" in args ? args.list : [args]; const useGroupName = "list" in args; const title = args.title ? `${useGroupName ? "by" : "of"} ${args.title}` : ""; return /** @satisfies {PartialOptionsGroup} */ ({ name: args.name || "all", tree: [ !("list" in args) ? { name: "supply", title: `Supply ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}supply`, name: "Supply", color: colors.default, }), createBaseSeries({ key: `${key}supply_in_btc`, name: "Supply", color: colors.default, }), createBaseSeries({ key: `${key}supply_in_usd`, name: "Supply", color: colors.default, }), ...(key ? [ createBaseSeries({ key: `${key}supply_relative_to_circulating_supply`, name: "Supply", color: colors.default, }), ] : []), createBaseSeries({ key: `${key}halved_supply`, name: "Halved", color: colors.gray, options: { lineStyle: 4, }, }), createBaseSeries({ key: `${key}supply_in_profit`, name: "In Profit", color: colors.green, }), createBaseSeries({ key: `${key}supply_in_profit_in_btc`, name: "In Profit", color: colors.green, }), createBaseSeries({ key: `${key}supply_in_profit_in_usd`, name: "In Profit", color: colors.green, }), createBaseSeries({ key: `${key}supply_in_loss`, name: "In Loss", color: colors.red, }), createBaseSeries({ key: `${key}supply_in_loss_in_btc`, name: "In Loss", color: colors.red, }), createBaseSeries({ key: `${key}supply_in_loss_in_usd`, name: "In Loss", color: colors.red, }), createBaseSeries({ key: `${key}supply_even`, name: useGroupName ? name : "Even", color: colors.yellow, }), createBaseSeries({ key: `${key}supply_even_in_btc`, name: useGroupName ? name : "Even", color: colors.yellow, }), createBaseSeries({ key: `${key}supply_even_in_usd`, name: useGroupName ? name : "Even", color: colors.yellow, }), createBaseSeries({ key: `${key}halved_supply_in_btc`, name: useGroupName ? name : "Halved", color: "list" in args ? color : colors.gray, options: { lineStyle: 4, }, }), createBaseSeries({ key: `${key}halved_supply_in_usd`, name: useGroupName ? name : "Halved", color: "list" in args ? color : colors.gray, options: { lineStyle: 4, }, }), ...(key ? [ createBaseSeries({ key: `${key}supply_in_profit_relative_to_circulating_supply`, name: "In Profit", color: colors.green, }), createBaseSeries({ key: `${key}supply_in_loss_relative_to_circulating_supply`, name: "In Loss", color: colors.red, }), createBaseSeries({ key: `${key}supply_even_relative_to_circulating_supply`, name: "Even", color: colors.yellow, }), ] : []), createBaseSeries({ key: `${key}supply_in_profit_relative_to_own_supply`, name: "In Profit", color: colors.green, }), createBaseSeries({ key: `${key}supply_in_loss_relative_to_own_supply`, name: "In Loss", color: colors.red, }), createBaseSeries({ key: `${key}supply_even_relative_to_own_supply`, name: "Even", color: colors.yellow, }), ]); }), } : { name: "supply", tree: [ { name: "total", title: `Supply ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}supply`, name, color, }), createBaseSeries({ key: `${key}supply_in_btc`, name, color, }), createBaseSeries({ key: `${key}supply_in_usd`, name, color, }), ...(key ? [ createBaseSeries({ key: `${key}supply_relative_to_circulating_supply`, name, color, }), ] : []), ]); }), }, { name: "in profit", title: `Supply In Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}supply_in_profit`, name, color, }), createBaseSeries({ key: `${key}supply_in_profit_in_btc`, name, color, }), createBaseSeries({ key: `${key}supply_in_profit_in_usd`, name, color, }), ...(key ? [ createBaseSeries({ key: `${key}supply_in_profit_relative_to_circulating_supply`, name, color, }), ] : []), createBaseSeries({ key: `${key}supply_in_profit_relative_to_own_supply`, name, color, }), ]); }), }, { name: "in loss", title: `Supply In loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}supply_in_loss`, name, color, }), createBaseSeries({ key: `${key}supply_in_loss_in_btc`, name, color, }), createBaseSeries({ key: `${key}supply_in_loss_in_usd`, name, color, }), ...(key ? [ createBaseSeries({ key: `${key}supply_in_loss_relative_to_circulating_supply`, name, color, }), ] : []), createBaseSeries({ key: `${key}supply_in_loss_relative_to_own_supply`, name, color, }), ]); }), }, { name: "even", title: `Even Supply ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}supply_even`, name, color, }), createBaseSeries({ key: `${key}supply_even_in_btc`, name, color, }), createBaseSeries({ key: `${key}supply_even_in_usd`, name, color, }), ...(key ? [ createBaseSeries({ key: `${key}supply_even_relative_to_circulating_supply`, name, color, }), ] : []), createBaseSeries({ key: `${key}supply_even_relative_to_own_supply`, name, color, }), ]); }), }, ], }, { name: "utxo count", title: `UTXO Count ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}utxo_count`, name: useGroupName ? name : "Count", color, }), ]); }), }, ...(list.filter( ({ key }) => `${fixKey(key)}address_count` in vecIdToIndexes, ).length ? !("list" in args) || list.filter( ({ key }) => `${fixKey(key)}empty_address_count` in vecIdToIndexes, ).length == 0 ? [ { name: "address count", title: `Address Count ${title}`, bottom: list.flatMap(({ name, color, key: _key }) => { const key = fixKey(_key); return [ ...(`${key}address_count` in vecIdToIndexes ? /** @type {const} */ ([ createBaseSeries({ key: `${key}address_count`, name: useGroupName ? name : "Loaded", color: useGroupName ? color : colors.orange, }), ]) : []), ...(`${key}empty_address_count` in vecIdToIndexes ? /** @type {const} */ ([ createBaseSeries({ key: `${key}empty_address_count`, name: "Empty", color: colors.gray, defaultActive: false, }), ]) : []), ]; }), }, ] : [ { name: "address count", tree: [ { name: "loaded", title: `Loaded Address Count ${title}`, bottom: list .filter( ({ key }) => `${fixKey(key)}address_count` in vecIdToIndexes, ) .flatMap(({ name, color, key: _key }) => { const key = fixKey(_key); return [ createBaseSeries({ key: `${key}address_count`, name, color, }), ]; }), }, ...(list.filter( ({ key }) => `${fixKey(key)}empty_address_count` in vecIdToIndexes, ).length ? [ { name: "empty", title: `Empty Address Count ${title}`, bottom: list .filter( ({ key }) => `${fixKey(key)}empty_address_count` in vecIdToIndexes, ) .flatMap(({ name, color, key: _key }) => { const key = fixKey(_key); return [ createBaseSeries({ key: `${key}empty_address_count`, name, color, }), ]; }), }, ] : []), ], }, ] : []), { name: "Realized", tree: [ ...("list" in args ? [ { name: "Price", title: `Realized Price ${title}`, top: args.list.map(({ color, name, key }) => createBaseSeries({ key: `${fixKey(key)}realized_price`, name, color, }), ), }, ] : createPriceWithRatioOptions({ title: `Realized Price ${title}`, key: `${fixKey(args.key)}realized_price`, name: "price", legend: "realized", color: args.color, })), { name: "capitalization", title: `Realized Capitalization ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}realized_cap`, name: useGroupName ? name : "Capitalization", color, }), ...(!("list" in args) ? [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${key}realized_cap_30d_change`, title: "30d change", defaultActive: false, }), createPriceLine({ unit: "USD", defaultActive: false, }), ] : []), ]); }), }, ...(!("list" in args) ? [ { name: "pnl", title: `Realized Profit And Loss ${title}`, bottom: [ createBaseSeries({ key: `${fixKey(args.key)}realized_profit`, name: "Profit", color: colors.green, }), createBaseSeries({ key: `${fixKey(args.key)}realized_profit_cumulative`, name: "Cumulative Profit", color: colors.green, defaultActive: false, }), createBaseSeries({ key: `${fixKey(args.key)}realized_loss`, name: "Loss", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${fixKey(args.key)}realized_loss_cumulative`, name: "Cumulative Loss", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${fixKey(args.key)}negative_realized_loss`, name: "Negative Loss", color: colors.red, }), createBaseSeries({ key: `${fixKey( args.key, )}negative_realized_loss_cumulative`, name: "Cumulative Negative Loss", color: colors.red, defaultActive: false, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( args.key, )}realized_profit_relative_to_realized_cap`, title: "Profit", color: colors.green, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( args.key, )}realized_loss_relative_to_realized_cap`, title: "Loss", color: colors.red, }), createPriceLine({ unit: "%rcap", }), createPriceLine({ unit: "USD", defaultActive: false, }), ], }, { name: "Net pnl", title: `Net Realized Profit And Loss ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey(key)}net_realized_profit_and_loss`, title: "Raw", }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative`, title: "Cumulative", defaultActive: false, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative_30d_change`, title: "cumulative 30d change", defaultActive: false, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_relative_to_realized_cap`, title: "Raw", }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap`, title: "cumulative 30d change", defaultActive: false, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap`, title: "cumulative 30d change", }), createPriceLine({ unit: "%mcap", }), createPriceLine({ unit: "%rcap", }), createPriceLine({ unit: "USD", }), ]), }, { name: "sopr", title: `Spent Output Profit Ratio ${title}`, bottom: list.flatMap(({ color, name, key }) => { const soprKey = `${fixKey(key)}spent_output_profit_ratio`; const asoprKey = `${fixKey(key)}adjusted_spent_output_profit_ratio`; return [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: soprKey, title: "normal", options: { baseValue: { price: 1, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${soprKey}_7d_ema`, title: "7d ema", colors: [colors.lime, colors.rose], defaultActive: false, options: { baseValue: { price: 1, }, }, }), ...(asoprKey in vecIdToIndexes ? [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: asoprKey, title: "adjusted", colors: [colors.avocado, colors.pink], defaultActive: false, options: { baseValue: { price: 1, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${asoprKey}_7d_ema`, title: "adj. 7d ema", colors: [colors.yellow, colors.fuchsia], defaultActive: false, options: { baseValue: { price: 1, }, }, }), ] : []), createPriceLine({ number: 1, unit: "Ratio", }), ]; }), }, ] : [ { name: "profit", title: `Realized Profit ${title}`, bottom: [ ...list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}realized_profit`, name, color, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${key}realized_profit_relative_to_realized_cap`, title: name, color, }), ]); }), createPriceLine({ unit: "USD", }), ], }, { name: "loss", title: `Realized Loss ${title}`, bottom: [ ...list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}realized_loss`, name, color, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${key}realized_loss_relative_to_realized_cap`, title: name, color, }), ]); }), createPriceLine({ unit: "USD", }), ], }, { name: "Net pnl", title: `Net Realized Profit And Loss ${title}`, bottom: [ ...list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey(key)}net_realized_profit_and_loss`, title: name, color, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_relative_to_realized_cap`, title: name, color, }), ]), createPriceLine({ unit: "USD", }), createPriceLine({ unit: "%rcap", }), ], }, { name: "cumulative", tree: [ { name: "profit", title: `Cumulative Realized Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}realized_profit_cumulative`, name, color, }), ]); }), }, { name: "loss", title: `Cumulative Realized Loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}realized_loss_cumulative`, name, color, }), ]); }), }, { name: "Net pnl", title: `Cumulative Net Realized Profit And Loss ${title}`, bottom: [ ...list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative`, title: name, color, defaultActive: false, }), ]), createPriceLine({ unit: "USD", }), ], }, { name: "Net pnl 30d change", title: `Cumulative Net Realized Profit And Loss 30 Day Change ${title}`, bottom: [ ...list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative_30d_change`, title: name, color, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap`, title: name, color, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap`, title: name, color, }), ]), createPriceLine({ unit: "USD", }), createPriceLine({ unit: "%mcap", }), createPriceLine({ unit: "%rcap", }), ], }, ], }, { name: "sopr", tree: [ { name: "Normal", title: `Spent Output Profit Ratio ${title}`, bottom: [ ...list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey(key)}spent_output_profit_ratio`, title: name, color, }), ]), createPriceLine({ number: 1, unit: "Ratio", }), ], }, ...(() => { const reducedList = list .map(({ color, name, key }) => ({ color, name, key: `${fixKey( key, )}adjusted_spent_output_profit_ratio`, })) .filter(({ key }) => key in vecIdToIndexes); return reducedList.length ? [ { name: "Adjusted", title: `Adjusted Spent Output Profit Ratio ${title}`, bottom: [ ...reducedList.flatMap( ({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key, title: name, color, }), ], ), createPriceLine({ number: 1, unit: "Ratio", }), ], }, ] : []; })(), ], }, ]), { name: "Sell Side Risk Ratio", title: `Sell Side Risk Ratio ${title}`, bottom: !("list" in args) ? list.flatMap(({ key }) => [ createBaseSeries({ key: `${fixKey(key)}sell_side_risk_ratio`, name: "raw", color: colors.orange, }), createBaseSeries({ key: `${fixKey(key)}sell_side_risk_ratio_7d_ema`, name: "7d ema", color: colors.red, defaultActive: false, }), ]) : list.flatMap(({ color, name, key }) => [ createBaseSeries({ key: `${fixKey(key)}sell_side_risk_ratio`, name, color: color, }), ]), }, ], }, { name: "Unrealized", tree: [ ...(!("list" in args) ? [ { name: "pnl", title: `Unrealized Profit And Loss ${title}`, bottom: [ createBaseSeries({ key: `${fixKey(args.key)}unrealized_profit`, name: "Profit", color: colors.green, }), createBaseSeries({ key: `${fixKey(args.key)}unrealized_loss`, name: "Loss", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${fixKey(args.key)}negative_unrealized_loss`, name: "Negative Loss", color: colors.red, }), createPriceLine({ unit: "USD", defaultActive: false, }), ], }, ] : [ { name: "profit", title: `Unrealized Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}unrealized_profit`, name: useGroupName ? name : "Profit", color: useGroupName ? color : colors.green, }), ]); }), }, { name: "loss", title: `Unrealized Loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}unrealized_loss`, name: useGroupName ? name : "Loss", color: useGroupName ? color : colors.red, }), ]); }), }, ]), { name: "Net pnl", title: `Net Unrealized Profit And Loss ${title}`, bottom: [ ...list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey(key)}net_unrealized_profit_and_loss`, title: useGroupName ? name : "Net", color: useGroupName ? color : undefined, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", key: `${fixKey( key, )}net_unrealized_profit_and_loss_relative_to_market_cap`, title: useGroupName ? name : "Net", color: useGroupName ? color : undefined, }), ]), createPriceLine({ unit: "USD", }), createPriceLine({ unit: "%mcap", }), ], }, ], }, ...("list" in args ? [ { name: "Cost Basis", tree: [ { name: "Average", title: `Average Cost Basis ${title}`, top: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}realized_price`, name, color: color, }), ]); }), }, { name: "Min", title: `Min Cost Basis ${title}`, top: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}min_price_paid`, name, color: color, }), ]); }), }, { name: "Max", title: `Max Cost Basis ${title}`, top: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}max_price_paid`, name, color: color, }), ]); }), }, ], }, ] : [ { name: "Cost Basis", title: `Costs Basis ${title}`, top: [ createBaseSeries({ key: `${fixKey(args.key)}realized_price`, name: "Average", color: args.color, }), createBaseSeries({ key: `${fixKey(args.key)}min_price_paid`, name: "Min", color: colors.green, // defaultActive: false, }), createBaseSeries({ key: `${fixKey(args.key)}max_price_paid`, name: "Max", color: colors.red, // defaultActive: false, }), ], }, ]), { name: "Coins Destroyed", title: `Coins Destroyed ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ key: `${key}coinblocks_destroyed`, name: useGroupName ? name : "sum", color, }), createBaseSeries({ key: `${key}coinblocks_destroyed_cumulative`, name: useGroupName ? name : "cumulative", color, defaultActive: false, }), createBaseSeries({ key: `${key}coindays_destroyed`, name: useGroupName ? name : "sum", color, }), createBaseSeries({ key: `${key}coindays_destroyed_cumulative`, name: useGroupName ? name : "cumulative", color, defaultActive: false, }), ]); }), }, ], }); } return [ ...(env.localhost ? /** @type {const} */ ([ { name: "Explorer", title: "Explorer", kind: "explorer", }, ]) : []), { name: "Charts", tree: [ { name: "Price", title: "Bitcoin Price", }, { name: "Market", tree: [ { name: "Capitalization", title: "Market Capitalization", bottom: [ createBaseSeries({ key: "marketcap", name: "Capitalization", }), ], }, { name: "All Time High", title: "All Time High", // tree: [ // { // name: "Value", top: [ createBaseSeries({ key: "ath", name: "ath", }), ], bottom: [ createBaseSeries({ key: "drawdown", name: "Drawdown", color: colors.red, }), createBaseSeries({ key: "days_since_ath", name: "Days since", }), createBaseSeries({ key: "max_days_between_aths", name: "Max", color: colors.red, }), createBaseSeries({ key: "max_years_between_aths", name: "Max", color: colors.red, }), ], }, { name: "Averages", tree: [ { nameAddon: "Simple", keyAddon: "sma", }, { nameAddon: "Exponential", keyAddon: "ema", }, ].map(({ nameAddon, keyAddon }) => ({ name: nameAddon, tree: [ { name: "Compare", title: `Market Price ${nameAddon} Moving Averages`, top: averages.map(({ days, key, name, color }) => createBaseSeries({ key: `${key}_${keyAddon}`, name: key, color, }), ), }, ...averages.map(({ key, name, color }) => ({ name, tree: createPriceWithRatioOptions({ key: `${key}_${keyAddon}`, name, title: `${name} Market Price ${nameAddon} Moving Average`, legend: "average", color, }), })), ], })), }, { name: "Performance", tree: /** @type {const} */ ([ { name: "1 Day", key: "1d" }, { name: "1 Week", key: "1w" }, { name: "1 Month", key: "1m" }, { name: "3 Month", key: "3m" }, { name: "6 Month", key: "6m" }, { name: "1 Year", key: "1y" }, { name: "2 Year", key: "2y" }, { name: "3 Year", key: "3y" }, { name: "4 Year", key: "4y" }, { name: "5 Year", key: "5y" }, { name: "6 Year", key: "6y" }, { name: "8 Year", key: "8y" }, { name: "10 Year", key: "10y" }, ]).map(({ name, key }) => ({ name, title: `${name} Performance`, bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_returns`, title: "Returns", type: "Baseline", }), createPriceLine({ unit: "performance", }), ...(`${key}_cagr` in vecIdToIndexes ? [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_cagr`, title: "cagr", type: "Baseline", }), createPriceLine({ unit: "cagr", }), ] : []), ], })), }, { name: "Indicators", tree: [ { name: "Mayer multiple", title: "Mayer multiple", top: [ createBaseSeries({ key: `200d_sma`, name: "200d sma", color: colors.yellow, }), createBaseSeries({ key: `200d_sma_x2_4`, name: "200d sma x2.4", color: colors.green, }), createBaseSeries({ key: `200d_sma_x0_8`, name: "200d sma x0.8", color: colors.red, }), ], }, ], }, ], }, { name: "Investing", tree: [ { name: "DCA vs Lump sum", tree: [ .../** @type {const} */ ([ { name: "1 Week", key: "1w" }, { name: "1 Month", key: "1m" }, { name: "3 Month", key: "3m" }, { name: "6 Month", key: "6m" }, { name: "1 Year", key: "1y" }, ]).map( ({ name, key }) => /** @satisfies {PartialChartOption} */ ({ name, title: `${name} DCA vs Lump Sum Returns`, top: [ createBaseSeries({ key: `${key}_dca_avg_price`, name: `dca`, color: colors.orange, }), createBaseSeries({ key: `price_${key}_ago`, name: `lump sum`, color: colors.cyan, }), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_dca_returns`, title: "dca", type: "Baseline", colors: [colors.yellow, colors.pink], }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_returns`, title: "lump sum", type: "Baseline", }), createPriceLine({ unit: "performance", }), ], }), ), .../** @type {const} */ ([ { name: "2 Year", key: "2y" }, { name: "3 Year", key: "3y" }, { name: "4 Year", key: "4y" }, { name: "5 Year", key: "5y" }, { name: "6 Year", key: "6y" }, { name: "8 Year", key: "8y" }, { name: "10 Year", key: "10y" }, ]).map( ({ name, key }) => /** @satisfies {PartialChartOption} */ ({ name, title: `${name} DCA vs Lump Sum Returns`, top: [ createBaseSeries({ key: `${key}_dca_avg_price`, name: `dca`, color: colors.orange, }), createBaseSeries({ key: `price_${key}_ago`, name: `lump sum price`, color: colors.cyan, }), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_dca_returns`, title: "dca", type: "Baseline", colors: [colors.yellow, colors.pink], }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_dca_cagr`, title: "dca", type: "Baseline", colors: [colors.yellow, colors.pink], }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_returns`, title: "lump sum", type: "Baseline", }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}_cagr`, title: "lump sum", type: "Baseline", }), createPriceLine({ unit: "performance", }), ], }), ), ], }, { name: "DCA Class", tree: [ { name: "Compare", title: "DCA Classes", top: dcaClasses.map(({ year, color, defaultActive }) => createBaseSeries({ key: `dca_class_${year}_avg_price`, name: `${year}`, color, defaultActive, }), ), }, ...dcaClasses.map( ({ year, color }) => /** @satisfies {PartialChartOption} */ ({ name: `${year}`, title: `DCA Since ${year}`, top: [ createBaseSeries({ key: `dca_class_${year}_avg_price`, name: `avg. price`, color, }), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `dca_class_${year}_returns`, title: "dca", type: "Baseline", }), createPriceLine({ unit: "performance", }), ], }), ), ], }, ], }, { name: "Mining", tree: [ { name: "Supply", title: "Circulating Supply", bottom: [ createBaseSeries({ key: "subsidy_in_btc_cumulative", name: "Mined", }), ], }, { name: "Coinbase", title: "Coinbase", bottom: [ ...createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "coinbase", name: "Coinbase", }), ...createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "coinbase_in_btc", name: "Coinbase", }), ...createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "coinbase_in_usd", name: "Coinbase", }), ], }, { name: "Subsidy", title: "Subsidy", bottom: [ ...createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "subsidy", name: "Subsidy", }), ...createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "subsidy_in_btc", name: "Subsidy", }), ...createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "subsidy_in_usd", name: "Subsidy", }), ], }, { name: "Fee", title: "Transaction Fee", bottom: [ ...createAverageSumCumulativeMinMaxPercentilesSeries("fee"), ...createAverageSumCumulativeMinMaxPercentilesSeries( "fee_in_btc", ), ...createAverageSumCumulativeMinMaxPercentilesSeries( "fee_in_usd", ), ], }, { name: "Unclaimed Rewards", title: "Unclaimed Rewards", bottom: [ ...createSumCumulativeSeries({ concat: "unclaimed_rewards", }), ...createSumCumulativeSeries({ concat: "unclaimed_rewards_in_btc", }), ...createSumCumulativeSeries({ concat: "unclaimed_rewards_in_usd", }), ], }, { name: "Feerate", title: "Transaction Fee Rate", bottom: [ createAverageSeries({ concat: "feerate" }), ...createMinMaxPercentilesSeries({ concat: "feerate", }), ], }, { name: "Difficulty", title: "Difficulty", bottom: [ createBaseSeries({ key: "difficulty", name: "Value", }), ], }, { name: "Difficulty Epoch", title: "Difficulty Epoch", bottom: [ createBaseSeries({ key: "difficultyepoch", name: "Epoch", }), ], }, { name: "Halving Epoch", title: "Halving Epoch", bottom: [ createBaseSeries({ key: "halvingepoch", name: "Epoch", }), ], }, ], }, { name: "Block", tree: [ { name: "Count", title: "Block Count", bottom: [ ...createSumCumulativeSeries({ concat: "block_count", }), createPriceLine({ unit: "Count", name: "Target", number: 144, }), ], }, { name: "Interval", title: "Block Interval", bottom: [ createBaseSeries({ key: "interval", name: "Interval", }), createAverageSeries({ concat: "block_interval" }), ...createMinMaxPercentilesSeries({ concat: "block_interval", }), createPriceLine({ unit: "secs", name: "Target", number: 600, }), ], }, { name: "Size", title: "Block Size", bottom: [ createBaseSeries({ key: "total_size", name: "Size", }), ...createSumCumulativeSeries({ concat: "block_size", }), ], }, { name: "Bytes", title: "Block Bytes", bottom: [ createBaseSeries({ key: "weight", name: "Weight", }), ...createSumCumulativeSeries({ concat: "block_weight", common: "weight", }), createBaseSeries({ key: "vbytes", name: "Vbytes", }), ...createSumCumulativeSeries({ concat: "block_vbytes", common: "Vbytes", }), ], }, ], }, { name: "Transaction", tree: [ { name: "Count", title: "Transaction Count", bottom: createBaseAverageSumCumulativeMinMaxPercentilesSeries({ key: "tx_count", name: "Count", }), }, { name: "Bytes", title: "Transaction Bytes", bottom: [ createAverageSeries({ concat: "tx_weight", title: "Weight" }), ...createMinMaxPercentilesSeries({ concat: "tx_weight", title: "Weight", }), createAverageSeries({ concat: "tx_vsize", title: "VSize" }), ...createMinMaxPercentilesSeries({ concat: "tx_vsize", title: "VSize", }), ], }, { name: "Versions", title: "Transaction Versions", bottom: [ [colors.orange, colors.red], [colors.cyan, colors.blue], [colors.lime, colors.green], ].flatMap(([sumColor, cumulativeColor], index) => createSumCumulativeSeries({ concat: `tx_v${index + 1}`, common: `v${index + 1}`, sumColor, cumulativeColor, }), ), }, ], }, { name: "Input", tree: [ { name: "Count", title: "Transaction Input Count", bottom: [ createAverageSeries({ concat: "input_count" }), createCumulativeSeries({ concat: "input_count", }), ...createMinMaxPercentilesSeries({ concat: "input_count", }), ], }, // { // name: "Value", // title: "Transaction Input Value", // bottom: [ // createAverageSeries({ concat: "input_value" }), // ...createSumCumulativeSeries({ concat: "input_value" }), // ], // }, ], }, { name: "Output", tree: [ { name: "Count", title: "Transaction Output Count", bottom: [ createAverageSeries({ concat: "output_count" }), createCumulativeSeries({ concat: "input_count", }), ...createMinMaxPercentilesSeries({ concat: "output_count", }), ], }, // { // name: "Value", // title: "Transaction Output Value", // bottom: [ // createAverageSeries({ concat: "output_value" }), // ...createSumCumulativeSeries({ concat: "output_value" }), // ], // }, ], }, { name: "Cohorts", tree: [ createCohortGroupFolder({ key: "", name: "", title: "", color: colors.orange, }), { name: "terms", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs Term", list: terms, }), ...terms.map(createCohortGroupFolder), ], }, { name: "Epochs", tree: [ createCohortGroupFolder({ name: "Compare", title: "Epoch", list: epoch, }), ...epoch.map(createCohortGroupFolder), ], }, { name: "types", tree: [ createCohortGroupFolder({ name: "Compare", title: "Type", list: type, }), ...type.map(createCohortGroupFolder), ], }, { name: "UTXOs Up to age", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs Up To Age", list: upToDate, }), ...upToDate.map(createCohortGroupFolder), ], }, { name: "UTXOs from age", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs from age", list: fromDate, }), ...fromDate.map(createCohortGroupFolder), ], }, { name: "UTXOs age Ranges", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs Age Range", list: dateRange, }), ...dateRange.map(createCohortGroupFolder), ], }, { name: "UTXOs under amounts", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs under amount", list: utxosUnderAmount, }), ...utxosUnderAmount.map(createCohortGroupFolder), ], }, { name: "UTXOs Above Amounts", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs Above Amount", list: utxosAboveAmount, }), ...utxosAboveAmount.map(createCohortGroupFolder), ], }, { name: "UTXOs between amounts", tree: [ createCohortGroupFolder({ name: "Compare", title: "UTXOs between amounts", list: utxosAmountRanges, }), ...utxosAmountRanges.map(createCohortGroupFolder), ], }, { name: "Addresses under amount", tree: [ createCohortGroupFolder({ name: "Compare", title: "Addresses under Amount", list: addressesUnderAmount, }), ...addressesUnderAmount.map(createCohortGroupFolder), ], }, { name: "Addresses above amount", tree: [ createCohortGroupFolder({ name: "Compare", title: "Addresses above amount", list: addressesAboveAmount, }), ...addressesAboveAmount.map(createCohortGroupFolder), ], }, { name: "Addresses between amounts", tree: [ createCohortGroupFolder({ name: "Compare", title: "Addresses between amounts", list: addressesAmountRanges, }), ...addressesAmountRanges.map(createCohortGroupFolder), ], }, ], }, { name: "Unspendable", tree: [ { name: "supply", title: "Unspendable Supply", bottom: [ createBaseSeries({ key: "unspendable_supply", name: "Supply", }), createBaseSeries({ key: "unspendable_supply_in_btc", name: "Supply", }), createBaseSeries({ key: "unspendable_supply_in_usd", name: "Supply", }), ], }, { name: "op_return", tree: [ { name: "outputs", title: "op_return outputs", bottom: [ createBaseSeries({ key: "opreturn_count", name: "Count" }), createBaseSeries({ key: "opreturn_count", name: "sum", }), createBaseSeries({ key: "opreturn_count_cumulative", name: "cumulative", color: colors.red, }), ], }, { name: "supply", title: "OP_return Supply", bottom: [ createBaseSeries({ key: "opreturn_supply", name: "Supply", }), createBaseSeries({ key: "opreturn_supply_in_btc", name: "Supply", }), createBaseSeries({ key: "opreturn_supply_in_usd", name: "Supply", }), ], }, ], }, ], }, { name: "Cointime", tree: [ { name: "Prices", tree: [ { name: "Compare", title: "Compare Cointime Prices", top: cointimePrices.map(({ key, name, color }) => createBaseSeries({ key, name, color, }), ), }, ...cointimePrices.map(({ key, name, color, title }) => ({ name, tree: createPriceWithRatioOptions({ key, legend: name, color, name, title, }), })), ], }, { name: "Capitalization", tree: [ { name: "Compare", title: "Compare Cointime Capitalizations", bottom: [ createBaseSeries({ key: `marketcap`, name: "Market", color: colors.default, }), createBaseSeries({ key: `realized_cap`, name: "Realized", color: colors.orange, }), ...cointimeCapitalizations.map(({ key, name, color }) => createBaseSeries({ key, name, color, }), ), ], }, ...cointimeCapitalizations.map( ({ key, name, color, title }) => ({ name, title, bottom: [ createBaseSeries({ key, name, color, }), createBaseSeries({ key: `marketcap`, name: "Market", color: colors.default, }), createBaseSeries({ key: `realized_cap`, name: "Realized", color: colors.orange, }), ], }), ), ], }, { name: "Supply", title: "Cointime Supply", bottom: /** @type {const} */ ([ { name: "all", color: colors.orange, }, { name: "vaulted", color: colors.lime, }, { name: "active", color: colors.rose }, ]).flatMap( ({ name, color }) => /** @type {const} */ ([ createBaseSeries({ key: `${ name !== "all" ? /** @type {const} */ (`${name}_`) : "" }supply`, name, color, }), createBaseSeries({ key: `${ name !== "all" ? /** @type {const} */ (`${name}_`) : "" }supply_in_btc`, name, color, }), createBaseSeries({ key: `${ name !== "all" ? /** @type {const} */ (`${name}_`) : "" }supply_in_usd`, name, color, }), ]), ), }, { name: "Liveliness & Vaultedness", title: "Liveliness & Vaultedness", bottom: [ createBaseSeries({ key: "liveliness", name: "Liveliness", color: colors.rose, }), createBaseSeries({ key: "vaultedness", name: "Vaultedness", color: colors.lime, }), ], }, { name: "Coinblocks", title: "Coinblocks", bottom: [ createBaseSeries({ key: "coinblocks_destroyed", name: "Destroyed", color: colors.red, }), createBaseSeries({ key: "coinblocks_destroyed_cumulative", name: "Cumulative Destroyed", color: colors.red, defaultActive: false, }), createBaseSeries({ key: "coinblocks_created", name: "created", color: colors.orange, }), createBaseSeries({ key: "coinblocks_created_cumulative", name: "Cumulative created", color: colors.orange, defaultActive: false, }), createBaseSeries({ key: "coinblocks_stored", name: "stored", color: colors.green, }), createBaseSeries({ key: "coinblocks_stored_cumulative", name: "Cumulative stored", color: colors.green, defaultActive: false, }), ], }, ], }, ], }, { kind: "table", title: "Table", name: "Table", }, { name: "Simulations", tree: [ { kind: "simulation", title: "Save In Bitcoin", name: "Save In Bitcoin", }, ], }, { name: "Tools", tree: [ { name: "API", url: () => "/api", }, { name: "MCP", url: () => "https://github.com/bitcoinresearchkit/brk/tree/main/crates/brk_mcp#brk-mcp", }, { name: "Crates", url: () => "https://crates.io/crates/brk", }, { name: "Source", url: () => "https://github.com/bitcoinresearchkit/brk", }, ], }, { name: "Hosting", tree: [ { name: "Status", url: () => "https://status.bitview.space/", }, { name: "Self", url: () => "https://crates.io/crates/brk_cli", }, { name: "As a service", url: () => "https://github.com/bitcoinresearchkit/brk?tab=readme-ov-file#hosting-as-a-service", }, ], }, { name: "Social", tree: [ { name: "GitHub", url: () => "https://github.com/bitcoinresearchkit/brk", }, { name: "Nostr", url: () => "https://primal.net/p/npub1jagmm3x39lmwfnrtvxcs9ac7g300y3dusv9lgzhk2e4x5frpxlrqa73v44", }, { name: "Discord", url: () => "https://discord.com/invite/HaR3wpH3nr", }, ], }, { name: "Donate", tree: [ { name: "Bitcoin", qrcode: true, url: () => "bitcoin:bc1q098zsm89m7kgyze338vfejhpdt92ua9p3peuve", }, { name: "Lightning", qrcode: true, url: () => "lightning:lnurl1dp68gurn8ghj7ampd3kx2ar0veekzar0wd5xjtnrdakj7tnhv4kxctttdehhwm30d3h82unvwqhkxmmww3jkuar8d35kgetj8yuq363hv4", }, { name: "Geyser", url: () => "https://geyser.fund/project/brk", }, ], }, { name: "Share", qrcode: true, url: () => window.location.href, }, ]; } /** * @param {Object} args * @param {Colors} args.colors * @param {Signals} args.signals * @param {Env} args.env * @param {Utilities} args.utils * @param {VecIdToIndexes} args.vecIdToIndexes * @param {Signal} args.qrcode */ export function initOptions({ colors, signals, env, utils, qrcode, vecIdToIndexes, }) { const LS_SELECTED_KEY = `selected_id`; const urlSelected = utils.url.pathnameToSelectedId(); const savedSelectedId = utils.storage.read(LS_SELECTED_KEY); /** @type {Signal