Skip to content

Commit 47d3ebc

Browse files
committed
feat: add total value securing metric
1 parent 0e7aa6c commit 47d3ebc

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

app/[locale]/enterprise/page.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ import type { Case, EcosystemPlayer, Feature } from "./types"
5454
import { parseActivity } from "./utils"
5555

5656
import { fetchEthereumStablecoinsMcap } from "@/lib/api/fetchEthereumStablecoinsMcap"
57+
import { fetchEthPrice } from "@/lib/api/fetchEthPrice"
5758
import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie"
59+
import { fetchTotalEthStaked } from "@/lib/api/fetchTotalEthStaked"
5860
import EthGlyph from "@/public/images/assets/svgs/eth-diamond-rainbow.svg"
5961
import heroImage from "@/public/images/heroes/enterprise-hero-white.png"
6062

@@ -82,8 +84,10 @@ const CasesSwiper = dynamic(() => import("./_components/CasesSwiper"), {
8284
// TODO: Switch back to this for cache and mock-data dev fallback
8385
// const loadData = dataLoader(
8486
// [
85-
// ["ethereumStablecoinsResponse", fetchEthereumStablecoinsMcap],
8687
// ["growThePieData", fetchGrowThePie],
88+
// ["ethereumStablecoins", fetchEthereumStablecoinsMcap],
89+
// ["ethPrice", fetchEthPrice],
90+
// ["totalEthStaked", fetchTotalEthStaked],
8791
// ],
8892
// BASE_TIME_UNIT * 1000
8993
// )
@@ -93,14 +97,19 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
9397

9498
const t = await getTranslations({ locale, namespace: "page-enterprise" })
9599

96-
// const [{ txCount }, ethereumStablecoinsResponse] = await loadData()
100+
// const [{ txCount }, stablecoinMarketCap, ethPrice, totalEthStaked] =
101+
// await loadData()
97102
const { txCount } = await fetchGrowThePie()
98103
const stablecoinMarketCap = await fetchEthereumStablecoinsMcap()
104+
const ethPrice = await fetchEthPrice()
105+
const totalEthStaked = await fetchTotalEthStaked()
99106

100107
const metrics = await parseActivity(
101108
{
102109
txCount,
103110
stablecoinMarketCap,
111+
ethPrice,
112+
totalEthStaked,
104113
// totalCapitalSecured,
105114
},
106115
locale

app/[locale]/enterprise/utils.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export const parseActivity = async (
1414
{
1515
txCount,
1616
stablecoinMarketCap,
17+
ethPrice,
18+
totalEthStaked,
1719
// totalCapitalSecured,
1820
}: AllEnterpriseActivityData,
1921
locale: Lang
@@ -41,6 +43,26 @@ export const parseActivity = async (
4143
),
4244
}
4345

46+
const hasEthStakerAndPriceData =
47+
"value" in totalEthStaked && "value" in ethPrice
48+
const totalStakedInUsd = hasEthStakerAndPriceData
49+
? totalEthStaked.value * ethPrice.value
50+
: 0
51+
52+
const totalValueSecuringFormatted = !totalStakedInUsd
53+
? {
54+
error:
55+
"error" in totalEthStaked
56+
? totalEthStaked.error
57+
: "error" in ethPrice
58+
? ethPrice.error
59+
: "",
60+
}
61+
: {
62+
...totalEthStaked,
63+
value: formatLargeUSD(totalStakedInUsd, localeForNumberFormat),
64+
}
65+
4466
// const totalCapitalSecuredFormatted =
4567
// "error" in totalCapitalSecured
4668
// ? { error: totalCapitalSecured.error }
@@ -65,6 +87,12 @@ export const parseActivity = async (
6587
apiUrl: "https://www.coingecko.com/en/categories/stablecoins",
6688
state: stablecoinMarketCapFormatted,
6789
},
90+
{
91+
label: t("page-enterprise-activity-value-protecting"),
92+
apiProvider: "Dune Analytics",
93+
apiUrl: "https://dune.com/hildobby/eth2-staking",
94+
state: totalValueSecuringFormatted,
95+
},
6896
// {
6997
// // TODO
7098
// label: t("page-enterprise-activity-total-secured"),

src/intl/en/page-enterprise.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"page-enterprise-cases-eib-content": "<strong>Issued a €100M digital bond</strong> on public Ethereum. The project was conducted in cooperation with the Banque de France, Goldman Sachs, Santander and Société Générale.",
99
"page-enterprise-activity-tx-count": "Daily transactions",
1010
"page-enterprise-activity-stablecoin-mktcap": "Stablecoin market cap",
11+
"page-enterprise-activity-value-protecting": "Value protecting Ethereum",
1112
"page-enterprise-activity-total-secured": "Total capital secured",
1213
"page-enterprise-ecosystem-cta": "See use cases",
1314
"page-enterprise-ecosystem-description": "The question is not whether money will become programmable, but how quickly the transition will occur and which platforms will enable it.",

src/lib/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,11 @@ export type AllHomepageActivityData = Record<
574574
MetricReturnData
575575
>
576576

577-
export type EnterpriseActivityMetric = "txCount" | "stablecoinMarketCap"
577+
export type EnterpriseActivityMetric =
578+
| "txCount"
579+
| "stablecoinMarketCap"
580+
| "ethPrice" // Use with `totalEthStaked` to convert ETH to USD
581+
| "totalEthStaked"
578582
// | "totalCapitalSecured"
579583

580584
export type AllEnterpriseActivityData = Record<

0 commit comments

Comments
 (0)