Skip to content

Commit

Permalink
fix: farming rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
damnnou committed Mar 20, 2024
1 parent bf99d70 commit aeaf55e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/components/farming/ActiveFarming/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const ActiveFarming = ({
reward: bonusRewardEarned,
});

const farmingRewards = (rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(4);

const rewardTokenCurrency = useCurrency(farming.farming.rewardToken);
const bonusRewardTokenCurrency = useCurrency(
farming.farming.bonusRewardToken
Expand Down Expand Up @@ -174,12 +176,7 @@ const ActiveFarming = ({
className="w-full"
title="EARNED"
>
<p className="text-cyan-300">
$
{(rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(
4
)}
</p>
<p className="text-cyan-300">${farmingRewards}</p>
</CardInfo>
</div>

Expand Down
2 changes: 2 additions & 0 deletions src/hooks/farming/useRewardEarnedUSD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export function useRewardEarnedUSD({
const { data: nativePrice } = useNativePriceQuery();

return useMemo(() => {
if (!token) return 0;

const formattedRewardEarned = Number(
formatUnits(reward, token?.decimals)
);
Expand Down
6 changes: 5 additions & 1 deletion src/utils/farming/isSameRewards.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { ADDRESS_ZERO } from '@cryptoalgebra/integral-sdk';
import { Address } from 'viem';

export const isSameRewards = (
rewardToken: Address,
bonusRewardToken: Address
): boolean => {
return rewardToken.toLowerCase() === bonusRewardToken.toLowerCase();
return (
rewardToken.toLowerCase() === bonusRewardToken.toLowerCase() ||
bonusRewardToken === ADDRESS_ZERO
);
};

0 comments on commit aeaf55e

Please sign in to comment.