Skip to content

Commit

Permalink
Merge pull request #11 from GenerationSoftware/gen-353-macro-issue-q-…
Browse files Browse the repository at this point in the history
…13-events-emitted-in-twabcontroller-even-when

Only emit events when amounts non-zero
  • Loading branch information
asselstine committed Aug 16, 2023
2 parents 8381358 + 2b58494 commit f55d8b2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/TwabController.sol
Expand Up @@ -667,7 +667,9 @@ contract TwabController {
) = TwabLib.increaseBalances(PERIOD_LENGTH, PERIOD_OFFSET, _account, _amount, _delegateAmount);

// Always emit the balance change event
emit IncreasedBalance(_vault, _user, _amount, _delegateAmount);
if (_amount != 0 || _delegateAmount != 0) {
emit IncreasedBalance(_vault, _user, _amount, _delegateAmount);
}

// Conditionally emit the observation recorded event
if (_isObservationRecorded) {
Expand Down Expand Up @@ -710,7 +712,9 @@ contract TwabController {
);

// Always emit the balance change event
emit DecreasedBalance(_vault, _user, _amount, _delegateAmount);
if (_amount != 0 || _delegateAmount != 0) {
emit DecreasedBalance(_vault, _user, _amount, _delegateAmount);
}

// Conditionally emit the observation recorded event
if (_isObservationRecorded) {
Expand Down Expand Up @@ -752,7 +756,9 @@ contract TwabController {
);

// Always emit the balance change event
emit DecreasedTotalSupply(_vault, _amount, _delegateAmount);
if (_amount != 0 || _delegateAmount != 0) {
emit DecreasedTotalSupply(_vault, _amount, _delegateAmount);
}

// Conditionally emit the observation recorded event
if (_isObservationRecorded) {
Expand Down Expand Up @@ -786,7 +792,9 @@ contract TwabController {
) = TwabLib.increaseBalances(PERIOD_LENGTH, PERIOD_OFFSET, _account, _amount, _delegateAmount);

// Always emit the balance change event
emit IncreasedTotalSupply(_vault, _amount, _delegateAmount);
if (_amount != 0 || _delegateAmount != 0) {
emit IncreasedTotalSupply(_vault, _amount, _delegateAmount);
}

// Conditionally emit the observation recorded event
if (_isObservationRecorded) {
Expand Down

0 comments on commit f55d8b2

Please sign in to comment.