re-al-Foundation / rwa-contracts

0 stars 0 forks source link

[VEV-02M] Misleading Documentation of Function #67

Closed chasebrownn closed 5 months ago

chasebrownn commented 5 months ago

VEV-02M: Misleading Documentation of Function

Type Severity Location
Standard Conformity VotingEscrowVesting.sol:L166, L182-L186, L192

Description:

Based on the implementation of RWAVotingEscrow::burn, a user is able to burn their NFT early by incurring a fee. The VotingEscrowVesting::claim function, however, denotes that it should only be invoke-able when the vesting period has completed which contradicts its implementation.

Example:

/**
 * @dev Claims the underlying locked tokens of a vested VotingEscrow token, effectively burning the VotingEscrow
 * token. The function can only be called once the vesting period has completed.
 *
 * @param receiver The address to receive the underlying locked tokens.
 * @param tokenId The identifier of the VotingEscrow token to be claimed.
 * The VotingEscrow token is burned, and the locked tokens are transferred to the receiver.
 */
function claim(address receiver, uint256 tokenId) external nonReentrant {
    if (depositors[tokenId] != msg.sender) {
        revert NotAuthorized(msg.sender);
    }

    VestingSchedule storage tokenSchedule = vestingSchedules[tokenId];

    uint256 endTime = tokenSchedule.endTime;
    uint256 remainingTime;

    if (endTime > block.timestamp) {
        unchecked {
            remainingTime = endTime - block.timestamp;
        }
    }

    _removeTokenFromDepositorEnumeration(msg.sender, tokenId);

    delete vestingSchedules[tokenId];

    votingEscrow.updateVestingDuration(tokenId, remainingTime);
    votingEscrow.burn(receiver, tokenId);
}

Recommendation:

We advise the documentation to be corrected as we consider the early claim possibility to be desirable per the implementation of RWAVotingEscrow::burn.

chasebrownn commented 5 months ago

Resolved