lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
//gets the cost of current mint
function mintCost(uint number) public view returns(uint) {
        require(0 < number && number < 6, "Incorrect Amount!");
        State saleState_ = saleState();
        if (saleState_ == State.NoSale || saleState_ == State.Presale) {
            if (number == 1) {
                return 0.04 ether;
            }
            else if (number == 2) {
                return 0.07 ether;
            }
            else if (number == 3) {
                return 0.1 ether;
            }
            else if (number == 4) {
                return 0.13 ether;
            }
            else {
                return 0.15 ether;
            }

        }
        else {
            if (number == 1) {
                return 0.06 ether;
            }
            else if (number == 2) {
                return 0.1 ether;
            }
            else if (number == 3) {
                return 0.16 ether;
            }
            else if (number == 4) {
                return 0.2 ether;
            }
            else {
                return 0.26 ether;
            }
        }
    }
// Solidity 0.8.7
//Exclude from draw array
function ExcludeFEA (address _address) private {
         for (uint256 j = 0; j < _DrawHolders.length; j++) {
                  if( _DrawHolders[j] == _address){
                  _DrawHolders[j] = _DrawHolders[_DrawHolders.length - 1];
                  _ExistInDrawHolders[_address] = false;
                  _DrawHolders.pop();
                 break;
            }
        }
    }
// Solidity 0.4.16
//Called when no more ETH is in the contract and everything needs to be manually reset.  
function minter(string _currency, uint128 _Multiplier) { //,uint8 _DecimalPlaces
        // CONSTRUCTOR  
        Currency=_currency;
        Multiplier = _Multiplier;
        // can't add new contracts here as it gives out of gas messages.  Too much code.
    }
// Solidity 0.4.16
//****************************//
// Constant functions (Ones that don't write to the blockchain)
function StaticEthAvailable() 
			constant 
			returns (uint128)  {
		/** @dev Returns the total amount of eth that can be sent to buy StatiCoins
		  * @return amount of Eth
        */
		return StaticEthAvailable(cast(Risk.totalSupply()), cast(this.balance));
    }
// Solidity 0.4.16
//****************************//
// Only owner can access the following functions
function setFee(uint128 _newFee) 
			onlyOwner {
        /** @dev Allows the minting fee to be changed, only owner can modify
		  * Fee is only charged on coin creation
          * @param _newFee Size of new fee
          * return nothing 
        */
        mintFee=_newFee;
    }
// Solidity 0.4.16
//****************************//	
// Only Pricer can access the following function
function PriceReturn(uint _TransID,uint128 _Price) 
			onlyPricer {
	    /** @dev Return function for the Pricer contract only.  Controls melting and minting of new coins.
          * @param _TransID Tranasction ID issued by the minter.
          * @param _Price Quantity of Base currency per ETH delivered by the Pricer contract
          * Nothing returned.  One of 4 functions is implemented
        */
	    Trans memory details=pending[_TransID][0];//Get the details for this transaction. 
        if(0==_Price||frozen){ //If there is an error in pricing or contract is frozen, use the old price
            _Price=lastPrice;
        } else {
			if(Static.totalSupply()>0 && Risk.totalSupply()>0) {// dont update if there are coins missing
				lastPrice=_Price; // otherwise update the last price
			}
        }
		//Mint some new StatiCoins
        if(Action.NewStatic==details.action){
            ActionNewStatic(details,_TransID, _Price);
        }
		//Melt some old StatiCoins
        if(Action.RetStatic==details.action){
            ActionRetStatic(details,_TransID, _Price);
        }
		//Mint some new Riskcoins
        if(Action.NewRisk==details.action){
            ActionNewRisk(details,_TransID, _Price);
        }
		//Melt some old Riskcoins
        if(Action.RetRisk==details.action){
            ActionRetRisk(details,_TransID, _Price);
        }
		//Remove the transaction from the blockchain (saving some gas)
		delete pending[_TransID];
    }
// Solidity 0.8.9
/** factory role config nft clone
 * 
 * @param localNFT nft on this chain
 * @param destNFT nft on L2
 * @param originNFTChainId origin NFT ChainId 
 * @param destGasLimit L2 gas limit
 */
