The splitRewards function in the LSTRewardsSplitter contract reverts when there are no new rewards to split, causing unexpected behavior and violating the intended functionality of the contract. This issue occurs due to the else if (newRewards == 0) condition that explicitly reverts when newRewards is zero.
The splitRewards function reverts with the InsufficientRewards error when there are no new rewards to split. This occurs because the function calculates the new rewards by subtracting the principalDeposits from the current balance of the contract. If the result is exactly zero, the function enters the else if (newRewards == 0) condition and reverts.
The issue arises when a user attempts to call the splitRewards function when there are no new rewards to distribute. Instead of gracefully handling this scenario and returning without performing any actions, the function reverts, causing the transaction to fail and potentially leading to unexpected behavior for users interacting with the contract.
Instead of gracefully handling the scenario where there are no new rewards and returning without performing any actions, the function reverts, causing the transaction to fail and potentially leading to confusion and frustration for users interacting with the contract.
To reproduce.
Call the deposit function with an amount equal to the current balance of the contract, ensuring that there are no new rewards to split.
Call the splitRewards function.
The splitRewards function will revert with the InsufficientRewards error because newRewards will be zero.
The reverting behavior of the splitRewards function can negatively impact users who attempt to call the function when there are no new rewards to split. Instead of the function executing successfully and not performing any actions, it will revert and cause the transaction to fail. This can lead to confusion and frustration for users interacting with the contract, as they may expect the function to handle the case when there are no new rewards gracefully.
Manual Review
Modify the splitRewards function to handle the case when newRewards is zero without reverting by removing the else if (newRewards == 0) condition and only calling _splitRewards when newRewards is greater than zero.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.