hats-finance / Fenix--0x9d7765a7ebd5b6322a30797a44a5428531970d3d

0 stars 1 forks source link

non-linear increase of epoch due to divide before multiply #64

Open hats-bug-reporter[bot] opened 1 month ago

hats-bug-reporter[bot] commented 1 month ago

Github username: @agbanusi Twitter username: -- Submission hash (on-chain): 0xb22d944d6c8eea7d122a50327642c5950e81a09c2a1b9f14c501f537e6a5bafa Severity: medium

Description: Description\ There is a non-linear increase of epoch due to divide before multiply can cause unwanted issues

Attack Scenario\

 function _roundToEpoch(uint256 timestamp_) internal pure returns (uint256) {
        return (timestamp_ / _WEEK) * _WEEK;
    }

An example is

now gives an epoch of 1721260800
and an hour later gives an epoch of 1721865600

The disparity of epoch is large and non-predictable which can lead to complexity issues

Attachments

  1. Proof of Concept (PoC) File\ https://github.com/hats-finance/Fenix--0x9d7765a7ebd5b6322a30797a44a5428531970d3d/blob/353c8e8e24454336e805e5c0e11e4e9ae1491d03/contracts/nest/SingelTokenVirtualRewarderUpgradeable.sol#L358

  2. Revised Code File (Optional)

0xmahdirostami commented 1 month ago

The time rounding down is specially designed to consider the epoch boundaries