crytic / crytic/slither

Invalid detection of divide-before-multiply in if-else block

Open
#844 0 comments 0 reactions 0 assignees View on GitHub
false-positive
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

```
slither --version
0.7.1
```

Please consider the following code:
```
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(DURATION);
} else {
// ...
uint256 leftover = remaining.mul(rewardRate);
// ...
}
```

Slither says:
```
RewardsPool.topUpReward(uint256) (contracts/RewardsPool.sol#28-45) performs a multiplication on the result of a division:
-rewardRate = reward.div(DURATION) (contracts/RewardsPool.sol#33)
-leftover = remaining.mul(rewardRate) (contracts/RewardsPool.sol#36)
```

Those two operations are in a separate if-else paths and should not affect each other.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.