Skip to content

Commit 859a9de

Browse files
committed
feat: add a threshold above which rewards start accruing for a subgraph
1 parent b9d3c48 commit 859a9de

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

contracts/rewards/RewardsManager.sol

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
2323

2424
uint256 private constant TOKEN_DECIMALS = 1e18;
2525
uint256 private constant MIN_ISSUANCE_RATE = 1e18;
26+
uint256 private constant REWARDS_ACCRUAL_SIGNALLED_THRESHOLD = 100e18;
2627

2728
// -- Events --
2829

@@ -223,11 +224,16 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
223224
{
224225
Subgraph storage subgraph = subgraphs[_subgraphDeploymentID];
225226

226-
uint256 newRewardsPerSignal = getAccRewardsPerSignal().sub(
227-
subgraph.accRewardsPerSignalSnapshot
228-
);
227+
// Get tokens signalled on the subgraph
229228
uint256 subgraphSignalledTokens = curation().getCurationPoolTokens(_subgraphDeploymentID);
230-
uint256 newRewards = newRewardsPerSignal.mul(subgraphSignalledTokens).div(TOKEN_DECIMALS);
229+
230+
// Only accrue rewards if over a threshold
231+
uint256 newRewards = (subgraphSignalledTokens > REWARDS_ACCRUAL_SIGNALLED_THRESHOLD) // Accrue new rewards since last snapshot
232+
? getAccRewardsPerSignal()
233+
.sub(subgraph.accRewardsPerSignalSnapshot)
234+
.mul(subgraphSignalledTokens)
235+
.div(TOKEN_DECIMALS)
236+
: 0;
231237
return subgraph.accRewardsForSubgraph.add(newRewards);
232238
}
233239

0 commit comments

Comments
 (0)