diff --git a/config/example.env b/config/example.env index aa9ca0efa..6e3ef8104 100644 --- a/config/example.env +++ b/config/example.env @@ -311,5 +311,4 @@ GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE= GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE= # 1 day GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS=86400000 -MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD= ACTIVATE_GITCOIN_SCORE_CHECK= diff --git a/migration/1733350243725-addGitcoinCapToQfRound.ts b/migration/1733350243725-addGitcoinCapToQfRound.ts new file mode 100644 index 000000000..3dea6dbe6 --- /dev/null +++ b/migration/1733350243725-addGitcoinCapToQfRound.ts @@ -0,0 +1,17 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddGitcoinCapToQfRound1733350243725 implements MigrationInterface { + name = 'AddGitcoinCapToQfRound1733350243725'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "qf_round" ADD "roundUSDCapPerUserPerProjectWithGitcoinScoreOnly" integer`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "qf_round" DROP COLUMN "roundUSDCapPerUserPerProjectWithGitcoinScoreOnly"`, + ); + } +} diff --git a/src/constants/gitcoin.ts b/src/constants/gitcoin.ts index dff805189..35fba33c7 100644 --- a/src/constants/gitcoin.ts +++ b/src/constants/gitcoin.ts @@ -6,6 +6,3 @@ export const GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE = (+config.get('GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE') as number) || 50; export const GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE = (+config.get('GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE') as number) || 15; -export const MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD = - (+config.get('MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD') as number) || - 1000; diff --git a/src/entities/qfRound.ts b/src/entities/qfRound.ts index 91fe30d5b..0360723b2 100644 --- a/src/entities/qfRound.ts +++ b/src/entities/qfRound.ts @@ -135,6 +135,10 @@ export class QfRound extends BaseEntity { @Column({ nullable: true }) roundUSDCapPerUserPerProject?: number; + @Field(() => Int, { nullable: true }) + @Column({ nullable: true }) + roundUSDCapPerUserPerProjectWithGitcoinScoreOnly?: number; + @Field(_type => Boolean) @Column({ default: false }) isBatchMintingExecuted: boolean; diff --git a/src/resolvers/qAccResolver.test.ts b/src/resolvers/qAccResolver.test.ts index ddd3d17e2..27e08ba28 100644 --- a/src/resolvers/qAccResolver.test.ts +++ b/src/resolvers/qAccResolver.test.ts @@ -31,7 +31,6 @@ import { EarlyAccessRound } from '../entities/earlyAccessRound'; import { GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE, GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE, - MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD, } from '../constants/gitcoin'; import { PrivadoAdapter } from '../adapters/privado/privadoAdapter'; @@ -268,6 +267,7 @@ function userCapsTestCases() { endDate: new Date('2001-01-16'), roundUSDCapPerProject: 10000, roundUSDCapPerUserPerProject: 2500, + roundUSDCapPerUserPerProjectWithGitcoinScoreOnly: 1000, tokenPrice: 0.5, }).save(); sinon.useFakeTimers({ @@ -335,7 +335,7 @@ function userCapsTestCases() { ); assert.equal( response.data?.data.userCaps?.gitcoinPassport?.unusedCap, - MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD / + Number(qfRound1.roundUSDCapPerUserPerProjectWithGitcoinScoreOnly) / Number(qfRound1.tokenPrice) - donationAmount, ); @@ -395,7 +395,7 @@ function userCapsTestCases() { ); assert.equal( response.data?.data.userCaps?.gitcoinPassport?.unusedCap, - MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD / + Number(qfRound1.roundUSDCapPerUserPerProjectWithGitcoinScoreOnly) / Number(qfRound1.tokenPrice) - donationAmount, ); diff --git a/src/services/qAccService.ts b/src/services/qAccService.ts index 96910126f..0253711c6 100644 --- a/src/services/qAccService.ts +++ b/src/services/qAccService.ts @@ -13,7 +13,6 @@ import { GITCOIN_PASSPORT_EXPIRATION_PERIOD_MS, GITCOIN_PASSPORT_MIN_VALID_ANALYSIS_SCORE, GITCOIN_PASSPORT_MIN_VALID_SCORER_SCORE, - MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD, } from '../constants/gitcoin'; const getEaProjectRoundRecord = async ({ @@ -237,9 +236,14 @@ const getUserRemainedCapBasedOnGitcoinScore = async ({ if (!activeQfRound?.tokenPrice) { throw new Error('active qf round does not have token price!'); } + if (!activeQfRound?.roundUSDCapPerUserPerProjectWithGitcoinScoreOnly) { + throw new Error( + 'active qf round does not have round USDCapPerUserPerProjectWithGitcoinScoreOnly!', + ); + } return ( - MAX_CONTRIBUTION_WITH_GITCOIN_PASSPORT_ONLY_USD / - activeQfRound?.tokenPrice - + activeQfRound.roundUSDCapPerUserPerProjectWithGitcoinScoreOnly / + activeQfRound.tokenPrice - qfTotalDonationAmount ); };