Skip to content

Commit cb139f3

Browse files
committed
feat(insights): use the label "Yield" instead of "Price" for rates
1 parent c4461ef commit cb139f3

File tree

9 files changed

+106
-11
lines changed

9 files changed

+106
-11
lines changed

apps/insights/src/components/PriceComponentDrawer/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { StateType, useData } from "../../hooks/use-data";
3131
import { Cluster, ClusterToName } from "../../services/pyth";
3232
import type { Status } from "../../status";
3333
import { LiveConfidence, LivePrice, LiveComponentValue } from "../LivePrices";
34+
import { PriceName } from "../PriceName";
3435
import { Score } from "../Score";
3536
import { Status as StatusComponent } from "../Status";
3637

@@ -48,6 +49,7 @@ type Props = {
4849
publisherKey: string;
4950
symbol: string;
5051
displaySymbol: string;
52+
assetClass: string;
5153
feedKey: string;
5254
score: number | undefined;
5355
rank: number | undefined;
@@ -63,6 +65,7 @@ export const PriceComponentDrawer = ({
6365
onClose,
6466
symbol,
6567
displaySymbol,
68+
assetClass,
6669
feedKey,
6770
score,
6871
rank,
@@ -135,13 +138,21 @@ export const PriceComponentDrawer = ({
135138
<div className={styles.stats}>
136139
<StatCard
137140
nonInteractive
138-
header="Aggregate Price"
141+
header={
142+
<>
143+
Aggregated <PriceName assetClass={assetClass} />
144+
</>
145+
}
139146
small
140147
stat={<LivePrice feedKey={feedKey} cluster={cluster} />}
141148
/>
142149
<StatCard
143150
nonInteractive
144-
header="Publisher Price"
151+
header={
152+
<>
153+
Publisher <PriceName assetClass={assetClass} />
154+
</>
155+
}
145156
variant="primary"
146157
small
147158
stat={

apps/insights/src/components/PriceComponentsCard/index.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { EvaluationTime } from "../Explanations";
3030
import { FormattedNumber } from "../FormattedNumber";
3131
import { LivePrice, LiveConfidence, LiveComponentValue } from "../LivePrices";
3232
import { NoResults } from "../NoResults";
33+
import { PriceName } from "../PriceName";
3334
import rootStyles from "../Root/index.module.scss";
3435
import { Score } from "../Score";
3536
import { Status as StatusComponent } from "../Status";
@@ -45,6 +46,7 @@ type Props<T extends PriceComponent> = {
4546
searchPlaceholder: string;
4647
onPriceComponentAction: (component: T) => void;
4748
toolbarExtra?: ReactNode;
49+
assetClass?: string | undefined;
4850
};
4951

5052
type PriceComponent = {
@@ -279,6 +281,7 @@ type PriceComponentsCardProps<T extends PriceComponent> = Pick<
279281
| "label"
280282
| "searchPlaceholder"
281283
| "toolbarExtra"
284+
| "assetClass"
282285
> &
283286
(
284287
| { isLoading: true }
@@ -369,7 +372,10 @@ export const PriceComponentsCardContents = <T extends PriceComponent>({
369372
},
370373
})}
371374
items={[
372-
{ id: "prices", children: "Prices" },
375+
{
376+
id: "prices",
377+
children: <PriceName assetClass={props.assetClass} plural />,
378+
},
373379
{ id: "quality", children: "Quality" },
374380
]}
375381
/>
@@ -456,8 +462,9 @@ export const PriceComponentsCardContents = <T extends PriceComponent>({
456462

457463
const otherColumns = ({
458464
metricsTime,
465+
assetClass,
459466
...props
460-
}: { metricsTime?: Date | undefined } & (
467+
}: { metricsTime?: Date | undefined; assetClass?: string | undefined } & (
461468
| { isLoading: true }
462469
| { isLoading?: false; showQuality: boolean }
463470
)) => {
@@ -500,8 +507,8 @@ const otherColumns = ({
500507
DEVIATION SCORE
501508
<Explain size="xs" title="Deviation">
502509
<p>
503-
Deviation measures how close a publisher{"'"}s price is to
504-
what Pyth believes to be the true market price.
510+
Deviation measures how close a publisher{"'"}s quote is to
511+
what Pyth believes to be the true market quote.
505512
</p>
506513
{metricsTime && <EvaluationTime scoreTime={metricsTime} />}
507514
<Button
@@ -527,7 +534,7 @@ const otherColumns = ({
527534
<Explain size="xs" title="Stalled">
528535
<p>
529536
A feed is considered stalled if it is publishing the same
530-
value repeatedly for the price. This score component is
537+
value repeatedly for the quote. This score component is
531538
reduced each time a feed is stalled.
532539
</p>
533540
{metricsTime && <EvaluationTime scoreTime={metricsTime} />}
@@ -584,7 +591,12 @@ const otherColumns = ({
584591
]
585592
: [
586593
{ id: "slot", name: "SLOT", alignment: "left" as const, width: 40 },
587-
{ id: "price", name: "PRICE", alignment: "left" as const, width: 40 },
594+
{
595+
id: "price",
596+
name: <PriceName assetClass={assetClass} uppercase />,
597+
alignment: "left" as const,
598+
width: 40,
599+
},
588600
{
589601
id: "confidence",
590602
name: "CONFIDENCE INTERVAL",

apps/insights/src/components/PriceFeed/layout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
PriceFeedChangePercent,
2727
} from "../PriceFeedChangePercent";
2828
import { PriceFeedTag } from "../PriceFeedTag";
29+
import { PriceName } from "../PriceName";
2930
import { TabPanel, TabRoot, Tabs } from "../Tabs";
3031

3132
type Props = {
@@ -110,7 +111,11 @@ export const PriceFeedLayout = async ({ children, params }: Props) => {
110111
<section className={styles.stats}>
111112
<StatCard
112113
variant="primary"
113-
header="Aggregated Price"
114+
header={
115+
<>
116+
Aggregated <PriceName assetClass={feed.product.asset_type} />
117+
</>
118+
}
114119
stat={
115120
<LivePrice
116121
feedKey={feed.product.price_account}
@@ -158,7 +163,11 @@ export const PriceFeedLayout = async ({ children, params }: Props) => {
158163
}
159164
/>
160165
<StatCard
161-
header="1-Day Price Change"
166+
header={
167+
<>
168+
1-Day <PriceName assetClass={feed.product.asset_type} /> Change
169+
</>
170+
}
162171
stat={
163172
<YesterdaysPricesProvider
164173
feeds={{ [feed.symbol]: feed.product.price_account }}

apps/insights/src/components/PriceFeed/publishers-card.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = Omit<
2626
priceComponents: Publisher[];
2727
symbol: string;
2828
displaySymbol: string;
29+
assetClass: string;
2930
};
3031

3132
export const PublishersCard = ({
@@ -48,6 +49,7 @@ const ResolvedPublishersCard = ({
4849
priceComponents,
4950
symbol,
5051
displaySymbol,
52+
assetClass,
5153
...props
5254
}: Props) => {
5355
const logger = useLogger();
@@ -91,6 +93,7 @@ const ResolvedPublishersCard = ({
9193
<ResolvedPriceComponentsCard
9294
onPriceComponentAction={onPriceComponentAction}
9395
priceComponents={componentsFilteredByCluster}
96+
assetClass={assetClass}
9497
toolbarExtra={
9598
<Switch
9699
isSelected={includeTestFeeds}
@@ -115,6 +118,7 @@ const ResolvedPublishersCard = ({
115118
cluster={selectedPublisher.cluster}
116119
firstEvaluation={selectedPublisher.firstEvaluation ?? new Date()}
117120
navigateHref={`/publishers/${ClusterToName[selectedPublisher.cluster]}/${selectedPublisher.publisherKey}`}
121+
assetClass={assetClass}
118122
identifiesPublisher
119123
/>
120124
)}

apps/insights/src/components/PriceFeed/publishers.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const Publishers = async ({ params }: Props) => {
5252
nameLoadingSkeleton={<PublisherTag isLoading />}
5353
symbol={symbol}
5454
displaySymbol={feed.product.display_symbol}
55+
assetClass={feed.product.asset_type}
5556
priceComponents={publishers.map(
5657
({ ranking, publisher, status, cluster, knownPublisher }) => ({
5758
id: `${publisher}-${ClusterToName[cluster]}`,

apps/insights/src/components/PriceFeeds/price-feeds-card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from "../LivePrices";
3030
import { NoResults } from "../NoResults";
3131
import { PriceFeedTag } from "../PriceFeedTag";
32+
import { PriceName } from "../PriceName";
3233
import rootStyles from "../Root/index.module.scss";
3334

3435
type Props = {
@@ -317,7 +318,7 @@ const PriceFeedsCardContents = ({ id, ...props }: PriceFeedsCardContents) => (
317318
},
318319
{
319320
id: "price",
320-
name: "PRICE",
321+
name: <PriceName uppercase />,
321322
alignment: "right",
322323
width: 40,
323324
loadingSkeletonWidth: SKELETON_WIDTH,
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
type Props = {
2+
assetClass?: string | undefined;
3+
uppercase?: boolean | undefined;
4+
plural?: boolean | undefined;
5+
};
6+
7+
export const PriceName = ({ assetClass, uppercase, plural }: Props) =>
8+
getLabels(assetClass)[plural ? "plural" : "singular"][
9+
uppercase ? "upcase" : "title"
10+
];
11+
12+
const getLabels = (assetClass?: string | undefined) => {
13+
if (assetClass === undefined) {
14+
return LABELS.ambiguous;
15+
} else {
16+
const lowercaseAssetClass = assetClass.toLowerCase();
17+
return lowercaseAssetClass in LABELS
18+
? LABELS[lowercaseAssetClass as keyof typeof LABELS]
19+
: LABELS.default;
20+
}
21+
};
22+
23+
const LABELS = {
24+
rates: {
25+
plural: {
26+
upcase: "YIELDS",
27+
title: "Yields",
28+
},
29+
singular: {
30+
upcase: "YIELD",
31+
title: "Yield",
32+
},
33+
},
34+
ambiguous: {
35+
plural: {
36+
upcase: "PRICES / YIELDS",
37+
title: "Prices / Yields",
38+
},
39+
singular: {
40+
upcase: "PRICE / YIELD",
41+
title: "Price / Yield",
42+
},
43+
},
44+
default: {
45+
plural: {
46+
upcase: "PRICES",
47+
title: "Prices",
48+
},
49+
singular: {
50+
upcase: "PRICE",
51+
title: "Price",
52+
},
53+
},
54+
};

apps/insights/src/components/Publisher/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export const PublishersLayout = async ({ children, params }: Props) => {
9797
score: ranking?.final_score,
9898
rank: ranking?.final_rank,
9999
firstEvaluation: ranking?.first_ranking_time,
100+
assetClass: feed.product.asset_type,
100101
status,
101102
}))}
102103
>

apps/insights/src/components/Publisher/price-feed-drawer-provider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type PriceFeed = {
4040
rank: number | undefined;
4141
status: Status;
4242
firstEvaluation: Date | undefined;
43+
assetClass: string;
4344
};
4445

4546
export const PriceFeedDrawerProvider = (
@@ -100,6 +101,7 @@ const PriceFeedDrawerProviderImpl = ({
100101
navigateHref={feedHref}
101102
title={<PriceFeedTag symbol={selectedFeed.symbol} />}
102103
cluster={cluster}
104+
assetClass={selectedFeed.assetClass}
103105
/>
104106
)}
105107
</PriceFeedDrawerContext>

0 commit comments

Comments
 (0)