Why uint32(block.timestamp % 2**32) ?
mudgen opened this issue · comments
The update
function in UniswapV2Pair.sol has this line of code:
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
In case of uint32 overflow the following return the same value:
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 blockTimestamp = uint32(block.timestamp);
So why do this block.timestamp % 2**32
?
It looks like the code is requiring the gas cost of doing a modulus operation for no reason.
Or is it done to show that overflow is okay?
You already reported this #96
Oh, sorry, I didn't realize that.
can you explain us ??
can somebody explain why the value is not changing, even after block.timestamp % 2**32
?? i know it is use for overflow but how ?
can somebody explain why the value is not changing, even after
block.timestamp % 2**32
?? i know it is use for overflow but how ?
This may help
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-September/018172.html
can somebody explain why the value is not changing, even after
block.timestamp % 2**32
?? i know it is use for overflow but how ?This may help
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-September/018172.html
Thanks i got it