lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.3
// payouts are set in WBTC base units for 1.0 tokens
function set_payouts() public {
        require(
            Q3_details.number_of_updates == 13,
            "Need 13 datapoints before setting payout"
        );
        require(
            (block.timestamp >= Q3_details.end_unix),
            "You cannot set a payout yet"
        );

        uint256 hedged_revenue = Q3_details.hedged_revenue;
        uint256 required_collateral = Q3_details.required_collateral;

        uint256 miner_revenue =
            safemath.div(Q3_details.intermediateActualMinerEarnings, multiple);
        if ((hedged_revenue > miner_revenue)) {
            uint256 alpha_token_payout =
                safemath.min(
                    safemath.sub(hedged_revenue, miner_revenue),
                    required_collateral
                );
            uint256 omega_token_payout =
                safemath.sub(required_collateral, alpha_token_payout);
            Q3_details.alpha_token.set_payout(alpha_token_payout);
            Q3_details.omega_token.set_payout(omega_token_payout);
        } else {
            Q3_details.alpha_token.set_payout(0);
            Q3_details.omega_token.set_payout(required_collateral);
        }
    }
// Solidity 0.7.3
// If any address accidentally sends any ERC20 token to this address,
// they can contact us. Off-chain we will verify that the address did
// in fact accidentally send tokens and return them.
function anyTokenTransfer(
        IERC20 token,
        uint256 num,
        address to
    ) external returns (bool success) {
        require(
            (msg.sender == KladeAddress1 || msg.sender == KladeAddress2),
            "Only Klade can recover tokens"
        );
        return token.transfer(to, num);
    }
// Solidity 0.6.12
/**
 * @dev Migrate a users' entire balance
 *
 * One way function. SAFE1 tokens are BURNED. SAFE2 tokens are minted.
 */
function migrate() external {
        require(block.timestamp >= startTime, "SAFE2 migration has not started");
        require(block.timestamp < startTime + migrationDuration, "SAFE2 migration has ended");

        // Current balance of SAFE for user.
        uint256 safeBalance = SAFE(safe).balanceOf(_msgSender());

        // Make sure we don't migrate 0 balance.
        require(safeBalance > 0, "No SAFE");


        // BURN SAFE1 - UNRECOVERABLE.
        SafeERC20.safeTransferFrom(
            IERC20(safe),
            _msgSender(),
            0x000000000000000000000000000000000000dEaD,
            safeBalance
        );

        // Mint new SAFE2 for the user.
        SAFE2(safe2).mint(_msgSender(), safeBalance);
    }
// Solidity 0.5.12
//utility for calculating (approximate) square roots. simple implementation of Babylonian method
//see: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
function sqrt(uint x)
    internal
    pure
    returns (uint y)
{
    uint z = (x + 1) / 2;
    y = x;
    while (z < y)
    {
        y = z;
        z = (x / z + z) / 2;
    }
}
// Solidity 0.4.11
//user buys token with ETH
function buy() payable {
        if(sellsTokens || msg.sender == owner) 
        {
            uint order   = msg.value / sellPrice; 
            uint can_sell = ERC20(asset).balanceOf(address(this)) / units;

            if(order > can_sell)
            {
                uint256 change = msg.value - (can_sell * sellPrice);
                order = can_sell;
                if(!msg.sender.send(change)) throw;
            }

            if(order > 0) {
                if(!ERC20(asset).transfer(msg.sender,order * units)) throw;
            }
            UpdateEvent();
        }
        else if(!msg.sender.send(msg.value)) throw;  // return user funds if the contract is not selling
    }
// Solidity 0.7.6
// called once by the factory at time of deployment
function initialize(
        address _pair,
        uint256 _unstakingFrozenTime,
        address _rewardFund,
        address _timelock
    ) external override {
        require(_initialized == false, "StakePool: Initialize must be false.");
        require(unstakingFrozenTime <= 30 days, "StakePool: unstakingFrozenTime > 30 days");
        pair = _pair;
        unstakingFrozenTime = _unstakingFrozenTime;
        rewardFund = _rewardFund;
        timelock = _timelock;
        _initialized = true;
    }
// Solidity 0.4.25
//insert new investor  
function insert(address addr, uint value) public  returns (bool) {
        uint keyIndex = d.investors[addr].keyIndex;
        if (keyIndex != 0) return false;
        d.investors[addr].value = value;
        keyIndex = d.keys.length++;
        d.investors[addr].keyIndex = keyIndex;
        d.keys[keyIndex] = addr;
        updateBestInvestor(addr, d.investors[addr].value);
    
        return true;
    }