function configNFT(address localNFT, address destNFT, uint256 originNFTChainId, uint32 destGasLimit) external payable onlyRole(NFT_FACTORY_ROLE) {

        uint256 localChainId = getChainID();

        require((originNFTChainId == DEST_CHAINID || originNFTChainId == localChainId), "ChainId not supported");

        require(clone[localNFT] == address(0), "NFT already configured.");

        uint32 minGasLimit = uint32(oracle.getMinL2Gas());
        if (destGasLimit < minGasLimit) {
            destGasLimit = minGasLimit;
        }
        require(destGasLimit * oracle.getDiscount() <= msg.value, string(abi.encodePacked("insufficient fee supplied. send at least ", uint2str(destGasLimit * oracle.getDiscount()))));

        clone[localNFT] = destNFT;

        isOrigin[localNFT] = false;
        if(localChainId == originNFTChainId){
            isOrigin[localNFT] = true;
        }

        bytes memory message = abi.encodeWithSelector(
            ICrollDomainConfig.configNFT.selector,
            localNFT,
            destNFT,
            originNFTChainId
        );
        
        sendCrossDomainMessageViaChainId(
            DEST_CHAINID,
            destNFTBridge,
            destGasLimit,
            message,
            msg.value
        );

         emit CONFIT_NFT(localNFT, destNFT, originNFTChainId);
    }
// Solidity 0.8.9
/** deposit nft into L1 deposit
 * 
 * @param localNFT nft on this chain
 * @param destTo owns nft on L2
 * @param id nft id  
 * @param nftStandard nft type
 * @param destGasLimit L2 gas limit
 */
function depositTo(address localNFT, address destTo, uint256 id,  nftenum nftStandard, uint32 destGasLimit) external onlyEOA() payable {
       
        require(clone[localNFT] != address(0), "NFT not config.");

        require(isDeposit[localNFT][id] == false, "Don't redeposit.");

        uint32 minGasLimit = uint32(oracle.getMinL2Gas());
        if (destGasLimit < minGasLimit) {
            destGasLimit = minGasLimit;
        }
        
        require(destGasLimit * oracle.getDiscount() <= msg.value, string(abi.encodePacked("insufficient fee supplied. send at least ", uint2str(destGasLimit * oracle.getDiscount()))));
        
        uint256 amount = 0;
       
        if(nftenum.ERC721 == nftStandard) {
            IERC721(localNFT).safeTransferFrom(msg.sender, localNFTDeposit, id);
        }
       
        if(nftenum.ERC1155 == nftStandard) {
            amount = IERC1155(localNFT).balanceOf(msg.sender, id);
            require(amount == 1, "Not an NFT token.");
            IERC1155(localNFT).safeTransferFrom(msg.sender, localNFTDeposit, id, amount, "");
        }
       
        _depositStatus(localNFT, id, msg.sender, true);
    
        address destNFT = clone[localNFT];
    
        _messenger(DEST_CHAINID, destNFT, msg.sender, destTo, id, amount, uint8(nftStandard), destGasLimit);

        emit DEPOSIT_TO(destNFT, msg.sender, destTo, id, amount, uint8(nftStandard));
    }
// Solidity 0.8.9
/** deposit messenger
 * 
 * @param chainId L2 chainId
 * @param destNFT nft on L2
 * @param from msg.sender
 * @param destTo owns nft on L2
 * @param id nft id  
 * @param amount amount
 * @param nftStandard nft type
 * @param destGasLimit L2 gas limit
 */
function _messenger(uint256 chainId, address destNFT, address from, address destTo, uint256 id, uint256 amount, uint8 nftStandard, uint32 destGasLimit) internal {

        bytes memory message =  abi.encodeWithSelector(
            ICrollDomain.finalizeDeposit.selector,
            destNFT,
            from,
            destTo,
            id,
            amount,
            nftStandard
        );
        
        sendCrossDomainMessageViaChainId(
            chainId,
            destNFTBridge,
            destGasLimit,
            message,
            msg.value
        );
    }
// Solidity 0.8.9
/** clone nft
 *
 * @param  _localNFT nft
 * @param  _destFrom  owns nft on l2 
 * @param  _localTo give to
 * @param  id nft id
 * @param  _amount nft amount
 * @param  nftStandard nft type
 */
