lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.18
/// @notice Withdraw ether owed to a beneficiary.
/// @param beneficiary The address to withdraw the auction balance for.
function withdrawAuctionBalance(address beneficiary) external {
        // The sender must either be the beneficiary or the core deed contract.
        require(
            msg.sender == beneficiary ||
            msg.sender == address(deedContract)
        );
        
        uint256 etherOwed = addressToEtherOwed[beneficiary];
        
        // Ensure ether is owed to the beneficiary.
        require(etherOwed > 0);
         
        // Set ether owed to 0   
        delete addressToEtherOwed[beneficiary];
        
        // Subtract from total outstanding balance. etherOwed is guaranteed
        // to be less than or equal to outstandingEther, so this cannot
        // underflow.
        outstandingEther -= etherOwed;
        
        // Transfer ether owed to the beneficiary (not susceptible to re-entry
        // attack, as the ether owed is set to 0 before the transfer takes place).
        beneficiary.transfer(etherOwed);
    }
// Solidity 0.4.18
/// @notice Withdraw (unowed) contract balance.
function withdrawFreeBalance() external {
        // Calculate the free (unowed) balance. This never underflows, as
        // outstandingEther is guaranteed to be less than or equal to the
        // contract balance.
        uint256 freeBalance = this.balance - outstandingEther;
        
        address deedContractAddress = address(deedContract);

        require(
            msg.sender == owner ||
            msg.sender == deedContractAddress
        );
        
        deedContractAddress.transfer(freeBalance);
    }
// Solidity 0.4.18
/// @notice Create an auction for a given deed. Be careful when calling
/// createAuction for a RentAuction, that this overloaded function (including
/// the _rentPeriod parameter) is used. Otherwise the rent period defaults to
/// a week.
/// Must previously have been given approval to take ownership of the deed.
/// @param _deedId The identifier of the deed to create an auction for.
/// @param _startPrice The starting price of the auction.
/// @param _endPrice The ending price of the auction.
/// @param _duration The duration in seconds of the dynamic pricing part of the auction.
/// @param _rentPeriod The rent period in seconds being auctioned.
function createAuction(
        uint256 _deedId,
        uint256 _startPrice,
        uint256 _endPrice,
        uint256 _duration,
        uint256 _rentPeriod
    )
        external
    {
        // Require the rent period to be at least one hour.
        require(_rentPeriod >= 3600);
        
        // Require there to be no active renter.
        DWorldRenting dWorldRentingContract = DWorldRenting(deedContract);
        var (renter,) = dWorldRentingContract.renterOf(_deedId);
        require(renter == address(0));
    
        // Set the rent period.
        identifierToRentPeriod[_deedId] = _rentPeriod;
    
        // Throws (reverts) if creating the auction fails.
        createAuction(_deedId, _startPrice, _endPrice, _duration);
    }
// Solidity 0.4.18
/// @dev Perform the bid win logic (in this case: give renter status to the winner).
/// @param _seller The address of the seller.
/// @param _winner The address of the winner.
/// @param _deedId The identifier of the deed.
/// @param _price The price the auction was bought at.
function _winBid(address _seller, address _winner, uint256 _deedId, uint256 _price) internal {
        DWorldRenting dWorldRentingContract = DWorldRenting(deedContract);
    
        uint256 rentPeriod = identifierToRentPeriod[_deedId];
        if (rentPeriod == 0) {
            rentPeriod = 604800; // 1 week by default
        }
    
        // Rent the deed out to the winner.
        dWorldRentingContract.rentOut(_winner, identifierToRentPeriod[_deedId], _deedId);
        
        // Transfer the deed back to the seller.
        _transfer(_seller, _deedId);
    }