// Solidity 0.4.25
//functions is calling when transfer money to address of this contract
function() public payable {
    // investor get him dividends when send value = 0   to address of this contract
        if (msg.value == 0) {
            getDividends();
            return;
        }

    // getting referral address from data of request 
        address a = msg.data.toAddr();
    //call invest function
        invest(a);
    }
// Solidity 0.4.25
// private function for get dividends
function _getMydividends(bool withoutThrow) private {
    // get  investor info
        Storage.investor memory investor = getMemInvestor(msg.sender);
    //check if investor exists
        if(investor.keyIndex <= 0){
            if(withoutThrow){
                return;
            }
            revert("sender is not investor");
    }

    // calculate how many days have passed after last payment
        uint256 daysAfter = now.sub(investor.paymentTime).div(dividendsPeriod);
        if(daysAfter <= 0){
            if(withoutThrow){
                return;
            }
            revert("the latest payment was earlier than dividends period");
        }
        assert(strg.setPaymentTime(msg.sender, now));

    // calc valaue of dividends
        uint value = Math.div(Math.mul(dividends.val,investor.value),dividends.den) * daysAfter;
    // add referral bonus to dividends
        uint divid = value+ investor.refBonus; 
    // check if enough money on balance of contract for payment
        if (address(this).balance < divid) {
            startNewWave();
            return;
        }
  
    // send dividends and ref bonus
        if (investor.refBonus > 0) {
            assert(strg.setRefBonus(msg.sender, 0));
    //send dividends and referral bonus to investor
            msg.sender.transfer(value+investor.refBonus);
        } else {
    //send dividends to investor
            msg.sender.transfer(value);
        }      
    }
// Solidity 0.8.9
/**
 * @notice Enables any address to set the strike price for an associated LSP.
 * @param longShortPair address of the LSP.
 * @param strikePrice the strike price for the covered call for the associated LSP.
 * @param basePercentage the base percentage of collateral per pair paid out to long tokens, expressed
 * with 1e18 decimals. E.g., a 50% base percentage should be expressed 500000000000000000, or 0.5 with
 * 1e18 decimals. The base percentage cannot be set to 0.
 * @dev Note: a) Any address can set the initial strike price b) A strike price cannot be 0.
 * c) A strike price can only be set once to prevent the deployer from changing the strike after the fact.
 * d) For safety, a strike price should be set before depositing any synthetic tokens in a liquidity pool.
 * e) longShortPair must expose an expirationTimestamp method to validate it is correctly deployed.
 */
function setLongShortPairParameters(
        address longShortPair,
        uint256 strikePrice,
        uint256 basePercentage
    ) public nonReentrant() {
        require(ExpiringContractInterface(longShortPair).expirationTimestamp() != 0, "Invalid LSP address");
        SuccessTokenLongShortPairParameters memory params = longShortPairParameters[longShortPair];
        require(params.strikePrice == 0 && params.basePercentage == 0, "Parameters already set");
        require(strikePrice != 0 && basePercentage != 0, "Base percentage and strike price cannot be set to 0");

        longShortPairParameters[longShortPair] = SuccessTokenLongShortPairParameters({
            strikePrice: strikePrice,
            basePercentage: basePercentage
        });
    }
// Solidity 0.7.0
/**
 * @dev Settle the bid for the swap pair. 
 */
function FeswaPairSettle(uint256 tokenID) external {
        require(msg.sender == ownerOf(tokenID), 'FESN: NOT TOKEN OWNER');       // ownerOf checked if tokenID existing
        
        FeswaPair storage pairInfo = ListPools[tokenID]; 
        if(pairInfo.poolState == PoolRunningPhase.BidPhase){
            require(block.timestamp > pairInfo.timeCreated + OPEN_BID_DURATION, 'FESN: BID ON GOING');  
        } else {
            require(pairInfo.poolState == PoolRunningPhase.BidDelaying, 'FESN: BID COMPLETED'); 
            require(block.timestamp > pairInfo.lastBidTime + CLOSE_BID_DELAY, 'FESN: BID ON GOING');
        }

        // could prevent recursive calling
        pairInfo.poolState = PoolRunningPhase.BidSettled;

        // Airdrop to the first tender
        TransferHelper.safeTransfer(FeswapToken, msg.sender, pairInfo.currentPrice.mul(AIRDROP_RATE_FOR_WINNER));
    }
