sherlock-audit / 2022-10-merit-circle-judging

1 stars 0 forks source link

rvierdiiev - User can't transfer all amount of claimed rewards #42

Closed sherlock-admin closed 2 years ago

sherlock-admin commented 2 years ago

rvierdiiev

medium

User can't transfer all amount of claimed rewards

Summary

User can't transfer all amount of claimed rewards.

Vulnerability Detail

There is developer error in BasePool.claimRewards function. It's not possible to transfer value that less then 2. See here. That means that when amount nonEscrowedRewardAmount == 1 it will not be transferred to receiver and receiver will lost it.

Impact

Receiver lose funds.

Code Snippet

function claimRewards(address _receiver) external {
        uint256 rewardAmount = _prepareCollect(_msgSender());
        uint256 escrowedRewardAmount = rewardAmount * escrowPortion / 1e18;
        uint256 nonEscrowedRewardAmount = rewardAmount - escrowedRewardAmount;

        if(escrowedRewardAmount != 0 && address(escrowPool) != address(0)) {
            escrowPool.deposit(escrowedRewardAmount, escrowDuration, _receiver);
        }

        // ignore dust
        if(nonEscrowedRewardAmount > 1) {
            rewardToken.safeTransfer(_receiver, nonEscrowedRewardAmount);
        }

        emit RewardsClaimed(_msgSender(), _receiver, escrowedRewardAmount, nonEscrowedRewardAmount);
    }

Tool used

Manual Review

Recommendation

Change check condition to if(nonEscrowedRewardAmount > 0).