// Solidity 0.4.18
/// @notice Create a sale auction.
/// @param _deedId The identifier of the deed to create a sale auction for.
/// @param _startPrice The starting price of the sale auction.
/// @param _endPrice The ending price of the sale auction.
/// @param _duration The duration in seconds of the dynamic pricing part of the sale auction.
function createSaleAuction(uint256 _deedId, uint256 _startPrice, uint256 _endPrice, uint256 _duration)
        external
        whenNotPaused
    {
        require(_owns(msg.sender, _deedId));
        
        // Prevent creating a sale auction if no sale auction contract is configured.
        require(address(saleAuctionContract) != address(0));
    
        // Approve the deed for transferring to the sale auction.
        _approve(msg.sender, address(saleAuctionContract), _deedId);
    
        // Auction contract checks input values (throws if invalid) and places the deed into escrow.
        saleAuctionContract.createAuction(_deedId, _startPrice, _endPrice, _duration);
    }
// Solidity 0.4.18
/// @notice Allow withdrawing balances from the auction contracts
/// in a single step.
function withdrawAuctionBalances() external {
        // Withdraw from the sale contract if the sender is owed Ether.
        if (saleAuctionContract.addressToEtherOwed(msg.sender) > 0) {
            saleAuctionContract.withdrawAuctionBalance(msg.sender);
        }
        
        // Withdraw from the rent contract if the sender is owed Ether.
        if (rentAuctionContract.addressToEtherOwed(msg.sender) > 0) {
            rentAuctionContract.withdrawAuctionBalance(msg.sender);
        }
    }
// Solidity 0.4.18
/// @notice Set the data associated with a plot.
function setPlotData(uint256 _deedId, string name, string description, string imageUrl, string infoUrl)
        public
        whenNotPaused
    {
        // The sender requesting the data update should be
        // the owner (without an active renter) or should
        // be the active renter.
        require(_owns(msg.sender, _deedId) && identifierToRentPeriodEndTimestamp[_deedId] < now || _rents(msg.sender, _deedId));
    
        // Set the data
        _setPlotData(_deedId, name, description, imageUrl, infoUrl);
    }
// Solidity 0.4.18
/// @notice Set the data associated with multiple plots.
function setPlotDataMultiple(uint256[] _deedIds, string name, string description, string imageUrl, string infoUrl)
        external
        whenNotPaused
    {
        for (uint256 i = 0; i < _deedIds.length; i++) {
            uint256 _deedId = _deedIds[i];
        
            setPlotData(_deedId, name, description, imageUrl, infoUrl);
        }
    }
// Solidity 0.5.11
/**
 * @dev Sets the values for `name` and `symbol`. Both of
 * these values are immutable: they can only be set once during
 * construction.
 */
function init(string memory name, string memory symbol, address _beneficiary) public {
    require(beneficiary == address(0), "Already initialized");

    _name = name;
    _symbol = symbol;

    // Set beneficiary
    require(_beneficiary != address(0), "Beneficiary can't be zero");
    beneficiary = _beneficiary;
    emit SetBeneficiary(address(0), _beneficiary);
    
    _transferOwnership(msg.sender);

    // Enter cDAI market
    Comptroller troll = Comptroller(COMPTROLLER_ADDRESS);
    address[] memory cTokens = new address[](1);
    cTokens[0] = CDAI_ADDRESS;
    uint[] memory errors = troll.enterMarkets(cTokens);
    require(errors[0] == 0, "Failed to enter cDAI market");
  }
// Solidity 0.5.11
// 10B tokens
function mintWithETH(PooledCDAI pcDAI, address to) public payable returns (bool) {
    // convert `msg.value` ETH to DAI
    ERC20 dai = ERC20(DAI_ADDRESS);
    (uint256 actualDAIAmount, uint256 actualETHAmount) = _kyberTrade(ETH_TOKEN_ADDRESS, msg.value, dai);

    // mint `actualDAIAmount` pcDAI
    _mint(pcDAI, to, actualDAIAmount);

    // return any leftover ETH
    if (actualETHAmount < msg.value) {
      msg.sender.transfer(msg.value.sub(actualETHAmount));
    }

    return true;
  }
