lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/// @notice Add a new LP to the pool. Can only be called by the owner.
/// DO NOT add the same LP token more than once. Rewards will be messed up if you do.
/// @param allocPoint AP of the new pool.
/// @param _pid Pid on MCV2
function addPool(uint256 _pid, uint256 allocPoint) public onlyOwner {
		require(poolInfo[_pid].lastRewardBlock == 0, "ALCXRewarder::add: cannot add existing pool");

		uint256 lastRewardBlock = block.number;
		totalAllocPoint = totalAllocPoint.add(allocPoint);

		poolInfo[_pid] = PoolInfo({
			allocPoint: allocPoint.to64(),
			lastRewardBlock: lastRewardBlock.to64(),
			accTokenPerShare: 0
		});
		poolIds.push(_pid);

		emit PoolAdded(_pid, allocPoint);
	}
// Solidity 0.6.12
/// @notice Update reward variables of the given pool.
/// @param pid The index of the pool. See `poolInfo`.
/// @return pool Returns the pool that was updated.
function updatePool(uint256 pid) public returns (PoolInfo memory pool) {
		pool = poolInfo[pid];

		if (block.number > pool.lastRewardBlock) {
			uint256 lpSupply = MC_V2.lpToken(pid).balanceOf(address(MC_V2));

			if (lpSupply > 0) {
				uint256 blocks = block.number.sub(pool.lastRewardBlock);
				uint256 tokenReward = blocks.mul(tokenPerBlock).mul(pool.allocPoint) / totalAllocPoint;
				pool.accTokenPerShare = pool.accTokenPerShare.add(
					(tokenReward.mul(ACC_TOKEN_PRECISION) / lpSupply).to128()
				);
			}

			pool.lastRewardBlock = block.number.to64();
			poolInfo[pid] = pool;

			emit PoolUpdated(pid, pool.lastRewardBlock, lpSupply, pool.accTokenPerShare);
		}
	}
// Solidity 0.6.12
/// @notice View function to see pending Token
/// @param _pid The index of the pool. See `poolInfo`.
/// @param _user Address of user.
/// @return pending SUSHI reward for a given user.
function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) {
		PoolInfo memory pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][_user];

		uint256 accTokenPerShare = pool.accTokenPerShare;
		uint256 lpSupply = MC_V2.lpToken(_pid).balanceOf(address(MC_V2));

		if (block.number > pool.lastRewardBlock && lpSupply != 0) {
			uint256 blocks = block.number.sub(pool.lastRewardBlock);
			uint256 tokenReward = blocks.mul(tokenPerBlock).mul(pool.allocPoint) / totalAllocPoint;
			accTokenPerShare = accTokenPerShare.add(tokenReward.mul(ACC_TOKEN_PRECISION) / lpSupply);
		}

		pending = (user.amount.mul(accTokenPerShare) / ACC_TOKEN_PRECISION).sub(user.rewardDebt);
	}
// Solidity 0.8.0
/**
 * @dev token purchase with pay Land tokens
 * @param beneficiary Recipient of the token purchase
 * @param tokenId uint256 ID of the token to be purchase
 */
function buyToken(address beneficiary, uint256 tokenId) public payable{
        require(beneficiary != address(0), "Presale: beneficiary is the zero address");
        require(weiPerToken() == msg.value, "Presale: Not enough Eth");
        require(!_cellToken.exists(tokenId), "Presale: token already minted");
        require(tokenId < 11520, "Presale: tokenId must be less than max token count");
        (uint256 x, uint256 y) = cellById(tokenId);
        require(x < 38 || x > 53 || y < 28 || y > 43, "Presale: tokenId should not be in the unsold range");
        _wallet.transfer(msg.value);
        _cellToken.mint(beneficiary, tokenId);
        emit TokensPurchased(msg.sender, beneficiary, tokenId);
    }
