From 8d3a3b5848b536730123ac8dd80c9ffa70aa2fce Mon Sep 17 00:00:00 2001 From: Davide Silva Date: Wed, 26 Jun 2024 13:26:45 +0100 Subject: [PATCH] fix: bonus --- packages/web-app/app/_lib/queries.tsx | 11 +++++++++++ packages/web-app/app/_ui/my-projects/my-tokens.tsx | 14 +++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/web-app/app/_lib/queries.tsx b/packages/web-app/app/_lib/queries.tsx index 6523e929..c0fb7a84 100644 --- a/packages/web-app/app/_lib/queries.tsx +++ b/packages/web-app/app/_lib/queries.tsx @@ -313,6 +313,17 @@ export const useUserTotalInvestedUsdcCtznd = (address: `0x${string}`) => { return usdcValue; }; +export const useUserAvailableCtznd = (address: `0x${string}`) => { + const { data: ctzndTokensSold } = useReadCtzndSaleUncappedAllocation({ + args: [address], + query: { + staleTime: 0, + }, + }); + + return formatEther(ctzndTokensSold || 0n); +} + export const useCtzndMinContributionUsdc = () => { const { data: min } = useReadCtzndSaleMinContribution(); diff --git a/packages/web-app/app/_ui/my-projects/my-tokens.tsx b/packages/web-app/app/_ui/my-projects/my-tokens.tsx index e6d1ec71..b7562958 100644 --- a/packages/web-app/app/_ui/my-projects/my-tokens.tsx +++ b/packages/web-app/app/_ui/my-projects/my-tokens.tsx @@ -1,11 +1,11 @@ import { - useCtzndRisingTideCap, useCtzndSaleCapStatus, useCtzndSaleStatus, } from '@/app/_lib/hooks'; import { useExtraAllocation, useTotalInvestedUsdcCtznd, + useUserAvailableCtznd, useUserTotalInvestedUsdcCtznd, } from '@/app/_lib/queries'; import { @@ -22,7 +22,6 @@ import { Tooltip } from '../components/tooltip'; const useAvailableToClaim = () => { const { address } = useAccount(); const capStatus = useCtzndSaleCapStatus(); - const cap = useCtzndRisingTideCap(); const { data: availableToClaim } = useReadCtzndSaleAllocation({ args: [address!], query: { @@ -30,12 +29,17 @@ const useAvailableToClaim = () => { staleTime: 0, }, }); + const available = useUserAvailableCtznd(address!); if (capStatus == 'above') { return 'TBD once sale ends'; } - return `${number(Number(formatEther(availableToClaim || 0n)))} CTND`; + if (capStatus == 'below') { + return Number(available); + } + + return Number(availableToClaim); }; export const MyTokens = () => { @@ -57,7 +61,7 @@ export const MyTokens = () => { const extraAllocation = useExtraAllocation(address).data; const bonusAllocation = typeof availableToClaim === 'number' - ? availableToClaim * 1.25 + ? availableToClaim * 0.25 : 'TBD once sale ends'; return ( @@ -93,7 +97,7 @@ export const MyTokens = () => {

CTND Available to Claim

-
{availableToClaim}
+
{`${availableToClaim} CTND`}
{extraAllocation ? (