- Contract performs integer arithmetic (division, fee calculations, reward distributions)
function calculateFee(uint256 amount, uint256 daysEarly) external view returns (uint256) {
// Division BEFORE multiplication — truncates intermediate result
uint256 dailyRate = amount / 365; // Loses precision
uint256 fee = dailyRate * daysEarly; // Error compounds
// Correct: amount * daysEarly / 365 (multiply first)
return fee;
}
function distribute(uint256 reward, uint256 totalShares) external {
for (uint256 i = 0; i < holders.length; i++) {
// If reward < totalShares, this is always 0
uint256 share = reward / totalShares * balances[holders[i]];
_transfer(holders[i], share);
}
}
/) in arithmetic expressionsamount * rate / divisor instead of amount / divisor * ratemulDiv from OpenZeppelin or PRBMath for safe full-precision multiplication then division// Correct: multiply first, then divide
uint256 fee = amount * daysEarly / 365;
// With scaling for precision
uint256 WAD = 1e18;
uint256 scaledRate = (amount * WAD) / totalSupply;
uint256 reward = (scaledRate * userBalance) / WAD;