// Solidity 0.8.0
/**
 * @dev batch token purchase with pay our ERC20 tokens
 * @param beneficiary Recipient of the token purchase
 * @param tokenIds uint256 IDs of the token to be purchase
 */
function buyBatchTokens(address beneficiary, uint256[] memory tokenIds) public payable{
        require(beneficiary != address(0), "Presale: beneficiary is the zero address");
        uint256 weiAmount = weiPerToken() * tokenIds.length;
        require(weiAmount == msg.value, "Presale: Not enough Eth");
        for (uint256 i = 0; i < tokenIds.length; ++i) {
            require(!_cellToken.exists(tokenIds[i]), "Presale: token already minted");
            require(tokenIds[i] < 11520, "Presale: tokenId must be less than max token count");
            (uint256 x, uint256 y) = cellById(tokenIds[i]);
            require(x < 38 || x > 53 || y < 28 || y > 43, "Presale: tokenId should not be in the unsold range");
        }
        _wallet.transfer(msg.value);
        for (uint256 i = 0; i < tokenIds.length; ++i) {
            _cellToken.mint(beneficiary, tokenIds[i]);
            emit TokensPurchased(msg.sender, beneficiary, tokenIds[i]);
        }
    }
// Solidity 0.8.1
/* ==========  MUTATIVE FUNCTIONS  ========== */
function handleKeeperIncentive(
    bytes32 _contractName,
    uint8 _i,
    address _keeper
  ) external {
    require(msg.sender == controllerContracts[_contractName], "Can only be called by the controlling contract");
    require(
      IStaking(_getContract(keccak256("PopLocker"))).balanceOf(_keeper) >= requiredKeeperStake,
      "not enough pop at stake"
    );

    Incentive memory incentive = incentives[_contractName][_i];

    if (!incentive.openToEveryone) {
      _requireRole(KEEPER_ROLE, _keeper);
    }
    if (incentive.enabled && incentive.reward <= incentiveBudget && incentive.reward > 0) {
      incentiveBudget = incentiveBudget - incentive.reward;
      uint256 amountToBurn = (incentive.reward * burnRate) / 1e18;
      uint256 incentivePayout = incentive.reward - amountToBurn;
      IERC20(_getContract(keccak256("POP"))).safeTransfer(_keeper, incentivePayout);
      _burn(amountToBurn);
    }
  }
// Solidity 0.8.1
/* ========== RESTRICTED FUNCTIONS ========== */
function updateIncentive(
    bytes32 _contractName,
    uint8 _i,
    uint256 _reward,
    bool _enabled,
    bool _openToEveryone
  ) external onlyRole(DAO_ROLE) {
    Incentive storage incentive = incentives[_contractName][_i];
    uint256 oldReward = incentive.reward;
    bool oldOpenToEveryone = incentive.openToEveryone;
    incentive.reward = _reward;
    incentive.enabled = _enabled;
    incentive.openToEveryone = _openToEveryone;
    emit IncentiveChanged(_contractName, oldReward, _reward, oldOpenToEveryone, _openToEveryone);
  }
// Solidity 0.6.12
// Update reward variables of the given pool to be up-to-date.
// No new RLY are minted, distribution is dependent on sufficient RLY tokens being sent to this contract
function updatePool(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        if (block.number <= pool.lastRewardBlock) {
            return;
        }
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        if (lpSupply == 0) {
            pool.lastRewardBlock = block.number;
            return;
        }
        uint256 multiplier = block.number.sub(pool.lastRewardBlock);
        uint256 rallyReward = multiplier.mul(rallyPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
        pool.accRallyPerShare = pool.accRallyPerShare.add(rallyReward.mul(1e12).div(lpSupply));
        pool.lastRewardBlock = block.number;
    }
// Solidity 0.6.12
/**
 	 * @notice Delegates votes from signatory to `delegatee`
 	 * @param delegatee The address to delegate votes to
 	 * @param nonce The contract state required to match the signature
 	 * @param expiry The time at which to expire the signature
 	 * @param v The recovery byte of the signature
 	 * @param r Half of the ECDSA signature pair
 	 * @param s Half of the ECDSA signature pair
 	 */
function delegateBySig(
		address delegatee,
		uint256 nonce,
		uint256 expiry,
		uint8 v,
		bytes32 r,
		bytes32 s
	) external {
		bytes32 domainSeparator =
			keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this)));

		bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));

		bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));

		address signatory = ecrecover(digest, v, r, s);
		require(signatory != address(0), "SUSHI::delegateBySig: invalid signature");
		require(nonce == nonces[signatory]++, "SUSHI::delegateBySig: invalid nonce");
		require(now <= expiry, "SUSHI::delegateBySig: signature expired");
		return _delegate(signatory, delegatee);
	}
