Skip to content

Commit 12fdcef

Browse files
authored
fix: threshold fix (#2258)
1 parent da0d851 commit 12fdcef

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

apps/namadillo/src/App/Masp/ShieldedFungibleTable.tsx

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from "@namada/components";
77
import { sortedTableData } from "App/AccountOverview/common";
88
import { FiatCurrency } from "App/Common/FiatCurrency";
9+
import { IconTooltip } from "App/Common/IconTooltip";
910
import { TableWithPaginator } from "App/Common/TableWithPaginator";
1011
import { TokenCard } from "App/Common/TokenCard";
1112
import { TokenCurrency } from "App/Common/TokenCurrency";
@@ -14,6 +15,7 @@ import { applicationFeaturesAtom } from "atoms/settings/atoms";
1415
import BigNumber from "bignumber.js";
1516
import { useAtomValue } from "jotai";
1617
import { useEffect, useState } from "react";
18+
import { FaExclamation } from "react-icons/fa6";
1719
import { IoSwapHorizontal } from "react-icons/io5";
1820
import { Link, useNavigate } from "react-router-dom";
1921
import { twMerge } from "tailwind-merge";
@@ -23,6 +25,26 @@ import { namadaAsset } from "utils";
2325
const resultsPerPage = 100;
2426
const initialPage = 0;
2527

28+
// Minimum thresholds to earn rewards for each asset
29+
const REWARD_THRESHOLDS: Record<string, BigNumber> = {
30+
statom: new BigNumber(10),
31+
stosmo: new BigNumber(100),
32+
sttia: new BigNumber(20),
33+
osmo: new BigNumber(100),
34+
atom: new BigNumber(10),
35+
tia: new BigNumber(20),
36+
usdc: new BigNumber(50),
37+
};
38+
39+
// Check if amount is below the minimum threshold to earn rewards
40+
const isBelowRewardThreshold = (
41+
assetSymbol: string,
42+
amount: BigNumber
43+
): boolean => {
44+
const threshold = REWARD_THRESHOLDS[assetSymbol.toLowerCase()];
45+
return threshold ? amount.lt(threshold) : false;
46+
};
47+
2648
export const ShieldedFungibleTable = ({
2749
data,
2850
rewards,
@@ -49,7 +71,7 @@ export const ShieldedFungibleTable = ({
4971
dollar,
5072
}: TokenBalance): TableRow => {
5173
const reward = rewards?.[address];
52-
74+
const belowThreshold = isBelowRewardThreshold(asset.symbol, amount);
5375
return {
5476
cells: [
5577
<TokenCard key={`token-${address}`} address={address} asset={asset} />,
@@ -65,15 +87,30 @@ export const ShieldedFungibleTable = ({
6587
/>
6688
)}
6789
</div>,
68-
<div key={`ssr-rate-${address}`} className="text-right leading-tight ">
90+
<div
91+
key={`ssr-rate-${address}`}
92+
className="text-right leading-tight relative"
93+
>
6994
{shieldingRewardsEnabled &&
95+
REWARD_THRESHOLDS[asset.symbol.toLowerCase()] &&
7096
(reward ?
71-
<TokenCurrency
72-
symbol={namadaAsset().symbol}
73-
amount={reward}
74-
className="text-yellow"
75-
decimalPlaces={reward.isZero() ? 0 : 3}
76-
/>
97+
<div className="flex items-center justify-end gap-2">
98+
<TokenCurrency
99+
symbol={namadaAsset().symbol}
100+
amount={reward}
101+
className="text-yellow"
102+
decimalPlaces={reward.isZero() ? 0 : 3}
103+
/>
104+
{belowThreshold && (
105+
<IconTooltip
106+
className="bg-yellow text-black"
107+
icon={<FaExclamation />}
108+
text={`${REWARD_THRESHOLDS[asset.symbol.toLowerCase()]} ${asset.symbol} required to earn rewards`}
109+
tooltipClassName="w-fit px-2 py-1 -mr-2"
110+
tooltipPosition="right"
111+
/>
112+
)}
113+
</div>
77114
: <SkeletonLoading
78115
width="120px"
79116
height="20px"

0 commit comments

Comments
 (0)