Skip to content

Commit 545ec42

Browse files
authored
Merge pull request #132 from ajna-finance/get-dr
return 0 for getDelegateRewards if voter didn't vote in the screening stage
2 parents d31162f + 232e817 commit 545ec42

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ build :; forge clean && forge build --optimize --optimizer-runs 1000000
1717
# Tests
1818
tests :; forge clean && forge test --mt test --optimize --optimizer-runs 1000000 -v # --ffi # enable if you need the `ffi` cheat code on HEVM
1919
test-with-gas-report :; forge clean && forge build && forge test --mt test --optimize --optimizer-runs 1000000 -v --gas-report # --ffi # enable if you need the `ffi` cheat code on HEVM
20+
test-unit :; forge clean && forge test --no-match-test invariant --optimize --optimizer-runs 1000000 -v # --ffi # enable if you need the `ffi` cheat code on HEVM
2021
test-invariant :; ./test/invariants/test-invariant.sh ${SCENARIO} ${NUM_ACTORS} ${NUM_PROPOSALS} ${PER_ADDRESS_TOKEN_REQ_CAP}
2122
test-invariant-all :; forge clean && forge t --mt invariant
2223
test-invariant-multiple-distribution :; forge clean && ./test/invariants/test-invariant.sh MultipleDistribution 2 25 200

src/grants/GrantFund.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,8 @@ contract GrantFund is IGrantFund, Storage, ReentrancyGuard {
10991099
DistributionPeriod storage currentDistribution = _distributions[distributionId_];
11001100
VoterInfo storage voter = _voterInfo[distributionId_][voter_];
11011101

1102+
if (voter.screeningVotesCast == 0) return 0;
1103+
11021104
rewards_ = _getDelegateReward(currentDistribution, voter);
11031105
}
11041106

test/unit/StandardFunding.t.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,10 @@ contract StandardFundingGrantFundTest is GrantFundTestHelper {
12731273
/******************************/
12741274

12751275
// Claim delegate reward for all delegatees
1276+
// delegates who didn't vote in the screening stage have zero rewards
1277+
delegateRewards = _grantFund.getDelegateReward(distributionId, _tokenHolder11);
1278+
assertEq(delegateRewards, 0);
1279+
12761280
// delegates who didn't vote with their full power receive fewer rewards
12771281
delegateRewards = _grantFund.getDelegateReward(distributionId, _tokenHolder1);
12781282
assertEq(delegateRewards, 327_029.344384908148174595 * 1e18);

0 commit comments

Comments
 (0)