lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.3
/* to be called 5 times */
function reserveToken() public onlyOwner {        
        uint supply = totalSupply()+1;
        uint i;
        uint j;
           
        ReserveList[] memory _acc = new ReserveList[](5);
        _acc[0].addr=msg.sender; _acc[0].nbOfToken=20;
        _acc[1].addr= address(0xa5cbD48F84BB626B32b49aC2c7479b88Cd871567);_acc[1].nbOfToken=5;
        _acc[2].addr= address(0xc06695Ce0AED905A3a3C24Ce99ab75C4bd8b7466);_acc[2].nbOfToken=5;
        _acc[3].addr= address(0xe72bf39949CD3D56031895c152B2168ca73b50e9);_acc[3].nbOfToken=5;
        _acc[4].addr= address(0x425f1E9bcCdC796f36190b5933d6319c78BA9f19);_acc[4].nbOfToken=5;

        
        for (j=0;j<_acc.length;j++){
            for (i = 0; i < _acc[j].nbOfToken; i++) {
                _safeMint(_acc[j].addr, supply);
                supply++;
            }
        }
    }
// Solidity 0.7.3
/**
 * Claim token for owners of old SSF 
 */
function claimToken(uint numberOfTokens) public {
        require(!lockClaim);
        lockClaim=true;
        
        require(claimIsActive, "Claim must be active");
        require(totalSupply().add(numberOfTokens) <= MAX_TOKEN, "Purchase would exceed max supply.");
  
        uint ssf_balance ;
        uint  ssfu_claimable;
        (,ssf_balance,ssfu_claimable) = dualBalanceOf(msg.sender);
         require(ssf_balance >0, "Must hold at least 1 SSF to claim a SSFU");
         require(numberOfTokens <= ssfu_claimable , "Claimed too many.");

        for(uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply()+1;
            if (totalSupply() <= MAX_TOKEN) {
                if (decreaseClaimable(msg.sender)) {
                    _safeMint(msg.sender, mintIndex);
                }
            }
        }

        lockClaim=false;
    }
// Solidity 0.7.3
/**
 * Mints token - Comes after the claim phase
 */
