diff --git a/config/example.env b/config/example.env index 8ca1f1f40..2610c1a28 100644 --- a/config/example.env +++ b/config/example.env @@ -310,5 +310,5 @@ MONGO_DB_REPORT_DB_NAME= GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE= # 1 day GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS=86400000 -MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY= +MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_IN_USD= ACTIVATE_GITCOIN_SCORE_CHECK= diff --git a/src/constants/gitcoin.ts b/src/constants/gitcoin.ts index f4a4ef7e5..34c4cdce5 100644 --- a/src/constants/gitcoin.ts +++ b/src/constants/gitcoin.ts @@ -4,6 +4,7 @@ export const GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS = (+config.get('GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS') as number) || 86400000; // 1 day export const GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE = (+config.get('GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE') as number) || 50; -export const MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY = - (+config.get('MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY') as number) || - 1000; +export const MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_IN_USD = + (+config.get( + 'MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_IN_USD', + ) as number) || 1000; diff --git a/src/services/qAccService.ts b/src/services/qAccService.ts index 65402d4a9..729a63a4d 100644 --- a/src/services/qAccService.ts +++ b/src/services/qAccService.ts @@ -12,7 +12,7 @@ import { updateUserGitcoinAnalysisScore } from './userService'; import { GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS, GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE, - MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY, + MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_IN_USD, } from '../constants/gitcoin'; const getEaProjectRoundRecord = async ({ @@ -226,8 +226,16 @@ const getUserRemainedCapBasedOnGitcoinScore = async ({ projectId, userId: user.id, }); + const activeQfRound = await findActiveQfRound(); const qfTotalDonationAmount = userRecord.qfTotalDonationAmount; - return MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY - qfTotalDonationAmount; + if (!activeQfRound?.tokenPrice) { + throw new Error('active qf round does not have token price!'); + } + return ( + MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_IN_USD / + activeQfRound?.tokenPrice - + qfTotalDonationAmount + ); }; const validDonationAmountBasedOnKYCAndScore = async ({