lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/**
 Internal function to add a new payee.
 @dev will update totalShares and therefore reduce the relative share of all other payees.
 @param _payee The address of the payee to add.
 @param _shares The number of shares owned by the payee.
 */
function _addPayee(address _payee, uint256 _shares) internal {
    require(_payee != address(0), "payee is the zero address");
    require(_shares > 0, "shares are 0");
    require(shares[_payee] == 0, "payee already has shares");

    payees.push(_payee);
    shares[_payee] = _shares;
    totalShares = totalShares.add(_shares);
    emit PayeeAdded(_payee, _shares);
  }
// Solidity 0.6.12
/**
 Updates the payee configuration to a new one.
 @dev will release existing fees before the update.
 @param _payees Array of payees
 @param _shares Array of shares for each payee
 */
function changePayees(address[] memory _payees, uint256[] memory _shares) public override onlyManager {
    require(_payees.length == _shares.length, "Payees and shares mismatched");
    require(_payees.length > 0, "No payees");

    uint256 income = a.core().availableIncome();
    if (income > 0 && payees.length > 0) {
      release();
    }

    for (uint256 i = 0; i < payees.length; i++) {
      delete shares[payees[i]];
    }
    delete payees;
    totalShares = 0;

    for (uint256 i = 0; i < _payees.length; i++) {
      _addPayee(_payees[i], _shares[i]);
    }
  }
// Solidity 0.7.6
/// @notice Calculates the sqrt ratio for given price
/// @param token0 The address of token0
/// @param token1 The address of token1
/// @param price The amount with decimals of token1 for 1 token0
/// @return sqrtPriceX96 The greatest tick for which the ratio is less than or equal to the input ratio
function getSqrtRatioAtPrice(
    address token0,
    address token1,
    uint256 price
  ) internal pure returns (uint160 sqrtPriceX96) {
    uint256 base = 1e18;
    if (token0 > token1) {
      (token0, token1) = (token1, token0);
      (base, price) = (price, base);
    }
    uint256 priceX96 = (price << 192) / base;
    sqrtPriceX96 = uint160(sqrt(priceX96));
  }
// Solidity 0.7.6
/// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
/// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
/// ever return.
/// @param token0 The address of token0
/// @param token1 The address of token1
/// @param sqrtPriceX96 The sqrt ratio for which to compute the price as a Q64.96
/// @return price The amount with decimals of token1 for 1 token0
function getPriceAtSqrtRatio(
    address token0,
    address token1,
    uint160 sqrtPriceX96
  ) internal pure returns (uint256 price) {
    // second inequality must be < because the price can never reach the price at the max tick
    require(sqrtPriceX96 >= TickMath.MIN_SQRT_RATIO && sqrtPriceX96 < TickMath.MAX_SQRT_RATIO, 'R');

    uint256 base = 1e18;
    uint256 priceX96 = uint256(sqrtPriceX96) * uint256(sqrtPriceX96);
    if (token0 > token1) {
      price = UnsafeMath.divRoundingUp(base << 192, priceX96);
    } else {
      price = (priceX96 * base) >> 192;
    }
  }
// Solidity 0.8.6
/**
 * @dev Claims outstanding rewards from market
 */
function claimRewards() external {
        uint256 len = bAssetsMapped.length;
        address[] memory pTokens = new address[](len);
        for (uint256 i = 0; i < len; i++) {
            pTokens[i] = bAssetToPToken[bAssetsMapped[i]];
        }
        uint256 rewards = rewardController.claimRewards(pTokens, type(uint256).max, address(this));

        emit RewardsClaimed(pTokens, rewards);
    }
// Solidity 0.5.17
/**
 * @dev Multiplies two unsigned integers, reverts on overflow.
 */
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }
// Solidity 0.5.17
/**
 * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
 */
function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }
// Solidity 0.8.12
/**
 * @dev Returns total holdings for all pools (strategy's)
 * @return Returns sum holdings (USD) for all pools
 */
function totalHoldings() public view returns (uint256) {
        uint256 length = _poolInfo.length;
        uint256 totalHold = 0;
        for (uint256 pid = 0; pid < length; pid++) {
            totalHold += _poolInfo[pid].strategy.totalHoldings();
        }
        return totalHold;
    }
// Solidity 0.8.12
/**
 * @dev in this func user sends funds to the contract and then waits for the completion
 * of the transaction for all users
 * @param amounts - array of deposit amounts by user
 */
