Open code423n4 opened 3 years ago
shw
The averagePriceForPeriod function of LibPrices does not handle the case where j equals 0 (i.e., no trades happened in the last 24 hours). The transaction reverts due to dividing by 0 without a proper error message returned.
averagePriceForPeriod
LibPrices
j
Referenced code: LibPrices.sol#L73
Add require(j > 0, "...") before line 73 to handle this special case.
require(j > 0, "...")
Handle
shw
Vulnerability details
Impact
The
averagePriceForPeriod
function ofLibPrices
does not handle the case wherej
equals 0 (i.e., no trades happened in the last 24 hours). The transaction reverts due to dividing by 0 without a proper error message returned.Proof of Concept
Referenced code: LibPrices.sol#L73
Recommended Mitigation Steps
Add
require(j > 0, "...")
before line 73 to handle this special case.