Skip to content

Commit

Permalink
feat: emit an event per token on bulkClaims
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Jul 19, 2022
1 parent ad313d6 commit 64f23b0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions contracts/RewardsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ contract RewardsManager is ReentrancyGuard {
event ClaimReward(uint256 epochId, address indexed vault, address indexed token, uint256 amount, address indexed claimer);

// Fired off when using bulk claim functions to save gas
// NOTE: We don't list tokens nor amounts to save gas, see events for that
event BulkClaimReward(uint256 startEpoch, uint256 endEpoch, address indexed vault, address indexed claimer);
event BulkClaimReward(uint256 startEpoch, uint256 endEpoch, address indexed vault, address indexed token, uint256 totalAmount, address indexed claimer);

constructor() {
DEPLOY_TIME = block.timestamp;
Expand Down Expand Up @@ -417,10 +416,11 @@ contract RewardsManager is ReentrancyGuard {
unchecked { ++epochId; }
}

emit BulkClaimReward(epochStart, epochEnd, vault, user);

// Go ahead and transfer
for(uint256 i; i < tokensLength; ){
emit BulkClaimReward(epochStart, epochEnd, vault, tokens[i], amounts[i], user);


IERC20(tokens[i]).safeTransfer(user, amounts[i]);

Expand Down Expand Up @@ -522,11 +522,12 @@ contract RewardsManager is ReentrancyGuard {
// For last epoch, we don't delete the shares, but we delete the points
delete points[epochEnd][vault][user];

emit BulkClaimReward(epochStart, epochEnd, vault, user);

// Go ahead and transfer
for(uint256 i; i < tokensLength; ){
emit BulkClaimReward(epochStart, epochEnd, vault, tokens[i], amounts[i], user);

IERC20(tokens[i]).safeTransfer(user, amounts[i]);

unchecked { ++i; }
}
}
Expand Down Expand Up @@ -1165,10 +1166,11 @@ contract RewardsManager is ReentrancyGuard {
// Go ahead and transfer
{

emit BulkClaimReward(params.epochStart, params.epochEnd, params.vault, user);

for(uint256 i; i < tokensLength; ){
emit BulkClaimReward(params.epochStart, params.epochEnd, params.vault, params.tokens[i], amounts[i], user);

IERC20(params.tokens[i]).safeTransfer(user, amounts[i]);

unchecked { ++i; }
}
}
Expand Down Expand Up @@ -1270,10 +1272,11 @@ contract RewardsManager is ReentrancyGuard {
// Go ahead and transfer
{

emit BulkClaimReward(params.epochStart, params.epochEnd, params.vault, user);

for(uint256 i; i < tokensLength; ){
emit BulkClaimReward(params.epochStart, params.epochEnd, params.vault, params.tokens[i], amounts[i], user);

IERC20(params.tokens[i]).safeTransfer(user, amounts[i]);

unchecked { ++i; }
}
}
Expand Down

0 comments on commit 64f23b0

Please sign in to comment.