function mintToken(uint numberOfTokens) public payable {
        require(saleIsActive, "Sale must be active");
        require(totalSupply().add(numberOfTokens) <= MAX_TOKEN, "Purchase would exceed max supply.");
        require(tokenPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
        
        require(numberOfTokens <= maxTokenPurchase, "Can only mint maxTokenPurchase tokens at a time");
        
        
        
        for(uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply()+1;
            if (totalSupply() <= MAX_TOKEN) {
                _safeMint(msg.sender, mintIndex);
            }
        }

        // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after
        // the end of pre-sale, set the starting index block
        if (startingIndexBlock == 0 && (totalSupply() == MAX_TOKEN || block.timestamp >= REVEAL_TIMESTAMP)) {
            startingIndexBlock = block.number;
        } 
    }
// Solidity 0.7.3
/**
 * Set the starting index once the startingBlox index is known
 */
function setStartingIndex() onlyOwner public {
        require(startingIndex == 0, "Starting index is already set");
        require(startingIndexBlock != 0, "Starting index block must be set");
        
        startingIndex = uint(blockhash(startingIndexBlock)) % MAX_TOKEN;
        // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
        if (block.number.sub(startingIndexBlock) > 255) {
            startingIndex = uint(blockhash(block.number - 1)) % MAX_TOKEN;
        }
        // Prevent default sequence
        if (startingIndex == 0) {
            startingIndex = startingIndex.add(1);
        }
    }
// Solidity 0.8.4
// Returns the missing amount of collateral (in E18) needed to maintain the collateral ratio
function recollatTheoColAvailableE18() public view returns (uint256) {
        uint256 frax_total_supply = FRAX.totalSupply();
        uint256 effective_collateral_ratio = FRAX.globalCollateralValue().mul(PRICE_PRECISION).div(frax_total_supply); // Returns it in 1e6
        
        uint256 desired_collat_e24 = (FRAX.global_collateral_ratio()).mul(frax_total_supply);
        uint256 effective_collat_e24 = effective_collateral_ratio.mul(frax_total_supply);

        // Return 0 if already overcollateralized
        // Otherwise, return the deficiency
        if (effective_collat_e24 >= desired_collat_e24) return 0;
        else {
            return (desired_collat_e24.sub(effective_collat_e24)).div(PRICE_PRECISION);
        }
    }
// Solidity 0.8.4
// Returns the value of FXS available to be used for recollats
// Also has throttling to avoid dumps during large price movements
function recollatAvailableFxs() public view returns (uint256) {
        uint256 fxs_price = getFXSPrice();

        // Get the amount of collateral theoretically available
        uint256 recollat_theo_available_e18 = recollatTheoColAvailableE18();

        // Get the amount of FXS theoretically outputtable
        uint256 fxs_theo_out = recollat_theo_available_e18.mul(PRICE_PRECISION).div(fxs_price);

        // See how much FXS has been issued this hour
        uint256 current_hr_rct = rctHourlyCum[curEpochHr()];

        // Account for the throttling
        return comboCalcBbkRct(current_hr_rct, rctMaxFxsOutPerHour, fxs_theo_out);
    }
// Solidity 0.8.4
// After a redemption happens, transfer the newly minted FXS and owed collateral from this pool
// contract to the user. Redemption is split into two functions to prevent flash loans from being able
// to take out FRAX/collateral from the system, use an AMM to trade the new price, and then mint back into the system.
function collectRedemption(uint256 col_idx) external returns (uint256 fxs_amount, uint256 collateral_amount) {
        require(redeemPaused[col_idx] == false, "Redeeming is paused");
        require((lastRedeemed[msg.sender].add(redemption_delay)) <= block.number, "Too soon");
        bool sendFXS = false;
        bool sendCollateral = false;

        // Use Checks-Effects-Interactions pattern
        if(redeemFXSBalances[msg.sender] > 0){
            fxs_amount = redeemFXSBalances[msg.sender];
            redeemFXSBalances[msg.sender] = 0;
            unclaimedPoolFXS = unclaimedPoolFXS.sub(fxs_amount);
            sendFXS = true;
        }
        
        if(redeemCollateralBalances[msg.sender][col_idx] > 0){
            collateral_amount = redeemCollateralBalances[msg.sender][col_idx];
            redeemCollateralBalances[msg.sender][col_idx] = 0;
            unclaimedPoolCollateral[col_idx] = unclaimedPoolCollateral[col_idx].sub(collateral_amount);
            sendCollateral = true;
        }

        // Send out the tokens
        if(sendFXS){
            TransferHelper.safeTransfer(address(FXS), msg.sender, fxs_amount);
        }
        if(sendCollateral){
            TransferHelper.safeTransfer(collateral_addresses[col_idx], msg.sender, collateral_amount);
        }
    }
// Solidity 0.8.4
/* ========== RESTRICTED FUNCTIONS, CUSTODIAN CAN CALL TOO ========== */
function toggleMRBR(uint256 col_idx, uint8 tog_idx) external onlyByOwnGovCust {
        if (tog_idx == 0) mintPaused[col_idx] = !mintPaused[col_idx];
        else if (tog_idx == 1) redeemPaused[col_idx] = !redeemPaused[col_idx];
        else if (tog_idx == 2) buyBackPaused[col_idx] = !buyBackPaused[col_idx];
        else if (tog_idx == 3) recollateralizePaused[col_idx] = !recollateralizePaused[col_idx];

        emit MRBRToggled(col_idx, tog_idx);
    }
// Solidity 0.8.4
// Add an AMO Minter
function addAMOMinter(address amo_minter_addr) external onlyByOwnGov {
        require(amo_minter_addr != address(0), "Zero address detected");

        // Make sure the AMO Minter has collatDollarBalance()
        uint256 collat_val_e18 = IFraxAMOMinter(amo_minter_addr).collatDollarBalance();
        require(collat_val_e18 >= 0, "Invalid AMO");

        amo_minter_addresses[amo_minter_addr] = true;

        emit AMOMinterAdded(amo_minter_addr);
    }
// Solidity 0.8.4
// Set the Chainlink oracles
function setOracles(address _frax_usd_chainlink_addr, address _fxs_usd_chainlink_addr) external onlyByOwnGov {
        // Set the instances
        priceFeedFRAXUSD = AggregatorV3Interface(_frax_usd_chainlink_addr);
        priceFeedFXSUSD = AggregatorV3Interface(_fxs_usd_chainlink_addr);

        // Set the decimals
        chainlink_frax_usd_decimals = priceFeedFRAXUSD.decimals();
        chainlink_fxs_usd_decimals = priceFeedFXSUSD.decimals();
        
        emit OraclesSet(_frax_usd_chainlink_addr, _fxs_usd_chainlink_addr);
    }
// Solidity 0.8.3
/**
 * @notice Migrate assets to a new contract
 * @dev The caller has to set the addresses list since we don't maintain a list of them
 * @param _assets List of assets' address to transfer from
 * @param _to Assets recipient
 */
function migrateAssets(address[] memory _assets, address _to) external onlyGovernor {
        require(_assets.length > 0, "assets-list-is-empty");
        require(_to != address(this), "new-contract-is-invalid");

        for (uint256 i = 0; i < _assets.length; ++i) {
            IERC20 _asset = IERC20(_assets[i]);
            uint256 _balance = _asset.balanceOf(address(this));
            _asset.safeTransfer(_to, _balance);
            emit MigratedAsset(_asset, _balance);
        }
    }
// Solidity 0.8.3
///////////////////////////// Only Keeper ///////////////////////////////
/// @notice Perform a slippage-protected swap for VSP
/// @dev The vVVSP is the beneficiary of the swap
/// @dev Have to check allowance to routers before calling this
function swapForVspAndTransferToVVSP(address _tokenIn, uint256 _amountIn) external onlyKeeper {
        if (_amountIn > 0) {
            uint256 _minAmtOut =
                (swapSlippage != 10000)
                    ? _calcAmtOutAfterSlippage(
                        _getOracleRate(_simpleOraclePath(_tokenIn, address(vsp)), _amountIn),
                        swapSlippage
                    )
                    : 1;
            _safeSwap(_tokenIn, address(vsp), _amountIn, _minAmtOut, address(vVSP));
        }
    }
// Solidity 0.6.12
// called when minting many NFTs
// updated_amount = (balanceOG(user) * base_rate * delta / 86400) + amount * initial rate
function updateRewardOnMint(address _user, uint256 _amount) external {
		require(msg.sender == address(kongzContract), "Can't call this");
		uint256 time = min(block.timestamp, END);
		uint256 timerUser = lastUpdate[_user];
		if (timerUser > 0)
			rewards[_user] = rewards[_user].add(kongzContract.balanceOG(_user).mul(BASE_RATE.mul((time.sub(timerUser)))).div(86400)
				.add(_amount.mul(INITIAL_ISSUANCE)));
		else 
			rewards[_user] = rewards[_user].add(_amount.mul(INITIAL_ISSUANCE));
		lastUpdate[_user] = time;
	}
// Solidity 0.6.12
// called on transfers
function updateReward(address _from, address _to, uint256 _tokenId) external {
		require(msg.sender == address(kongzContract));
		if (_tokenId < 1001) {
			uint256 time = min(block.timestamp, END);
			uint256 timerFrom = lastUpdate[_from];
			if (timerFrom > 0)
				rewards[_from] += kongzContract.balanceOG(_from).mul(BASE_RATE.mul((time.sub(timerFrom)))).div(86400);
			if (timerFrom != END)
				lastUpdate[_from] = time;
			if (_to != address(0)) {
				uint256 timerTo = lastUpdate[_to];
				if (timerTo > 0)
					rewards[_to] += kongzContract.balanceOG(_to).mul(BASE_RATE.mul((time.sub(timerTo)))).div(86400);
				if (timerTo != END)
					lastUpdate[_to] = time;
			}
		}
	}
// Solidity 0.8.0
/**
 * @dev Virtual implementation of the vesting formula. This returns the amout vested, as a function of time, for
 * an asset given its total historical allocation.
 */
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual returns (uint256) {
        if (timestamp < start()) {
            return 0;
        } else if (timestamp > start() + duration()) {
            return totalAllocation;
        } else {
            return (totalAllocation * (timestamp - start())) / duration();
        }
    }
// Solidity 0.8.3
/**
 * @notice Safe swap via Uniswap / Sushiswap (better rate of the two)
 * @dev There are many scenarios when token swap via Uniswap can fail, so this
 * method will wrap Uniswap call in a 'try catch' to make it fail safe.
 * however, this method will throw minAmountOut is not met
 * @param _tokenIn address of from token
 * @param _tokenOut address of to token
 * @param _amountIn Amount to be swapped
 * @param _minAmountOut minimum amount out
 */
function _safeSwap(
        address _tokenIn,
        address _tokenOut,
        uint256 _amountIn,
        uint256 _minAmountOut,
        address _to
    ) internal {
        (address[] memory path, uint256 amountOut, uint256 rIdx) =
            swapManager.bestOutputFixedInput(_tokenIn, _tokenOut, _amountIn);
        if (_minAmountOut == 0) _minAmountOut = 1;
        if (amountOut != 0) {
            swapManager.ROUTERS(rIdx).swapExactTokensForTokens(_amountIn, _minAmountOut, path, _to, block.timestamp);
        }
    }
// Solidity 0.7.6
/// @dev Return the usd price of asset. mutilpled by 1e18
/// @param _asset The address of asset
function price(address _asset) public view override returns (uint256) {
    AggregatorV3Interface _feed = feeds[_asset];
    require(address(_feed) != address(0), "ChainlinkPriceOracle: not supported");

    uint8 _decimals = _feed.decimals();
    (, int256 _price, , , ) = _feed.latestRoundData();
    return uint256(_price).mul(1e18).div(10**_decimals);
  }
// Solidity 0.8.7
/**
 * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
 * defined by `root`. For this, a `proof` must be provided, containing
 * sibling hashes on the branch from the leaf to the root of the tree. Each
 * pair of leaves and each pair of pre-images are assumed to be sorted.
 */
function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool, uint256) {
        bytes32 computedHash = leaf;
        uint256 index = 0;

        for (uint256 i = 0; i < proof.length; i++) {
            index *= 2;
            bytes32 proofElement = proof[i];

            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
                index += 1;
            }
        }

        // Check if the computed hash (root) is equal to the provided root
        return (computedHash == root, index);
    }
