From bce7c74d5aca2d067a5644ab38315fb4ec7dd3a0 Mon Sep 17 00:00:00 2001
From: madlabman <10616301+madlabman@users.noreply.github.com>
Date: Thu, 9 Jan 2025 16:18:52 +0100
Subject: [PATCH 1/2] fix: log the last distributed amount

---
 src/CSFeeDistributor.sol             | 2 ++
 src/interfaces/ICSFeeDistributor.sol | 3 +++
 test/CSFeeDistributor.t.sol          | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/src/CSFeeDistributor.sol b/src/CSFeeDistributor.sol
index c9a1b28f..90b21a53 100644
--- a/src/CSFeeDistributor.sol
+++ b/src/CSFeeDistributor.sol
@@ -121,6 +121,8 @@ contract CSFeeDistributor is
             );
         }
 
+        emit LastDistributed(distributed);
+
         // NOTE: Make sure off-chain tooling provides a distinct CID of a log even for empty reports, e.g. by mixing
         // in a frame identifier such as reference slot to a file.
         if (bytes(_logCid).length == 0) revert InvalidLogCID();
diff --git a/src/interfaces/ICSFeeDistributor.sol b/src/interfaces/ICSFeeDistributor.sol
index 438db952..b65a4997 100644
--- a/src/interfaces/ICSFeeDistributor.sol
+++ b/src/interfaces/ICSFeeDistributor.sol
@@ -20,6 +20,9 @@ interface ICSFeeDistributor is IAssetRecovererLib {
     /// @dev Emitted when distribution log is updated
     event DistributionLogUpdated(string logCid);
 
+    /// @dev It logs how many shares were distributed in the latest report
+    event LastDistributed(uint256 shares);
+
     error ZeroAccountingAddress();
     error ZeroStEthAddress();
     error ZeroAdminAddress();
diff --git a/test/CSFeeDistributor.t.sol b/test/CSFeeDistributor.t.sol
index 79037a95..b5b0f9ce 100644
--- a/test/CSFeeDistributor.t.sol
+++ b/test/CSFeeDistributor.t.sol
@@ -419,6 +419,9 @@ contract CSFeeDistributorTest is CSFeeDistributorTestBase {
             treeCid
         );
 
+        vm.expectEmit(true, true, true, true, address(feeDistributor));
+        emit ICSFeeDistributor.LastDistributed(shares);
+
         vm.expectEmit(true, true, true, true, address(feeDistributor));
         emit ICSFeeDistributor.DistributionLogUpdated(logCid);
 

From 50e82eacba86a51ff6eccfd52bdaba9fe544e6e1 Mon Sep 17 00:00:00 2001
From: madlabman <10616301+madlabman@users.noreply.github.com>
Date: Mon, 13 Jan 2025 15:21:17 +0100
Subject: [PATCH 2/2] refactor!: change fee distribution events

---
 src/CSFeeDistributor.sol             | 4 ++--
 src/interfaces/ICSFeeDistributor.sol | 7 +++++--
 test/CSFeeDistributor.t.sol          | 4 ++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/CSFeeDistributor.sol b/src/CSFeeDistributor.sol
index 90b21a53..f6043d7b 100644
--- a/src/CSFeeDistributor.sol
+++ b/src/CSFeeDistributor.sol
@@ -82,7 +82,7 @@ contract CSFeeDistributor is
         }
 
         STETH.transferShares(ACCOUNTING, sharesToDistribute);
-        emit FeeDistributed(nodeOperatorId, sharesToDistribute);
+        emit OperatorFeeDistributed(nodeOperatorId, sharesToDistribute);
     }
 
     /// @inheritdoc ICSFeeDistributor
@@ -121,7 +121,7 @@ contract CSFeeDistributor is
             );
         }
 
-        emit LastDistributed(distributed);
+        emit ModuleFeeDistributed(distributed);
 
         // NOTE: Make sure off-chain tooling provides a distinct CID of a log even for empty reports, e.g. by mixing
         // in a frame identifier such as reference slot to a file.
diff --git a/src/interfaces/ICSFeeDistributor.sol b/src/interfaces/ICSFeeDistributor.sol
index b65a4997..928373af 100644
--- a/src/interfaces/ICSFeeDistributor.sol
+++ b/src/interfaces/ICSFeeDistributor.sol
@@ -8,7 +8,10 @@ pragma solidity 0.8.24;
 
 interface ICSFeeDistributor is IAssetRecovererLib {
     /// @dev Emitted when fees are distributed
-    event FeeDistributed(uint256 indexed nodeOperatorId, uint256 shares);
+    event OperatorFeeDistributed(
+        uint256 indexed nodeOperatorId,
+        uint256 shares
+    );
 
     /// @dev Emitted when distribution data is updated
     event DistributionDataUpdated(
@@ -21,7 +24,7 @@ interface ICSFeeDistributor is IAssetRecovererLib {
     event DistributionLogUpdated(string logCid);
 
     /// @dev It logs how many shares were distributed in the latest report
-    event LastDistributed(uint256 shares);
+    event ModuleFeeDistributed(uint256 shares);
 
     error ZeroAccountingAddress();
     error ZeroStEthAddress();
diff --git a/test/CSFeeDistributor.t.sol b/test/CSFeeDistributor.t.sol
index b5b0f9ce..34ab111f 100644
--- a/test/CSFeeDistributor.t.sol
+++ b/test/CSFeeDistributor.t.sol
@@ -161,7 +161,7 @@ contract CSFeeDistributorTest is CSFeeDistributorTestBase {
         );
 
         vm.expectEmit(true, true, true, true, address(feeDistributor));
-        emit ICSFeeDistributor.FeeDistributed(nodeOperatorId, shares);
+        emit ICSFeeDistributor.OperatorFeeDistributed(nodeOperatorId, shares);
 
         vm.prank(address(accounting));
         feeDistributor.distributeFees({
@@ -420,7 +420,7 @@ contract CSFeeDistributorTest is CSFeeDistributorTestBase {
         );
 
         vm.expectEmit(true, true, true, true, address(feeDistributor));
-        emit ICSFeeDistributor.LastDistributed(shares);
+        emit ICSFeeDistributor.ModuleFeeDistributed(shares);
 
         vm.expectEmit(true, true, true, true, address(feeDistributor));
         emit ICSFeeDistributor.DistributionLogUpdated(logCid);