|
| 1 | +import { Button } from "@pythnetwork/component-library/Button"; |
| 2 | +import { useMemo } from "react"; |
| 3 | + |
| 4 | +import { Explain } from "../Explain"; |
| 5 | +import { FormattedDate } from "../FormattedDate"; |
| 6 | + |
| 7 | +export const ExplainAverage = ({ |
| 8 | + scoreTime, |
| 9 | +}: { |
| 10 | + scoreTime?: Date | undefined; |
| 11 | +}) => { |
| 12 | + return ( |
| 13 | + <Explain size="xs" title="Average Feed Score"> |
| 14 | + <p> |
| 15 | + Each <b>Price Feed Component</b> that a <b>Publisher</b> provides has an |
| 16 | + associated <b>Score</b>, which is determined by that component{"'"}s{" "} |
| 17 | + <b>Uptime</b>, <b>Price Deviation</b>, and <b>Staleness</b>. The{" "} |
| 18 | + <b>Average Feed Score</b> is the average of the scores for all{" "} |
| 19 | + <b>Price Feed Components</b>. |
| 20 | + </p> |
| 21 | + {scoreTime && <EvaluationTime scoreTime={scoreTime} />} |
| 22 | + <Button |
| 23 | + size="xs" |
| 24 | + variant="solid" |
| 25 | + href="https://docs.pyth.network/home/oracle-integrity-staking/publisher-quality-ranking" |
| 26 | + target="_blank" |
| 27 | + > |
| 28 | + Learn more |
| 29 | + </Button> |
| 30 | + </Explain> |
| 31 | + ); |
| 32 | +}; |
| 33 | + |
| 34 | +export const EvaluationTime = ({ scoreTime }: { scoreTime: Date }) => { |
| 35 | + const startTime = useMemo(() => { |
| 36 | + const date = new Date(scoreTime); |
| 37 | + date.setDate(date.getDate() - 1); |
| 38 | + return date; |
| 39 | + }, [scoreTime]); |
| 40 | + |
| 41 | + return ( |
| 42 | + <p> |
| 43 | + This value is calculated based on feed performance from{" "} |
| 44 | + <b> |
| 45 | + <FormattedDate |
| 46 | + value={startTime} |
| 47 | + dateStyle="long" |
| 48 | + timeStyle="long" |
| 49 | + timeZone="utc" |
| 50 | + /> |
| 51 | + </b>{" "} |
| 52 | + to{" "} |
| 53 | + <b> |
| 54 | + <FormattedDate |
| 55 | + value={scoreTime} |
| 56 | + dateStyle="long" |
| 57 | + timeStyle="long" |
| 58 | + timeZone="utc" |
| 59 | + /> |
| 60 | + </b> |
| 61 | + . |
| 62 | + </p> |
| 63 | + ); |
| 64 | +}; |
| 65 | + |
| 66 | +export const ExplainActive = () => ( |
| 67 | + <Explain size="xs" title="Active Feeds"> |
| 68 | + <p> |
| 69 | + This is the number of feeds which the publisher is permissioned for, where |
| 70 | + the publisher{"'"}s feed has 50% or better uptime over the last day. |
| 71 | + </p> |
| 72 | + <NeitherActiveNorInactiveNote /> |
| 73 | + </Explain> |
| 74 | +); |
| 75 | + |
| 76 | +export const ExplainInactive = () => ( |
| 77 | + <Explain size="xs" title="Inactive Feeds"> |
| 78 | + <p> |
| 79 | + This is the number of feeds which the publisher is permissioned for, but |
| 80 | + for which the publisher{"'"}s feed has less than 50% uptime over the last |
| 81 | + day. |
| 82 | + </p> |
| 83 | + <NeitherActiveNorInactiveNote /> |
| 84 | + </Explain> |
| 85 | +); |
| 86 | + |
| 87 | +const NeitherActiveNorInactiveNote = () => ( |
| 88 | + <p> |
| 89 | + Note that a publisher{"'"}s feed may not be considered either active or |
| 90 | + inactive if Pyth has not yet calculated quality rankings for it. |
| 91 | + </p> |
| 92 | +); |
0 commit comments