function delegateDeposit(uint256[3] memory amounts) external whenNotPaused {
        for (uint256 i = 0; i < amounts.length; i++) {
            if (amounts[i] > 0) {
                IERC20Metadata(tokens[i]).safeTransferFrom(_msgSender(), address(this), amounts[i]);
                pendingDeposits[_msgSender()][i] += amounts[i];
            }
        }

        emit CreatedPendingDeposit(_msgSender(), amounts);
    }
// Solidity 0.8.12
/**
 * @dev in this func user sends pending withdraw to the contract and then waits
 * for the completion of the transaction for all users
 * @param  lpAmount - amount of ZLP for withdraw
 * @param minAmounts - array of amounts stablecoins that user want minimum receive
 */
function delegateWithdrawal(uint256 lpAmount, uint256[3] memory minAmounts)
        external
        whenNotPaused
    {
        PendingWithdrawal memory withdrawal;
        address userAddr = _msgSender();
        require(lpAmount > 0, 'Zunami: lpAmount must be higher 0');

        withdrawal.lpShares = lpAmount;
        withdrawal.minAmounts = minAmounts;

        pendingWithdrawals[userAddr] = withdrawal;

        emit CreatedPendingWithdrawal(userAddr, minAmounts, lpAmount);
    }
// Solidity 0.8.12
/**
 * @dev Zunami protocol owner complete all active pending withdrawals of users
 * @param userList - array of users from pending withdraw to complete
 */
function completeWithdrawals(address[] memory userList)
        external
        onlyRole(OPERATOR_ROLE)
        startedPool
    {
        require(userList.length > 0, 'Zunami: there are no pending withdrawals requests');

        IStrategy strategy = _poolInfo[defaultWithdrawPid].strategy;

        address user;
        PendingWithdrawal memory withdrawal;
        for (uint256 i = 0; i < userList.length; i++) {
            user = userList[i];
            withdrawal = pendingWithdrawals[user];

            if (balanceOf(user) >= withdrawal.lpShares) {
                if (
                    !(
                        strategy.withdraw(
                            user,
                            withdrawal.lpShares * 1e18 / _poolInfo[defaultWithdrawPid].lpShares,
                            withdrawal.minAmounts,
                            IStrategy.WithdrawalType.Base,
                            0
                        )
                    )
                ) {
                    emit FailedWithdrawal(user, withdrawal.minAmounts, withdrawal.lpShares);
                    delete pendingWithdrawals[user];
                    continue;
                }

                uint256 userDeposit = (totalDeposited * withdrawal.lpShares) / totalSupply();
                _burn(user, withdrawal.lpShares);
                _poolInfo[defaultWithdrawPid].lpShares -= withdrawal.lpShares;
                totalDeposited -= userDeposit;

                emit Withdrawn(user, IStrategy.WithdrawalType.Base, withdrawal.minAmounts, withdrawal.lpShares, 0);
            }

            delete pendingWithdrawals[user];
        }
    }
// Solidity 0.8.12
/**
 * @dev deposit in one tx, without waiting complete by dev
 * @return Returns amount of lpShares minted for user
 * @param amounts - user send amounts of stablecoins to deposit
 */
function deposit(uint256[POOL_ASSETS] memory amounts)
        external
        whenNotPaused
        startedPool
        returns (uint256)
    {
        IStrategy strategy = _poolInfo[defaultDepositPid].strategy;
        uint256 holdings = totalHoldings();

        for (uint256 i = 0; i < amounts.length; i++) {
            if (amounts[i] > 0) {
                IERC20Metadata(tokens[i]).safeTransferFrom(
                    _msgSender(),
                    address(strategy),
                    amounts[i]
                );
            }
        }
        uint256 newDeposited = strategy.deposit(amounts);
        require(newDeposited > 0, 'Zunami: too low deposit!');

        uint256 lpShares = 0;
        if (totalSupply() == 0) {
            lpShares = newDeposited;
        } else {
            lpShares = (totalSupply() * newDeposited) / holdings;
        }
        _mint(_msgSender(), lpShares);
        _poolInfo[defaultDepositPid].lpShares += lpShares;
        totalDeposited += newDeposited;

        emit Deposited(_msgSender(), amounts, lpShares);
        return lpShares;
    }
// Solidity 0.8.12
/**
 * @dev withdraw in one tx, without waiting complete by dev
 * @param lpShares - amount of ZLP for withdraw
 * @param tokenAmounts -  array of amounts stablecoins that user want minimum receive
 */