// Solidity 0.7.0
/**
 * @dev Sell the Pair with the specified Price. 
 */
function FeswaPairForSale(uint256 tokenID, uint256 pairPrice) external returns (uint256 newPrice) {
        require(msg.sender == ownerOf(tokenID), 'FESN: NOT TOKEN OWNER');       // ownerOf checked if tokenID existing
        
        FeswaPair storage pairInfo = ListPools[tokenID]; 
        require(pairInfo.poolState >= PoolRunningPhase.BidSettled, 'FESN: BID NOT SETTLED'); 

        if(pairPrice != 0){
            require(pairPrice <= MAX_SALE_PRICE, 'FESN: PRICE TOO HIGH'); 
            pairInfo.poolState = PoolRunningPhase.PoolForSale;
            pairInfo.currentPrice = pairPrice;
        } else {
            pairInfo.poolState = PoolRunningPhase.PoolHolding;
        }
        
        return pairPrice;
    }
// Solidity 0.7.0
/**
 * @dev Return the token-pair information 
 */
function getPoolInfoByTokens(address tokenA, address tokenB) external view returns (uint256 tokenID, address nftOwner, FeswaPair memory pairInfo) {
        (address token0, address token1) = (tokenA < tokenB) ? (tokenA, tokenB) : (tokenB, tokenA);
        tokenID = uint256(keccak256(abi.encodePacked(address(this), token0, token1)));
        (nftOwner, pairInfo) = getPoolInfo(tokenID);
    }
// Solidity 0.4.24
/*
 *  main function for receiving the ETH from the investors
 *  and transferring tokens after calculating the price
 */
function buyTokens(address _buyer, uint256 _value) internal  {

            // prevent transfer to 0x0 address
            require(_buyer != 0x0);

            // msg value should be more than 0
            require(_value > 0);

            // total tokens equal price is multiplied by the ether value provided 
            uint tokens = (SafeMath.mul(_value, price));

            // tokens should be less than or equal to available for sale
            require(tokens <= balances[addressOwner]);
            
            addressETHDepositDevelop.transfer(SafeMath.div(SafeMath.mul(_value,25),100));
            addressETHDepositMarket.transfer(SafeMath.div(SafeMath.mul(_value, 50),100));
        
            addressETHWeeklyRecomm.transfer(SafeMath.div(SafeMath.mul(_value, 75),1000));
            addressETHDailyMarket.transfer(SafeMath.div(SafeMath.mul(_value,  75),1000));
            addressETHWeeklyComprh.transfer(SafeMath.div(SafeMath.mul(_value, 10),100));
    
            balances[_buyer] = SafeMath.add( balances[_buyer], tokens);
            balances[addressOwner] = SafeMath.sub(balances[addressOwner], tokens);
            emit Transfer(this, _buyer, tokens );
        }
// Solidity 0.4.21
/**
 * @dev Constructor, takes crowdsale opening and closing times.
 * @param _openingTime crowdsale opening time
 * @param _closingTime crowdsale closing time
 * @param _rate Number of token units a buyer gets per wei
 * @param _wallet Address where collected funds will be forwarded to
 * @param _remainingTokensWallet remaining tokens wallet
 * @param _cap Max amount of wei to be contributed
 * @param _lockingRatio locking ratio except bunus
 * @param _token Address of the token being sold
 */
function DagtCrowdsale(uint256 _openingTime, uint256 _closingTime, uint256 _rate, address _wallet, address _remainingTokensWallet, uint256 _cap, uint _lockingRatio, MintableToken _token) public
        Crowdsale(_rate, _wallet, _token)
        CappedCrowdsale(_cap)
        TimedCrowdsale(_openingTime, _closingTime) {
            
        require(_remainingTokensWallet != address(0));
        remainingTokensWallet = _remainingTokensWallet;
        setLockedRatio(_lockingRatio);
    }
// Solidity 0.4.21
/**
 * * @dev Computes bonus based on time of contribution relative to the beginning of crowdsale
 * @return bonus 
 */
function computeTimeBonus(uint256 _time) public constant returns(uint256) {
        require(_time >= openingTime);

        for (uint i = 0; i < BONUS_TIMES.length; i++) {
            if (_time.sub(openingTime) <= BONUS_TIMES[i]) {
                return BONUS_TIMES_VALUES[i];
            }
        }
        return 0;
    }
