import { ArrowSquareOut } from "@phosphor-icons/react/dist/ssr/ArrowSquareOut"; import { ClockCountdown } from "@phosphor-icons/react/dist/ssr/ClockCountdown"; import { Button } from "@pythnetwork/component-library/Button"; import { Card } from "@pythnetwork/component-library/Card"; import { StatCard } from "@pythnetwork/component-library/StatCard"; import { lookup as lookupPublisher } from "@pythnetwork/known-publishers"; import styles from "./index.module.scss"; import { PublishersCard } from "./publishers-card"; import { getPublishers } from "../../services/clickhouse"; import { getPublisherCaps } from "../../services/hermes"; import { getDelState, getClaimableRewards, getDistributedRewards, } from "../../services/staking"; import { ExplainAverage } from "../Explanations"; import { FormattedDate } from "../FormattedDate"; import { FormattedTokens } from "../FormattedTokens"; import { PublisherIcon } from "../PublisherIcon"; import { SemicircleMeter, Label } from "../SemicircleMeter"; import { TokenIcon } from "../TokenIcon"; const INITIAL_REWARD_POOL_SIZE = 60_000_000_000_000n; export const Publishers = async () => { const [publishers, oisStats] = await Promise.all([ getPublishers(), getOisStats(), ]); const rankingTime = publishers[0]?.timestamp; const scoreTime = publishers[0]?.scoreTime; return (

Publishers

{rankingTime && (
Rankings last updated{" "}
)}
} stat={( publishers.reduce( (sum, publisher) => sum + publisher.averageScore, 0, ) / publishers.length ).toFixed(2)} /> Staking App } >

/{" "}

} /> } />
} publishers={publishers.map( ({ key, rank, inactiveFeeds, activeFeeds, averageScore }) => { const knownPublisher = lookupPublisher(key); return { id: key, ranking: rank, activeFeeds: activeFeeds, inactiveFeeds: inactiveFeeds, averageScore, ...(knownPublisher && { name: knownPublisher.name, icon: , }), }; }, )} />
); }; const getOisStats = async () => { const [delState, claimableRewards, distributedRewards, publisherCaps] = await Promise.all([ getDelState(), getClaimableRewards(), getDistributedRewards(), getPublisherCaps(), ]); return { totalStaked: sumDelegations(delState.delState) + sumDelegations(delState.selfDelState), rewardsDistributed: claimableRewards + INITIAL_REWARD_POOL_SIZE - distributedRewards, maxPoolSize: publisherCaps.parsed?.[0]?.publisher_stake_caps .map(({ cap }) => cap) .reduce((acc, value) => acc + value), }; }; const sumDelegations = ( values: { totalDelegation: bigint; deltaDelegation: bigint }[], ) => values.reduce( (acc, value) => acc + value.totalDelegation + value.deltaDelegation, 0n, );