function withdraw(
        uint256 lpShares,
        uint256[POOL_ASSETS] memory tokenAmounts,
        IStrategy.WithdrawalType withdrawalType,
        uint128 tokenIndex
    ) external whenNotPaused startedPool {
        require( checkBit(availableWithdrawalTypes, uint8(withdrawalType)), 'Zunami: withdrawal type not available' );
        IStrategy strategy = _poolInfo[defaultWithdrawPid].strategy;
        address userAddr = _msgSender();

        require(balanceOf(userAddr) >= lpShares, 'Zunami: not enough LP balance');
        require(
            strategy.withdraw(userAddr, lpShares * 1e18 / _poolInfo[defaultWithdrawPid].lpShares, tokenAmounts, withdrawalType, tokenIndex),
            'Zunami: user lps share should be at least required'
        );

        uint256 userDeposit = (totalDeposited * lpShares) / totalSupply();
        _burn(userAddr, lpShares);
        _poolInfo[defaultWithdrawPid].lpShares -= lpShares;

        totalDeposited -= userDeposit;

        emit Withdrawn(userAddr, withdrawalType, tokenAmounts, lpShares, tokenIndex);
    }
// Solidity 0.8.12
/**
 * @dev add a new pool, deposits in the new pool are blocked for one day for safety
 * @param _strategyAddr - the new pool strategy address
 */
function addPool(address _strategyAddr) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(_strategyAddr != address(0), 'Zunami: zero strategy addr');
        uint256 startTime = block.timestamp + (launched ? MIN_LOCK_TIME : 0);
        _poolInfo.push(
            PoolInfo({ strategy: IStrategy(_strategyAddr), startTime: startTime, lpShares: 0 })
        );
        emit AddedPool(_poolInfo.length - 1, _strategyAddr, startTime);
    }
// Solidity 0.8.12
/**
 * @dev dev can transfer funds from few strategy's to one strategy for better APY
 * @param _strategies - array of strategy's, from which funds are withdrawn
 * @param withdrawalsPercents - A percentage of the funds that should be transfered
 * @param _receiverStrategyId - number strategy, to which funds are deposited
 */
function moveFundsBatch(
        uint256[] memory _strategies,
        uint256[] memory withdrawalsPercents,
        uint256 _receiverStrategyId
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            _strategies.length == withdrawalsPercents.length,
            'Zunami: incorrect arguments for the moveFundsBatch'
        );
        require(_receiverStrategyId < _poolInfo.length, 'Zunami: incorrect a reciver strategy ID');

        uint256[POOL_ASSETS] memory tokenBalance;
        for (uint256 y = 0; y < POOL_ASSETS; y++) {
            tokenBalance[y] = IERC20Metadata(tokens[y]).balanceOf(address(this));
        }

        uint256 pid;
        uint256 zunamiLp;
        for (uint256 i = 0; i < _strategies.length; i++) {
            pid = _strategies[i];
            zunamiLp += _moveFunds(pid, withdrawalsPercents[i]);
        }

        uint256[POOL_ASSETS] memory tokensRemainder;
        for (uint256 y = 0; y < POOL_ASSETS; y++) {
            tokensRemainder[y] =
                IERC20Metadata(tokens[y]).balanceOf(address(this)) -
                tokenBalance[y];
            if (tokensRemainder[y] > 0) {
                IERC20Metadata(tokens[y]).safeTransfer(
                    address(_poolInfo[_receiverStrategyId].strategy),
                    tokensRemainder[y]
                );
            }
        }

        _poolInfo[_receiverStrategyId].lpShares += zunamiLp;

        require(
            _poolInfo[_receiverStrategyId].strategy.deposit(tokensRemainder) > 0,
            'Zunami: Too low amount!'
        );
    }
// Solidity 0.8.7
//Returns a tokenURI of a specific token
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token.");

        string memory baseURI2 = _baseURI();
        return bytes(baseURI2).length > 0
            ? string(abi.encodePacked(baseURI2, tokenId.toString(), ".json")) : '.json';
    }
// Solidity 0.8.7
//Exclusive Presale mint for the OG's || Moet nog testen of het goe dgaat met de total suplly
function mintPresaleToken(uint16 _amount) public payable {
        require( presaleActive,                  "Presale is not active" );
        uint16 reservedAmt = presaleAddresses[msg.sender];
        require( reservedAmt > 0,                "No tokens reserved for your address" );
        require( _amount < reservedAmt,         "max reserved token supply reached!" );
        require( totalMints + _amount < totalCount, "Cannot mint more than max supply" );
        require( msg.value == presalePrice * _amount,   "Wrong amount of ETH sent" );
        presaleAddresses[msg.sender] = reservedAmt - _amount;
        for(uint16 i; i < _amount; i++){
            _safeMint( msg.sender, 1 + totalMints++);
        }
    }
