mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-05 12:41:57 -07:00
global: big snapshot
This commit is contained in:
@@ -1557,6 +1557,149 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- IMPORTMAP -->
|
||||
<link rel="modulepreload" href="/scripts/chart/index.aa4df929.js">
|
||||
<link rel="modulepreload" href="/scripts/chart/oklch.21450255.js">
|
||||
<link rel="modulepreload" href="/scripts/entry.15f91516.js">
|
||||
<link rel="modulepreload" href="/scripts/lazy.cdb73318.js">
|
||||
<link rel="modulepreload" href="/scripts/main.60f735cb.js">
|
||||
<link rel="modulepreload" href="/scripts/modules/brk-client/index.0b8c7f06.js">
|
||||
<link rel="modulepreload" href="/scripts/modules/lean-qr/2.6.1/index.09195c13.mjs">
|
||||
<link rel="modulepreload" href="/scripts/modules/leeoniya-ufuzzy/1.0.19/dist/uFuzzy.803b7fb0.mjs">
|
||||
<link rel="modulepreload" href="/scripts/modules/lightweight-charts/5.0.9/dist/lightweight-charts.standalone.production.1e264451.mjs">
|
||||
<link rel="modulepreload" href="/scripts/modules/lightweight-charts/5.1.0/dist/lightweight-charts.standalone.production.5c2a821a.mjs">
|
||||
<link rel="modulepreload" href="/scripts/modules/modern-screenshot/4.6.6/dist/index.6340736f.mjs">
|
||||
<link rel="modulepreload" href="/scripts/modules/modern-screenshot/4.6.7/dist/index.070574d6.js">
|
||||
<link rel="modulepreload" href="/scripts/modules/modern-screenshot/4.6.7/dist/index.e9e389fe.mjs">
|
||||
<link rel="modulepreload" href="/scripts/modules/modern-screenshot/4.6.7/dist/worker.1265d9cd.js">
|
||||
<link rel="modulepreload" href="/scripts/modules/solidjs-signals/0.6.3/dist/prod.2f80e335.js">
|
||||
<link rel="modulepreload" href="/scripts/modules/solidjs-signals/0.8.5/dist/prod.8ae56250.js">
|
||||
<link rel="modulepreload" href="/scripts/options/_partial_old.62bf3faa.js">
|
||||
<link rel="modulepreload" href="/scripts/options/chain.6d38c01e.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cohorts/address.225a99f5.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cohorts/data.9860384e.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cohorts/index.47f11280.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cohorts/shared.ae420ee3.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cohorts/types.1e23c94d.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cohorts/utxo.531a3d0f.js">
|
||||
<link rel="modulepreload" href="/scripts/options/cointime.59c74043.js">
|
||||
<link rel="modulepreload" href="/scripts/options/colors/cohorts.262d4551.js">
|
||||
<link rel="modulepreload" href="/scripts/options/colors/index.a54dc83f.js">
|
||||
<link rel="modulepreload" href="/scripts/options/colors/misc.bee7dbee.js">
|
||||
<link rel="modulepreload" href="/scripts/options/constants.988e7f83.js">
|
||||
<link rel="modulepreload" href="/scripts/options/context.8a1faf4c.js">
|
||||
<link rel="modulepreload" href="/scripts/options/full.cbb89ca5.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/averages.52ae3c62.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/index.b5f62388.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/indicators/bands.eb583383.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/indicators/index.70e9b3e4.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/indicators/momentum.8f20362c.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/indicators/onchain.d06affed.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/indicators/volatility.a12b9495.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/investing.c00cb6ed.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/performance.f381010b.js">
|
||||
<link rel="modulepreload" href="/scripts/options/market/utils.e3e058d8.js">
|
||||
<link rel="modulepreload" href="/scripts/options/partial.1bfb5914.js">
|
||||
<link rel="modulepreload" href="/scripts/options/series.d82ddec3.js">
|
||||
<link rel="modulepreload" href="/scripts/options/types.19186083.js">
|
||||
<link rel="modulepreload" href="/scripts/options/unused.24a71427.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/chart/index.8a9decf6.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/chart/screenshot.adc8da89.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/explorer.91a5a9ae.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/nav.0338dc4b.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/search.0338dc4b.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/simulation.abf9ee5d.js">
|
||||
<link rel="modulepreload" href="/scripts/panes/table.00486691.js">
|
||||
<link rel="modulepreload" href="/scripts/resources.77bdf76f.js">
|
||||
<link rel="modulepreload" href="/scripts/signals.2ba0669e.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/array.1863f57c.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/colors.c95b2e03.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/date.12ad717d.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/dom.4d99f37f.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/elements.6fe024ed.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/env.594127e7.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/format.4bdbfe40.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/serde.f9c7ed2b.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/storage.cbd2ff9c.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/timing.ae6a47b8.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/units.97b1a45f.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/url.20469bf9.js">
|
||||
<link rel="modulepreload" href="/scripts/utils/ws.fe3fb4b1.js">
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"/scripts/chart/index.js": "/scripts/chart/index.aa4df929.js",
|
||||
"/scripts/chart/oklch.js": "/scripts/chart/oklch.21450255.js",
|
||||
"/scripts/entry.js": "/scripts/entry.15f91516.js",
|
||||
"/scripts/lazy.js": "/scripts/lazy.cdb73318.js",
|
||||
"/scripts/main.js": "/scripts/main.60f735cb.js",
|
||||
"/scripts/modules/brk-client/index.js": "/scripts/modules/brk-client/index.0b8c7f06.js",
|
||||
"/scripts/modules/lean-qr/2.6.1/index.mjs": "/scripts/modules/lean-qr/2.6.1/index.09195c13.mjs",
|
||||
"/scripts/modules/leeoniya-ufuzzy/1.0.19/dist/uFuzzy.mjs": "/scripts/modules/leeoniya-ufuzzy/1.0.19/dist/uFuzzy.803b7fb0.mjs",
|
||||
"/scripts/modules/lightweight-charts/5.0.9/dist/lightweight-charts.standalone.production.mjs": "/scripts/modules/lightweight-charts/5.0.9/dist/lightweight-charts.standalone.production.1e264451.mjs",
|
||||
"/scripts/modules/lightweight-charts/5.1.0/dist/lightweight-charts.standalone.production.mjs": "/scripts/modules/lightweight-charts/5.1.0/dist/lightweight-charts.standalone.production.5c2a821a.mjs",
|
||||
"/scripts/modules/modern-screenshot/4.6.6/dist/index.mjs": "/scripts/modules/modern-screenshot/4.6.6/dist/index.6340736f.mjs",
|
||||
"/scripts/modules/modern-screenshot/4.6.7/dist/index.js": "/scripts/modules/modern-screenshot/4.6.7/dist/index.070574d6.js",
|
||||
"/scripts/modules/modern-screenshot/4.6.7/dist/index.mjs": "/scripts/modules/modern-screenshot/4.6.7/dist/index.e9e389fe.mjs",
|
||||
"/scripts/modules/modern-screenshot/4.6.7/dist/worker.js": "/scripts/modules/modern-screenshot/4.6.7/dist/worker.1265d9cd.js",
|
||||
"/scripts/modules/solidjs-signals/0.6.3/dist/prod.js": "/scripts/modules/solidjs-signals/0.6.3/dist/prod.2f80e335.js",
|
||||
"/scripts/modules/solidjs-signals/0.8.5/dist/prod.js": "/scripts/modules/solidjs-signals/0.8.5/dist/prod.8ae56250.js",
|
||||
"/scripts/options/_partial_old.js": "/scripts/options/_partial_old.62bf3faa.js",
|
||||
"/scripts/options/chain.js": "/scripts/options/chain.6d38c01e.js",
|
||||
"/scripts/options/cohorts/address.js": "/scripts/options/cohorts/address.225a99f5.js",
|
||||
"/scripts/options/cohorts/data.js": "/scripts/options/cohorts/data.9860384e.js",
|
||||
"/scripts/options/cohorts/index.js": "/scripts/options/cohorts/index.47f11280.js",
|
||||
"/scripts/options/cohorts/shared.js": "/scripts/options/cohorts/shared.ae420ee3.js",
|
||||
"/scripts/options/cohorts/types.js": "/scripts/options/cohorts/types.1e23c94d.js",
|
||||
"/scripts/options/cohorts/utxo.js": "/scripts/options/cohorts/utxo.531a3d0f.js",
|
||||
"/scripts/options/cointime.js": "/scripts/options/cointime.59c74043.js",
|
||||
"/scripts/options/colors/cohorts.js": "/scripts/options/colors/cohorts.262d4551.js",
|
||||
"/scripts/options/colors/index.js": "/scripts/options/colors/index.a54dc83f.js",
|
||||
"/scripts/options/colors/misc.js": "/scripts/options/colors/misc.bee7dbee.js",
|
||||
"/scripts/options/constants.js": "/scripts/options/constants.988e7f83.js",
|
||||
"/scripts/options/context.js": "/scripts/options/context.8a1faf4c.js",
|
||||
"/scripts/options/full.js": "/scripts/options/full.cbb89ca5.js",
|
||||
"/scripts/options/market/averages.js": "/scripts/options/market/averages.52ae3c62.js",
|
||||
"/scripts/options/market/index.js": "/scripts/options/market/index.b5f62388.js",
|
||||
"/scripts/options/market/indicators/bands.js": "/scripts/options/market/indicators/bands.eb583383.js",
|
||||
"/scripts/options/market/indicators/index.js": "/scripts/options/market/indicators/index.70e9b3e4.js",
|
||||
"/scripts/options/market/indicators/momentum.js": "/scripts/options/market/indicators/momentum.8f20362c.js",
|
||||
"/scripts/options/market/indicators/onchain.js": "/scripts/options/market/indicators/onchain.d06affed.js",
|
||||
"/scripts/options/market/indicators/volatility.js": "/scripts/options/market/indicators/volatility.a12b9495.js",
|
||||
"/scripts/options/market/investing.js": "/scripts/options/market/investing.c00cb6ed.js",
|
||||
"/scripts/options/market/performance.js": "/scripts/options/market/performance.f381010b.js",
|
||||
"/scripts/options/market/utils.js": "/scripts/options/market/utils.e3e058d8.js",
|
||||
"/scripts/options/partial.js": "/scripts/options/partial.1bfb5914.js",
|
||||
"/scripts/options/series.js": "/scripts/options/series.d82ddec3.js",
|
||||
"/scripts/options/types.js": "/scripts/options/types.19186083.js",
|
||||
"/scripts/options/unused.js": "/scripts/options/unused.24a71427.js",
|
||||
"/scripts/panes/chart/index.js": "/scripts/panes/chart/index.8a9decf6.js",
|
||||
"/scripts/panes/chart/screenshot.js": "/scripts/panes/chart/screenshot.adc8da89.js",
|
||||
"/scripts/panes/explorer.js": "/scripts/panes/explorer.91a5a9ae.js",
|
||||
"/scripts/panes/nav.js": "/scripts/panes/nav.0338dc4b.js",
|
||||
"/scripts/panes/search.js": "/scripts/panes/search.0338dc4b.js",
|
||||
"/scripts/panes/simulation.js": "/scripts/panes/simulation.abf9ee5d.js",
|
||||
"/scripts/panes/table.js": "/scripts/panes/table.00486691.js",
|
||||
"/scripts/resources.js": "/scripts/resources.77bdf76f.js",
|
||||
"/scripts/signals.js": "/scripts/signals.2ba0669e.js",
|
||||
"/scripts/utils/array.js": "/scripts/utils/array.1863f57c.js",
|
||||
"/scripts/utils/colors.js": "/scripts/utils/colors.c95b2e03.js",
|
||||
"/scripts/utils/date.js": "/scripts/utils/date.12ad717d.js",
|
||||
"/scripts/utils/dom.js": "/scripts/utils/dom.4d99f37f.js",
|
||||
"/scripts/utils/elements.js": "/scripts/utils/elements.6fe024ed.js",
|
||||
"/scripts/utils/env.js": "/scripts/utils/env.594127e7.js",
|
||||
"/scripts/utils/format.js": "/scripts/utils/format.4bdbfe40.js",
|
||||
"/scripts/utils/serde.js": "/scripts/utils/serde.f9c7ed2b.js",
|
||||
"/scripts/utils/storage.js": "/scripts/utils/storage.cbd2ff9c.js",
|
||||
"/scripts/utils/timing.js": "/scripts/utils/timing.ae6a47b8.js",
|
||||
"/scripts/utils/units.js": "/scripts/utils/units.97b1a45f.js",
|
||||
"/scripts/utils/url.js": "/scripts/utils/url.20469bf9.js",
|
||||
"/scripts/utils/ws.js": "/scripts/utils/ws.fe3fb4b1.js"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!-- /IMPORTMAP -->
|
||||
|
||||
<!-- --- -->
|
||||
<!-- PWA -->
|
||||
<!-- --- -->
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Unit } from "../utils/units.js";
|
||||
*/
|
||||
export function createChainSection(ctx) {
|
||||
const { colors, brk, s, createPriceLine } = ctx;
|
||||
const { mergeMetricPatterns } = brk;
|
||||
const {
|
||||
blocks,
|
||||
transactions,
|
||||
@@ -33,7 +32,7 @@ export function createChainSection(ctx) {
|
||||
*/
|
||||
const fromBlockCount = (pattern, name, unit, sumColor, cumulativeColor) => [
|
||||
s({
|
||||
metric: mergeMetricPatterns(pattern.base, pattern.sum),
|
||||
metric: pattern.sum,
|
||||
name: `${name} sum`,
|
||||
color: sumColor,
|
||||
unit,
|
||||
@@ -55,7 +54,7 @@ export function createChainSection(ctx) {
|
||||
* @param {Unit} unit
|
||||
*/
|
||||
const fromBlockSize = (pattern, name, unit) => [
|
||||
s({ metric: pattern.distribution.average, name: `${name} avg`, unit }),
|
||||
s({ metric: pattern.average, name: `${name} avg`, unit }),
|
||||
s({
|
||||
metric: pattern.sum,
|
||||
name: `${name} sum`,
|
||||
@@ -85,35 +84,35 @@ export function createChainSection(ctx) {
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct10,
|
||||
metric: pattern.percentiles.pct10,
|
||||
name: `${name} pct10`,
|
||||
color: colors.rose,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct25,
|
||||
metric: pattern.percentiles.pct25,
|
||||
name: `${name} pct25`,
|
||||
color: colors.pink,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.median,
|
||||
metric: pattern.percentiles.median,
|
||||
name: `${name} median`,
|
||||
color: colors.purple,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct75,
|
||||
metric: pattern.percentiles.pct75,
|
||||
name: `${name} pct75`,
|
||||
color: colors.violet,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct90,
|
||||
metric: pattern.percentiles.pct90,
|
||||
name: `${name} pct90`,
|
||||
color: colors.fuchsia,
|
||||
unit,
|
||||
@@ -159,35 +158,35 @@ export function createChainSection(ctx) {
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct10,
|
||||
metric: pattern.percentiles.pct10,
|
||||
name: `${name} pct10`,
|
||||
color: colors.rose,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct25,
|
||||
metric: pattern.percentiles.pct25,
|
||||
name: `${name} pct25`,
|
||||
color: colors.pink,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.median,
|
||||
metric: pattern.percentiles.median,
|
||||
name: `${name} median`,
|
||||
color: colors.purple,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct75,
|
||||
metric: pattern.percentiles.pct75,
|
||||
name: `${name} pct75`,
|
||||
color: colors.violet,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.distribution.percentiles.pct90,
|
||||
metric: pattern.percentiles.pct90,
|
||||
name: `${name} pct90`,
|
||||
color: colors.fuchsia,
|
||||
unit,
|
||||
@@ -335,7 +334,7 @@ export function createChainSection(ctx) {
|
||||
*/
|
||||
const fromValuePattern = (pattern, name, sumColor, cumulativeColor) => [
|
||||
s({
|
||||
metric: pattern.sats.base,
|
||||
metric: pattern.sats.sum,
|
||||
name: `${name}`,
|
||||
color: sumColor,
|
||||
unit: Unit.sats,
|
||||
@@ -348,7 +347,7 @@ export function createChainSection(ctx) {
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.bitcoin.base,
|
||||
metric: pattern.bitcoin.sum,
|
||||
name: `${name}`,
|
||||
color: sumColor,
|
||||
unit: Unit.btc,
|
||||
@@ -361,7 +360,7 @@ export function createChainSection(ctx) {
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.dollars.base,
|
||||
metric: pattern.dollars.sum,
|
||||
name: `${name}`,
|
||||
color: sumColor,
|
||||
unit: Unit.usd,
|
||||
@@ -398,7 +397,7 @@ export function createChainSection(ctx) {
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pattern.bitcoin.base,
|
||||
metric: pattern.bitcoin.sum,
|
||||
name: `${name}`,
|
||||
color: sumColor,
|
||||
unit: Unit.btc,
|
||||
@@ -439,16 +438,6 @@ export function createChainSection(ctx) {
|
||||
name: "Dominance",
|
||||
title: `Mining Dominance of ${poolName}`,
|
||||
bottom: [
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
pool._1dDominance.base,
|
||||
pool._1dDominance.sum,
|
||||
),
|
||||
name: "1d",
|
||||
color: colors.rose,
|
||||
unit: Unit.percentage,
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: pool._1wDominance,
|
||||
name: "1w",
|
||||
@@ -465,10 +454,7 @@ export function createChainSection(ctx) {
|
||||
defaultActive: false,
|
||||
}),
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
pool.dominance.base,
|
||||
pool.dominance.sum,
|
||||
),
|
||||
metric: pool.dominance,
|
||||
name: "all time",
|
||||
color: colors.teal,
|
||||
unit: Unit.percentage,
|
||||
@@ -481,10 +467,7 @@ export function createChainSection(ctx) {
|
||||
title: `Blocks mined by ${poolName}`,
|
||||
bottom: [
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
pool.blocksMined.base,
|
||||
pool.blocksMined.sum,
|
||||
),
|
||||
metric: pool.blocksMined.sum,
|
||||
name: "Sum",
|
||||
unit: Unit.count,
|
||||
}),
|
||||
@@ -650,10 +633,7 @@ export function createChainSection(ctx) {
|
||||
title: "Transaction Volume",
|
||||
bottom: [
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
transactions.volume.sentSum.sats.base,
|
||||
transactions.volume.sentSum.sats.rest,
|
||||
),
|
||||
metric: transactions.volume.sentSum.sats.sum,
|
||||
name: "Sent",
|
||||
unit: Unit.sats,
|
||||
}),
|
||||
@@ -663,10 +643,7 @@ export function createChainSection(ctx) {
|
||||
unit: Unit.btc,
|
||||
}),
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
transactions.volume.sentSum.dollars.base,
|
||||
transactions.volume.sentSum.dollars.rest,
|
||||
),
|
||||
metric: transactions.volume.sentSum.dollars,
|
||||
name: "Sent",
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
|
||||
@@ -198,7 +198,6 @@ function createRealizedCapWithExtras(ctx, list, args, useGroupName) {
|
||||
*/
|
||||
function createRealizedPnlSection(ctx, args, title) {
|
||||
const { colors, s } = ctx;
|
||||
const { mergeMetricPatterns } = ctx.brk;
|
||||
const { realized } = args.tree;
|
||||
|
||||
return [
|
||||
@@ -234,10 +233,13 @@ function createRealizedPnlSection(ctx, args, title) {
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
realized.negRealizedLoss.base,
|
||||
realized.negRealizedLoss.sum,
|
||||
),
|
||||
metric: realized.negRealizedLoss.sum,
|
||||
name: "Negative Loss",
|
||||
color: colors.red,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
s({
|
||||
metric: realized.negRealizedLoss.cumulative,
|
||||
name: "Negative Loss",
|
||||
color: colors.red,
|
||||
unit: Unit.usd,
|
||||
@@ -360,7 +362,6 @@ function createCostBasisSection(ctx, list, useGroupName, title) {
|
||||
*/
|
||||
function createActivitySection(ctx, list, useGroupName, title) {
|
||||
const { s, brk } = ctx;
|
||||
const { mergeMetricPatterns } = brk;
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -371,10 +372,13 @@ function createActivitySection(ctx, list, useGroupName, title) {
|
||||
title: `Coinblocks Destroyed ${title}`,
|
||||
bottom: list.flatMap(({ color, name, tree }) => [
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
tree.activity.coinblocksDestroyed.base,
|
||||
tree.activity.coinblocksDestroyed.sum,
|
||||
),
|
||||
metric: tree.activity.coinblocksDestroyed.sum,
|
||||
name: useGroupName ? name : "Coinblocks",
|
||||
color,
|
||||
unit: Unit.coinblocks,
|
||||
}),
|
||||
s({
|
||||
metric: tree.activity.coinblocksDestroyed.cumulative,
|
||||
name: useGroupName ? name : "Coinblocks",
|
||||
color,
|
||||
unit: Unit.coinblocks,
|
||||
@@ -386,10 +390,13 @@ function createActivitySection(ctx, list, useGroupName, title) {
|
||||
title: `Coindays Destroyed ${title}`,
|
||||
bottom: list.flatMap(({ color, name, tree }) => [
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
tree.activity.coindaysDestroyed.base,
|
||||
tree.activity.coindaysDestroyed.sum,
|
||||
),
|
||||
metric: tree.activity.coindaysDestroyed.sum,
|
||||
name: useGroupName ? name : "Coindays",
|
||||
color,
|
||||
unit: Unit.coindays,
|
||||
}),
|
||||
s({
|
||||
metric: tree.activity.coindaysDestroyed.cumulative,
|
||||
name: useGroupName ? name : "Coindays",
|
||||
color,
|
||||
unit: Unit.coindays,
|
||||
|
||||
@@ -228,7 +228,12 @@ function createRealizedPriceOptions(ctx, args, title) {
|
||||
name: "price",
|
||||
title: `Realized Price ${title}`,
|
||||
top: [
|
||||
s({ metric: tree.realized.realizedPrice, name: "realized", color, unit: Unit.usd }),
|
||||
s({
|
||||
metric: tree.realized.realizedPrice,
|
||||
name: "realized",
|
||||
color,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -275,7 +280,11 @@ function createRealizedCapWithExtras(ctx, list, args, useGroupName) {
|
||||
options: { baseValue: { price: 100 } },
|
||||
colors: [colors.red, colors.green],
|
||||
}),
|
||||
createPriceLine({ unit: Unit.pctOwnMcap, defaultActive: true, number: 100 }),
|
||||
createPriceLine({
|
||||
unit: Unit.pctOwnMcap,
|
||||
defaultActive: true,
|
||||
number: 100,
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
]);
|
||||
@@ -290,7 +299,6 @@ function createRealizedCapWithExtras(ctx, list, args, useGroupName) {
|
||||
*/
|
||||
function createRealizedPnlSection(ctx, args, title) {
|
||||
const { colors, s, brk } = ctx;
|
||||
const { mergeMetricPatterns } = brk;
|
||||
const { tree } = args;
|
||||
|
||||
return [
|
||||
@@ -335,10 +343,13 @@ function createRealizedPnlSection(ctx, args, title) {
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
tree.realized.negRealizedLoss.base,
|
||||
tree.realized.negRealizedLoss.sum,
|
||||
),
|
||||
metric: tree.realized.negRealizedLoss.sum,
|
||||
name: "Negative Loss",
|
||||
color: colors.red,
|
||||
unit: Unit.usd,
|
||||
}),
|
||||
s({
|
||||
metric: tree.realized.negRealizedLoss.cumulative,
|
||||
name: "Negative Loss",
|
||||
color: colors.red,
|
||||
unit: Unit.usd,
|
||||
@@ -509,7 +520,6 @@ function createCostBasisSectionBasic(ctx, list, useGroupName, title) {
|
||||
*/
|
||||
function createActivitySection(ctx, list, useGroupName, title) {
|
||||
const { s, brk } = ctx;
|
||||
const { mergeMetricPatterns } = brk;
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -167,7 +167,6 @@ function createCointimePriceWithRatioOptions(
|
||||
*/
|
||||
export function createCointimeSection(ctx) {
|
||||
const { colors, brk, s } = ctx;
|
||||
const { mergeMetricPatterns } = brk;
|
||||
const { cointime, distribution, supply } = brk.tree.computed;
|
||||
const { pricing, cap, activity, supply: cointimeSupply, adjusted } = cointime;
|
||||
const { all } = distribution.utxoCohorts;
|
||||
@@ -381,10 +380,7 @@ export function createCointimeSection(ctx) {
|
||||
bottom: [
|
||||
// Destroyed comes from the all cohort's activity
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
all.activity.coinblocksDestroyed.base,
|
||||
all.activity.coinblocksDestroyed.sum,
|
||||
),
|
||||
metric: all.activity.coinblocksDestroyed.sum,
|
||||
name: "Destroyed",
|
||||
color: colors.red,
|
||||
unit: Unit.coinblocks,
|
||||
@@ -398,10 +394,7 @@ export function createCointimeSection(ctx) {
|
||||
}),
|
||||
// Created and stored from cointime
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
activity.coinblocksCreated.base,
|
||||
activity.coinblocksCreated.sum,
|
||||
),
|
||||
metric: activity.coinblocksCreated.sum,
|
||||
name: "Created",
|
||||
color: colors.orange,
|
||||
unit: Unit.coinblocks,
|
||||
@@ -414,10 +407,7 @@ export function createCointimeSection(ctx) {
|
||||
unit: Unit.coinblocks,
|
||||
}),
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
activity.coinblocksStored.base,
|
||||
activity.coinblocksStored.sum,
|
||||
),
|
||||
metric: activity.coinblocksStored.sum,
|
||||
name: "Stored",
|
||||
color: colors.green,
|
||||
unit: Unit.coinblocks,
|
||||
@@ -464,10 +454,7 @@ export function createCointimeSection(ctx) {
|
||||
title: "Cointime-Adjusted Transactions Velocity",
|
||||
bottom: [
|
||||
s({
|
||||
metric: mergeMetricPatterns(
|
||||
supply.velocity.btc.dateindex,
|
||||
supply.velocity.btc.rest,
|
||||
),
|
||||
metric: supply.velocity.btc.dateindex,
|
||||
name: "BTC",
|
||||
color: colors.orange,
|
||||
unit: Unit.ratio,
|
||||
|
||||
@@ -1,114 +1,96 @@
|
||||
// DO NOT CHANGE, Exact format is expected in `brk_bundler`
|
||||
const CACHE_VERSION = "__VERSION__";
|
||||
const CACHE = "v1";
|
||||
const ROOT = "/";
|
||||
const API = "/api";
|
||||
|
||||
const SHELL_FILES = ["/", "/index.html"];
|
||||
const BYPASS = new Set([
|
||||
"/changelog", "/crate", "/discord", "/github", "/health",
|
||||
"/install", "/mcp", "/nostr", "/service", "/status", "/version"
|
||||
]);
|
||||
|
||||
// Match hashed filenames: name.abc12345.js/mjs/css
|
||||
const HASHED_RE = /\.[0-9a-f]{8}\.(js|mjs|css)$/;
|
||||
|
||||
/** @type {ServiceWorkerGlobalScope} */
|
||||
const sw = /** @type {any} */ (self);
|
||||
|
||||
sw.addEventListener("install", (event) => {
|
||||
console.log("sw: install");
|
||||
event.waitUntil(
|
||||
caches
|
||||
.open(CACHE_VERSION)
|
||||
.then((c) => c.addAll(SHELL_FILES))
|
||||
.then(() => sw.skipWaiting()),
|
||||
const offline = () => new Response("Offline", {
|
||||
status: 503,
|
||||
headers: { "Content-Type": "text/plain" }
|
||||
});
|
||||
|
||||
sw.addEventListener("install", (e) => {
|
||||
e.waitUntil(
|
||||
caches.open(CACHE)
|
||||
.then((c) => c.addAll([ROOT]))
|
||||
.then(() => sw.skipWaiting())
|
||||
);
|
||||
});
|
||||
|
||||
sw.addEventListener("activate", (event) => {
|
||||
console.log("sw: active");
|
||||
event.waitUntil(
|
||||
sw.addEventListener("activate", (e) => {
|
||||
e.waitUntil(
|
||||
Promise.all([
|
||||
sw.clients.claim(),
|
||||
caches
|
||||
.keys()
|
||||
.then((keys) =>
|
||||
Promise.all(
|
||||
keys
|
||||
.filter((key) => key !== CACHE_VERSION)
|
||||
.map((key) => caches.delete(key)),
|
||||
),
|
||||
),
|
||||
]),
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
|
||||
),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
async function indexHTMLOrOffline() {
|
||||
return caches.match("/index.html").then((cached) => {
|
||||
if (cached) return cached;
|
||||
return new Response("Offline and no cached version", {
|
||||
status: 503,
|
||||
statusText: "Service Unavailable",
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
sw.addEventListener("fetch", (event) => {
|
||||
const req = event.request;
|
||||
const url = new URL(req.url);
|
||||
|
||||
// 1) Bypass API calls & non-GETs
|
||||
if (
|
||||
req.method !== "GET" ||
|
||||
url.pathname.startsWith("/api") ||
|
||||
url.pathname === "/changelog" ||
|
||||
url.pathname === "/crate" ||
|
||||
url.pathname === "/discord" ||
|
||||
url.pathname === "/github" ||
|
||||
url.pathname === "/health" ||
|
||||
url.pathname === "/install" ||
|
||||
url.pathname === "/mcp" ||
|
||||
url.pathname === "/nostr" ||
|
||||
url.pathname === "/service" ||
|
||||
url.pathname === "/status" ||
|
||||
url.pathname === "/version"
|
||||
) {
|
||||
return; // let the browser handle it
|
||||
}
|
||||
// Only handle same-origin GET requests
|
||||
if (req.method !== "GET" || url.origin !== location.origin) return;
|
||||
|
||||
const cache = caches.open(CACHE_VERSION);
|
||||
const path = url.pathname;
|
||||
|
||||
// 2) NAVIGATION: network‐first on your shell
|
||||
// Bypass API and redirects
|
||||
if (path.startsWith(API) || BYPASS.has(path)) return;
|
||||
|
||||
// Navigation: network-first for shell
|
||||
if (req.mode === "navigate") {
|
||||
event.respondWith(
|
||||
// Always fetch index.html
|
||||
fetch("/index.html")
|
||||
.then((response) => {
|
||||
// If we got a valid 2xx back, cache it (optional) and return it
|
||||
if (response.ok || response.status === 304) {
|
||||
if (response.ok) {
|
||||
const clone = response.clone();
|
||||
cache.then((cache) => cache.put("/index.html", clone));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
throw new Error("Non-2xx on shell");
|
||||
fetch(ROOT)
|
||||
.then((res) => {
|
||||
if (res.ok) caches.open(CACHE).then((c) => c.put(ROOT, res.clone()));
|
||||
return res;
|
||||
})
|
||||
// On any failure, fall back to the cached shell
|
||||
.catch(indexHTMLOrOffline),
|
||||
.catch(() => caches.match(ROOT).then((c) => c || offline()))
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 3) For all other GETs: network-first, fallback to cache
|
||||
// Hashed assets: cache-first (immutable)
|
||||
if (HASHED_RE.test(path)) {
|
||||
event.respondWith(
|
||||
caches.match(req)
|
||||
.then((cached) =>
|
||||
cached ||
|
||||
fetch(req).then((res) => {
|
||||
if (res.ok) caches.open(CACHE).then((c) => c.put(req, res.clone()));
|
||||
return res;
|
||||
})
|
||||
)
|
||||
.catch(() => offline())
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Other: network-first with cache fallback
|
||||
// SPA routes (no extension) fall back to ROOT, static assets get 503
|
||||
const isStatic = path.includes(".") && !path.endsWith(".html");
|
||||
event.respondWith(
|
||||
fetch(req)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
const clone = response.clone();
|
||||
cache.then((cache) => cache.put(req, clone));
|
||||
}
|
||||
return response;
|
||||
.then((res) => {
|
||||
if (res.ok) caches.open(CACHE).then((c) => c.put(req, res.clone()));
|
||||
return res;
|
||||
})
|
||||
.catch(async () =>
|
||||
caches
|
||||
.match(req)
|
||||
.then((cached) => {
|
||||
return cached || indexHTMLOrOffline();
|
||||
})
|
||||
.catch(indexHTMLOrOffline),
|
||||
),
|
||||
.catch(() =>
|
||||
caches.match(req).then((cached) =>
|
||||
cached || (isStatic ? offline() : caches.match(ROOT).then((c) => c || offline()))
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user