contract RoundedTokenVesting is TokenVesting {
    using SafeMath for uint256;

    // Minimum transferable chunk
    uint256 public granularity;

    /**
     * @dev Creates a vesting contract that vests its balance of any ERC20 token to the
     * _beneficiary, gradually in a linear fashion until _start + _duration. By then all
     * of the balance will have vested.
     * @param _beneficiary address of the beneficiary to whom vested tokens are transferred
     * @param _cliff duration in seconds of the cliff in which tokens will begin to vest
     * @param _start the time (as Unix time) at which point vesting starts 
     * @param _duration duration in seconds of the period in which the tokens will vest
     * @param _revocable whether the vesting is revocable or not
     */
    constructor(
        address _beneficiary,
        uint256 _start,
        uint256 _cliff,
        uint256 _duration,
        bool _revocable,
        uint256 _granularity
    )
        public
        TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable)
    {
        granularity = _granularity;
    }
    
    /**
     * @dev Calculates the amount that has already vested.
     * @param token ERC20 token which is being vested
     */
    function vestedAmount(ERC20Basic token) public view returns (uint256) {
        uint256 currentBalance = token.balanceOf(this);
        uint256 totalBalance = currentBalance.add(released[token]);

        if (block.timestamp < cliff) {
            return 0;
        } else if (block.timestamp >= start.add(duration) || revoked[token]) {
            return totalBalance;
        } else {
            uint256 notRounded = totalBalance.mul(block.timestamp.sub(start)).div(duration);

            // Round down to the nearest token chunk by using integer division: (x / 1e18) * 1e18
            uint256 rounded = notRounded.div(granularity).mul(granularity);

            return rounded;
        }
    }
}
function vestedAmount(ERC20Basic token) public view returns (uint256) {
    uint256 currentBalance = token.balanceOf(this);
    uint256 totalBalance = currentBalance.add(released[token]);

    if (block.timestamp < cliff) {
        return 0;
    } else if (block.timestamp >= start.add(duration) || revoked[token]) {
        return totalBalance;
    } else {
        uint256 notRounded = totalBalance.mul(block.timestamp.sub(start)).div(duration);

        // Round down to the nearest token chunk by using integer division: (x / 1e18) * 1e18
        uint256 rounded = notRounded.div(granularity).mul(granularity);

        return rounded;
    }
}

/**
 * @dev Calculates the amount that has already vested.
 * @param token ERC20 token which is being vested
 */