Skip to content

feat(insights): use the label "Yield" instead of "Price" for rates #2390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions apps/insights/src/components/PriceComponentDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { StateType, useData } from "../../hooks/use-data";
import { Cluster, ClusterToName } from "../../services/pyth";
import type { Status } from "../../status";
import { LiveConfidence, LivePrice, LiveComponentValue } from "../LivePrices";
import { PriceName } from "../PriceName";
import { Score } from "../Score";
import { Status as StatusComponent } from "../Status";

Expand All @@ -48,6 +49,7 @@ type Props = {
publisherKey: string;
symbol: string;
displaySymbol: string;
assetClass: string;
feedKey: string;
score: number | undefined;
rank: number | undefined;
Expand All @@ -63,6 +65,7 @@ export const PriceComponentDrawer = ({
onClose,
symbol,
displaySymbol,
assetClass,
feedKey,
score,
rank,
Expand Down Expand Up @@ -135,13 +138,21 @@ export const PriceComponentDrawer = ({
<div className={styles.stats}>
<StatCard
nonInteractive
header="Aggregate Price"
header={
<>
Aggregated <PriceName assetClass={assetClass} />
</>
}
small
stat={<LivePrice feedKey={feedKey} cluster={cluster} />}
/>
<StatCard
nonInteractive
header="Publisher Price"
header={
<>
Publisher <PriceName assetClass={assetClass} />
</>
}
variant="primary"
small
stat={
Expand Down
24 changes: 18 additions & 6 deletions apps/insights/src/components/PriceComponentsCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { EvaluationTime } from "../Explanations";
import { FormattedNumber } from "../FormattedNumber";
import { LivePrice, LiveConfidence, LiveComponentValue } from "../LivePrices";
import { NoResults } from "../NoResults";
import { PriceName } from "../PriceName";
import rootStyles from "../Root/index.module.scss";
import { Score } from "../Score";
import { Status as StatusComponent } from "../Status";
Expand All @@ -45,6 +46,7 @@ type Props<T extends PriceComponent> = {
searchPlaceholder: string;
onPriceComponentAction: (component: T) => void;
toolbarExtra?: ReactNode;
assetClass?: string | undefined;
};

type PriceComponent = {
Expand Down Expand Up @@ -279,6 +281,7 @@ type PriceComponentsCardProps<T extends PriceComponent> = Pick<
| "label"
| "searchPlaceholder"
| "toolbarExtra"
| "assetClass"
> &
(
| { isLoading: true }
Expand Down Expand Up @@ -369,7 +372,10 @@ export const PriceComponentsCardContents = <T extends PriceComponent>({
},
})}
items={[
{ id: "prices", children: "Prices" },
{
id: "prices",
children: <PriceName assetClass={props.assetClass} plural />,
},
{ id: "quality", children: "Quality" },
]}
/>
Expand Down Expand Up @@ -456,8 +462,9 @@ export const PriceComponentsCardContents = <T extends PriceComponent>({

const otherColumns = ({
metricsTime,
assetClass,
...props
}: { metricsTime?: Date | undefined } & (
}: { metricsTime?: Date | undefined; assetClass?: string | undefined } & (
| { isLoading: true }
| { isLoading?: false; showQuality: boolean }
)) => {
Expand Down Expand Up @@ -500,8 +507,8 @@ const otherColumns = ({
DEVIATION SCORE
<Explain size="xs" title="Deviation">
<p>
Deviation measures how close a publisher{"'"}s price is to
what Pyth believes to be the true market price.
Deviation measures how close a publisher{"'"}s quote is to
what Pyth believes to be the true market quote.
</p>
{metricsTime && <EvaluationTime scoreTime={metricsTime} />}
<Button
Expand All @@ -527,7 +534,7 @@ const otherColumns = ({
<Explain size="xs" title="Stalled">
<p>
A feed is considered stalled if it is publishing the same
value repeatedly for the price. This score component is
value repeatedly for the quote. This score component is
reduced each time a feed is stalled.
</p>
{metricsTime && <EvaluationTime scoreTime={metricsTime} />}
Expand Down Expand Up @@ -584,7 +591,12 @@ const otherColumns = ({
]
: [
{ id: "slot", name: "SLOT", alignment: "left" as const, width: 40 },
{ id: "price", name: "PRICE", alignment: "left" as const, width: 40 },
{
id: "price",
name: <PriceName assetClass={assetClass} uppercase />,
alignment: "left" as const,
width: 40,
},
{
id: "confidence",
name: "CONFIDENCE INTERVAL",
Expand Down
13 changes: 11 additions & 2 deletions apps/insights/src/components/PriceFeed/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
PriceFeedChangePercent,
} from "../PriceFeedChangePercent";
import { PriceFeedTag } from "../PriceFeedTag";
import { PriceName } from "../PriceName";
import { TabPanel, TabRoot, Tabs } from "../Tabs";

type Props = {
Expand Down Expand Up @@ -110,7 +111,11 @@ export const PriceFeedLayout = async ({ children, params }: Props) => {
<section className={styles.stats}>
<StatCard
variant="primary"
header="Aggregated Price"
header={
<>
Aggregated <PriceName assetClass={feed.product.asset_type} />
</>
}
stat={
<LivePrice
feedKey={feed.product.price_account}
Expand Down Expand Up @@ -158,7 +163,11 @@ export const PriceFeedLayout = async ({ children, params }: Props) => {
}
/>
<StatCard
header="1-Day Price Change"
header={
<>
1-Day <PriceName assetClass={feed.product.asset_type} /> Change
</>
}
stat={
<YesterdaysPricesProvider
feeds={{ [feed.symbol]: feed.product.price_account }}
Expand Down
4 changes: 4 additions & 0 deletions apps/insights/src/components/PriceFeed/publishers-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Props = Omit<
priceComponents: Publisher[];
symbol: string;
displaySymbol: string;
assetClass: string;
};

export const PublishersCard = ({
Expand All @@ -48,6 +49,7 @@ const ResolvedPublishersCard = ({
priceComponents,
symbol,
displaySymbol,
assetClass,
...props
}: Props) => {
const logger = useLogger();
Expand Down Expand Up @@ -91,6 +93,7 @@ const ResolvedPublishersCard = ({
<ResolvedPriceComponentsCard
onPriceComponentAction={onPriceComponentAction}
priceComponents={componentsFilteredByCluster}
assetClass={assetClass}
toolbarExtra={
<Switch
isSelected={includeTestFeeds}
Expand All @@ -115,6 +118,7 @@ const ResolvedPublishersCard = ({
cluster={selectedPublisher.cluster}
firstEvaluation={selectedPublisher.firstEvaluation ?? new Date()}
navigateHref={`/publishers/${ClusterToName[selectedPublisher.cluster]}/${selectedPublisher.publisherKey}`}
assetClass={assetClass}
identifiesPublisher
/>
)}
Expand Down
1 change: 1 addition & 0 deletions apps/insights/src/components/PriceFeed/publishers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const Publishers = async ({ params }: Props) => {
nameLoadingSkeleton={<PublisherTag isLoading />}
symbol={symbol}
displaySymbol={feed.product.display_symbol}
assetClass={feed.product.asset_type}
priceComponents={publishers.map(
({ ranking, publisher, status, cluster, knownPublisher }) => ({
id: `${publisher}-${ClusterToName[cluster]}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from "../LivePrices";
import { NoResults } from "../NoResults";
import { PriceFeedTag } from "../PriceFeedTag";
import { PriceName } from "../PriceName";
import rootStyles from "../Root/index.module.scss";

type Props = {
Expand Down Expand Up @@ -317,7 +318,7 @@ const PriceFeedsCardContents = ({ id, ...props }: PriceFeedsCardContents) => (
},
{
id: "price",
name: "PRICE",
name: <PriceName uppercase />,
alignment: "right",
width: 40,
loadingSkeletonWidth: SKELETON_WIDTH,
Expand Down
54 changes: 54 additions & 0 deletions apps/insights/src/components/PriceName/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
type Props = {
assetClass?: string | undefined;
uppercase?: boolean | undefined;
plural?: boolean | undefined;
};

export const PriceName = ({ assetClass, uppercase, plural }: Props) =>
getLabels(assetClass)[plural ? "plural" : "singular"][
uppercase ? "upcase" : "title"
];

const getLabels = (assetClass?: string | undefined) => {
if (assetClass === undefined) {
return LABELS.ambiguous;
} else {
const lowercaseAssetClass = assetClass.toLowerCase();
return lowercaseAssetClass in LABELS
? LABELS[lowercaseAssetClass as keyof typeof LABELS]
: LABELS.default;
}
};

const LABELS = {
rates: {
plural: {
upcase: "YIELDS",
title: "Yields",
},
singular: {
upcase: "YIELD",
title: "Yield",
},
},
ambiguous: {
plural: {
upcase: "PRICES / YIELDS",
title: "Prices / Yields",
},
singular: {
upcase: "PRICE / YIELD",
title: "Price / Yield",
},
},
default: {
plural: {
upcase: "PRICES",
title: "Prices",
},
singular: {
upcase: "PRICE",
title: "Price",
},
},
};
1 change: 1 addition & 0 deletions apps/insights/src/components/Publisher/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const PublishersLayout = async ({ children, params }: Props) => {
score: ranking?.final_score,
rank: ranking?.final_rank,
firstEvaluation: ranking?.first_ranking_time,
assetClass: feed.product.asset_type,
status,
}))}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type PriceFeed = {
rank: number | undefined;
status: Status;
firstEvaluation: Date | undefined;
assetClass: string;
};

export const PriceFeedDrawerProvider = (
Expand Down Expand Up @@ -100,6 +101,7 @@ const PriceFeedDrawerProviderImpl = ({
navigateHref={feedHref}
title={<PriceFeedTag symbol={selectedFeed.symbol} />}
cluster={cluster}
assetClass={selectedFeed.assetClass}
/>
)}
</PriceFeedDrawerContext>
Expand Down
Loading