LSTRewardsSplitter incorrectly updates the principalDeposits value during reward distribution which could cause a loss of initial deposit information and wrong misclassification of undistributed rewards as principal.
The _splitRewards function overwrites the principalDeposits value with the current contract balance after each reward distribution.
The function doesn't take into account for the possibility that the sum of all fee amounts might be less than the total _rewardsAmount. due to rounding down in the calculation of each fee amount.
For example, if there are multiple small fees, each calculation of amount might round down, leaving some rewards undistributed. These leftover rewards will remain in the contract and be counted as part of the principal deposits in the last line:
This albeit causes two main issues:
-- The contract loses track of the initial deposits made by users.
-- Undistributed rewards (resulting from rounding errors in fee calculations) are incorrectly classified as principal deposits.
This can cause incorrect calculations resulting in over or under-distribution of rewards and loss of user funds.
Add the test below to lst-rewards-splitter.test.ts:
Run the test using:
Logs:
-- The contract loses track of initial user deposits, potentially leading to fund loss and future reward calculations may be inaccurate due to the misclassification of undistributed rewards as principal.
-- yarn
-- Manual review
Keep track of the total distributed amount and transfer any remainder to a designated address (something like a treasury).
Or, adjust the last fee to account for any rounding errors, ensuring all rewards are distributed.
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.