Skip to content

Commit

Permalink
fix: bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSilva committed Jun 26, 2024
1 parent 0374629 commit 8d3a3b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 11 additions & 0 deletions packages/web-app/app/_lib/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
14 changes: 9 additions & 5 deletions packages/web-app/app/_ui/my-projects/my-tokens.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
useCtzndRisingTideCap,
useCtzndSaleCapStatus,
useCtzndSaleStatus,
} from '@/app/_lib/hooks';
import {
useExtraAllocation,
useTotalInvestedUsdcCtznd,
useUserAvailableCtznd,
useUserTotalInvestedUsdcCtznd,
} from '@/app/_lib/queries';
import {
Expand All @@ -22,20 +22,24 @@ import { Tooltip } from '../components/tooltip';
const useAvailableToClaim = () => {
const { address } = useAccount();
const capStatus = useCtzndSaleCapStatus();
const cap = useCtzndRisingTideCap();
const { data: availableToClaim } = useReadCtzndSaleAllocation({
args: [address!],
query: {
enabled: !!address,
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 = () => {
Expand All @@ -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 (
Expand Down Expand Up @@ -93,7 +97,7 @@ export const MyTokens = () => {
</div>
<div className="flex flex-col gap-2">
<h3 className="text-sm text-mono-800">CTND Available to Claim</h3>
<div>{availableToClaim}</div>
<div>{`${availableToClaim} CTND`}</div>
</div>
{extraAllocation ? (
<div className="flex flex-col gap-2">
Expand Down

0 comments on commit 8d3a3b5

Please sign in to comment.