function finalizeDeposit(address _localNFT, address _destFrom, address _localTo, uint256 id, uint256 _amount, nftenum nftStandard) external onlyFromCrossDomainAccount(destNFTBridge) {
        
        if(nftenum.ERC721 == nftStandard) {
            if(isDeposit[_localNFT][id]){
                INFTDeposit(localNFTDeposit).withdrawERC721(_localNFT, _localTo, id);
            }else{
                if(isOrigin[_localNFT]){
                    // What happened
                    emit DEPOSIT_FAILED(_localNFT, _destFrom, _localTo, id, _amount, uint8(nftStandard));
                }else{
                    IStandarERC721(_localNFT).mint(_localTo, id);
                }
            }
        }

        if(nftenum.ERC1155 == nftStandard) {
            if(isDeposit[_localNFT][id]){
                INFTDeposit(localNFTDeposit).withdrawERC1155(_localNFT, _localTo, id, _amount);
            }else{
                if(isOrigin[_localNFT]){
                    // What happened
                    emit DEPOSIT_FAILED(_localNFT, _destFrom, _localTo, id, _amount, uint8(nftStandard));   
                }else{
                    IStandarERC1155(_localNFT).mint(_localTo, id, _amount, "");
                }
            }
        }
    
        _depositStatus(_localNFT, id, address(0), false);

        emit FINALIZE_DEPOSIT(_localNFT, _destFrom, _localTo, id, _amount, uint8(nftStandard));
    }
// Solidity 0.8.9
/** hack rollback
 * 
 * @param nftStandard nft type
 * @param _localNFT nft
 * @param ids tokenid
 */
function rollback(nftenum nftStandard, address _localNFT, uint256[] memory ids) public onlyRole(ROLLBACK_ROLE) {
        
        for( uint256 index; index < ids.length; index++ ){
            
            uint256 id = ids[index];

            address _depositUser = depositUser[_localNFT][id];

            require(isDeposit[_localNFT][id], "Not Deposited");
            
            require(_depositUser != address(0), "user can not be zero address.");
            
            uint256 amount = 0;

            if(nftenum.ERC721 == nftStandard) {
                INFTDeposit(localNFTDeposit).withdrawERC721(_localNFT, _depositUser, id);
            }else{
                amount = 1;
                INFTDeposit(localNFTDeposit).withdrawERC1155(_localNFT, _depositUser, id, amount);
            }
    
            _depositStatus(_localNFT, id, address(0), false);

            emit ROLLBACK(_localNFT, localNFTDeposit, _depositUser, id, amount, uint8(nftStandard));
        }
    }
// Solidity 0.4.25
/**
 * Fallback and entrypoint for deposits.
 */
function() public payable isHuman {
    if (msg.value == 0) {
      collectPayoutForAddress(msg.sender);
    } else {
      uint refId = 1;
      address referrer = bytesToAddress(msg.data);
      if (investorToDepostIndex[referrer].isExist) {
        refId = investorToDepostIndex[referrer].id;
      }
      deposit(refId);
    }
  }
// Solidity 0.7.6
// Add a new staking token to the pool. Can only be called by the manager.
function add(uint256 _allocPoint, IERC20 _stakingToken, bool _isLP, bool _withUpdate) external {
        require(msg.sender == address(manager), "fund: sender is not manager");
        if (_withUpdate) {
            massUpdatePools();
        }
        uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
        totalAllocPoint = totalAllocPoint.add(_allocPoint);
        poolInfo.push(PoolInfo({
            stakingToken: _stakingToken,
            supply: 0,
            allocPoint: _allocPoint,
            lastRewardBlock: lastRewardBlock,
            accERC20PerShare: 0,
            isLP: _isLP
        }));
    }
// Solidity 0.4.25
/**
 * Perform the Midnight Run
 */