// Solidity 0.8.7
//Mint function
function mint(uint16 _amount) public payable {
        require( saleActive,"Sale is not active" );
        require( _amount < maxBatch, "You can only Mint 10 tokens at once" );
        require( totalMints + _amount < totalCount,"Cannot mint more than max supply" );
        require( msg.value == price * _amount,"Wrong amount of ETH sent" );
        for(uint16 i; i < _amount; i++){
            _safeMint( msg.sender, 1+ totalMints++);
        }
    }
// Solidity 0.5.11
/*
 * @notice This function starts dividend payout round, and can be started from ANY address if the time has come.
 */
function startDividendsPayments() public returns (bool success) {

        require(
            dividendsRound[dividendsRoundsCounter].roundIsRunning == false,
            "Already running"
        );

        // dividendsRound[dividendsRoundsCounter].roundFinishedOnUnixTime is zero for first round
        // so it can be started right after contract deploy
        require(now.sub(dividendsRound[dividendsRoundsCounter].roundFinishedOnUnixTime) > dividendsPeriod,
            "To early to start"
        );

        require(registeredShares > 0,
            "No registered shares to distribute dividends to"
        );

        uint sumWeiToPayForOneToken = address(this).balance / registeredShares;
        uint sumXEurToPayForOneToken = xEuro.balanceOf(address(this)) / registeredShares;

        require(
            sumWeiToPayForOneToken > 0 || sumXEurToPayForOneToken > 0,
            "Nothing to pay"
        );

        // here we start the next dividends payout round:
        dividendsRoundsCounter++;

        dividendsRound[dividendsRoundsCounter].roundIsRunning = true;
        dividendsRound[dividendsRoundsCounter].roundStartedOnUnixTime = now;
        dividendsRound[dividendsRoundsCounter].registeredShares = registeredShares;
        dividendsRound[dividendsRoundsCounter].allRegisteredShareholders = shareholdersCounter;

        dividendsRound[dividendsRoundsCounter].sumWeiToPayForOneToken = sumWeiToPayForOneToken;
        dividendsRound[dividendsRoundsCounter].sumXEurToPayForOneToken = sumXEurToPayForOneToken;

        emit DividendsPaymentsStarted(
            dividendsRoundsCounter,
            msg.sender,
            address(this).balance,
            xEuro.balanceOf(address(this)),
            registeredShares,
            sumWeiToPayForOneToken,
            sumXEurToPayForOneToken
        );

        return true;
    }
// Solidity 0.5.11
/*
 * Function to add funds to reward transactions distributing dividends in this round/
 */
function fundDividendsPayout() public payable returns (bool success){

        /* We allow this only for running round */
        require(
            dividendsRound[dividendsRoundsCounter].roundIsRunning,
            "Dividends payout is not running"
        );

        dividendsRound[dividendsRoundsCounter].weiForTxFees = dividendsRound[dividendsRoundsCounter].weiForTxFees + msg.value;

        emit FundsToPayForDividendsDistributionReceived(
            dividendsRoundsCounter,
            msg.value,
            msg.sender,
            dividendsRound[dividendsRoundsCounter].weiForTxFees // totalSum
        );

        return true;
    }
// Solidity 0.5.11
/*
 * dev: Private function, that calls 'tokenFallback' function if token receiver is a contract.
 */
function _erc223Call(address _to, uint _value, bytes memory _data) private returns (bool success) {

        uint codeLength;

        assembly {
        // Retrieve the size of the code on target address, this needs assembly .
            codeLength := extcodesize(_to)
        }

        if (codeLength > 0) {
            ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
            receiver.tokenFallback(msg.sender, _value, _data);
            emit DataSentToAnotherContract(msg.sender, _to, _data);
        }

        return true;
    }
// Solidity 0.5.16
/// Whitelisted entity makes changes to the notifications
function setPoolBatch(address[] calldata poolAddress, uint256[] calldata poolPercentage, NotificationType[] calldata notificationType, bool[] calldata vests) external onlyChanger {
    for (uint256 i = 0; i < poolAddress.length; i++) {
      setPool(poolAddress[i], poolPercentage[i], notificationType[i], vests[i]);
    }
  }
