Skip to content

Commit fdbc60c

Browse files
committed
feat: make the minimum signal threshold configurable
1 parent 859a9de commit fdbc60c

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

contracts/rewards/IRewardsManager.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ interface IRewardsManager {
1313
uint256 accRewardsPerAllocatedToken;
1414
}
1515

16-
// -- Params --
16+
// -- Config --
1717

1818
function setIssuanceRate(uint256 _issuanceRate) external;
1919

20+
function setMinimumSubgraphSignal(uint256 _minimumSubgraphSignal) external;
21+
2022
// -- Denylist --
2123

2224
function setSubgraphAvailabilityOracle(address _subgraphAvailabilityOracle) external;

contracts/rewards/RewardsManager.sol

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ import "./IRewardsManager.sol";
1818
* total rewards for the Subgraph are split up for each Indexer based on much they have Staked on
1919
* that Subgraph.
2020
*/
21-
contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsManager {
21+
contract RewardsManager is RewardsManagerV2Storage, GraphUpgradeable, IRewardsManager {
2222
using SafeMath for uint256;
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;
2726

2827
// -- Events --
2928

@@ -67,6 +66,8 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
6766
_setIssuanceRate(_issuanceRate);
6867
}
6968

69+
// -- Config --
70+
7071
/**
7172
* @dev Sets the issuance rate.
7273
* The issuance rate is defined as a percentage increase of the total supply per block.
@@ -106,6 +107,24 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
106107
emit ParameterUpdated("subgraphAvailabilityOracle");
107108
}
108109

110+
/**
111+
* @dev Sets the minimum signaled tokens on a subgraph to start accruing rewards.
112+
* @dev Can be set to zero which means that this feature is not being used.
113+
* @param _minimumSubgraphSignal Minimum signaled tokens
114+
*/
115+
function setMinimumSubgraphSignal(uint256 _minimumSubgraphSignal) external override {
116+
// Caller can be the SAO or the governor
117+
require(
118+
msg.sender == address(subgraphAvailabilityOracle) ||
119+
msg.sender == controller.getGovernor(),
120+
"Not authorized"
121+
);
122+
minimumSubgraphSignal = _minimumSubgraphSignal;
123+
emit ParameterUpdated("minimumSubgraphSignal");
124+
}
125+
126+
// -- Denylist --
127+
109128
/**
110129
* @dev Denies to claim rewards for a subgraph.
111130
* NOTE: Can only be called by the subgraph availability oracle
@@ -156,6 +175,8 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
156175
return denylist[_subgraphDeploymentID] > 0;
157176
}
158177

178+
// -- Getters --
179+
159180
/**
160181
* @dev Gets the issuance of rewards per signal since last updated.
161182
*
@@ -228,7 +249,7 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
228249
uint256 subgraphSignalledTokens = curation().getCurationPoolTokens(_subgraphDeploymentID);
229250

230251
// Only accrue rewards if over a threshold
231-
uint256 newRewards = (subgraphSignalledTokens > REWARDS_ACCRUAL_SIGNALLED_THRESHOLD) // Accrue new rewards since last snapshot
252+
uint256 newRewards = (subgraphSignalledTokens > minimumSubgraphSignal) // Accrue new rewards since last snapshot
232253
? getAccRewardsPerSignal()
233254
.sub(subgraph.accRewardsPerSignalSnapshot)
234255
.mul(subgraphSignalledTokens)
@@ -272,6 +293,8 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
272293
);
273294
}
274295

296+
// -- Updates --
297+
275298
/**
276299
* @dev Updates the accumulated rewards per signal and save checkpoint block number.
277300
* Must be called before `issuanceRate` or `total signalled GRT` changes

contracts/rewards/RewardsManagerStorage.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ contract RewardsManagerV1Storage is Managed {
2121
// Subgraph denylist : subgraph deployment ID => block when added or zero (if not denied)
2222
mapping(bytes32 => uint256) public denylist;
2323
}
24+
25+
contract RewardsManagerV2Storage is RewardsManagerV1Storage {
26+
// Minimum amount of signaled tokens on a subgraph required to accrue rewards
27+
uint256 public minimumSubgraphSignal;
28+
}

0 commit comments

Comments
 (0)