Skip to content

Latest commit

 

History

History
41 lines (23 loc) · 1.38 KB

File metadata and controls

41 lines (23 loc) · 1.38 KB

Glorious Coal Rook

Medium

Some reward Tokens will get stuck in the contract due to amountPerEpoch division remainder not being accounted for

Summary

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.

Root Cause

Failure to account for token remainders from reward amount division.

Internal pre-conditions

  1. 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)

External pre-conditions

No response

Attack Path

No response

Impact

Dust amounts of reward tokens accumulate in the contract which cannot be claimed by anyone

PoC

No response

Mitigation

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);