Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/polite-trees-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@venusprotocol/evm": minor
---

add total reward info for reward card
1 change: 1 addition & 0 deletions apps/evm/src/clients/api/__mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ export const getPrimeCurrentCycle = vi.fn(async () => ({
computedAt: new Date('2026-06-17T00:00:00Z'),
primeHolderCount: 500,
totalCurrentCycleUsdMantissa: '462300000000000000000000',
currentEstimatedTotalUsdMantissa: '600000000000000000000000',
byRewardToken: [
{
rewardTokenAddress: usdc.address,
Expand Down
11 changes: 11 additions & 0 deletions apps/evm/src/clients/api/queries/getPrimeCurrentCycle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface PrimePendingRewardPool {
computedAt: Date;
primeHolderCount: number;
totalCurrentCycleUsdMantissa: string;
currentEstimatedTotalUsdMantissa: string;
byRewardToken: PrimePendingRewardTokenTotal[];
}

Expand Down Expand Up @@ -42,6 +43,11 @@ interface PrimePendingRewardTokenTotalResponse {
totalPendingUsdMantissa: string;
totalCurrentCycleUsdCents: string;
totalCurrentCycleUsdMantissa: string;
estimatedAmountMantissa: string;
currentEstimatedUsdCents: string;
currentEstimatedUsdMantissa: string;
cycleStartEstimatedUsdCents: string;
cycleStartEstimatedUsdMantissa: string;
}

interface PrimePendingRewardPoolResponse {
Expand All @@ -53,6 +59,10 @@ interface PrimePendingRewardPoolResponse {
totalPendingUsdMantissa: string;
totalCurrentCycleUsdCents: string;
totalCurrentCycleUsdMantissa: string;
currentEstimatedTotalUsdCents: string;
currentEstimatedTotalUsdMantissa: string;
cycleStartEstimatedTotalUsdCents: string;
cycleStartEstimatedTotalUsdMantissa: string;
byRewardToken: PrimePendingRewardTokenTotalResponse[];
}

Expand Down Expand Up @@ -99,6 +109,7 @@ export const getPrimeCurrentCycle = async ({
computedAt: new Date(payload.pendingPool.computedAt),
primeHolderCount: payload.pendingPool.primeHolderCount,
totalCurrentCycleUsdMantissa: payload.pendingPool.totalCurrentCycleUsdMantissa,
currentEstimatedTotalUsdMantissa: payload.pendingPool.currentEstimatedTotalUsdMantissa,
byRewardToken: payload.pendingPool.byRewardToken.map(token => ({
rewardTokenAddress: token.rewardTokenAddress,
totalCurrentCycleUsdMantissa: token.totalCurrentCycleUsdMantissa,
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "Prime leaderboard",
"totalRewards": {
"title": "Total Prime rewards distributed this cycle"
"title": "Total Prime rewards distributed",
"totalPoolLabel": "of <Highlight>{{amount}}</Highlight> total rewards this cycle"
},
"userRewards": {
"eligibleMessage": "You are currently eligible for sharing the Prime rewards during this cycle. Supply assets below to share the rewards.",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "Prime リーダーボード",
"totalRewards": {
"title": "今サイクルに分配された Prime 報酬の総額"
"title": "分配された Prime 報酬の総額",
"totalPoolLabel": "今サイクルの総報酬 <Highlight>{{amount}}</Highlight> のうち"
},
"userRewards": {
"eligibleMessage": "今サイクルで Prime 報酬を分け合う対象になっています。下記の資産を供給して報酬を獲得しましょう。",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "กระดานผู้นำ Prime",
"totalRewards": {
"title": "รางวัล Prime ทั้งหมดที่แจกในรอบนี้"
"title": "รางวัล Prime ทั้งหมดที่แจก",
"totalPoolLabel": "จากทั้งหมด <Highlight>{{amount}}</Highlight> ในรอบนี้"
},
"userRewards": {
"eligibleMessage": "คุณมีสิทธิ์ร่วมรับรางวัล Prime ในรอบนี้ จัดหาสินทรัพย์ด้านล่างเพื่อรับรางวัล",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "Prime lider tablosu",
"totalRewards": {
"title": "Bu döngüde dağıtılan toplam Prime ödülü"
"title": "Dağıtılan toplam Prime ödülü",
"totalPoolLabel": "bu döngüdeki toplam <Highlight>{{amount}}</Highlight> ödülden"
},
"userRewards": {
"eligibleMessage": "Bu döngüde Prime ödüllerini paylaşmaya uygunsun. Ödülleri paylaşmak için aşağıdan varlık sağla.",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "Bảng xếp hạng Prime",
"totalRewards": {
"title": "Tổng thưởng Prime đã phân phối trong chu kỳ này"
"title": "Tổng thưởng Prime đã phân phối",
"totalPoolLabel": "trên tổng <Highlight>{{amount}}</Highlight> phần thưởng chu kỳ này"
},
"userRewards": {
"eligibleMessage": "Bạn hiện đủ điều kiện chia sẻ phần thưởng Prime trong chu kỳ này. Hãy cung cấp tài sản bên dưới để nhận phần thưởng.",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "Prime 排行榜",
"totalRewards": {
"title": "本周期已分配的 Prime 总奖励"
"title": "已分配的 Prime 总奖励",
"totalPoolLabel": "本周期总奖励 <Highlight>{{amount}}</Highlight>"
},
"userRewards": {
"eligibleMessage": "你在本周期已具备分享 Prime 奖励的资格。在下方供给资产以分享奖励。",
Expand Down
3 changes: 2 additions & 1 deletion apps/evm/src/libs/translations/translations/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@
},
"title": "Prime 排行榜",
"totalRewards": {
"title": "本週期已分配的 Prime 總獎勵"
"title": "已分配的 Prime 總獎勵",
"totalPoolLabel": "本週期總獎勵 <Highlight>{{amount}}</Highlight>"
},
"userRewards": {
"eligibleMessage": "你在本週期已具備分享 Prime 獎勵的資格。在下方供給資產以分享獎勵。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ describe('pages/PrimeLeaderboard/TotalRewardsCard', () => {
renderComponent(
<TotalRewardsCard
totalRewardsCents={46_230_000}
totalEstimatedRewardsCents={60_000_000}
marketRewards={[
{ token: usdc, rewardsCents: 28_040_000 },
{ token: xvs, rewardsCents: 17_190_000 },
]}
/>,
);

expect(screen.getByText('Total Prime rewards distributed this cycle')).toBeInTheDocument();
expect(screen.getByText('Total Prime rewards distributed')).toBeInTheDocument();
expect(screen.getByText('$462.3K')).toBeInTheDocument();
expect(screen.getByText('$600K')).toBeInTheDocument();
expect(screen.getByText('$280.4K')).toBeInTheDocument();
expect(screen.getByText('$171.9K')).toBeInTheDocument();
expect(screen.getByText(usdc.symbol)).toBeInTheDocument();
Expand Down
14 changes: 13 additions & 1 deletion apps/evm/src/pages/PrimeLeaderboard/TotalRewardsCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface MarketReward {

export interface TotalRewardsCardProps {
totalRewardsCents: number;
totalEstimatedRewardsCents: number;
marketRewards: MarketReward[];
title?: React.ReactNode;
isLoading?: boolean;
Expand All @@ -22,12 +23,13 @@ export interface TotalRewardsCardProps {

export const TotalRewardsCard: React.FC<TotalRewardsCardProps> = ({
totalRewardsCents,
totalEstimatedRewardsCents,
marketRewards,
title,
isLoading,
className,
}) => {
const { t } = useTranslation();
const { t, Trans } = useTranslation();

const cardClassName = cn(
'flex flex-col gap-y-3 rounded-lg bg-background-active p-4 min-h-[182px] lg:h-58',
Expand All @@ -52,6 +54,16 @@ export const TotalRewardsCard: React.FC<TotalRewardsCardProps> = ({
<p className="text-h5 text-white">
{formatCentsToReadableValue({ value: totalRewardsCents })}
</p>

{!!totalEstimatedRewardsCents && (
<p className="text-b1r text-light-grey">
<Trans
i18nKey="primeLeaderboard.totalRewards.totalPoolLabel"
components={{ Highlight: <span className="text-white" /> }}
values={{ amount: formatCentsToReadableValue({ value: totalEstimatedRewardsCents }) }}
/>
</p>
)}
Comment on lines +57 to +66

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Zero Total Pool Is Hidden

When the API returns an active pending pool with currentEstimatedTotalUsdMantissa: "0", totalPoolCents is 0 and this truthiness gate suppresses the new denominator text. The card still shows distributed rewards, but users do not see the $0 total rewards context that this change adds.

Context Used: AGENTS.md (source)

</div>

<div className="flex max-h-15 flex-col gap-2 overflow-y-auto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('pages/PrimeLeaderboard/TotalRewardsSection', () => {
it('renders the total Prime rewards from the data hook', async () => {
renderComponent(<TotalRewardsSection />);

expect(
await screen.findByText('Total Prime rewards distributed this cycle'),
).toBeInTheDocument();
expect(await screen.findByText('Total Prime rewards distributed')).toBeInTheDocument();
expect(await screen.findByText('$462.3K')).toBeInTheDocument();
expect(await screen.findByText('$600K')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ export interface TotalRewardsSectionProps {
}

export const TotalRewardsSection: React.FC<TotalRewardsSectionProps> = ({ className }) => {
const { isLoading, totalRewardsCents, marketRewards } = useGetPrimeTotalRewards();
const { isLoading, totalRewardsCents, totalEstimatedRewardsCents, marketRewards } =
useGetPrimeTotalRewards();

return (
<TotalRewardsCard
totalRewardsCents={totalRewardsCents}
totalEstimatedRewardsCents={totalEstimatedRewardsCents}
marketRewards={marketRewards}
isLoading={isLoading}
className={className}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { MarketReward } from '../TotalRewardsCard';
export interface UseGetPrimeTotalRewardsOutput {
isLoading: boolean;
totalRewardsCents: number;
totalEstimatedRewardsCents: number;
marketRewards: MarketReward[];
}

Expand Down Expand Up @@ -41,6 +42,9 @@ export const useGetPrimeTotalRewards = (): UseGetPrimeTotalRewardsOutput => {
totalRewardsCents: pendingPool
? convertUsdMantissaToCents(pendingPool.totalCurrentCycleUsdMantissa).toNumber()
: 0,
totalEstimatedRewardsCents: pendingPool
? convertUsdMantissaToCents(pendingPool.currentEstimatedTotalUsdMantissa).toNumber()
: 0,
marketRewards,
};
};
Loading