function stake(uint256 amount, bool lock_) public whenNotPaused {
    _stakeFor(msg.sender, amount, lock_);
}
/// @notice Locks an existing unlocked balance.
function lock(uint256 amount) public whenNotPaused {
    if (amount == 0) {
        revert ErrZeroAmount();
    }
    _updateRewardsForUser(msg.sender);
    _balances[msg.sender].unlocked -= amount;
    unlockedSupply -= amount;
    _createLock(msg.sender, amount);
}
function _createLock(address user, uint256 amount) internal {
    Balances storage bal = _balances[user];
    uint256 _nextUnlockTime = nextUnlockTime();
    function nextUnlockTime() public view returns (uint256) {
        return nextEpoch() + lockDuration;
    }
function epoch() public view returns (uint256) {
    return (block.timestamp / rewardsDuration) * rewardsDuration;
}
function nextEpoch() public view returns (uint256) {
    return epoch() + rewardsDuration;
}
