@@ -56,8 +56,14 @@ contract YieldDistributor is IYieldDistributor, Ownable2StepUpgradeable, VotingM
5656 ERC20VotesUpgradeable public BUTTERED_BREAD;
5757 /// @notice The block number before the last yield distribution
5858 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;
6167
6268 /// @custom:oz-upgrades-unsafe-allow constructor
6369 constructor (address _votingStreakMultiplier ) {
@@ -233,14 +239,26 @@ contract YieldDistributor is IYieldDistributor, Ownable2StepUpgradeable, VotingM
233239 _castVote (msg .sender , _points, _currentVotingPower);
234240 }
235241
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+
236253 /**
237254 * @notice Cast votes for the distribution of $BREAD yield with multipliers
238255 * @param _points List of points as integers for each project
239256 * @param _multiplierIndices List of indices of multipliers to use for each project
240257 */
241258 function castVoteWithMultipliers (uint256 [] calldata _points , uint256 [] calldata _multiplierIndices ) public {
242259 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);
244262 _currentVotingPower = multiplier == 0 ? _currentVotingPower : (_currentVotingPower * multiplier) / PRECISION;
245263 if (_currentVotingPower < minRequiredVotingPower) revert BelowMinRequiredVotingPower ();
246264 _castVote (msg .sender , _points, _currentVotingPower);
@@ -410,4 +428,16 @@ contract YieldDistributor is IYieldDistributor, Ownable2StepUpgradeable, VotingM
410428 function setButteredBread (address _butteredBread ) public onlyOwner {
411429 BUTTERED_BREAD = ERC20VotesUpgradeable (_butteredBread);
412430 }
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+ }
413443}
0 commit comments