The order of state changes and external calls in the function Distribution._stake
may introduce a reentrancy vulnerability.
The order of state changes and external calls in the function Distribution._stake
may introduce a reentrancy vulnerability. External calls should generally be placed at the end of the function to prevent potential reentrancy attacks.
Found in contracts/Distribution.sol:
Potential loss of funds.
Hardhat
To reduce the risk of reentrancy attacks, the lines
"IERC20(depositToken).safeTransferFrom(msgSender(), address(this), amount);" and
"userData.pendingRewards = getCurrentUserReward(currentPoolRate, userData);
"
should be moved outside of the if (pool.isPublic) block and placed after the state changes.
By moving these two lines of code outside of the if (pool.isPublic) block, you ensure that the state changes are already completed before any external interaction takes place. This helps in minimizing the risk of reentrancy attacks.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.