sherlock-audit/2023-02-gmx-judging

hack3r-0m - loss of precision while diving `block.timestamp` due to runding towards 0

Closed this issue · 0 comments

hack3r-0m

medium

loss of precision while diving block.timestamp due to runding towards 0

Summary

loss of precision while diving block.timestamp due to runding towards 0

Vulnerability Detail

uint256 timeKey = block.timestamp / divisor;

if divisor > 1e9 then this value is always 0, if divisor > 1e8 then this value is always 1

Impact

such rounding can lead to loss of precision and incrementing same key slot again and again

Code Snippet

https://github.com/sherlock-audit/2023-02-gmx/blob/main/gmx-synthetics/contracts/market/MarketUtils.sol#L542

Tool used

Manual Review

Recommendation

add bounds for possible values of divisor or apply precision