Skip to content

Commit

Permalink
Skip claiming on zero rewards instead of reverting
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatmittal committed May 7, 2024
1 parent 533e94d commit 8286472
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion contracts/rewards/GenericMultiRewardsVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract GenericMultiRewardsVault is ERC4626, Ownable {
uint256 rewardAmount = accruedRewards[user][_rewardTokens[i]];

if (rewardAmount == 0) {
revert Errors.ZeroRewards(_rewardTokens[i]);
continue;
}

accruedRewards[user][_rewardTokens[i]] = 0;
Expand Down
3 changes: 0 additions & 3 deletions contracts/rewards/definitions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ struct RewardInfo {
}

abstract contract Errors {
// Reward Claiming
error ZeroRewards(IERC20 rewardToken);

// Reward Management
error RewardTokenAlreadyExist(IERC20 rewardToken);
error RewardTokenDoesNotExist(IERC20 rewardToken);
Expand Down
14 changes: 0 additions & 14 deletions test/GenericMultiRewardsVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -854,18 +854,4 @@ contract GenericMultiRewardsVaultTest is Test {
assertEq(staking.accruedRewards(alice, iRewardToken1), 0);
assertEq(rewardToken1.balanceOf(alice), 5 ether);
}

function testFail__claim_non_existent_rewardsToken() public {
IERC20[] memory rewardsTokenKeys = new IERC20[](1);

vm.prank(alice);
staking.claimRewards(alice, rewardsTokenKeys);
}

function testFail__claim_non_existent_reward() public {
IERC20[] memory rewardsTokenKeys = new IERC20[](1);

vm.prank(alice);
staking.claimRewards(alice, rewardsTokenKeys);
}
}

0 comments on commit 8286472

Please sign in to comment.