// Solidity 0.5.11
/**
 * @notice Wrapper function for doing token conversion on Kyber Network
 * @param _srcToken the token to convert from
 * @param _srcAmount the amount of tokens to be converted
 * @param _destToken the destination token
 * @return _destPriceInSrc the price of the dest token, in terms of source tokens
 *         _srcPriceInDest the price of the source token, in terms of dest tokens
 *         _actualDestAmount actual amount of dest token traded
 *         _actualSrcAmount actual amount of src token traded
 */
function _kyberTrade(ERC20 _srcToken, uint256 _srcAmount, ERC20 _destToken)
    internal
    returns(
      uint256 _actualDestAmount,
      uint256 _actualSrcAmount
    )
  {
    // Get current rate & ensure token is listed on Kyber
    KyberNetworkProxy kyber = KyberNetworkProxy(KYBER_ADDRESS);
    (, uint256 rate) = kyber.getExpectedRate(_srcToken, _destToken, _srcAmount);
    require(rate > 0, "Price for token is 0 on Kyber");

    uint256 beforeSrcBalance = _getBalance(_srcToken, address(this));
    uint256 msgValue;
    if (_srcToken != ETH_TOKEN_ADDRESS) {
      msgValue = 0;
      _srcToken.safeApprove(KYBER_ADDRESS, 0);
      _srcToken.safeApprove(KYBER_ADDRESS, _srcAmount);
    } else {
      msgValue = _srcAmount;
    }
    _actualDestAmount = kyber.tradeWithHint.value(msgValue)(
      _srcToken,
      _srcAmount,
      _destToken,
      _toPayableAddr(address(this)),
      MAX_QTY,
      rate,
      0x8B2315243349f461045854beec3c5aFA84f600B6,
      PERM_HINT
    );
    require(_actualDestAmount > 0, "Received 0 dest token");
    if (_srcToken != ETH_TOKEN_ADDRESS) {
      _srcToken.safeApprove(KYBER_ADDRESS, 0);
    }

    _actualSrcAmount = beforeSrcBalance.sub(_getBalance(_srcToken, address(this)));
  }
// Solidity 0.6.7
/**
 * @notice Modify a uint256 parameter
 * @param parameter The parameter name
 * @param data The new parameter value
 **/
function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized {
        if (parameter == "openRefill") {
          require(data <= 1, "StakeRewardRefill/invalid-open-refill");
          openRefill = data;
        } else if (parameter == "lastRefillTime") {
          require(data >= lastRefillTime, "StakeRewardRefill/invalid-refill-time");
          lastRefillTime = data;
        } else if (parameter == "refillDelay") {
          require(data > 0, "StakeRewardRefill/null-refill-delay");
          refillDelay = data;
        } else if (parameter == "refillAmount") {
          require(data > 0, "StakeRewardRefill/null-refill-amount");
          refillAmount = data;
        }
        else revert("StakeRewardRefill/modify-unrecognized-param");
    }
// Solidity 0.6.7
/**
 * @notice Send tokens to refillDestination
 * @dev This function can only be called if msg.sender passes canRefill checks
 **/
function refill() external canRefill {
        uint256 delay = subtract(now, lastRefillTime);
        require(delay >= refillDelay, "StakeRewardRefill/wait-more");

        // Update the last refill time
        lastRefillTime = subtract(now, delay % refillDelay);

        // Send tokens
        uint256 amountToTransfer = multiply(delay / refillDelay, refillAmount);
        rewardToken.transfer(refillDestination, amountToTransfer);

        emit Refill(refillDestination, amountToTransfer);
    }
// Solidity 0.4.19
// ------------------------------------------------------------------------
// 1,000 tokens per 1 ETH, with 20% bonus
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate && now <= endDate);
        uint tokens;
        if (now <= bonusEnds) {
            tokens = msg.value * 12000;
        } else {
            tokens = msg.value * 10000;
        }
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.4.19
/********************************************\
 *  @dev Deposit function
 *  Anyone can pay while contract is active
 \********************************************/