// Solidity 0.5.16
/// Pool management, adds, updates or removes a transfer/notification
function setPool(address poolAddress, uint256 poolPercentage, NotificationType notificationType, bool vests) public onlyChanger {
    require(notificationType != NotificationType.VOID, "Use valid indication");
    if (notificationExists(poolAddress) && poolPercentage == 0) {
      // remove
      removeNotification(poolAddress);
    } else if (notificationExists(poolAddress)) {
      // update
      updateNotification(poolAddress, notificationType, poolPercentage, vests);
    } else if (poolPercentage > 0) {
      // add because it does not exist
      addNotification(poolAddress, poolPercentage, notificationType, vests);
    }
    emit PoolChanged(poolAddress, poolPercentage, uint256(notificationType), vests);
  }
// Solidity 0.5.16
/// configuration check method
function getConfig(uint256 totalAmount) external view returns(address[] memory, uint256[] memory, uint256[] memory) {
    address[] memory pools = new address[](notifications.length);
    uint256[] memory percentages = new uint256[](notifications.length);
    uint256[] memory amounts = new uint256[](notifications.length);
    for (uint256 i = 0; i < notifications.length; i++) {
      Notification storage notification = notifications[i];
      pools[i] = notification.poolAddress;
      percentages[i] = notification.percentage.mul(1000000).div(totalPercentage);
      amounts[i] = notification.percentage.mul(totalAmount).div(totalPercentage);
    }
    return (pools, percentages, amounts);
  }
// Solidity 0.8.10
/// @notice Used to withdraw ETH balance of the contract, this function is dedicated
///         to contract owner according to { onlyOwner } modifier.
function withdrawEquity()
    public onlyOwner nonReentrant {
        uint256 balance = address(this).balance;

        address[2] memory shareholders = [
            ADDRESS_PBOY,
            ADDRESS_JOLAN
        ];

        uint256[2] memory _shares = [
            SHARE_PBOY * balance / 100,
            SHARE_JOLAN * balance / 100
        ];

        uint i = 0;
        while (i < 2) {
            require(payable(shareholders[i]).send(_shares[i]));
            emit Withdraw(_shares[i], shareholders[i]);
            i++;
        }
    }
// Solidity 0.8.10
/// @notice Used to manage authorization and reentrancy of the genesis NFT mint
/// @param  _genesisId Used to increment { genesisId } and write { epochMintingRegistry }
function genesisController(uint256 _genesisId)
    private {
        require(epoch == 0, "error epoch");
        require(genesisId <= maxGenesisSupply, "error genesisId");
        require(!epochMintingRegistry[epoch][_genesisId], "error epochMintingRegistry");

        /// @dev Set { _genesisId } for { epoch } as true
        epochMintingRegistry[epoch][_genesisId] = true;

        /// @dev When { genesisId } reaches { maxGenesisSupply } the function
        ///      will compute the data to increment the epoch according
        ///
        ///      { blockGenesis } is set only once, at this time
        ///      { blockMeta } is set to { blockGenesis } because epoch=0
        ///      Then it is computed into the function epochRegulator()
        ///
        ///      Once the epoch is regulated, the new generation start
        ///      straight away, { generationMintAllowed } is set to true
        if (genesisId == maxGenesisSupply) {
            blockGenesis = block.number;
            blockMeta = blockGenesis;
            
            emit Genesis(epoch, blockGenesis);
            epochRegulator();
        }
    }
// Solidity 0.8.10
/// @notice Used to protect epoch block length from difficulty bomb of the
///         Ethereum network. A difficulty bomb heavily increases the difficulty
///         on the network, likely also causing an increase in block time.
///         If the block time increases too much, the epoch generation could become
///         exponentially higher than what is desired, ending with an undesired Ice-Age.
///         To protect against this, the emergencySecure() function is allowed to
///         manually reconfigure the epoch block length and the block Meta
///         to match the network conditions if necessary.
///
///         It can also be useful if the block time decreases for some reason with consensus change.
///
///         This function is dedicated to contract owner according to { onlyOwner } modifier
function emergencySecure(uint256 _epoch, uint256 _epochLen, uint256 _blockMeta, uint256 _inflateRatio)
    public onlyOwner {
        require(epoch > 0, "error epoch");
        require(_epoch > 0, "error _epoch");
        require(maxTokenSupply >= tokenId, "error maxTokenSupply");

        epoch = _epoch;
        epochLen = _epochLen;
        blockMeta = _blockMeta;
        inflateRatio = _inflateRatio;

        computeBlockOmega();
        emit Securized(epoch, epochLen, blockMeta, inflateRatio);
    }