// Solidity 0.6.12
/**
 	 * @notice Determine the prior number of votes for an account as of a block number
 	 * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
 	 * @param account The address of the account to check
 	 * @param blockNumber The block number to get the vote balance at
 	 * @return The number of votes the account had as of the given block
 	 */
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) {
		require(blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined");

		uint32 nCheckpoints = numCheckpoints[account];
		if (nCheckpoints == 0) {
			return 0;
		}

		// First check most recent balance
		if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
			return checkpoints[account][nCheckpoints - 1].votes;
		}

		// Next check implicit zero balance
		if (checkpoints[account][0].fromBlock > blockNumber) {
			return 0;
		}

		uint32 lower = 0;
		uint32 upper = nCheckpoints - 1;
		while (upper > lower) {
			uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
			Checkpoint memory cp = checkpoints[account][center];
			if (cp.fromBlock == blockNumber) {
				return cp.votes;
			} else if (cp.fromBlock < blockNumber) {
				lower = center;
			} else {
				upper = center - 1;
			}
		}
		return checkpoints[account][lower].votes;
	}
// Solidity 0.8.12
//TEAM Withdraw
function withdraw() public onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "Insufficent balance");
        uint256 witdrawAmount = calculateWithdraw(budgetDev1,(balance * 25) / 100);
        if (witdrawAmount>0){
            budgetDev1 -= witdrawAmount;
            _withdraw(DEV1, witdrawAmount);
        }
        witdrawAmount = calculateWithdraw(budgetCommunityWallet,(balance * 75) / 100);
        if (witdrawAmount>0){
            budgetCommunityWallet -= witdrawAmount;
            _withdraw(CommunityWallet, witdrawAmount);
        }
      
    }
// Solidity 0.6.12
/// @dev Creates a new pool.
///
/// The created pool will need to have its reward weight initialized before it begins generating rewards.
///
/// @param _token The token the pool will accept for staking.
///
/// @return the identifier for the newly created pool.
function createPool(IERC20 _token) external onlyGovernance returns (uint256) {
		require(tokenPoolIds[_token] == 0, "StakingPools: token already has a pool");

		uint256 _poolId = _pools.length();

		_pools.push(
			Pool.Data({
				token: _token,
				totalDeposited: 0,
				rewardWeight: 0,
				accumulatedRewardWeight: FixedPointMath.uq192x64(0),
				lastUpdatedBlock: block.number
			})
		);

		tokenPoolIds[_token] = _poolId + 1;

		emit PoolCreated(_poolId, _token);

		return _poolId;
	}
// Solidity 0.6.12
/// @dev Sets the reward weights of all of the pools.
///
/// @param _rewardWeights The reward weights of all of the pools.
function setRewardWeights(uint256[] calldata _rewardWeights) external onlyGovernance {
		require(_rewardWeights.length == _pools.length(), "StakingPools: weights length mismatch");

		_updatePools();

		uint256 _totalRewardWeight = _ctx.totalRewardWeight;
		for (uint256 _poolId = 0; _poolId < _pools.length(); _poolId++) {
			Pool.Data storage _pool = _pools.get(_poolId);

			uint256 _currentRewardWeight = _pool.rewardWeight;
			if (_currentRewardWeight == _rewardWeights[_poolId]) {
				continue;
			}

			// FIXME
			_totalRewardWeight = _totalRewardWeight.sub(_currentRewardWeight).add(_rewardWeights[_poolId]);
			_pool.rewardWeight = _rewardWeights[_poolId];

			emit PoolRewardWeightUpdated(_poolId, _rewardWeights[_poolId]);
		}

		_ctx.totalRewardWeight = _totalRewardWeight;
	}
