code-423n4 / 2022-01-trader-joe-findings

2 stars 0 forks source link

Unchecked math operations #296

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

pauliax

Vulnerability details

Impact

The unchecked keyword can be applied in the following lines of code since there are statements before to ensure the arithmetic operations would not cause an integer underflow or overflow:

    if (newAllocation > user.allocation) {
        ...
        rJoeNeeded = getRJoeAmount(newAllocation - user.allocation);

      if (block.timestamp > lastRewardTimestamp && joeSupply != 0) {
            uint256 multiplier = block.timestamp - lastRewardTimestamp;

        require(
            user.amount >= _amount,
            "RocketJoeStaking: withdraw amount exceeds balance"
        );
       ...
        user.amount = user.amount - _amount;

        if (block.timestamp <= lastRewardTimestamp) {
            return;
        }
        ...
        uint256 multiplier = block.timestamp - lastRewardTimestamp;