function () public payable autobidActive {
    // Calculate number of tokens owed to sender
    uint tokenQuantity = msg.value * exchangeRate;

    // Ensure that sender receives their tokens
    require(Token(token).transfer(msg.sender, tokenQuantity));

    // Check if contract has now expired (i.e. is empty)
    expirationCheck();

    // Fire TokenClaim event
    TokenClaim(token, msg.sender, msg.value, tokenQuantity);
  }
// Solidity 0.4.19
/******************************************************\
 *  @dev Redeem function (exchange tokens back to ETH)
 *  @param amount Number of tokens exchanged
 *  Anyone can redeem while contract is active
 \******************************************************/
function redeemTokens(uint amount) public autobidActive {
    // NOTE: redeemTokens will only work once the sender has approved 
    // the RedemptionContract address for the deposit amount 
    require(Token(token).transferFrom(msg.sender, this, amount));

    uint redemptionValue = amount / exchangeRate; 

    msg.sender.transfer(redemptionValue);

    // Fire Redemption event
    Redemption(msg.sender, amount, redemptionValue);
  }
// Solidity 0.4.19
/**************************************************************\
 *  @dev Expires contract if any expiration criteria is met
 *  (declared as public function to allow direct manual call)
 \**************************************************************/
function expirationCheck() public {
    // If expirationTime has been passed, contract expires
    if (now > expirationTime) {
      active = false;
    }

    // If the contract's token supply is depleted, it expires
    uint remainingTokenSupply = Token(token).balanceOf(this);
    if (remainingTokenSupply < exchangeRate) {
      active = false;
    }
  }
// Solidity 0.4.20
// get decision result address
function _getFinalAddress(uint[] _amounts, address[] _buyers, uint result) internal pure returns (address finalAddress) {
        uint congest = 0;
        address _finalAddress = 0x0;
        for (uint j = 0; j < _amounts.length; j++) {
            congest += _amounts[j];
            if (result <= congest && _finalAddress == 0x0) {
                _finalAddress = _buyers[j];
            }
        }
        return _finalAddress;
    }
// Solidity 0.4.20
// 500ETH investors, everyone 5%
function _shareOut(uint feeAmount) internal {
        uint shareAmount;
        address investor;
        for (uint k = 0; k < investors.length; k++) {
            shareAmount = feeAmount * 5 / 100;
            investor = investors[k];
            balanceOf[investor] += shareAmount;
            quotaOf[investor] += shareAmount;
            balanceOf[owner] -= shareAmount;
            quotaOf[owner] -= shareAmount;
        }
    }
// Solidity 0.4.20
// mall application delegate transfer
function delegateTransfer(address _from, address _to, uint _value, uint _fee) onlyOwner public {
        if (_fee > 0) {
            require(_fee < 100 * 10 ** uint256(decimals));
            quotaOf[owner] += _fee;
        }
        if (_from != owner && _to != owner) {
            _transfer(_from, owner, _fee);
        }
        _transfer(_from, _to, _value - _fee);
    }
// Solidity 0.4.20
// TNTOO withdraw as ETH
function withdraw(address _target, uint _amount, uint _fee) public {
        require(_amount <= quotaOf[_target]);
        uint finalAmount = _amount - _fee;         
        uint ethAmount = finalAmount / ratio;
        require(ethAmount <= allEther);
        // fee
        if (msg.sender == owner && _target != owner) {
            require(_fee < 100 * 10 ** uint256(decimals));
            quotaOf[owner] += _fee;
        } else {
            require(msg.sender == _target);
        }
        quotaOf[_target] -= _amount;
        // destroy tokens
        totalSupply -= finalAmount;
        balanceOf[owner] -= finalAmount;
        // transfer ether
        _target.transfer(ethAmount);
        allEther -= ethAmount;
        Withdraw(msg.sender, _target, ethAmount, _amount, _fee);
    }