// Solidity 0.4.12
// privileged transfer
function transferPrivileged(address _to, uint _value) onlyPayloadSize(2 * 32) returns (bool success) {
    if (msg.sender != owner) throw;
    balances[msg.sender] = safeSub(balances[msg.sender], _value);
    balances[_to] = safeAdd(balances[_to], _value);
    previligedBalances[_to] = safeAdd(previligedBalances[_to], _value);
    Transfer(msg.sender, _to, _value);
    return true;
  }
// Solidity 0.4.12
// admin only can transfer from the privileged accounts
function transferFromPrivileged(address _from, address _to, uint _value) returns (bool success) {
    if (msg.sender != owner) throw;

    uint availablePrevilegedBalance = previligedBalances[_from];

    balances[_from] = safeSub(balances[_from], _value);
    balances[_to] = safeAdd(balances[_to], _value);
    previligedBalances[_from] = safeSub(availablePrevilegedBalance, _value);
    Transfer(_from, _to, _value);
    return true;
  }
// Solidity 0.5.16
// When is the address's next reward going to become unstakable? 
function nextRewardApplicableTime(address account) external view returns (uint256) {
        require(_stakedTime[account] != 0, "You dont have a stake in progress");
        require(_stakedTime[account] <= getTime(), "Your stake takes 24 hours to become available to interact with");
        uint256 secondsRemaining = (getTime() - _stakedTime[account]).mod(rewardInterval);
        return secondsRemaining;
    }