// Solidity 0.6.12
/// @dev Stakes tokens into a pool.
///
/// The pool and stake MUST be updated before calling this function.
///
/// @param _poolId        the pool to deposit tokens into.
/// @param _depositAmount the amount of tokens to deposit.
function _deposit(uint256 _poolId, uint256 _depositAmount) internal {
		Pool.Data storage _pool = _pools.get(_poolId);
		Stake.Data storage _stake = _stakes[msg.sender][_poolId];

		_pool.totalDeposited = _pool.totalDeposited.add(_depositAmount);
		_stake.totalDeposited = _stake.totalDeposited.add(_depositAmount);

		_pool.token.safeTransferFrom(msg.sender, address(this), _depositAmount);

		emit TokensDeposited(msg.sender, _poolId, _depositAmount);
	}
// Solidity 0.8.9
/**
 * @notice delegate all calls to implementation contract
 * @dev reverts if implementation address contains no code, for compatibility with metamorphic contracts
 * @dev memory location in use by assembly may be unsafe in other contexts
 */
fallback() external payable virtual {
        address implementation = _getImplementation();

        require(
            implementation.isContract(),
            'Proxy: implementation must be contract'
        );

        assembly {
            calldatacopy(0, 0, calldatasize())
            let result := delegatecall(
                gas(),
                implementation,
                0,
                calldatasize(),
                0,
                0
            )
            returndatacopy(0, 0, returndatasize())

            switch result
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }
// Solidity 0.4.25
/**
 * @dev Internal function that burns an amount of the token of a given
 * account, deducting from the sender's allowance for said account. Uses the
 * internal burn function.
 * @param account The account whose tokens will be burnt.
 * @param value The amount that will be burnt.
 */
function _burnFrom(address account, uint256 value) internal {
    require(value <= _allowed[account][msg.sender]);

    // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
    // this function needs to emit an event with the updated approval.
    _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
      value);
      _burn(account, value);
  }
// Solidity 0.4.25
/**
 * @dev low level token purchase ***DO NOT OVERRIDE***
 * @param beneficiary Address performing the token purchase
 */
function buyTokens(address beneficiary) public payable {

    uint256 weiAmount = msg.value;
    _preValidatePurchase(beneficiary, weiAmount);

    // calculate token amount to be created
    uint256 tokens = _getTokenAmount(weiAmount);

    // update state
    _weiRaised = _weiRaised.add(weiAmount);

    _processPurchase(beneficiary, tokens);
    emit TokensPurchased(
      msg.sender,
      beneficiary,
      weiAmount,
      tokens
    );

    _updatePurchasingState(beneficiary, weiAmount);

    _forwardFunds();
    _postValidatePurchase(beneficiary, weiAmount);
  }
// Solidity 0.4.25
/**
 * calculate a percentage with parts per notation.
 * the value returned will be in terms of 10e precision
 */
function percent(uint numerator, uint denominator, uint precision) private pure returns(uint quotient) {
    // caution, keep this a private function so the numbers are safe
    uint _numerator = (numerator * 10 ** (precision+1));
    // with rounding of last digit
    uint _quotient = ((_numerator / denominator)) / 10;
    return ( _quotient);
  }
// Solidity 0.4.25
/**
 * @dev wallet can send funds
 */
