Skip to content

Commit

Permalink
emit more data in PromotionCreated event
Browse files Browse the repository at this point in the history
  • Loading branch information
trmid committed Nov 21, 2023
1 parent 8bb759e commit c9ed00c
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
24 changes: 22 additions & 2 deletions src/TwabRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,20 @@ contract TwabRewards is ITwabRewards, Multicall {
* @param promotionId Id of the newly created promotion
* @param vault The address of the vault that the promotion applies to
* @param token The token that will be rewarded from the promotion
* @param startTimestamp The timestamp at which the promotion starts
* @param tokensPerEpoch The number of tokens emitted per epoch
* @param epochDuration The duration of epoch in seconds
* @param initialNumberOfEpochs The initial number of epochs the promotion is set to run for
*/
event PromotionCreated(uint256 indexed promotionId, address indexed vault, IERC20 indexed token);
event PromotionCreated(
uint256 indexed promotionId,
address indexed vault,
IERC20 indexed token,
uint64 startTimestamp,
uint256 tokensPerEpoch,
uint48 epochDuration,
uint8 initialNumberOfEpochs
);

/**
* @notice Emitted when a promotion is ended.
Expand Down Expand Up @@ -222,7 +234,15 @@ contract TwabRewards is ITwabRewards, Multicall {
if (_afterBalance < _beforeBalance + _amount)
revert TokensReceivedLessThanExpected(_afterBalance - _beforeBalance, _amount);

emit PromotionCreated(_nextPromotionId, _vault, _token);
emit PromotionCreated(
_nextPromotionId,
_vault,
_token,
_startTimestamp,
_tokensPerEpoch,
_epochDuration,
_numberOfEpochs
);

return _nextPromotionId;
}
Expand Down
20 changes: 18 additions & 2 deletions test/TwabRewards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ contract TwabRewardsTest is Test {

/* ============ Events ============ */

event PromotionCreated(uint256 indexed promotionId, address indexed vault, IERC20 indexed token);
event PromotionCreated(
uint256 indexed promotionId,
address indexed vault,
IERC20 indexed token,
uint64 startTimestamp,
uint256 tokensPerEpoch,
uint48 epochDuration,
uint8 initialNumberOfEpochs
);
event PromotionEnded(uint256 indexed promotionId, address indexed recipient, uint256 amount, uint8 epochNumber);
event PromotionDestroyed(uint256 indexed promotionId, address indexed recipient, uint256 amount);
event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);
Expand Down Expand Up @@ -101,7 +109,15 @@ contract TwabRewardsTest is Test {
uint64 _startTimestamp = 1 days;
uint256 _promotionId = 2;
vm.expectEmit();
emit PromotionCreated(_promotionId, vaultAddress, IERC20(mockToken));
emit PromotionCreated(
_promotionId,
vaultAddress,
IERC20(mockToken),
_startTimestamp,
tokensPerEpoch,
epochDuration,
numberOfEpochs
);
twabRewards.createPromotion(
vaultAddress,
mockToken,
Expand Down
30 changes: 27 additions & 3 deletions test/fork/TwabRewardsFork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ contract TwabRewardsForkTest is Test {

/* ============ Events ============ */

event PromotionCreated(uint256 indexed promotionId, address indexed vault, IERC20 indexed token);
event PromotionCreated(
uint256 indexed promotionId,
address indexed vault,
IERC20 indexed token,
uint64 startTimestamp,
uint256 tokensPerEpoch,
uint48 epochDuration,
uint8 initialNumberOfEpochs
);
event PromotionEnded(uint256 indexed promotionId, address indexed recipient, uint256 amount, uint8 epochNumber);
event PromotionDestroyed(uint256 indexed promotionId, address indexed recipient, uint256 amount);
event PromotionExtended(uint256 indexed promotionId, uint256 numberOfEpochs);
Expand Down Expand Up @@ -163,7 +171,15 @@ contract TwabRewardsForkTest is Test {

// Setup new OP token promotions on pUSDC.e vault and pweth vault
vm.expectEmit();
emit PromotionCreated(1 + 2 * i, pusdce, tokenTestCases[i].token);
emit PromotionCreated(
1 + 2 * i,
pusdce,
tokenTestCases[i].token,
startTimestamp,
tokenTestCases[i].tokensPerEpochPusdce,
epochDuration,
numberOfEpochs
);
uint256 pusdcePromotionId = twabRewards.createPromotion(
pusdce,
tokenTestCases[i].token,
Expand All @@ -175,7 +191,15 @@ contract TwabRewardsForkTest is Test {
assertEq(pusdcePromotionId, 1 + 2 * i);

vm.expectEmit();
emit PromotionCreated(2 + 2 * i, pweth, tokenTestCases[i].token);
emit PromotionCreated(
2 + 2 * i,
pweth,
tokenTestCases[i].token,
startTimestamp,
tokenTestCases[i].tokensPerEpochPweth,
epochDuration,
numberOfEpochs
);
uint256 pwethPromotionId = twabRewards.createPromotion(
pweth,
tokenTestCases[i].token,
Expand Down

0 comments on commit c9ed00c

Please sign in to comment.