// Solidity 0.5.16
// ------ FUNCTION -------
// 
//  STAKE ()
// 
//      #require() amount is greater than ZERO
//      #require() address that is staking is not the contract address
// 
//      Insert : token balance to user stakedBalances[address]
//      Insert : current block timestamp timestamp to stakeTime[address]
//      Add : token balance to total supply
//      Transfer : token balance from user to this contract
// 
//  EXIT
//  
function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) {
        
        require(amount > 0, "Cannot stake 0");
        uint256 newStakedBalance = _stakedBalance[msg.sender].add(amount);
        require(newStakedBalance >= minStakeBalance, "Staked balance is less than minimum stake balance");
        uint256 currentTimestamp = getTime();
        _stakedBalance[msg.sender] = newStakedBalance;
        _stakedTime[msg.sender] = currentTimestamp;
        _totalSupply = _totalSupply.add(amount);


        // 
            if (_addressToIndex[msg.sender] > 0) {
               
            } else {
                allAddress.push(msg.sender);
                uint256 index = allAddress.length;
                _addressToIndex[msg.sender] = index;
            }
        // 

        stakingToken.safeTransferFrom(msg.sender, address(this), amount);
        emit Staked(msg.sender, amount);
    }
// Solidity 0.5.16
// Allows user to unstake tokens without (or with partial) rewards in case of empty reward distribution pool
function exit() public {
        uint256 reward = Math.min(earned(msg.sender), rewardDistributorBalance);
        require(reward > 0 || _rewardBalance[msg.sender] > 0 || _stakedBalance[msg.sender] > 0, "No tokens to exit");
        _addReward(msg.sender, reward);
        _stakedTime[msg.sender] = 0;
        if (_rewardBalance[msg.sender] > 0) withdrawReward();
        if (_stakedBalance[msg.sender] > 0) _unstake(msg.sender, _stakedBalance[msg.sender]);
    }
