// @ts-check /** * @typedef {Height | DateIndex | WeekIndex | DifficultyEpoch | MonthIndex | QuarterIndex | YearIndex | HalvingEpoch | DecadeIndex} ChartableIndex */ /** * @template {readonly unknown[]} T * @typedef {Extract extends never ? false : true} IncludesChartableIndex */ /** * @typedef {{[K in VecId]: IncludesChartableIndex extends true ? K : never}[VecId]} ChartableVecId */ /** * @typedef {Object} BaseSeriesBlueprint * @property {string} title * @property {boolean} [defaultActive] * * @typedef {Object} CreatePriceLine * @property {number} value * * @typedef {Object} CreatePriceLineOptions * @property {CreatePriceLine} createPriceLine * * @typedef {Object} BaselineSeriesBlueprintSpecific * @property {"Baseline"} type * @property {Color} [color] * @property {[Color, Color]} [colors] * @property {DeepPartial} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & BaselineSeriesBlueprintSpecific} BaselineSeriesBlueprint * * @typedef {Object} CandlestickSeriesBlueprintSpecific * @property {"Candlestick"} type * @property {Color} [color] * @property {DeepPartial} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & CandlestickSeriesBlueprintSpecific} CandlestickSeriesBlueprint * * @typedef {Object} LineSeriesBlueprintSpecific * @property {"Line"} [type] * @property {Color} [color] * @property {DeepPartial} [options] * @property {Accessor} [data] * @typedef {BaseSeriesBlueprint & LineSeriesBlueprintSpecific} LineSeriesBlueprint * * @typedef {BaselineSeriesBlueprint | CandlestickSeriesBlueprint | LineSeriesBlueprint} AnySeriesBlueprint * * @typedef {AnySeriesBlueprint["type"]} SeriesType * * @typedef {{ key: ChartableVecId }} FetchedAnySeriesOptions * * @typedef {BaselineSeriesBlueprint & FetchedAnySeriesOptions} FetchedBaselineSeriesBlueprint * @typedef {CandlestickSeriesBlueprint & FetchedAnySeriesOptions} FetchedCandlestickSeriesBlueprint * @typedef {LineSeriesBlueprint & FetchedAnySeriesOptions} FetchedLineSeriesBlueprint * @typedef {AnySeriesBlueprint & FetchedAnySeriesOptions} AnyFetchedSeriesBlueprint * * @typedef {Object} PartialOption * @property {string} name * * @typedef {Object} ProcessedOptionAddons * @property {string} id * @property {string} title * @property {string[]} path * * @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 {PartialChartOption | PartialTableOption | PartialSimulationOption | PartialUrlOption} AnyPartialOption * * @typedef {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 {Colors} colors * @returns {PartialOptionsTree} */ function createPartialOptions(colors) { /** * @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 */ /** * @typedef {"total-"} TotalPrefix * @typedef {StartsWith} TotalVecId * @typedef {WithoutPrefix} TotalVecIdBase * @typedef {"-sum"} SumSuffix * @typedef {EndsWith} VecIdSum * @typedef {WithoutSuffix} VecIdSumBase * @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 }, { name: "8 Days", key: "8d", days: 8 }, { name: "13 Days", key: "13d", days: 13 }, { name: "21 Days", key: "21d", days: 21 }, { name: "1 Month", key: "1m", days: 30 }, { name: "34 Days", key: "34d", days: 34 }, { name: "55 Days", key: "55d", days: 55 }, { name: "89 Days", key: "89d", days: 89 }, { name: "144 Days", key: "144d", days: 144 }, { name: "1 Year", key: "1y", days: 365 }, { name: "2 Years", key: "2y", days: 2 * 365 }, { name: "200 Weeks", key: "200w", days: 200 * 7 }, { name: "4 Years", key: "4y", days: 4 * 365 }, ]); const dcaClasses = /** @type {const} */ ([ 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, ]); /** * @param {Object} args * @param {ChartableVecId} args.key * @param {string} args.name * @param {Color} [args.color] * @param {boolean} [args.defaultActive] * @param {DeepPartial} [args.options] */ function createBaseSeries({ key, name, color, defaultActive, options }) { return /** @satisfies {AnyFetchedSeriesBlueprint} */ ({ key, title: name, color, defaultActive, options, }); } /** * @param {Object} args * @param {VecIdAverageBase} args.concat */ function createAverageSeries({ concat }) { return /** @satisfies {AnyFetchedSeriesBlueprint} */ ({ key: `${concat}-average`, title: "Average", }); } /** * @param {Object} args * @param {VecIdSumBase & TotalVecIdBase} args.concat * @param {string} [args.name] */ function createSumTotalSeries({ concat, name }) { return /** @satisfies {AnyFetchedSeriesBlueprint[]} */ ([ { key: `${concat}-sum`, title: name ? `${name} Sum` : "Sum", color: colors.bitcoin, }, { key: `total-${concat}`, title: name ? `Total ${name}` : "Total", color: colors.offBitcoin, defaultActive: false, }, ]); } /** * @param {Object} args * @param {VecIdMinBase & VecIdMaxBase & VecId90pBase & VecId75pBase & VecIdMedianBase & VecId25pBase & VecId10pBase} args.concat */ function createMinMaxPercentilesSeries({ concat }) { return /** @satisfies {AnyFetchedSeriesBlueprint[]} */ ([ { key: `${concat}-max`, title: "Max", color: colors.pink, defaultActive: false, }, { key: `${concat}-min`, title: "Min", color: colors.green, defaultActive: false, }, { key: `${concat}-median`, title: "Median", color: colors.amber, defaultActive: false, }, { key: `${concat}-75p`, title: "75p", color: colors.red, defaultActive: false, }, { key: `${concat}-25p`, title: "25p", color: colors.yellow, defaultActive: false, }, { key: `${concat}-90p`, title: "90p", color: colors.rose, defaultActive: false, }, { key: `${concat}-10p`, title: "10p", color: colors.lime, defaultActive: false, }, ]); } /** * @param {VecIdAverageBase & VecIdSumBase & TotalVecIdBase & VecIdMinBase & VecIdMaxBase & VecId90pBase & VecId75pBase & VecIdMedianBase & VecId25pBase & VecId10pBase} key */ function createAverageSumTotalMinMaxPercentilesSeries(key) { return [ createAverageSeries({ concat: key }), ...createSumTotalSeries({ concat: key }), ...createMinMaxPercentilesSeries({ concat: key }), ]; } /** * @param {Object} args * @param {ChartableVecId & VecIdAverageBase & VecIdSumBase & TotalVecIdBase & VecIdMinBase & VecIdMaxBase & VecId90pBase & VecId75pBase & VecIdMedianBase & VecId25pBase & VecId10pBase} args.key * @param {string} args.name */ function createBaseAverageSumTotalMinMaxPercentilesSeries({ key, name }) { return [ createBaseSeries({ key, name, }), ...createAverageSumTotalMinMaxPercentilesSeries(key), ]; } return [ { 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", tree: [ { name: "Value", title: "All Time High", top: [ createBaseSeries({ key: "ath", name: "ath", }), ], }, { name: "drawdown", title: "All Time High Drawdown", top: [ createBaseSeries({ key: "ath", name: "ath", }), ], bottom: [ createBaseSeries({ key: "drawdown", name: "Drawdown", color: colors.red, }), ], }, { name: "days since", title: "Number of days Since All Time High", top: [ createBaseSeries({ key: "ath", name: "ath", }), ], bottom: [ createBaseSeries({ key: "days-since-ath", name: "Days", }), ], }, { name: "max between", title: "Maximum time between All Time Highs", top: [ createBaseSeries({ key: "ath", name: "ath", }), ], bottom: [ createBaseSeries({ key: "max-days-between-ath", name: "Days", }), createBaseSeries({ key: "max-years-between-ath", name: "Years", }), ], }, ], }, { name: "Average", tree: [ { name: "Compare", title: "Moving Averages", top: averages.map(({ days, key, name }) => createBaseSeries({ key: `${key}-sma`, name: key, color: colors[`_${key}`], }), ), }, ...averages.map(({ key, name }) => ({ name, title: `${name} Market Price Moving Average`, top: [ createBaseSeries({ key: `${key}-sma`, name: "Average", color: colors[`_${key}`], }), createBaseSeries({ key: `${key}-sma-ratio-p1sd-as-price`, name: "+1σ", color: colors.orange, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p2sd-as-price`, name: "+2σ", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p3sd-as-price`, name: "+3σ", color: colors.pink, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-m1sd-as-price`, name: "−1σ", color: colors.cyan, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-m2sd-as-price`, name: "−2σ", color: colors.blue, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-m3sd-as-price`, name: "−3σ", color: colors.violet, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p99-as-price`, name: "p99", color: colors.orange, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p99-5-as-price`, name: "p99.5", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p99-9-as-price`, name: "p99.9", color: colors.pink, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p1-as-price`, name: "p1", color: colors.cyan, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p0-5-as-price`, name: "p0.5", color: colors.blue, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p0-1-as-price`, name: "p0.1", color: colors.violet, defaultActive: false, }), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-sma-ratio`, title: "Ratio", type: "Baseline", options: { baseValue: { price: 1 }, createPriceLine: { value: 1, }, }, }), createBaseSeries({ key: `${key}-sma-ratio-sma`, name: "sma", color: colors.yellow, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p1sd`, name: "+1σ", color: colors.orange, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p2sd`, name: "+2σ", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p3sd`, name: "+3σ", color: colors.pink, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-m1sd`, name: "−1σ", color: colors.cyan, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-m2sd`, name: "−2σ", color: colors.blue, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-m3sd`, name: "−3σ", color: colors.violet, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p99`, name: "p99", color: colors.orange, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p99-5`, name: "p99.5", color: colors.red, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p99-9`, name: "p99.9", color: colors.pink, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p1`, name: "p1", color: colors.cyan, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p0-5`, name: "p0.5", color: colors.blue, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-p0-1`, name: "p0.1", color: colors.violet, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-1w-sma`, name: "1w sma", color: colors.fuchsia, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-1m-sma`, name: "1m sma", color: colors.pink, defaultActive: false, }), createBaseSeries({ key: `${key}-sma-ratio-1y-sma`, name: "1y sma", color: colors.rose, defaultActive: false, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-sma-ratio-1y-sma-momentum-oscillator`, title: "1Y Momentum", type: "Baseline", options: { createPriceLine: { value: 0, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-sma-ratio-zscore`, title: "Score", type: "Baseline", options: { createPriceLine: { value: 0, }, }, }), ], })), ], }, { 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", options: { createPriceLine: { value: 0, }, }, }), ], })), }, { 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], options: { createPriceLine: { value: 0, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-returns`, title: "lump sum", type: "Baseline", options: { createPriceLine: { value: 0, }, }, }), ], }), ), .../** @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 avg. price`, 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], options: { createPriceLine: { value: 0, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-dca-cagr`, title: "dca", type: "Baseline", colors: [colors.yellow, colors.pink], options: { createPriceLine: { value: 0, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-returns`, title: "lump sum", type: "Baseline", options: { createPriceLine: { value: 0, }, }, }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `${key}-cagr`, title: "lump sum", type: "Baseline", options: { createPriceLine: { value: 0, }, }, }), ], }), ), ], }, { name: "DCA Class", tree: [ { name: "Compare", title: "DCA Classes", top: dcaClasses.map((year) => createBaseSeries({ key: `dca-class-${year}-avg-price`, name: `${year}`, color: colors[year], }), ), }, ...dcaClasses.map( (year) => /** @satisfies {PartialChartOption} */ ({ name: `${year}`, title: `DCA Since ${year}`, top: [ createBaseSeries({ key: `dca-class-${year}-avg-price`, name: `avg. price`, color: colors[year], }), ], bottom: [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ key: `dca-class-${year}-returns`, title: "dca", type: "Baseline", options: { createPriceLine: { value: 0, }, }, }), ], }), ), ], }, ], }, { name: "Mining", tree: [ { name: "Supply", title: "Circulating Supply", bottom: [ createBaseSeries({ key: "total-subsidy-in-btc", name: "Mined", }), ], }, { name: "Coinbase", title: "Coinbase", bottom: [ ...createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "coinbase", name: "Coinbase", }), ...createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "coinbase-in-btc", name: "Coinbase", }), ...createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "coinbase-in-usd", name: "Coinbase", }), ], }, { name: "Subsidy", title: "Subsidy", bottom: [ ...createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "subsidy", name: "Subsidy", }), ...createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "subsidy-in-btc", name: "Subsidy", }), ...createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "subsidy-in-usd", name: "Subsidy", }), ], }, { name: "Fee", title: "Transaction Fee", bottom: [ ...createAverageSumTotalMinMaxPercentilesSeries("fee"), ...createAverageSumTotalMinMaxPercentilesSeries("fee-in-btc"), ...createAverageSumTotalMinMaxPercentilesSeries("fee-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: [ createBaseSeries({ key: "block-count", name: "Count", }), ...createSumTotalSeries({ concat: "block-count" }), ], }, { name: "Interval", title: "Block Interval", bottom: [ createBaseSeries({ key: "interval", name: "Interval", }), createAverageSeries({ concat: "block-interval" }), ...createMinMaxPercentilesSeries({ concat: "block-interval", }), ], }, { name: "Size", title: "Block Size", bottom: [ createBaseSeries({ key: "total-size", name: "Size", }), ...createSumTotalSeries({ concat: "block-size" }), ], }, { name: "Weight", title: "Block Weight", bottom: [ createBaseSeries({ key: "weight", name: "Weight", }), ...createSumTotalSeries({ concat: "block-weight" }), ], }, { name: "Vbytes", title: "Block Virtual Bytes", bottom: [ createBaseSeries({ key: "vbytes", name: "Vbytes", }), ...createSumTotalSeries({ concat: "block-vbytes" }), ], }, ], }, { name: "Transaction", tree: [ { name: "Count", title: "Transaction Count", bottom: createBaseAverageSumTotalMinMaxPercentilesSeries({ key: "tx-count", name: "Count", }), }, { name: "Weight", title: "Transaction Weight", bottom: [ createAverageSeries({ concat: "tx-weight" }), ...createMinMaxPercentilesSeries({ concat: "tx-weight", }), ], }, { name: "vsize", title: "Transaction Virtual Size", bottom: [ createAverageSeries({ concat: "tx-vsize" }), ...createMinMaxPercentilesSeries({ concat: "tx-vsize", }), ], }, { name: "Versions", title: "Transaction Versions", bottom: [ createBaseSeries({ key: "tx-v1", name: "v1 Count", }), ...createSumTotalSeries({ concat: "tx-v1", name: "v1" }), createBaseSeries({ key: "tx-v2", name: "v2 Count", }), ...createSumTotalSeries({ concat: "tx-v2", name: "v2" }), createBaseSeries({ key: "tx-v3", name: "v3 Count", }), ...createSumTotalSeries({ concat: "tx-v3", name: "v3" }), ], }, ], }, { name: "Input", tree: [ { name: "Count", title: "Transaction Input Count", bottom: [ createAverageSeries({ concat: "input-count" }), ...createSumTotalSeries({ concat: "input-count" }), ...createMinMaxPercentilesSeries({ concat: "input-count", }), ], }, // { // name: "Value", // title: "Transaction Input Value", // bottom: [ // createAverageSeries({ concat: "input-value" }), // ...createSumTotalSeries({ concat: "input-value" }), // ], // }, ], }, { name: "Output", tree: [ { name: "Count", title: "Transaction Output Count", bottom: [ createAverageSeries({ concat: "output-count" }), ...createSumTotalSeries({ concat: "output-count" }), ...createMinMaxPercentilesSeries({ concat: "output-count", }), ], }, { name: "Unspent Count", title: "Unspent Transaction Output Count", bottom: [ createBaseSeries({ key: "exact-utxo-count", name: "total", }), ], }, // { // name: "Value", // title: "Transaction Output Value", // bottom: [ // createAverageSeries({ concat: "output-value" }), // ...createSumTotalSeries({ concat: "output-value" }), // ], // }, { name: "types", tree: [ { name: "p2pk", title: "Pay To Public Key Outputs", bottom: [ createBaseSeries({ key: "p2pk33-count", name: "33B Count", }), createBaseSeries({ key: "p2pk33-count-sum", name: "33B sum", }), createBaseSeries({ key: "total-p2pk33-count", name: "33B total", }), createBaseSeries({ key: "p2pk65-count", name: "65B Count", }), createBaseSeries({ key: "p2pk65-count-sum", name: "65B sum", }), createBaseSeries({ key: "total-p2pk65-count", name: "65B total", }), ], }, { name: "p2pkh", title: "Pay To Public Key Hash Outputs", bottom: [ createBaseSeries({ key: "p2pkh-count", name: "Count", }), createBaseSeries({ key: "p2pkh-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2pkh-count", name: "total", }), ], }, { name: "p2ms", title: "Pay To Multisig Outputs", bottom: [ createBaseSeries({ key: "p2ms-count", name: "Count", }), createBaseSeries({ key: "p2ms-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2ms-count", name: "total", }), ], }, { name: "p2sh", title: "Pay To Script Hash Outputs", bottom: [ createBaseSeries({ key: "p2sh-count", name: "Count", }), createBaseSeries({ key: "p2sh-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2sh-count", name: "total", }), ], }, { name: "op_return", title: "op_return outputs", bottom: [ createBaseSeries({ key: "opreturn-count", name: "Count" }), createBaseSeries({ key: "opreturn-count-sum", name: "sum", }), createBaseSeries({ key: "total-opreturn-count", name: "total", }), ], }, { name: "p2wpkh", title: "Pay To Witness Public Key Hash Outputs", bottom: [ createBaseSeries({ key: "p2wpkh-count", name: "Count", }), createBaseSeries({ key: "p2wpkh-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2wpkh-count", name: "total", }), ], }, { name: "p2wsh", title: "Pay To Witness Script Hash Outputs", bottom: [ createBaseSeries({ key: "p2wsh-count", name: "Count", }), createBaseSeries({ key: "p2wsh-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2wsh-count", name: "total", }), ], }, { name: "p2tr", title: "Pay To Taproot Outputs", bottom: [ createBaseSeries({ key: "p2tr-count", name: "Count", }), createBaseSeries({ key: "p2tr-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2tr-count", name: "total", }), ], }, { name: "p2a", title: "Pay To Anchor outputs", bottom: [ createBaseSeries({ key: "p2a-count", name: "Count", }), createBaseSeries({ key: "p2a-count-sum", name: "sum", }), createBaseSeries({ key: "total-p2a-count", name: "total", }), ], }, { name: "empty", title: "empty outputs", bottom: [ createBaseSeries({ key: "emptyoutput-count", name: "Count", }), createBaseSeries({ key: "emptyoutput-count-sum", name: "sum", }), createBaseSeries({ key: "total-emptyoutput-count", name: "total", }), ], }, { name: "unknown", title: "unknown outputs", bottom: [ createBaseSeries({ key: "unknownoutput-count", name: "Count", }), createBaseSeries({ key: "unknownoutput-count-sum", name: "sum", }), createBaseSeries({ key: "total-unknownoutput-count", name: "total", }), ], }, ], // title: "Transaction Output Value", // bottom: [ // createAverageSeries({ concat: "output-value" }), // ...createSumTotalSeries({ concat: "output-value" }), // ], }, ], }, { name: "UTXOs", tree: [ { name: "supply", title: "Supply", bottom: [ createBaseSeries({ key: "supply", name: "Supply", }), createBaseSeries({ key: "supply-in-btc", name: "Supply", }), createBaseSeries({ key: "supply-in-usd", name: "Supply", }), ], }, { name: "unspendable 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: "count", title: "UTXO Count", bottom: [ createBaseSeries({ key: "utxo-count", name: "Count", }), ], }, { name: "realized cap", title: "Realized Capitalization", bottom: [ createBaseSeries({ key: "realized-cap", name: "Realized Cap", }), ], }, ], }, ], }, { kind: "table", title: "Table", name: "Table", }, { name: "Simulations", tree: [ { kind: "simulation", title: "Save In Bitcoin", name: "Save In Bitcoin", }, ], }, { 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: "Bluesky", url: () => "https://bsky.app/profile/bitcoinresearchkit.org", }, { name: "x", url: () => "https://x.com/brkdotorg", }, ], }, { name: "Developers", tree: [ { name: "API", url: () => "/api", }, { name: "Source", url: () => "https://github.com/bitcoinresearchkit/brk", }, { name: "Status", url: () => "https://status.kibo.money/", }, { name: "Crates", url: () => "https://crates.io/crates/brk", }, ], }, { name: "Donations", tree: [ { name: "Bitcoin QR Code", qrcode: true, url: () => "bitcoin:bc1q098zsm89m7kgyze338vfejhpdt92ua9p3peuve", }, { name: "Lightning QR Code", qrcode: true, url: () => "lightning:lnurl1dp68gurn8ghj7ampd3kx2ar0veekzar0wd5xjtnrdakj7tnhv4kxctttdehhwm30d3h82unvwqhkxmmww3jkuar8d35kgetj8yuq363hv4", }, { name: "Geyser", url: () => "https://geyser.fund/project/brk", }, { name: "OpenSats", url: () => "https://opensats.org/", }, ], }, { 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 {WebSockets} args.webSockets * @param {Signal} args.qrcode */ export function initOptions({ colors, signals, env, utils, webSockets, qrcode, }) { const LS_SELECTED_KEY = `selected-id`; const urlSelected = utils.url.pathnameToSelectedId(); const savedSelectedId = localStorage.getItem(LS_SELECTED_KEY); /** @type {Signal