Skip to content

Commit

Permalink
Fix a bug in converting usd to pol
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Nov 26, 2024
1 parent 312d2ac commit 0fa648d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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=
7 changes: 4 additions & 3 deletions src/constants/gitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
12 changes: 10 additions & 2 deletions src/services/qAccService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ({
Expand Down Expand Up @@ -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 ({
Expand Down

0 comments on commit 0fa648d

Please sign in to comment.