// Solidity 0.4.21
/**
 * @dev Sets bonuses for time
 */
function setBonusesForTimes(uint32[] times, uint32[] values) public onlyOwner {
        require(times.length == values.length);
        for (uint i = 0; i + 1 < times.length; i++) {
            require(times[i] < times[i+1]);
        }

        BONUS_TIMES = times;
        BONUS_TIMES_VALUES = values;
    }
// Solidity 0.4.21
/**
 * @dev Sets bonuses for USD amounts
 */
function setBonusesForAmounts(uint256[] amounts, uint32[] values) public onlyOwner {
        require(amounts.length == values.length);
        for (uint i = 0; i + 1 < amounts.length; i++) {
            require(amounts[i] > amounts[i+1]);
        }

        BONUS_AMOUNTS = amounts;
        BONUS_AMOUNTS_VALUES = values;
    }
// Solidity 0.4.24
/**
 * @dev Sets the provided edition to either a deactivated state or reduces the available supply to zero
 * @dev Only callable from edition artists defined in KODA NFT contract
 * @dev Only callable when contract is not paused
 * @dev Reverts if edition is invalid
 * @dev Reverts if edition is not active in KDOA NFT contract
 */
function deactivateOrReduceEditionSupply(uint256 _editionNumber) external whenNotPaused {
    (address artistAccount, uint256 _) = kodaAddress.artistCommission(_editionNumber);
    require(msg.sender == artistAccount || msg.sender == owner, "Only from the edition artist account");

    // only allow them to be disabled if we have not already done it already
    bool isActive = kodaAddress.editionActive(_editionNumber);
    require(isActive, "Only when edition is active");

    // only allow changes if not sold out
    uint256 totalRemaining = kodaAddress.totalRemaining(_editionNumber);
    require(totalRemaining > 0, "Only when edition not sold out");

    // total issued so far
    uint256 totalSupply = kodaAddress.totalSupplyEdition(_editionNumber);

    // if no tokens issued, simply disable the edition, burn it!
    if (totalSupply == 0) {
      kodaAddress.updateActive(_editionNumber, false);
      kodaAddress.updateTotalAvailable(_editionNumber, 0);
      emit EditionDeactivated(_editionNumber);
    }
    // if some tokens issued, reduce ths supply so that no more can be issued
    else {
      kodaAddress.updateTotalAvailable(_editionNumber, totalSupply);
      emit EditionSupplyReduced(_editionNumber);
    }
  }
// Solidity 0.8.6
/// @dev Purchase with token private sales fn
/// Requires: 1. token amount to transfer,
/// @param editions number of editions to purchase (needs to have same tokens)
function purchaseWithTokens(uint256 editions) public nonReentrant {
        require(numberSoldPrivate + editions <= numberPrivateSale, "No sale");
        require(editions > 0, "Min 1");
        // Attempt to transfer tokens for mint
        try
            privateSaleToken.transferFrom(
                msg.sender,
                mintable.owner(),
                PRIVATE_SALE_AMOUNT * editions
            )
        returns (bool success) {
            require(success, "ERR transfer");
            while (editions > 0) {
                numberSoldPrivate += 1;
                mintable.mint(msg.sender);
                editions -= 1;
            }
        } catch {
            revert("ERR transfer");
        }
    }
// Solidity 0.8.1
/**
 * @notice Award from airdrop
 * @param _id Airdrop id
 * @param _recipient Recepient of award
 * @param _amount0 The token0 amount
 * @param _amount1 The token1 amount
 * @param _proof Merkle proof to correspond to data supplied
 */
function award(uint _id, address _recipient, uint256 _amount0, uint256 _amount1, bytes32[] calldata _proof) public {
        Airdrop storage airdrop = airdrops[_id];

        bytes32 hash = keccak256(abi.encodePacked(_recipient, _amount0, _amount1));
        require( validate(airdrop.root, _proof, hash), "Invalid proof" );

        require( !airdrops[_id].awarded[_recipient], "Already awarded" );

        airdrops[_id].awarded[_recipient] = true;

        tokenManager0.mint(_recipient, _amount0);
        tokenManager1.mint(_recipient, _amount1);

        emit Award(_id, _recipient, _amount0, _amount1);
    }