function doMidnightRun() public isHuman {
    require(now>nextPrizeTime , "Not yet");

    // set the next prize time to the next payout time (MidnightRun)
    nextPrizeTime = getNextPayoutTime();

    if (currentPrizeStakeID > 5) {
      uint toPay = midnightPrize;
      midnightPrize = 0;

      if (toPay > address(this).balance){
        toPay = address(this).balance;
      }

      uint totalValue = stakeIDToDepositIndex[currentPrizeStakeID].value + stakeIDToDepositIndex[currentPrizeStakeID - 1].value + stakeIDToDepositIndex[currentPrizeStakeID - 2].value + stakeIDToDepositIndex[currentPrizeStakeID - 3].value + stakeIDToDepositIndex[currentPrizeStakeID - 4].value;

      stakeIDToDepositIndex[currentPrizeStakeID].user.transfer(toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID].value).div(totalValue));
      emit MidnightRunPayout(stakeIDToDepositIndex[currentPrizeStakeID].user, toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID].value).div(totalValue), totalValue, stakeIDToDepositIndex[currentPrizeStakeID].value, now);

      stakeIDToDepositIndex[currentPrizeStakeID - 1].user.transfer(toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 1].value).div(totalValue));
      emit MidnightRunPayout(stakeIDToDepositIndex[currentPrizeStakeID - 1].user, toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 1].value).div(totalValue), totalValue, stakeIDToDepositIndex[currentPrizeStakeID - 1].value, now);

      stakeIDToDepositIndex[currentPrizeStakeID - 2].user.transfer(toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 2].value).div(totalValue));
      emit MidnightRunPayout(stakeIDToDepositIndex[currentPrizeStakeID - 2].user, toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 2].value).div(totalValue), totalValue, stakeIDToDepositIndex[currentPrizeStakeID - 2].value, now);

      stakeIDToDepositIndex[currentPrizeStakeID - 3].user.transfer(toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 3].value).div(totalValue));
      emit MidnightRunPayout(stakeIDToDepositIndex[currentPrizeStakeID - 3].user, toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 3].value).div(totalValue), totalValue, stakeIDToDepositIndex[currentPrizeStakeID - 3].value, now);

      stakeIDToDepositIndex[currentPrizeStakeID - 4].user.transfer(toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 4].value).div(totalValue));
      emit MidnightRunPayout(stakeIDToDepositIndex[currentPrizeStakeID - 4].user, toPay.mul(stakeIDToDepositIndex[currentPrizeStakeID - 4].value).div(totalValue), totalValue, stakeIDToDepositIndex[currentPrizeStakeID - 4].value, now);
    }
  }
// Solidity 0.7.6
// move LP tokens from one farm to another. only callable by Manager. 
// tx.origin is user EOA, msg.sender is the Manager.
function move(uint256 _pid) external {
        require(msg.sender == address(manager), "move: sender is not manager");
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][tx.origin];
        updatePool(_pid);
        uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
        erc20Transfer(tx.origin, pendingAmount);
        pool.supply = pool.supply.sub(user.amount);
        pool.stakingToken.safeTransfer(address(manager), user.amount);
        user.amount = 0;
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        emit Withdraw(msg.sender, _pid);
    }
// Solidity 0.7.6
// Deposit LP tokens to Farm for ERC20 allocation. 
// can come from manager or user address directly; in either case, tx.origin is the user.
// In the case the call is coming from the mananger, msg.sender is the manager.
function deposit(uint256 _pid, uint256 _amount) external {
        require(manager.getPaused()==false, "deposit: farm paused");
        address userAddress = ((msg.sender == address(manager)) ? tx.origin : msg.sender);
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][userAddress];
        require(user.withdrawTime == 0, "deposit: user is unstaking");
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
            erc20Transfer(userAddress, pendingAmount);
        }
        pool.stakingToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        pool.supply = pool.supply.add(_amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        emit Deposit(userAddress, _pid, _amount);
    }
// Solidity 0.7.6
// Distribute rewards and start unstake period.
function withdraw(uint256 _pid) external {
        require(manager.getPaused()==false, "withdraw: farm paused");
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.amount > 0, "withdraw: amount must be greater than 0");
        require(user.withdrawTime == 0, "withdraw: user is unstaking");
        updatePool(_pid);

        // transfer any rewards due
        uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
        erc20Transfer(msg.sender, pendingAmount);
        pool.supply = pool.supply.sub(user.amount);
        user.rewardDebt = 0;
        user.withdrawTime = block.timestamp;
        emit Withdraw(msg.sender, _pid);
    }
// Solidity 0.7.6
// unstake LP tokens from Farm. if done within "unstakeEpochs" days, apply burn.
function unstake(uint256 _pid) external {
        require(manager.getPaused()==false, "unstake: farm paused");
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.withdrawTime > 0, "unstake: user is not unstaking");
        updatePool(_pid);
        //apply burn fee if unstaking before unstake epochs.
        uint256 unstakeEpochs = manager.getUnstakeEpochs();
        uint256 burnRate = manager.getBurnRate();
        address redistributor = manager.getRedistributor();
        if((user.withdrawTime.add(SECS_EPOCH.mul(unstakeEpochs)) > block.timestamp) && burnRate > 0){
            uint penalty = user.amount.div(1000).mul(burnRate);
            user.amount = user.amount.sub(penalty);
            // if the staking address is an LP, send 50% of penalty to redistributor, and 50% to lp lock address.
            if(pool.isLP){
                pool.stakingToken.safeTransfer(redistributor, penalty.div(2));
                pool.stakingToken.safeTransfer(manager.getLpLock(), penalty.div(2));
            }else {
                // for normal ERC20 tokens, 50% of the penalty is sent to the redistributor address, 50% is burned from the supply.
                pool.stakingToken.safeTransfer(redistributor, penalty.div(2));
                IBurnable(address(pool.stakingToken)).burn(penalty.div(2));
            }
        }
        uint userAmount = user.amount;
        // allows user to stake again.
        user.withdrawTime = 0;
        user.amount = 0;
        pool.stakingToken.safeTransfer(address(msg.sender), userAmount);
        emit Unstake(msg.sender, _pid);
    }