function sendTo(address _payee, uint256 _amount) private {
    require(_payee != 0 && _payee != address(this), "Burning tokens and self transfer not allowed");
    require(_amount > 0, "Must transfer greater than zero");
    _payee.transfer(_amount);
    emit Sent(_payee, _amount, address(this).balance);
  }
// Solidity 0.4.25
/**
 * @dev function for the player to cash in tokens
 */
function redeemTokens(address _player, address _tokenAddress) public returns (bool success) {
    require(acceptedToken(_tokenAddress), "Token must be a registered token");
    require(block.timestamp >= closeDate, "Game must be closed");
    require(gameDone == true, "Can't redeem tokens until results have been uploaded");
    // instantiate a token contract instance from the deployed address
    IPickFlixToken _token = IPickFlixToken(_tokenAddress);
    // check token allowance player has given to GameMaster contract
    uint256 _allowedValue = _token.allowance(_player, address(this));
    // transfer tokens to GameMaster
    _token.transferFrom(_player, address(this), _allowedValue);
    // check balance of tokens actually transfered
    uint256 _transferedTokens = _allowedValue;
    // calculate the percentage of the total token supply represented by the transfered tokens
    uint256 _playerPercentage = percent(_transferedTokens, _token.totalSupply(), 4);
    // calculate the particular player's rewards, as a percentage of total player rewards for the movie
    uint256 _playerRewards = movies[_tokenAddress].totalPlayerRewards.mul(_playerPercentage).div(10**4);
    // pay out ETH to the player
    sendTo(_player, _playerRewards);
    // return that the function succeeded
    return true;
  }
// Solidity 0.4.25
// this calculates how much Ether to reward for each game token
function calculateTotalPlayerRewardsPerMovie(uint256 _boxOfficeTotal) public view returns (uint256) {
    // 234 means 23.4%, using parts-per notation with three decimals of precision
    uint256 _boxOfficePercentage = percent(_boxOfficeTotal, totalBoxOffice, 4);
    // calculate the Ether rewards available for each movie
    uint256 _rewards = totalPlayerRewards.mul(_boxOfficePercentage).div(10**4);
    return _rewards;
  }
// Solidity 0.4.25
/**
 * @dev add box office results and token addresses for the movies, and calculate game results
 */
function calculateGameResults(address[] _tokenAddresses, uint256[] _boxOfficeTotals) public onlyOwner {
    // check that there are as many box office totals as token addresses
    require(_tokenAddresses.length == _boxOfficeTotals.length, "Must have box office results per token");
    // calculate Oracle Fee and amount of Ether available for player rewards
    require(gameDone == false, "Can only submit results once");
    require(block.timestamp >= closeDate, "Game must have ended before results can be entered");
    oracleFee = calculateOracleFee();
    totalPlayerRewards = calculateTotalPlayerRewards();
    totalBoxOffice = calculateTotalBoxOffice(_boxOfficeTotals);

    // create Movies (see: Movie struct) and calculate player rewards
    for (uint256 i = 0; i < _tokenAddresses.length; i++) {
      tokensIssued = tokensIssued.add(calculateTokensIssued(_tokenAddresses[i]));
      movies[_tokenAddresses[i]] = Movie(_boxOfficeTotals[i], calculateTotalPlayerRewardsPerMovie(_boxOfficeTotals[i]), true);
    }

    // The owner will be the Factory that deploys this contract.
    owner().transfer(oracleFee);
    gameDone = true;
  }
// Solidity 0.4.25
// Create a new game master and add it to the factories game list
function createGame(string gameName, uint closeDate, uint oracleFeePercent) public onlyOwner returns (address){
    address gameMaster = new PickflixGameMaster(gameName, closeDate, oracleFeePercent);
    games.push(Game({
      gameName: gameName,
      gameMaster: gameMaster,
      openDate: block.timestamp,
      closeDate: closeDate
    }));
    return gameMaster;
  }
