The getUnsaved function in the smart contract is designed to calculate the unsaved profit for a specific account based on the difference between totalProfit and lastProfit[account]. However, the function lacks a validation mechanism to ensure that totalProfit is always greater than or equal to lastProfit[account], which could lead to incorrect calculations if totalProfit is smaller than lastProfit[account], resulting in inaccurate results or unintended errors in the system.
The getUnsaved function performs the calculation:
totalProfit is the total profit calculated for the entire system.
lastProfit[account] is the profit that has already been saved for the specific account from the previous update.
However, no checks are performed to verify that totalProfit is not less than lastProfit[account]. If the value of totalProfit is incorrectly altered or erroneous during the calculation process, this could lead to incorrect calculations, for example, resulting in a negative value in the unsaved profit calculation.
If totalProfit is less than lastProfit[account], the calculation will result in a negative value for the unsaved profit, which will affect the accuracy of the result.
Manual
Add a condition check in the getUnsaved function to ensure that totalProfit is not less than lastProfit[account].
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.