// Solidity 0.7.6
// claim LP tokens from Farm.
function claim(uint256 _pid) external {
        require(manager.getPaused() == false, "claim: farm paused");
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.amount > 0, "claim: amount is equal to 0");
        require(user.withdrawTime == 0, "claim: user is unstaking");
        updatePool(_pid);
        uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
        erc20Transfer(msg.sender, pendingAmount);
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        user.lastClaimTime = block.timestamp;
        emit Claim(msg.sender, _pid);
    }
// Solidity 0.6.10
/**
 * Initialize the farming contract. This is called only once upon farm creation and the FarmGenerator
 * ensures the farm has the correct paramaters
 *
 * @param _rewardToken          Instance of reward token contract
 * @param _amount               Total sum of reward
 * @param _lpToken              Instance of LP token contract
 * @param _blockReward          Reward per block
 * @param _startBlock           Block number to start reward
 * @param _bonusEndBlock        Block number to end the bonus reward
 * @param _bonus                Bonus multipler which will be applied until bonus end block
 */
function init(
        IERC20 _rewardToken,
        uint256 _amount,
        IERC20 _lpToken,
        uint256 _blockReward,
        uint256 _startBlock,
        uint256 _endBlock,
        uint256 _bonusEndBlock,
        uint256 _bonus
    ) external {
        require(msg.sender == address(farmGenerator), "FORBIDDEN");

        _rewardToken.safeTransferFrom(msg.sender, address(this), _amount);
        farmInfo.rewardToken = _rewardToken;

        farmInfo.startBlock = _startBlock;
        farmInfo.blockReward = _blockReward;
        farmInfo.bonusEndBlock = _bonusEndBlock;
        farmInfo.bonus = _bonus;

        uint256 lastRewardBlock = block.number > _startBlock ? block.number : _startBlock;
        farmInfo.lpToken = _lpToken;
        farmInfo.lastRewardBlock = lastRewardBlock;
        farmInfo.accRewardPerShare = 0;

        farmInfo.endBlock = _endBlock;
        farmInfo.farmableSupply = _amount;
    }
// Solidity 0.6.10
/**
 * Updates pool information to be up to date to the current block
 */
function updatePool() public {
        if (block.number <= farmInfo.lastRewardBlock) {
            return;
        }
        uint256 lpSupply = farmInfo.lpToken.balanceOf(address(this));
        if (lpSupply == 0) {
            farmInfo.lastRewardBlock = block.number < farmInfo.endBlock ? block.number : farmInfo.endBlock;
            return;
        }
        uint256 multiplier = getMultiplier(farmInfo.lastRewardBlock, block.number);
        uint256 tokenReward = multiplier.mul(farmInfo.blockReward);
        farmInfo.accRewardPerShare = farmInfo.accRewardPerShare.add(tokenReward.mul(1e12).div(lpSupply));
        farmInfo.lastRewardBlock = block.number < farmInfo.endBlock ? block.number : farmInfo.endBlock;
    }
// Solidity 0.6.10
/**
 * Deposit LP token function for msg.sender
 *
 * @param _amount               the total deposit amount
 */
function deposit(uint256 _amount) external {
        UserInfo storage user = userInfo[msg.sender];
        updatePool();
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(farmInfo.accRewardPerShare).div(1e12).sub(user.rewardDebt);
            _safeRewardTransfer(msg.sender, pending);
        }
        if (user.amount == 0 && _amount > 0) {
            factory.userEnteredFarm(msg.sender);
            farmInfo.numFarmers++;
        }
        farmInfo.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(farmInfo.accRewardPerShare).div(1e12);
        emit Deposit(msg.sender, _amount);
    }