From 2b58494690aefb16e88e30f5ce01de5ed9ef5459 Mon Sep 17 00:00:00 2001 From: Brendan Asselstine Date: Tue, 15 Aug 2023 20:59:53 -0700 Subject: [PATCH] Only emit events when amounts non-zero --- src/TwabController.sol | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/TwabController.sol b/src/TwabController.sol index 613b634..dd91d1c 100644 --- a/src/TwabController.sol +++ b/src/TwabController.sol @@ -657,7 +657,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) { @@ -700,7 +702,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) { @@ -742,7 +746,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) { @@ -776,7 +782,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) {