// Solidity 0.4.25
// Create a token and associate it with a game
function createTokenForGame(uint gameIndex, string tokenName, string tokenSymbol, uint rate, string externalID) public onlyOwner returns (address) {
    Game storage game = games[gameIndex];
    address token = new PickFlixToken(tokenName, tokenSymbol, rate, game.gameMaster, game.closeDate, externalID);
    gameTokens[game.gameMaster].push(token);
    return token;
  }
// Solidity 0.8.11
/*
 * mintFreeDoodle
 * mints a free daijuking using a Doodles token - can only be claimed once per wallet
 */
function mintFreeDoodle() public payable IsSaleActive IsFreeMintActive {
        uint256 supply = TotalSupplyFix.current();

        require(supply <= maxGenCount, "All Genesis Daijukingz were claimed!");
        require(mintFreeDoodleList(msg.sender) >= 1, "You don't own any Doodles!");
        require((supply + 1) <= maxFreeMints, "All the free mints have been claimed!");
        require(freeMintList[msg.sender] < 1, "You already claimed your free daijuking!");
        require(!breedingEnabled, "Minting genesis has been disabled!");

        _safeMint(msg.sender, supply);
        TotalSupplyFix.increment();

        freeMintList[msg.sender] = 1;
        balanceGenesis[msg.sender]++;
        genCount++;
        freeMintCount += 1;
    }
// Solidity 0.8.11
/*
 * mintFreeGiveaway
 * this is for the giveaway winners - allows you to mint a free daijuking
 */
function mintFreeGiveaway() public payable IsSaleActive IsFreeMintActive {
        uint256 supply = TotalSupplyFix.current();

        require(supply <= maxGenCount, "All Genesis Daijukingz were claimed!");
        require((supply + 1) <= maxGivewayMint, "All giveaway mints were claimed!");
        require(giveawayMintList[msg.sender] >= 1, "You don't have any free mints left!");
        require(!breedingEnabled, "Minting genesis has been disabled!");

        _safeMint(msg.sender, supply);
        TotalSupplyFix.increment();

        giveawayMintList[msg.sender] = 0;
        balanceGenesis[msg.sender]++;
        genCount++;
        giveawayMintCount += 1;
    }
// Solidity 0.6.12
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(
		uint256 _allocPoint,
		IERC20 _lpToken,
		bool _withUpdate
	) public onlyOwner {
		if (_withUpdate) {
			massUpdatePools();
		}
		uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
		totalAllocPoint = totalAllocPoint.add(_allocPoint);
		poolInfo.push(
			PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accSushiPerShare: 0 })
		);
	}
// Solidity 0.6.12
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public {
		require(address(migrator) != address(0), "migrate: no migrator");
		PoolInfo storage pool = poolInfo[_pid];
		IERC20 lpToken = pool.lpToken;
		uint256 bal = lpToken.balanceOf(address(this));
		lpToken.safeApprove(address(migrator), bal);
		IERC20 newLpToken = migrator.migrate(lpToken);
		require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
		pool.lpToken = newLpToken;
	}
// Solidity 0.8.11
/*
 * mint
 * mints the daijuking using ETH as the payment token
 */
function mint(uint256 numberOfMints) public payable IsSaleActive {
        uint256 supply = TotalSupplyFix.current();
        require(numberOfMints > 0 && numberOfMints < 11, "Invalid purchase amount");

        if (block.timestamp <= freeEndTimestamp) {
            require(supply.add(numberOfMints) <= (maxGenCount - (maxFreeMints + maxGivewayMint)), "Purchase would exceed max supply");
        } else {
            require(supply.add(numberOfMints) <= maxGenCount, "Purchase would exceed max supply");
        }
        
        require(price.mul(numberOfMints) == msg.value, "Ether value sent is not correct");
        require(!breedingEnabled, "Minting genesis has been disabled!");

        for (uint256 i; i < numberOfMints; i++) {
            _safeMint(msg.sender, supply + i);
            balanceGenesis[msg.sender]++;
            genCount++;
            TotalSupplyFix.increment();
        }
    }