diff --git a/src/packages/v2v3/contexts/Project/useV2V3ProjectState.ts b/src/packages/v2v3/contexts/Project/useV2V3ProjectState.ts index d68207e8e1..70a19c2e17 100644 --- a/src/packages/v2v3/contexts/Project/useV2V3ProjectState.ts +++ b/src/packages/v2v3/contexts/Project/useV2V3ProjectState.ts @@ -1,4 +1,5 @@ import { PV_V2 } from 'constants/pv' +import { RomanStormVariables } from 'constants/romanStorm' import { ETH_PAYOUT_SPLIT_GROUP, RESERVED_TOKEN_SPLIT_GROUP, @@ -30,7 +31,6 @@ import { V2V3_CURRENCY_ETH, } from 'packages/v2v3/utils/currency' import { useContext, useMemo } from 'react' -import { RomanStormVariables } from 'constants/romanStorm' import { V2V3ProjectContractsContext } from '../ProjectContracts/V2V3ProjectContractsContext' import { V2V3ProjectContextType } from './V2V3ProjectContext' @@ -113,7 +113,7 @@ export function useV2V3ProjectState({ projectId }: { projectId: number }) { const projectRomanStormStatsData = first(romanStormData?.projects) let totalVolume = projectStatsData?.volume - let paymentsCount = projectStatsData?.paymentsCount + let paymentsCount = projectStatsData?.paymentsCount ?? 0 if (projectId === RomanStormVariables.PROJECT_ID && projectStatsData) { const BIG_ZERO = BigNumber.from(0) @@ -121,7 +121,7 @@ export function useV2V3ProjectState({ projectId }: { projectId: number }) { totalVolume = (totalVolume || BIG_ZERO).sub( projectRomanStormStatsData?.volume || BIG_ZERO, ) - paymentsCount -= projectRomanStormStatsData?.paymentsCount + paymentsCount -= projectRomanStormStatsData?.paymentsCount ?? 0 } const { createdAt, trendingVolume } = projectStatsData ?? {} diff --git a/src/pages/api/projects/trending.ts b/src/pages/api/projects/trending.ts index 945e1aa400..321fde416b 100644 --- a/src/pages/api/projects/trending.ts +++ b/src/pages/api/projects/trending.ts @@ -1,4 +1,6 @@ import { PV_V1, PV_V2 } from 'constants/pv' +import { RomanStormVariables } from 'constants/romanStorm' +import { BigNumber } from 'ethers' import { OrderDirection, Project_OrderBy, @@ -7,12 +9,10 @@ import { TrendingProjectsQuery, } from 'generated/graphql' import { serverClient } from 'lib/apollo/serverClient' -import { BigNumber } from 'ethers' import { NextApiHandler } from 'next' import { V1ArchivedProjectIds } from 'packages/v1/constants/archivedProjects' import { V2ArchivedProjectIds } from 'packages/v2v3/constants/archivedProjects' import { getSubgraphIdForProject } from 'utils/graph' -import { RomanStormVariables } from 'constants/romanStorm' const CACHE_MAXAGE = 60 * 5 // 5 minutes @@ -79,9 +79,9 @@ const handler: NextApiHandler = async (req, res) => { projects[romanProjectIndex] = { ...projects[romanProjectIndex], - volume: BigNumber.from(romanProject.volume) - .sub(romanProjectSnapshot.volume) - .toString() as BigNumber, // Incorrect types are declared + volume: BigNumber.from(romanProject.volume ?? 0).sub( + BigNumber.from(romanProjectSnapshot.volume ?? 0), + ), // Incorrect types are declared paymentsCount: romanProject.paymentsCount - romanProjectSnapshot.paymentsCount, }