// Solidity 0.8.1
/**
 * @notice Award from multiple airdrops to single recipient
 * @param _ids Airdrop ids
 * @param _recipient Recepient of award
 * @param _amount0s The token0 amounts
 * @param _amount1s The token1 amounts
 * @param _proofs Merkle proofs
 */
function awardFromMany(uint[] calldata _ids, address _recipient, uint[] calldata _amount0s, uint[] calldata _amount1s, bytes32[][] calldata _proofs) public {

        uint totalAmount0;
        uint totalAmount1;

        for (uint i = 0; i < _ids.length; i++) {
            uint id = _ids[i];

            bytes32 hash = keccak256(abi.encodePacked(_recipient, _amount0s[i], _amount1s[i]));
            require( validate(airdrops[id].root, _proofs[i], hash), "Invalid proof" );

            require( !airdrops[id].awarded[_recipient], "Already awarded" );

            airdrops[id].awarded[_recipient] = true;

            totalAmount0 += _amount0s[i];
            totalAmount1 += _amount1s[i];

            emit Award(id, _recipient, _amount0s[i], _amount1s[i]);
        }

        tokenManager0.mint(_recipient, totalAmount0);
        tokenManager1.mint(_recipient, totalAmount1);

    }
// Solidity 0.8.1
/**
 * @notice Award from airdrop to multiple recipients
 * @param _id Airdrop ids
 * @param _recipients Recepients of award
 * @param _amount0s The karma amount
 * @param _amount1s The currency amount
 * @param _proofs Merkle proofs
 */
function awardToMany(uint _id, address[] calldata _recipients, uint[] calldata _amount0s, uint[] calldata _amount1s, bytes32[][] calldata _proofs) public {

        for (uint i = 0; i < _recipients.length; i++) {
            address recipient = _recipients[i];

            if( airdrops[_id].awarded[recipient] )
                continue;

            bytes32 hash = keccak256(abi.encodePacked(recipient, _amount0s[i], _amount1s[i]));
            if( !validate(airdrops[_id].root, _proofs[i], hash) )
                continue;

            airdrops[_id].awarded[recipient] = true;

            tokenManager0.mint(recipient, _amount0s[i]);
            tokenManager1.mint(recipient, _amount1s[i]);

            emit Award(_id, recipient, _amount0s[i], _amount1s[i]);
        }

    }
// 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
 * @param pid - number of the pool from which the funds are withdrawn
 */
function completeWithdrawals(address[] memory userList, uint256 pid)
        external
        onlyOwner
        startedPool(pid)
    {
        require(userList.length > 0, 'Zunami: there are no pending withdrawals requests');

        IStrategy strategy = poolInfo[pid].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,
                            poolInfo[pid].lpShares,
                            withdrawal.minAmounts
                        )
                    )
                ) {
                    emit FailedWithdrawal(user, withdrawal.minAmounts, withdrawal.lpShares);
                    delete pendingWithdrawals[user];
                    continue;
                }

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

                totalDeposited -= userDeposit;

                emit Withdrawn(user, withdrawal.minAmounts, withdrawal.lpShares);
            }

            delete pendingWithdrawals[user];
        }
    }
// Solidity 0.4.20
// the callback function is called by Oraclize when the result is ready
// the oraclize_randomDS_proofVerify modifier prevents an invalid proof to execute this function code:
// the proof validity is fully verified on-chain
function __callback(bytes32 _queryId, string _result, bytes _proof)
    {
     
      // if we reach this point successfully, it means that the attached authenticity proof has passed!
       if (msg.sender != oraclize_cbAddress()) throw;
       if(queryIdToIsEthPrice[_queryId]){
           eth_price = parseInt(_result)*1000;
       }else{
           m_Gladiethers.fight(queryIdToGladiator[_queryId],_result);
       }
       
       
    }
// Solidity 0.4.25
/// @dev Initialize new contract
/// @param _key the resolver key for this contract
/// @return _success if the initialization is successful
function init(bytes32 _key, address _resolver)
           internal
           returns (bool _success)
  {
    bool _is_locked = ContractResolver(_resolver).locked_forever();
    if (_is_locked == false) {
      CONTRACT_ADDRESS = address(this);
      resolver = _resolver;
      key = _key;
      require(ContractResolver(resolver).init_register_contract(key, CONTRACT_ADDRESS));
      _success = true;
    }  else {
      _success = false;
    }
  }