Glorious Coal Rook
Medium
Some reward Tokens will get stuck in the contract due to amountPerEpoch division remainder not being accounted for
Failure to account for the token amount remainder when dividing realAmountToDistribute by ((_endBlockNum - _startBlockNum) / blocksPerEpoch) can cause the reward tokens present in the contract to be greater than the amount that can be claimed after all the epoch durations have passed. Leading to some tokens being stuck in the contract which cannot be claimed by anyone.
Failure to account for token remainders from reward amount division.
- User calls createDistribution() with an amount such than when the protocolFee is deducted from, will not be perfectly divisible by the outcome of _((_endBlockNum - startBlockNum) / blocksPerEpoch)
No response
No response
Dust amounts of reward tokens accumulate in the contract which cannot be claimed by anyone
No response
A possible solution would be to refund the remainder from the amountPerEpoch calculation to the msg.sender as such:
uint256 remainder = uint256 amountPerEpoch % realAmountToDistribute / ((_endBlockNum - _startBlockNum) / blocksPerEpoch);
IERC20(_rewardToken).safeTransferFrom(address(this), msg.sender, remainder);