// Solidity 0.5.16
// ------ FUNCTION -------
// 
//   WITHDRAW UNSTAKED BALANCE (uint256 amount) 
// 
//      updateReward()
//  
//      #require() that the amount of tokens specified to unstake is above ZERO    
//      #require() that the user has a current unstakingBalance[address] above amount specified to withdraw
//      #require() that the current block time is greater than their unstaking end date (their unstaking or vesting period has finished)
//   
//      MODIFY :  _unstakingBalance[address] to  _unstakingBalance[address] minus amount
//      MODIFY : _totalSupply to _totalSupply[address] minus amount
//      
//      TRANSFER : amount to address that called the function
// 
//   
//   EXIT
//  
function withdrawUnstakedBalance(uint256 amount) public nonReentrant updateReward(msg.sender) {

        require(amount > 0, "Account does not have an unstaking balance");
        require(_unstakingBalance[msg.sender] >= amount, "Account does not have that much balance unstaked");
        require(_unstakingTime[msg.sender] <= getTime(), "Unstaking period has not finished yet");

         _unstakingBalance[msg.sender] =  _unstakingBalance[msg.sender].sub(amount);
        _totalSupply = _totalSupply.sub(amount);

        stakingToken.safeTransfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);
    }
// Solidity 0.5.16
// ------ FUNCTION -------
// 
//   WITHDRAW REWARD ()
// 
//      updateReward()
//  
//      #require() that the reward balance of the user is above ZERO
//   
//      TRANSFER : transfer reward balance to address that called the function
// 
//      MODIFY : update rewardBalance to ZERO
//   
//   EXIT
//  
function withdrawReward() public updateReward(msg.sender) {
        uint256 reward = _rewardBalance[msg.sender];
        require(reward > 0, "You have not earned any rewards yet");
        _rewardBalance[msg.sender] = 0;
        _unstakingBalance[msg.sender] = _unstakingBalance[msg.sender].add(reward);
        _unstakingTime[msg.sender] = getTime() + unstakingInterval;
        emit RewardWithdrawn(msg.sender, reward);
    }
