From 64034c0ddb4c369ddc9f55013aacaa4ba80fc749 Mon Sep 17 00:00:00 2001 From: MananTank Date: Tue, 30 Sep 2025 22:37:28 +0000 Subject: [PATCH] Dashboard: Fix Token Rewards UI not accounting for token decimals (#8164) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on enhancing the handling of token rewards by adding `decimals` properties for tokens in various components and improving the retrieval of metadata related to tokens. ### Detailed summary - Added `decimals` property to `token0` and `token1` in `claim-rewards-page.stories.tsx`. - Introduced `chainMetadata` in `page.tsx`. - Updated `ClaimRewardsPageUI` to utilize `decimals` for token amounts. - Refactored `getUnclaimedFees` to fetch `decimals` and `symbol` for tokens. - Improved token contract retrieval logic in `getUnclaimedFees`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit - New Features - Token amounts now display using each token’s specific decimals. - Chain metadata is passed to unclaimed-fees retrieval to source native token symbol and decimals. - Bug Fixes - Removed hardcoded 18-decimal assumption so amounts render correctly for tokens with different precisions. - Tests - Story/test stubs updated to include decimals for token objects for more realistic scenarios. --- .../components/claim-rewards-page.stories.tsx | 2 + .../rewards/components/claim-rewards-page.tsx | 8 ++- .../[contractAddress]/rewards/page.tsx | 2 + .../rewards/utils/unclaimed-fees.ts | 64 ++++++++++++++----- 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.stories.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.stories.tsx index 529d53ec22a..abb5ea7cdbb 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.stories.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.stories.tsx @@ -30,11 +30,13 @@ function unclaimedFeesStub(token0Amount: bigint, token1Amount: bigint) { address: "0x1234567890123456789012345678901234567890", amount: token0Amount, symbol: "FOO", + decimals: 18, }, token1: { address: "0x0987654321098765432109876543210987654321", amount: token1Amount, symbol: "BAR", + decimals: 18, }, }; } diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.tsx index 679dd2a4f87..24c5794a4f9 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/rewards/components/claim-rewards-page.tsx @@ -29,11 +29,13 @@ export function ClaimRewardsPage(props: { address: string; amount: bigint; symbol: string; + decimals: number; }; token1: { address: string; amount: bigint; symbol: string; + decimals: number; }; }; chainSlug: string; @@ -98,11 +100,13 @@ export function ClaimRewardsPageUI(props: { address: string; amount: bigint; symbol: string; + decimals: number; }; token1: { address: string; amount: bigint; symbol: string; + decimals: number; }; }; recipient: string; @@ -275,6 +279,7 @@ function TokenReward(props: { address: string; amount: bigint; symbol: string; + decimals: number; }; client: ThirdwebClient; chain: Chain; @@ -303,7 +308,8 @@ function TokenReward(props: {

- {toTokens(props.token.amount, 18)} {props.token.symbol} + {toTokens(props.token.amount, props.token.decimals)}{" "} + {props.token.symbol}