Skip to content

Commit

Permalink
Remove casting
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Apr 24, 2024
1 parent 7e0daae commit db52be3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 4 additions & 8 deletions contracts/FixedRateRewardsSource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contract FixedRateRewardsSource is Governable, Initializable {
/// @param _strategistAddr Address of the Strategist
/// @param _rewardsTarget Address that receives rewards
/// @param _rewardsPerSecond Rate of reward emission
function initialize(address _strategistAddr, address _rewardsTarget, uint256 _rewardsPerSecond)
function initialize(address _strategistAddr, address _rewardsTarget, uint192 _rewardsPerSecond)
external
initializer
{
Expand Down Expand Up @@ -121,20 +121,16 @@ contract FixedRateRewardsSource is Governable, Initializable {

/// @dev Set the rate of reward emission
/// @param _rewardsPerSecond Amount of rewardToken to distribute per second
function setRewardsPerSecond(uint256 _rewardsPerSecond) external onlyGovernorOrStrategist {
function setRewardsPerSecond(uint192 _rewardsPerSecond) external onlyGovernorOrStrategist {
_setRewardsPerSecond(_rewardsPerSecond);
}

/// @dev Set the rate of reward emission
/// @param _rewardsPerSecond Amount of rewardToken to distribute per second
function _setRewardsPerSecond(uint256 _rewardsPerSecond) internal {
if (_rewardsPerSecond > type(uint192).max) {
revert InvalidRewardRate();
}

function _setRewardsPerSecond(uint192 _rewardsPerSecond) internal {
// Update storage
RewardConfig storage _config = rewardConfig;
emit RewardsPerSecondChanged(_rewardsPerSecond, _config.rewardsPerSecond);
_config.rewardsPerSecond = uint192(_rewardsPerSecond);
_config.rewardsPerSecond = _rewardsPerSecond;
}
}
6 changes: 0 additions & 6 deletions tests/staking/FixedRateRewardsSource.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ contract FixedRateRewardsSourceTest is Test {
assertEq(rewards.previewRewards(), 0 ether, "Pending reward mismatch");
}

function testInvalidRewardRate() public {
vm.prank(strategist);
vm.expectRevert(bytes4(keccak256("InvalidRewardRate()")));
rewards.setRewardsPerSecond(type(uint256).max);
}

function testRewardRatePermission() public {
// Should allow Strategist to change
vm.prank(strategist);
Expand Down

0 comments on commit db52be3

Please sign in to comment.