@@ -56,8 +56,14 @@ contract YieldDistributor is IYieldDistributor, Ownable2StepUpgradeable, VotingM
56
56
ERC20VotesUpgradeable public BUTTERED_BREAD;
57
57
/// @notice The block number before the last yield distribution
58
58
uint256 public previousCycleStartingBlock;
59
- /// @notice The interface for the `VotingStreakMultiplier` contract
60
- IVotingStreakMultiplier public votingStreakMultiplier;
59
+ /// @notice Mapping of user addresses to their current multiplier factor
60
+ mapping (address => uint256 ) public userToMultiplier;
61
+ /// @notice Mapping of user addresses to their multiplier validity period
62
+ mapping (address => uint256 ) public userToValidity;
63
+ /// @notice The maximum multiplier incrementation
64
+ uint256 public maxVotingStreakMultiplier;
65
+ /// @notice The increment value for the multiplier
66
+ uint256 public votingStreakMultiplierIncrement;
61
67
62
68
/// @custom:oz-upgrades-unsafe-allow constructor
63
69
constructor (address _votingStreakMultiplier ) {
@@ -233,14 +239,26 @@ contract YieldDistributor is IYieldDistributor, Ownable2StepUpgradeable, VotingM
233
239
_castVote (msg .sender , _points, _currentVotingPower);
234
240
}
235
241
242
+ /// @notice Calculate and return the voting streak multiplier for a user
243
+ /// @param _account Address of the user to calculate the multiplier for
244
+ /// @return uint256 The calculated voting streak multiplier
245
+ function votingStreakMultiplier (address _account ) public view returns (uint256 ) {
246
+ uint256 validity = userToValidity[_account];
247
+ if (block .number > validity) {
248
+ return 0 ; // No active multiplier
249
+ }
250
+ return userToMultiplier[_account]; // Return the current multiplier
251
+ }
252
+
236
253
/**
237
254
* @notice Cast votes for the distribution of $BREAD yield with multipliers
238
255
* @param _points List of points as integers for each project
239
256
* @param _multiplierIndices List of indices of multipliers to use for each project
240
257
*/
241
258
function castVoteWithMultipliers (uint256 [] calldata _points , uint256 [] calldata _multiplierIndices ) public {
242
259
uint256 _currentVotingPower = getCurrentVotingPower (msg .sender );
243
- uint256 multiplier = getTotalMultipliers (msg .sender , _multiplierIndices);
260
+ uint256 baseMultiplier = votingStreakMultiplier (msg .sender );
261
+ uint256 multiplier = getTotalMultipliers (msg .sender , baseMultiplier, _multiplierIndices);
244
262
_currentVotingPower = multiplier == 0 ? _currentVotingPower : (_currentVotingPower * multiplier) / PRECISION;
245
263
if (_currentVotingPower < minRequiredVotingPower) revert BelowMinRequiredVotingPower ();
246
264
_castVote (msg .sender , _points, _currentVotingPower);
@@ -410,4 +428,16 @@ contract YieldDistributor is IYieldDistributor, Ownable2StepUpgradeable, VotingM
410
428
function setButteredBread (address _butteredBread ) public onlyOwner {
411
429
BUTTERED_BREAD = ERC20VotesUpgradeable (_butteredBread);
412
430
}
431
+
432
+ /// @notice Sets the multiplier increment value
433
+ /// @param _multiplierIncrement The new multiplier increment value
434
+ function setVotingStreakMultiplierIncrement (uint256 _votingStreakMultiplierIncrement ) external onlyOwner {
435
+ votingStreakMultiplierIncrement = _votingStreakMultiplierIncrement;
436
+ }
437
+
438
+ /// @notice Sets the maximum multiplier value
439
+ /// @param _maxMultiplier The new maximum multiplier value
440
+ function setMaxVotingStreakMultiplier (uint256 _maxVotingStreakMultiplier ) external onlyOwner {
441
+ maxVotingStreakMultiplier = _maxVotingStreakMultiplier;
442
+ }
413
443
}
0 commit comments