// Solidity 0.5.16
// ------ FUNCTION -------
// 
//   REMOVE REWARD SUPPLY | ONLY OWNER
// 
//      #require() that the amount of tokens being removed is above ZERO
//      #require() that the amount is equal to or below the rewardDistributorBalance
//      #require() that the amount is equal to or below the totalSupply of tokens in the contract
//  
//      TRANSFER: amount of tokens from contract
//  
//      MODIFY : update rewardDistributorBalance = rewardDistributorBalance - amount
//      MODIFY : update _totalSupply = _totalSupply - amount
//   
//   EXIT
//  
function removeRewardSupply(uint256 amount) external onlyOwner nonReentrant {
        require(amount > 0, "Cannot withdraw 0");
        require(amount <= rewardDistributorBalance, "rewardDistributorBalance has less tokens than requested");
        require(amount <= _totalSupply, "Amount is greater that total supply");
        stakingToken.safeTransfer(owner, amount);
        rewardDistributorBalance = rewardDistributorBalance.sub(amount);
        _totalSupply = _totalSupply.sub(amount);
    }
// Solidity 0.4.25
//--------------------------------------------------------------------------
// BOOSTER 
//--------------------------------------------------------------------------
function buyBooster(uint256 idx) public payable 
    {
        require(idx < numberOfBoosts);
        BoostData storage b = boostData[idx];

        if (msg.value < b.basePrice || msg.sender == b.owner) revert();
        
        address beneficiary = b.owner;
        uint256 devFeePrize = devFee(b.basePrice);
        
        distributedToOwner(devFeePrize);
        addMiningWarPrizePool(devFeePrize);
        addPrizePool(SafeMath.sub(msg.value, SafeMath.mul(devFeePrize,3)));
        
        updateVirus(msg.sender);

        if ( beneficiary != 0x0 ) updateVirus(beneficiary);
        
        // transfer ownership    
        b.owner = msg.sender;

        emit BuyBooster(msg.sender, idx, beneficiary );
    }
// Solidity 0.4.25
/**
 * @dev subtract virus of player
 * @param _addr player address 
 * @param _value number virus subtract 
 */
function subVirus(address _addr, uint256 _value) public onlyContractsMiniGame
    {
        updateVirus(_addr);

        Player storage p = players[_addr];
        
        uint256 subtractVirus = SafeMath.mul(_value,VIRUS_MINING_PERIOD);
        
        if ( p.virusNumber < subtractVirus ) { revert(); }

        p.virusNumber = SafeMath.sub(p.virusNumber, subtractVirus);

        emit ChangeVirus(_addr, _value, 2);
    }
// Solidity 0.4.25
/**
 * @dev get player data
 * @param _addr player address
 */
function getPlayerData(address _addr) 
    public 
    view 
    returns(
        uint256 _virusNumber, 
        uint256 _currentVirus,
        uint256 _research, 
        uint256 _researchPerDay, 
        uint256 _lastUpdateTime, 
        uint256[8] _engineersCount
    )
    {
        Player storage p = players[_addr];
        for ( uint256 idx = 0; idx < numberOfEngineer; idx++ ) {
            _engineersCount[idx] = p.engineersCount[idx];
        }
        _currentVirus= SafeMath.div(calCurrentVirus(_addr), VIRUS_MINING_PERIOD);
        _virusNumber = SafeMath.div(p.virusNumber, VIRUS_MINING_PERIOD);
        _lastUpdateTime = p.lastUpdateTime;
        _research = p.research;
        _researchPerDay = getResearchPerDay(_addr);
    }