mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-27 08:09:58 -07:00
website: options: objectify
This commit is contained in:
@@ -131,22 +131,22 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "New",
|
||||
title: `${titlePrefix}New Address Count`,
|
||||
bottom: fromFullStatsPattern(distribution.newAddrCount[key], Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: distribution.newAddrCount[key], unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "Growth Rate",
|
||||
title: `${titlePrefix}Address Growth Rate`,
|
||||
bottom: fromBaseStatsPattern(distribution.growthRate[key], Unit.ratio),
|
||||
bottom: fromBaseStatsPattern({ pattern: distribution.growthRate[key], unit: Unit.ratio }),
|
||||
},
|
||||
{
|
||||
name: "Activity",
|
||||
tree: activityTypes.map((a) => ({
|
||||
name: a.name,
|
||||
title: `${titlePrefix}${a.name} Address Count`,
|
||||
bottom: fromBaseStatsPattern(
|
||||
distribution.addressActivity[key][a.key],
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromBaseStatsPattern({
|
||||
pattern: distribution.addressActivity[key][a.key],
|
||||
unit: Unit.count,
|
||||
}),
|
||||
})),
|
||||
},
|
||||
];
|
||||
@@ -250,19 +250,19 @@ export function createChainSection(ctx) {
|
||||
name: "Rewards",
|
||||
title: `${poolName} Rewards`,
|
||||
bottom: [
|
||||
...fromValuePattern(
|
||||
pool.coinbase,
|
||||
"coinbase",
|
||||
colors.orange,
|
||||
colors.red,
|
||||
),
|
||||
...fromValuePattern(
|
||||
pool.subsidy,
|
||||
"subsidy",
|
||||
colors.lime,
|
||||
colors.emerald,
|
||||
),
|
||||
...fromValuePattern(pool.fee, "fee", colors.cyan, colors.indigo),
|
||||
...fromValuePattern({
|
||||
pattern: pool.coinbase,
|
||||
title: "coinbase",
|
||||
sumColor: colors.orange,
|
||||
cumulativeColor: colors.red,
|
||||
}),
|
||||
...fromValuePattern({
|
||||
pattern: pool.subsidy,
|
||||
title: "subsidy",
|
||||
sumColor: colors.lime,
|
||||
cumulativeColor: colors.emerald,
|
||||
}),
|
||||
...fromValuePattern({ pattern: pool.fee, title: "fee", sumColor: colors.cyan, cumulativeColor: colors.indigo }),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -296,7 +296,7 @@ export function createChainSection(ctx) {
|
||||
name: "Count",
|
||||
title: "Block Count",
|
||||
bottom: [
|
||||
...fromCountPattern(blocks.count.blockCount, Unit.count),
|
||||
...fromCountPattern({ pattern: blocks.count.blockCount, unit: Unit.count }),
|
||||
line({
|
||||
metric: blocks.count.blockCountTarget,
|
||||
name: "Target",
|
||||
@@ -338,7 +338,7 @@ export function createChainSection(ctx) {
|
||||
name: "Interval",
|
||||
title: "Block Interval",
|
||||
bottom: [
|
||||
...fromBaseStatsPattern(blocks.interval, Unit.secs, "", { avgActive: false }),
|
||||
...fromBaseStatsPattern({ pattern: blocks.interval, unit: Unit.secs, avgActive: false }),
|
||||
priceLine({ ctx, unit: Unit.secs, name: "Target", number: 600 }),
|
||||
],
|
||||
},
|
||||
@@ -346,7 +346,7 @@ export function createChainSection(ctx) {
|
||||
name: "Size",
|
||||
title: "Block Size",
|
||||
bottom: [
|
||||
...fromSumStatsPattern(blocks.size, Unit.bytes),
|
||||
...fromSumStatsPattern({ pattern: blocks.size, unit: Unit.bytes }),
|
||||
line({
|
||||
metric: blocks.totalSize,
|
||||
name: "Total",
|
||||
@@ -354,8 +354,8 @@ export function createChainSection(ctx) {
|
||||
unit: Unit.bytes,
|
||||
defaultActive: false,
|
||||
}),
|
||||
...fromBaseStatsPattern(blocks.vbytes, Unit.vb),
|
||||
...fromBaseStatsPattern(blocks.weight, Unit.wu),
|
||||
...fromBaseStatsPattern({ pattern: blocks.vbytes, unit: Unit.vb }),
|
||||
...fromBaseStatsPattern({ pattern: blocks.weight, unit: Unit.wu }),
|
||||
line({
|
||||
metric: blocks.weight.sum,
|
||||
name: "Sum",
|
||||
@@ -375,7 +375,7 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "Fullness",
|
||||
title: "Block Fullness",
|
||||
bottom: fromBaseStatsPattern(blocks.fullness, Unit.percentage),
|
||||
bottom: fromBaseStatsPattern({ pattern: blocks.fullness, unit: Unit.percentage }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -387,7 +387,7 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "Count",
|
||||
title: "Transaction Count",
|
||||
bottom: fromFullStatsPattern(transactions.count.txCount, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: transactions.count.txCount, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "Speed",
|
||||
@@ -404,61 +404,59 @@ export function createChainSection(ctx) {
|
||||
name: "Volume",
|
||||
title: "Transaction Volume",
|
||||
bottom: [
|
||||
...satsBtcUsd(transactions.volume.sentSum, "Sent"),
|
||||
...satsBtcUsd(
|
||||
transactions.volume.receivedSum,
|
||||
"Received",
|
||||
colors.cyan,
|
||||
{
|
||||
defaultActive: false,
|
||||
},
|
||||
),
|
||||
...satsBtcUsd(
|
||||
transactions.volume.annualizedVolume,
|
||||
"Annualized",
|
||||
colors.red,
|
||||
{ defaultActive: false },
|
||||
),
|
||||
...satsBtcUsd({ pattern: transactions.volume.sentSum, name: "Sent" }),
|
||||
...satsBtcUsd({
|
||||
pattern: transactions.volume.receivedSum,
|
||||
name: "Received",
|
||||
color: colors.cyan,
|
||||
defaultActive: false,
|
||||
}),
|
||||
...satsBtcUsd({
|
||||
pattern: transactions.volume.annualizedVolume,
|
||||
name: "Annualized",
|
||||
color: colors.red,
|
||||
defaultActive: false,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Size",
|
||||
title: "Transaction Size",
|
||||
bottom: [
|
||||
...fromStatsPattern(transactions.size.weight, Unit.wu),
|
||||
...fromStatsPattern(transactions.size.vsize, Unit.vb),
|
||||
...fromStatsPattern({ pattern: transactions.size.weight, unit: Unit.wu }),
|
||||
...fromStatsPattern({ pattern: transactions.size.vsize, unit: Unit.vb }),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fee Rate",
|
||||
title: "Fee Rate",
|
||||
bottom: fromStatsPattern(transactions.fees.feeRate, Unit.feeRate),
|
||||
bottom: fromStatsPattern({ pattern: transactions.fees.feeRate, unit: Unit.feeRate }),
|
||||
},
|
||||
{
|
||||
name: "Versions",
|
||||
title: "Transaction Versions",
|
||||
bottom: [
|
||||
...fromCountPattern(
|
||||
transactions.versions.v1,
|
||||
Unit.count,
|
||||
"v1",
|
||||
colors.orange,
|
||||
colors.red,
|
||||
),
|
||||
...fromCountPattern(
|
||||
transactions.versions.v2,
|
||||
Unit.count,
|
||||
"v2",
|
||||
colors.cyan,
|
||||
colors.blue,
|
||||
),
|
||||
...fromCountPattern(
|
||||
transactions.versions.v3,
|
||||
Unit.count,
|
||||
"v3",
|
||||
colors.lime,
|
||||
colors.green,
|
||||
),
|
||||
...fromCountPattern({
|
||||
pattern: transactions.versions.v1,
|
||||
unit: Unit.count,
|
||||
title: "v1",
|
||||
sumColor: colors.orange,
|
||||
cumulativeColor: colors.red,
|
||||
}),
|
||||
...fromCountPattern({
|
||||
pattern: transactions.versions.v2,
|
||||
unit: Unit.count,
|
||||
title: "v2",
|
||||
sumColor: colors.cyan,
|
||||
cumulativeColor: colors.blue,
|
||||
}),
|
||||
...fromCountPattern({
|
||||
pattern: transactions.versions.v3,
|
||||
unit: Unit.count,
|
||||
title: "v3",
|
||||
sumColor: colors.lime,
|
||||
cumulativeColor: colors.green,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -488,12 +486,12 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "Input Count",
|
||||
title: "Input Count",
|
||||
bottom: [...fromSumStatsPattern(inputs.count, Unit.count)],
|
||||
bottom: [...fromSumStatsPattern({ pattern: inputs.count, unit: Unit.count })],
|
||||
},
|
||||
{
|
||||
name: "Output Count",
|
||||
title: "Output Count",
|
||||
bottom: [...fromSumStatsPattern(outputs.count.totalCount, Unit.count)],
|
||||
bottom: [...fromSumStatsPattern({ pattern: outputs.count.totalCount, unit: Unit.count })],
|
||||
},
|
||||
{
|
||||
name: "Inputs/sec",
|
||||
@@ -545,23 +543,17 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "P2PKH",
|
||||
title: "P2PKH Output Count",
|
||||
bottom: fromFullStatsPattern(scripts.count.p2pkh, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2pkh, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "P2PK33",
|
||||
title: "P2PK33 Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.p2pk33,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2pk33, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "P2PK65",
|
||||
title: "P2PK65 Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.p2pk65,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2pk65, unit: Unit.count }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -572,12 +564,12 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "P2SH",
|
||||
title: "P2SH Output Count",
|
||||
bottom: fromFullStatsPattern(scripts.count.p2sh, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2sh, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "P2MS",
|
||||
title: "P2MS Output Count",
|
||||
bottom: fromFullStatsPattern(scripts.count.p2ms, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2ms, unit: Unit.count }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -588,23 +580,17 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "All SegWit",
|
||||
title: "SegWit Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.segwit,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.segwit, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "P2WPKH",
|
||||
title: "P2WPKH Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.p2wpkh,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2wpkh, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "P2WSH",
|
||||
title: "P2WSH Output Count",
|
||||
bottom: fromFullStatsPattern(scripts.count.p2wsh, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2wsh, unit: Unit.count }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -615,12 +601,12 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "P2TR",
|
||||
title: "P2TR Output Count",
|
||||
bottom: fromFullStatsPattern(scripts.count.p2tr, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2tr, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "P2A",
|
||||
title: "P2A Output Count",
|
||||
bottom: fromFullStatsPattern(scripts.count.p2a, Unit.count),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.p2a, unit: Unit.count }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -631,26 +617,17 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "OP_RETURN",
|
||||
title: "OP_RETURN Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.opreturn,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.opreturn, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "Empty",
|
||||
title: "Empty Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.emptyoutput,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.emptyoutput, unit: Unit.count }),
|
||||
},
|
||||
{
|
||||
name: "Unknown",
|
||||
title: "Unknown Output Count",
|
||||
bottom: fromFullStatsPattern(
|
||||
scripts.count.unknownoutput,
|
||||
Unit.count,
|
||||
),
|
||||
bottom: fromFullStatsPattern({ pattern: scripts.count.unknownoutput, unit: Unit.count }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -712,7 +689,7 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "OP_RETURN Value",
|
||||
title: "OP_RETURN Value",
|
||||
bottom: fromCoinbasePattern(scripts.value.opreturn),
|
||||
bottom: fromCoinbasePattern({ pattern: scripts.value.opreturn }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -724,7 +701,7 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "Circulating",
|
||||
title: "Circulating Supply",
|
||||
bottom: fromSupplyPattern(supply.circulating, "Supply"),
|
||||
bottom: fromSupplyPattern({ pattern: supply.circulating, title: "Supply" }),
|
||||
},
|
||||
{
|
||||
name: "Inflation",
|
||||
@@ -740,12 +717,12 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "Unspendable",
|
||||
title: "Unspendable Supply",
|
||||
bottom: fromValuePattern(supply.burned.unspendable),
|
||||
bottom: fromValuePattern({ pattern: supply.burned.unspendable }),
|
||||
},
|
||||
{
|
||||
name: "OP_RETURN",
|
||||
title: "OP_RETURN Supply",
|
||||
bottom: fromValuePattern(supply.burned.opreturn),
|
||||
bottom: fromValuePattern({ pattern: supply.burned.opreturn }),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -758,20 +735,20 @@ export function createChainSection(ctx) {
|
||||
name: "Coinbase",
|
||||
title: "Coinbase Rewards",
|
||||
bottom: [
|
||||
...fromCoinbasePattern(blocks.rewards.coinbase),
|
||||
...satsBtcUsd(
|
||||
blocks.rewards._24hCoinbaseSum,
|
||||
"24h sum",
|
||||
colors.pink,
|
||||
{ defaultActive: false },
|
||||
),
|
||||
...fromCoinbasePattern({ pattern: blocks.rewards.coinbase }),
|
||||
...satsBtcUsd({
|
||||
pattern: blocks.rewards._24hCoinbaseSum,
|
||||
name: "24h sum",
|
||||
color: colors.pink,
|
||||
defaultActive: false,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Subsidy",
|
||||
title: "Block Subsidy",
|
||||
bottom: [
|
||||
...fromCoinbasePattern(blocks.rewards.subsidy),
|
||||
...fromCoinbasePattern({ pattern: blocks.rewards.subsidy }),
|
||||
line({
|
||||
metric: blocks.rewards.subsidyDominance,
|
||||
name: "Dominance",
|
||||
@@ -792,9 +769,9 @@ export function createChainSection(ctx) {
|
||||
name: "Fee",
|
||||
title: "Transaction Fees",
|
||||
bottom: [
|
||||
...fromSumStatsPattern(transactions.fees.fee.bitcoin, Unit.btc),
|
||||
...fromSumStatsPattern(transactions.fees.fee.sats, Unit.sats),
|
||||
...fromSumStatsPattern(transactions.fees.fee.dollars, Unit.usd),
|
||||
...fromSumStatsPattern({ pattern: transactions.fees.fee.bitcoin, unit: Unit.btc }),
|
||||
...fromSumStatsPattern({ pattern: transactions.fees.fee.sats, unit: Unit.sats }),
|
||||
...fromSumStatsPattern({ pattern: transactions.fees.fee.dollars, unit: Unit.usd }),
|
||||
line({
|
||||
metric: blocks.rewards.feeDominance,
|
||||
name: "Dominance",
|
||||
@@ -807,10 +784,10 @@ export function createChainSection(ctx) {
|
||||
{
|
||||
name: "Unclaimed",
|
||||
title: "Unclaimed Rewards",
|
||||
bottom: fromValuePattern(
|
||||
blocks.rewards.unclaimedRewards,
|
||||
"Unclaimed",
|
||||
),
|
||||
bottom: fromValuePattern({
|
||||
pattern: blocks.rewards.unclaimedRewards,
|
||||
title: "Unclaimed",
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -166,9 +166,9 @@ export function createCointimeSection(ctx) {
|
||||
name: "Supply",
|
||||
title: "Cointime Supply",
|
||||
bottom: [
|
||||
...satsBtcUsd(all.supply.total, "All", colors.orange),
|
||||
...satsBtcUsd(cointimeSupply.vaultedSupply, "Vaulted", colors.lime),
|
||||
...satsBtcUsd(cointimeSupply.activeSupply, "Active", colors.rose),
|
||||
...satsBtcUsd({ pattern: all.supply.total, name: "All", color: colors.orange }),
|
||||
...satsBtcUsd({ pattern: cointimeSupply.vaultedSupply, name: "Vaulted", color: colors.lime }),
|
||||
...satsBtcUsd({ pattern: cointimeSupply.activeSupply, name: "Active", color: colors.rose }),
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
@@ -124,10 +124,10 @@ function createSingleSupplySeriesBase(ctx, cohort) {
|
||||
const { tree } = cohort;
|
||||
|
||||
return [
|
||||
...satsBtcUsd(tree.supply.total, "Supply", colors.default),
|
||||
...satsBtcUsd(tree.unrealized.supplyInProfit, "In Profit", colors.green),
|
||||
...satsBtcUsd(tree.unrealized.supplyInLoss, "In Loss", colors.red),
|
||||
...satsBtcUsd(tree.supply.halved, "half", colors.gray).map((s) => ({
|
||||
...satsBtcUsd({ pattern: tree.supply.total, name: "Supply", color: colors.default }),
|
||||
...satsBtcUsd({ pattern: tree.unrealized.supplyInProfit, name: "In Profit", color: colors.green }),
|
||||
...satsBtcUsd({ pattern: tree.unrealized.supplyInLoss, name: "In Loss", color: colors.red }),
|
||||
...satsBtcUsd({ pattern: tree.supply.halved, name: "half", color: colors.gray }).map((s) => ({
|
||||
...s,
|
||||
options: { lineStyle: 4 },
|
||||
})),
|
||||
@@ -206,7 +206,7 @@ export function createSingleSupplySeriesWithoutRelative(ctx, cohort) {
|
||||
*/
|
||||
export function createGroupedSupplyTotalSeries(list, { relativeMetrics } = {}) {
|
||||
return list.flatMap((cohort) => [
|
||||
...satsBtcUsd(cohort.tree.supply.total, cohort.name, cohort.color),
|
||||
...satsBtcUsd({ pattern: cohort.tree.supply.total, name: cohort.name, color: cohort.color }),
|
||||
...(relativeMetrics ? relativeMetrics(cohort) : []),
|
||||
]);
|
||||
}
|
||||
@@ -221,7 +221,7 @@ export function createGroupedSupplyTotalSeries(list, { relativeMetrics } = {}) {
|
||||
*/
|
||||
export function createGroupedSupplyInProfitSeries(list, { relativeMetrics } = {}) {
|
||||
return list.flatMap((cohort) => [
|
||||
...satsBtcUsd(cohort.tree.unrealized.supplyInProfit, cohort.name, cohort.color),
|
||||
...satsBtcUsd({ pattern: cohort.tree.unrealized.supplyInProfit, name: cohort.name, color: cohort.color }),
|
||||
...(relativeMetrics ? relativeMetrics(cohort) : []),
|
||||
]);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ export function createGroupedSupplyInProfitSeries(list, { relativeMetrics } = {}
|
||||
*/
|
||||
export function createGroupedSupplyInLossSeries(list, { relativeMetrics } = {}) {
|
||||
return list.flatMap((cohort) => [
|
||||
...satsBtcUsd(cohort.tree.unrealized.supplyInLoss, cohort.name, cohort.color),
|
||||
...satsBtcUsd({ pattern: cohort.tree.unrealized.supplyInLoss, name: cohort.name, color: cohort.color }),
|
||||
...(relativeMetrics ? relativeMetrics(cohort) : []),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -947,26 +947,25 @@ function createSingleRealizedPnlSection(
|
||||
name: "P&L",
|
||||
title: title("Realized P&L"),
|
||||
bottom: [
|
||||
...fromCountPattern(
|
||||
tree.realized.realizedProfit,
|
||||
Unit.usd,
|
||||
"Profit",
|
||||
colors.green,
|
||||
),
|
||||
...fromCountPattern(
|
||||
tree.realized.realizedLoss,
|
||||
Unit.usd,
|
||||
"Loss",
|
||||
colors.red,
|
||||
),
|
||||
...fromBitcoinPatternWithUnit(
|
||||
tree.realized.negRealizedLoss,
|
||||
Unit.usd,
|
||||
"Negative Loss",
|
||||
colors.red,
|
||||
undefined,
|
||||
false,
|
||||
),
|
||||
...fromCountPattern({
|
||||
pattern: tree.realized.realizedProfit,
|
||||
unit: Unit.usd,
|
||||
title: "Profit",
|
||||
sumColor: colors.green,
|
||||
}),
|
||||
...fromCountPattern({
|
||||
pattern: tree.realized.realizedLoss,
|
||||
unit: Unit.usd,
|
||||
title: "Loss",
|
||||
sumColor: colors.red,
|
||||
}),
|
||||
...fromBitcoinPatternWithUnit({
|
||||
pattern: tree.realized.negRealizedLoss,
|
||||
unit: Unit.usd,
|
||||
title: "Negative Loss",
|
||||
sumColor: colors.red,
|
||||
defaultActive: false,
|
||||
}),
|
||||
...extra,
|
||||
line({
|
||||
metric: tree.realized.totalRealizedPnl,
|
||||
@@ -1009,11 +1008,11 @@ function createSingleRealizedPnlSection(
|
||||
name: "Net P&L",
|
||||
title: title("Net Realized P&L"),
|
||||
bottom: [
|
||||
...fromCountPattern(
|
||||
tree.realized.netRealizedPnl,
|
||||
Unit.usd,
|
||||
"Net",
|
||||
),
|
||||
...fromCountPattern({
|
||||
pattern: tree.realized.netRealizedPnl,
|
||||
unit: Unit.usd,
|
||||
title: "Net",
|
||||
}),
|
||||
baseline({
|
||||
metric: tree.realized.netRealizedPnlCumulative30dDelta,
|
||||
name: "Cumulative 30d Change",
|
||||
@@ -2618,24 +2617,21 @@ function createActivitySection({ ctx, cohort, title, valueMetrics = [] }) {
|
||||
name: "Sent",
|
||||
title: title("Sent"),
|
||||
bottom: [
|
||||
...fromCountPattern(
|
||||
tree.activity.sent.sats,
|
||||
Unit.sats,
|
||||
undefined,
|
||||
color,
|
||||
),
|
||||
...fromBitcoinPatternWithUnit(
|
||||
tree.activity.sent.bitcoin,
|
||||
Unit.btc,
|
||||
undefined,
|
||||
color,
|
||||
),
|
||||
...fromCountPattern(
|
||||
tree.activity.sent.dollars,
|
||||
Unit.usd,
|
||||
undefined,
|
||||
color,
|
||||
),
|
||||
...fromCountPattern({
|
||||
pattern: tree.activity.sent.sats,
|
||||
unit: Unit.sats,
|
||||
sumColor: color,
|
||||
}),
|
||||
...fromBitcoinPatternWithUnit({
|
||||
pattern: tree.activity.sent.bitcoin,
|
||||
unit: Unit.btc,
|
||||
sumColor: color,
|
||||
}),
|
||||
...fromCountPattern({
|
||||
pattern: tree.activity.sent.dollars,
|
||||
unit: Unit.usd,
|
||||
sumColor: color,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -147,8 +147,8 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
|
||||
name: "Stack",
|
||||
title: `${name} Stack`,
|
||||
bottom: [
|
||||
...satsBtcUsd(dca.periodStack[key], "DCA", colors.green),
|
||||
...satsBtcUsd(dca.periodLumpSumStack[key], "Lump sum", colors.orange),
|
||||
...satsBtcUsd({ pattern: dca.periodStack[key], name: "DCA", color: colors.green }),
|
||||
...satsBtcUsd({ pattern: dca.periodLumpSumStack[key], name: "Lump sum", color: colors.orange }),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -338,7 +338,7 @@ export function createDcaByYearSection(ctx, { dca }) {
|
||||
title: "DCA Stack",
|
||||
bottom: dcaClasses.flatMap(
|
||||
({ year, color, defaultActive, stack }) =>
|
||||
satsBtcUsd(stack, `${year}`, color, { defaultActive }),
|
||||
satsBtcUsd({ pattern: stack, name: `${year}`, color, defaultActive }),
|
||||
),
|
||||
},
|
||||
],
|
||||
@@ -415,7 +415,7 @@ export function createDcaByYearSection(ctx, { dca }) {
|
||||
{
|
||||
name: "Stack",
|
||||
title: `${year} Stack`,
|
||||
bottom: satsBtcUsd(stack, "Stack", color),
|
||||
bottom: satsBtcUsd({ pattern: stack, name: "Stack", color }),
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -290,12 +290,13 @@ export function histogram({
|
||||
/**
|
||||
* Create series from patterns with sum + cumulative + percentiles (NO base)
|
||||
* @param {Colors} colors
|
||||
* @param {AnyStatsPattern} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {Object} args
|
||||
* @param {AnyStatsPattern} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromSumStatsPattern(colors, pattern, unit, title = "") {
|
||||
export function fromSumStatsPattern(colors, { pattern, unit, title = "" }) {
|
||||
const { stat } = colors;
|
||||
return [
|
||||
{ metric: pattern.average, title: `${title} avg`.trim(), unit },
|
||||
@@ -320,15 +321,16 @@ export function fromSumStatsPattern(colors, pattern, unit, title = "") {
|
||||
/**
|
||||
* Create series from a BaseStatsPattern (base + avg + percentiles, NO sum)
|
||||
* @param {Colors} colors
|
||||
* @param {BaseStatsPattern<any>} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {{ baseColor?: Color, avgActive?: boolean }} [options]
|
||||
* @param {Object} args
|
||||
* @param {BaseStatsPattern<any>} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @param {Color} [args.baseColor]
|
||||
* @param {boolean} [args.avgActive]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromBaseStatsPattern(colors, pattern, unit, title = "", options) {
|
||||
export function fromBaseStatsPattern(colors, { pattern, unit, title = "", baseColor, avgActive = true }) {
|
||||
const { stat } = colors;
|
||||
const { baseColor, avgActive = true } = options || {};
|
||||
return [
|
||||
{ metric: pattern.base, title: title || "base", color: baseColor, unit },
|
||||
{
|
||||
@@ -345,12 +347,13 @@ export function fromBaseStatsPattern(colors, pattern, unit, title = "", options)
|
||||
/**
|
||||
* Create series from a FullStatsPattern (base + sum + cumulative + avg + percentiles)
|
||||
* @param {Colors} colors
|
||||
* @param {FullStatsPattern<any>} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {Object} args
|
||||
* @param {FullStatsPattern<any>} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromFullStatsPattern(colors, pattern, unit, title = "") {
|
||||
export function fromFullStatsPattern(colors, { pattern, unit, title = "" }) {
|
||||
const { stat } = colors;
|
||||
return [
|
||||
{ metric: pattern.base, title: title || "base", unit },
|
||||
@@ -379,14 +382,15 @@ export function fromFullStatsPattern(colors, pattern, unit, title = "") {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create series from a StatsPattern ({ average, min, max, percentiles })
|
||||
* Create series from a StatsPattern (avg + percentiles, NO base)
|
||||
* @param {Colors} colors
|
||||
* @param {StatsPattern<any>} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {Object} args
|
||||
* @param {StatsPattern<any>} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromStatsPattern(colors, pattern, unit, title = "") {
|
||||
export function fromStatsPattern(colors, { pattern, unit, title = "" }) {
|
||||
return [
|
||||
{
|
||||
type: "Dots",
|
||||
@@ -401,20 +405,16 @@ export function fromStatsPattern(colors, pattern, unit, title = "") {
|
||||
/**
|
||||
* Create series from AnyFullStatsPattern (base + sum + cumulative + avg + percentiles)
|
||||
* @param {Colors} colors
|
||||
* @param {AnyFullStatsPattern} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {Object} args
|
||||
* @param {AnyFullStatsPattern} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromAnyFullStatsPattern(
|
||||
colors,
|
||||
pattern,
|
||||
unit,
|
||||
title = "",
|
||||
) {
|
||||
export function fromAnyFullStatsPattern(colors, { pattern, unit, title = "" }) {
|
||||
const { stat } = colors;
|
||||
return [
|
||||
...fromBaseStatsPattern(colors, pattern, unit, title),
|
||||
...fromBaseStatsPattern(colors, { pattern, unit, title }),
|
||||
{
|
||||
metric: pattern.sum,
|
||||
title: `${title} sum`.trim(),
|
||||
@@ -434,49 +434,30 @@ export function fromAnyFullStatsPattern(
|
||||
/**
|
||||
* Create series from a CoinbasePattern ({ sats, bitcoin, dollars } each with stats + sum + cumulative)
|
||||
* @param {Colors} colors
|
||||
* @param {CoinbasePattern} pattern
|
||||
* @param {string} [title]
|
||||
* @param {Object} args
|
||||
* @param {CoinbasePattern} args.pattern
|
||||
* @param {string} [args.title]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromCoinbasePattern(colors, pattern, title = "") {
|
||||
export function fromCoinbasePattern(colors, { pattern, title = "" }) {
|
||||
return [
|
||||
...fromAnyFullStatsPattern(
|
||||
colors,
|
||||
pattern.bitcoin,
|
||||
Unit.btc,
|
||||
title,
|
||||
),
|
||||
...fromAnyFullStatsPattern(
|
||||
colors,
|
||||
pattern.sats,
|
||||
Unit.sats,
|
||||
title,
|
||||
),
|
||||
...fromAnyFullStatsPattern(
|
||||
colors,
|
||||
pattern.dollars,
|
||||
Unit.usd,
|
||||
title,
|
||||
),
|
||||
...fromAnyFullStatsPattern(colors, { pattern: pattern.bitcoin, unit: Unit.btc, title }),
|
||||
...fromAnyFullStatsPattern(colors, { pattern: pattern.sats, unit: Unit.sats, title }),
|
||||
...fromAnyFullStatsPattern(colors, { pattern: pattern.dollars, unit: Unit.usd, title }),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create series from a ValuePattern ({ sats, bitcoin, dollars } each as CountPattern with sum + cumulative)
|
||||
* @param {Colors} colors
|
||||
* @param {ValuePattern} pattern
|
||||
* @param {string} [title]
|
||||
* @param {Color} [sumColor]
|
||||
* @param {Color} [cumulativeColor]
|
||||
* @param {Object} args
|
||||
* @param {ValuePattern} args.pattern
|
||||
* @param {string} [args.title]
|
||||
* @param {Color} [args.sumColor]
|
||||
* @param {Color} [args.cumulativeColor]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromValuePattern(
|
||||
colors,
|
||||
pattern,
|
||||
title = "",
|
||||
sumColor,
|
||||
cumulativeColor,
|
||||
) {
|
||||
export function fromValuePattern(colors, { pattern, title = "", sumColor, cumulativeColor }) {
|
||||
return [
|
||||
{
|
||||
metric: pattern.bitcoin.sum,
|
||||
@@ -523,23 +504,16 @@ export function fromValuePattern(
|
||||
/**
|
||||
* Create sum/cumulative series from a BitcoinPattern ({ sum, cumulative }) with explicit unit and colors
|
||||
* @param {Colors} colors
|
||||
* @param {{ sum: AnyMetricPattern, cumulative: AnyMetricPattern }} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {Color} [sumColor]
|
||||
* @param {Color} [cumulativeColor]
|
||||
* @param {boolean} [defaultActive]
|
||||
* @param {Object} args
|
||||
* @param {{ sum: AnyMetricPattern, cumulative: AnyMetricPattern }} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @param {Color} [args.sumColor]
|
||||
* @param {Color} [args.cumulativeColor]
|
||||
* @param {boolean} [args.defaultActive]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromBitcoinPatternWithUnit(
|
||||
colors,
|
||||
pattern,
|
||||
unit,
|
||||
title = "",
|
||||
sumColor,
|
||||
cumulativeColor,
|
||||
defaultActive,
|
||||
) {
|
||||
export function fromBitcoinPatternWithUnit(colors, { pattern, unit, title = "", sumColor, cumulativeColor, defaultActive }) {
|
||||
return [
|
||||
{
|
||||
metric: pattern.sum,
|
||||
@@ -561,21 +535,15 @@ export function fromBitcoinPatternWithUnit(
|
||||
/**
|
||||
* Create sum/cumulative series from a CountPattern with explicit unit and colors
|
||||
* @param {Colors} colors
|
||||
* @param {CountPattern<any>} pattern
|
||||
* @param {Unit} unit
|
||||
* @param {string} [title]
|
||||
* @param {Color} [sumColor]
|
||||
* @param {Color} [cumulativeColor]
|
||||
* @param {Object} args
|
||||
* @param {CountPattern<any>} args.pattern
|
||||
* @param {Unit} args.unit
|
||||
* @param {string} [args.title]
|
||||
* @param {Color} [args.sumColor]
|
||||
* @param {Color} [args.cumulativeColor]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromCountPattern(
|
||||
colors,
|
||||
pattern,
|
||||
unit,
|
||||
title = "",
|
||||
sumColor,
|
||||
cumulativeColor,
|
||||
) {
|
||||
export function fromCountPattern(colors, { pattern, unit, title = "", sumColor, cumulativeColor }) {
|
||||
return [
|
||||
{
|
||||
metric: pattern.sum,
|
||||
@@ -595,12 +563,13 @@ export function fromCountPattern(
|
||||
|
||||
/**
|
||||
* Create series from a SupplyPattern (sats/bitcoin/dollars, no sum/cumulative)
|
||||
* @param {SupplyPattern} pattern
|
||||
* @param {string} title
|
||||
* @param {Color} [color]
|
||||
* @param {Object} args
|
||||
* @param {SupplyPattern} args.pattern
|
||||
* @param {string} args.title
|
||||
* @param {Color} [args.color]
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export function fromSupplyPattern(pattern, title, color) {
|
||||
export function fromSupplyPattern({ pattern, title, color }) {
|
||||
return [
|
||||
{
|
||||
metric: pattern.bitcoin,
|
||||
|
||||
@@ -14,14 +14,14 @@ export const formatCohortTitle = (cohortTitle) =>
|
||||
|
||||
/**
|
||||
* Create sats/btc/usd line series from a pattern with .sats/.bitcoin/.dollars
|
||||
* @param {{ sats: AnyMetricPattern, bitcoin: AnyMetricPattern, dollars: AnyMetricPattern }} pattern
|
||||
* @param {string} name
|
||||
* @param {Color} [color]
|
||||
* @param {{ defaultActive?: boolean }} [options]
|
||||
* @param {Object} args
|
||||
* @param {{ sats: AnyMetricPattern, bitcoin: AnyMetricPattern, dollars: AnyMetricPattern }} args.pattern
|
||||
* @param {string} args.name
|
||||
* @param {Color} [args.color]
|
||||
* @param {boolean} [args.defaultActive]
|
||||
* @returns {FetchedLineSeriesBlueprint[]}
|
||||
*/
|
||||
export function satsBtcUsd(pattern, name, color, options) {
|
||||
const { defaultActive } = options || {};
|
||||
export function satsBtcUsd({ pattern, name, color, defaultActive }) {
|
||||
return [
|
||||
line({
|
||||
metric: pattern.bitcoin,
|
||||
|
||||
Reference in New Issue
Block a user