Skip to content

Commit

Permalink
Display outperformance instead of market caps
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed May 26, 2024
1 parent 22bc41d commit 17311e9
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/mainsite/components/MarketCapRatioWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ const MarketCapRatiosWidget: FC<Props> = ({
const flippeningTimestamp =
flippeningDataPoint === undefined ? undefined : flippeningDataPoint[0];

const firstMarketCapRatio = marketCapRatiosSeries?.[0]?.[1];

const lastMarketCapSeriesTimestamp =
marketCapRatiosSeries?.[marketCapRatiosSeries.length - 1]?.[0];

Expand Down Expand Up @@ -341,45 +343,45 @@ const MarketCapRatiosWidget: FC<Props> = ({
}</div>`;

let p = points[0];
let rows =
p === undefined
? []
: [
`<tr>

let rows: string[] = [];
if (
p?.y != undefined &&
p?.y != null &&
firstMarketCapRatio !== undefined
) {
let outPerformanceTodate = p.y / firstMarketCapRatio;
let remainingOutPerformance = 100 / p.y;
rows = [
`<tr>
<td>
<div class="tt-series">
<div class="tt-series-name text-slate-300">marketcap ratio</div>
</div>
</td>
<td class="text-white">${formatOneDecimal(p.y || 0)}%</td>
</tr>`,
];

if (!isProjected && firstPoint?.x !== undefined) {
const marketCaps = marketCapsMap[firstPoint.x as number];
const marketCapRows = [
`<tr>
<td>
<div class="tt-series">
<div class="tt-series-name text-slate-300">ETH marketcap</div>
<div class="tt-series-name text-slate-300">outperformance to date</div>
</div>
</td>
<td class="text-white">${formatOneDecimal(
(marketCaps?.ethMarketcap || 0) / 1e9,
)}B USD</td>
outPerformanceTodate,
)}x</td>
</tr>`,
`<tr>
<td>
<div class="tt-series">
<div class="tt-series-name text-slate-300">BTC marketcap</div>
<div class="tt-series-name text-slate-300">remaining outperformance</div>
</div>
</td>
<td class="text-white">${formatOneDecimal(
(marketCaps?.btcMarketcap || 0) / 1e9,
)}B USD</td>
remainingOutPerformance,
)}x</td>
</tr>`,
];
rows = rows.concat(marketCapRows);
}

const table = `<table><tbody>${rows.join("")}</tbody></table>`;
Expand Down

0 comments on commit 17311e9

Please sign in to comment.