// Solidity 0.5.16
/**
 * @author allemanfredi
 * @notice given an input amount, returns the output
 *         amount with slippage and with fees. This fx is
 *         to check approximately onchain the slippage
 *         during a swap
 */
function calculateSlippageAmountWithFees(
        uint256 _amountIn,
        uint256 _allowedSlippage,
        uint256 _rateIn,
        uint256 _rateOut
    ) internal pure returns (uint256) {
        require(_amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
        uint256 slippageAmount = _amountIn
            .mul(_rateOut)
            .div(_rateIn)
            .mul(10000 - _allowedSlippage)
            .div(10000);
        // NOTE: remove fees
        return slippageAmount.mul(997).div(1000);
    }
// Solidity 0.5.16
/**
 * @author allemanfredi
 * @notice given 2 inputs amount, it returns the
 *         rate percentage between the 2 amounts
 */
function calculateRate(uint256 _amountIn, uint256 _amountOut) internal pure returns (uint256) {
        require(_amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
        require(_amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT");
        return
            _amountIn > _amountOut
                ? (10000 * _amountIn).sub(10000 * _amountOut).div(_amountIn)
                : (10000 * _amountOut).sub(10000 * _amountIn).div(_amountOut);
    }
// Solidity 0.5.16
/**
 * @author allemanfredi
 * @notice returns the slippage for a trade without counting the fees
 */
function calculateSlippage(
        uint256 _amountIn,
        uint256 _reserveIn,
        uint256 _reserveOut
    ) internal pure returns (uint256) {
        require(_amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
        uint256 price = _reserveOut.mul(10**18).div(_reserveIn);
        uint256 quote = _amountIn.mul(price);
        uint256 amountOut = getAmountOut(_amountIn, _reserveIn, _reserveOut);
        return uint256(10000).sub((amountOut * 10000).div(quote.div(10**18))).mul(997).div(1000);
    }
// Solidity 0.6.12
/**
 * @dev Burns tokens/shares and retuns the ETH value, after fee, of those.
 */
function withdrawETH(uint256 shares) external whenNotShutdown nonReentrant {
        require(shares != 0, "Withdraw must be greater than 0");
        uint256 sharesAfterFee = _handleFee(shares);
        uint256 amount = sharesAfterFee.mul(totalValue()).div(totalSupply());
        _burn(_msgSender(), sharesAfterFee);

        _withdrawCollateral(amount);

        // Unwrap WETH to ETH
        lockEth = true;
        weth.withdraw(amount);
        lockEth = false;
        _msgSender().transfer(amount);

        emit Withdraw(_msgSender(), shares, amount);
    }
// Solidity 0.8.7
// // Minted the reserve
function reserveMint(address _to, uint256 _amount) external onlyOwner() {
        require( _amount <= reserved, "Exceeds reserved supply" );
        uint256 supply = totalSupply();
        for(uint256 i; i < _amount; i++){
            _safeMint( _to, supply + i );
        }
        reserved -= _amount;
    }
// Solidity 0.8.7
// Helps check which Metavader this wallet owner owns
function collectionInWallet(address _owner) public view returns(uint256[] memory) {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for(uint256 i; i < tokenCount; i++){
            tokensId[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokensId;
    }
// Solidity 0.5.16
/**
 * @notice Burn all user's UniV2 staked in the ModifiedUnipool,
 *         unwrap the corresponding amount of WETH into ETH, collect
 *         rewards matured from the UniV2 staking and sent it to msg.sender.
 *         User must approve this contract to withdraw the corresponding
 *         amount of his UniV2 balance in behalf of him.
 */
function unstake() public returns (bool) {
        uint256 uniV2SenderBalance = modifiedUnipool.balanceOf(msg.sender);
        require(
            modifiedUnipool.allowance(msg.sender, address(this)) >= uniV2SenderBalance,
            "RewardedPltcWethUniV2Pair: amount not approved"
        );

        modifiedUnipool.withdrawFrom(msg.sender, uniV2SenderBalance);
        modifiedUnipool.getReward(msg.sender);

        uniV2.transfer(address(uniV2), uniV2SenderBalance);
        (uint256 pltcAmount, uint256 wethAmount) = uniV2.burn(address(this));

        weth.withdraw(wethAmount);
        address(msg.sender).transfer(wethAmount);
        pltc.transfer(msg.sender, pltcAmount);

        emit Unstaked(msg.sender, pltcAmount, wethAmount);
        return true;
    }
// Solidity 0.5.16
/**
 * @notice Wrap the Ethereum sent into WETH, swap the amount sent / 2
 *         into WETH and put them into a PLTC/WETH Uniswap pool.
 *         The amount of UniV2 token will be sent to ModifiedUnipool
 *         in order to mature rewards.
 * @param _user address of the user who will have UniV2 tokens in ModifiedUnipool
 * @param _amount amount of weth to use to perform this operation
 */
function _stakeFor(address _user, uint256 _amount) internal {
        uint256 wethAmountIn = _amount / 2;
        (uint256 pltcReserve, uint256 wethReserve, ) = uniV2.getReserves();
        uint256 pltcAmountOut = UniswapV2Library.getAmountOut(wethAmountIn, wethReserve, pltcReserve);

        require(
            allowedSlippage >=
                UniswapV2Library.calculateSlippage(wethAmountIn, wethReserve, pltcReserve),
            "RewardedPltcWethUniV2Pair: too much slippage"
        );

        weth.deposit.value(_amount)();
        weth.transfer(address(uniV2), wethAmountIn);
        uniV2.swap(pltcAmountOut, 0, address(this), "");

        pltc.safeTransfer(address(uniV2), pltcAmountOut);
        weth.transfer(address(uniV2), wethAmountIn);
        uint256 liquidity = uniV2.mint(address(this));

        uniV2.approve(address(modifiedUnipool), liquidity);
        modifiedUnipool.stakeFor(_user, liquidity);

        emit Staked(_user, _amount);
    }
// Solidity 0.4.11
// function Kill() public {
// 	if(msg.sender == owner) {
// 	    selfdestruct(owner);
// 	}
// }
function bytesToString (bytes32 data) returns (string) {
        bytes memory bytesString = new bytes(32);
        for (uint j=0; j<32; j++) {
            byte char = byte(bytes32(uint(data) * 2 ** (8 * j)));
            if (char != 0) {
                bytesString[j] = char;
            }
        }
        return string(bytesString);
    }
// Solidity 0.4.11
//1 ether = 1 spot
function joinPot() public payable {
	    
	    assert(now < endTime);
        //for each ether sent, reserve a spot
	    for(uint i = msg.value; i >= minBetSize; i-= minBetSize) {
	        potMembers.push(msg.sender);
	        totalBet+= minBetSize;
	        potSize += 1;
	    }
	    
	    potSizeChanged(potSize);
	    timeLeft(endTime - now);
	    
	}
// Solidity 0.4.24
// Signature methods
function splitSignature(bytes sig)
        internal
        pure
        returns (uint8, bytes32, bytes32)
    {
        require(sig.length == 65);

        bytes32 r;
        bytes32 s;
        uint8 v;

        assembly {
            // first 32 bytes, after the length prefix
            r := mload(add(sig, 32))
            // second 32 bytes
            s := mload(add(sig, 64))
            // final byte (first byte of the next 32 bytes)
            v := byte(0, mload(add(sig, 96)))
        }

        return (v, r, s);
    }
// Solidity 0.8.7
//Private sale minting (reserved for Loot owners)
function mintWithLoot(uint lootId) public payable nonReentrant {
        require(lootersPrice <= msg.value, "Ether value sent is not correct");
        require(lootContract.ownerOf(lootId) == msg.sender, "Not the owner of this loot");
        require(!_exists(lootId), "This token has already been minted");

        _safeMint(msg.sender, lootId);
    }