Skip to content

Commit

Permalink
handle claimableYield === 0 edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
subject026 committed Nov 2, 2024
1 parent 03772c2 commit d2a4e21
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/governance/components/DistributionOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ export function DistributionOverview({
}, [apyStatus, apyData, totalSupplyStatus, totalSupplyData]);

const estimateTotal = useMemo(() => {
if (cycleDates.status === "SUCCESS" && claimableYield && yieldPerHour) {
if (
cycleDates.status === "SUCCESS" &&
claimableYield !== null &&
yieldPerHour
) {
const difference = differenceInHours(cycleDates.end, new Date());
return difference * yieldPerHour + claimableYield;
}
}, [yieldPerHour, claimableYield, cycleDates]);

useEffect(() => {
let intervalId: NodeJS.Timeout;
if (claimableYield && yieldPerHour) {
if (claimableYield !== null && yieldPerHour) {
intervalId = setInterval(() => {
setYieldIncrement((val) => (val += (yieldPerHour / 60 / 60) * 1.5));
}, 1500);
Expand Down Expand Up @@ -108,7 +112,7 @@ export function DistributionOverview({
Amount to Distribute
</h4>
<div className="pt-4 pb-6 w-full items-center">
{claimableYield ? (
{claimableYield !== null ? (
<div className="w-full flex justify-center tracking-wider text-3xl font-bold text-breadgray-grey100 dark:text-breadgray-ultra-white leading-none">
<div className=" flex gap-2 justify-end">
<div className="mt-1">
Expand Down

0 comments on commit d2a4e21

Please sign in to comment.