Closed code423n4 closed 3 years ago
In this specific case, the use of WAD maths is actually not wanted. This is due to the fact that trades is not a WAD value itself, so we actually want the divide to reduce decimal places if needed to compute the true average.
If we used the WAD maths library, the output would not be as expected due to this. We could convert the number of trades used to compute the average into a WAD, however the output would be the same as using built in division.
Marking this issue as invalid as @raymogg's explanation makes sense.
Handle
a_delamo
Vulnerability details
Impact
In order to calculate the average price during the last 24h, we use the method
averagePriceForPeriod
from the librarylibPrice
. To calculate this, is doing the average of each hour and then the average of all the previous results. But for doing these operations, we are not using the fixed-point library (PRBMathSD59x18.sol), so with each operation, we are accumulating errors and it can affect the final result.