lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * Returns funds of the previous highest bidder back to them if present
 */
function _refundHighestBidder(uint256 _editionNumber) internal {
    // Get current highest bidder
    address currentHighestBidder = editionHighestBid[_editionNumber];

    // Get current highest bid amount
    uint256 currentHighestBiddersAmount = editionBids[_editionNumber][currentHighestBidder];

    if (currentHighestBidder != address(0) && currentHighestBiddersAmount > 0) {

      // Clear out highest bidder as there is no long one
      delete editionHighestBid[_editionNumber];

      // Refund it
      currentHighestBidder.transfer(currentHighestBiddersAmount);

      // Emit event
      emit BidderRefunded(_editionNumber, currentHighestBidder, currentHighestBiddersAmount);
    }
  }
// Solidity 0.4.24
/**
 * @dev Enables the edition for auctions in a single call
 * @dev Only callable from whitelisted account or KODA edition artists
 */
function enableEditionForArtist(uint256 _editionNumber)
  public
  whenNotPaused
  whenEditionExists(_editionNumber)
  returns (bool)
  {
    // Ensure caller is whitelisted or artists
    (address artistAccount, uint256 artistCommission) = kodaAddress.artistCommission(_editionNumber);
    require(whitelist(msg.sender) || msg.sender == artistAccount, "Cannot enable when not the edition artist");

    // Ensure not already setup
    require(!enabledEditions[_editionNumber], "Edition already enabled");

    // Enable the auction
    enabledEditions[_editionNumber] = true;

    // keep track of the edition
    editionsOnceEnabledForAuctions.push(_editionNumber);

    // Setup the controller address to be the artist
    editionNumberToArtistControlAddress[_editionNumber] = artistAccount;

    emit AuctionEnabled(_editionNumber, msg.sender);

    return true;
  }
// Solidity 0.4.24
/**
 * @dev Sets the edition artist control address and enables the edition for auction
 * @dev Only callable from whitelist
 */
function setArtistsControlAddressAndEnabledEdition(uint256 _editionNumber, address _address)
  onlyIfWhitelisted(msg.sender)
  public returns (bool) {
    require(!enabledEditions[_editionNumber], "Edition already enabled");

    // Enable the edition
    enabledEditions[_editionNumber] = true;

    // Setup the artist address for this edition
    editionNumberToArtistControlAddress[_editionNumber] = _address;

    // keep track of the edition
    editionsOnceEnabledForAuctions.push(_editionNumber);

    emit AuctionEnabled(_editionNumber, _address);

    return true;
  }
// Solidity 0.4.24
/**
 * @dev Allows for the ability to extract specific ether amounts so we can distribute to the correct bidders accordingly
 * @dev Only callable from whitelist
 */
function withdrawStuckEtherOfAmount(address _withdrawalAccount, uint256 _amount)
  onlyIfWhitelisted(msg.sender)
  public {
    require(_withdrawalAccount != address(0), "Invalid address provided");
    require(_amount != 0, "Invalid amount to withdraw");
    require(address(this).balance >= _amount, "No more ether to withdraw");
    _withdrawalAccount.transfer(_amount);
  }
// Solidity 0.4.24
/**
 * @dev Look up all the known data about the latest edition bidding round
 * @dev Returns zeros for all values when not valid
 */
function auctionDetails(uint256 _editionNumber) public view returns (bool _enabled, address _bidder, uint256 _value, address _controller) {
    address highestBidder = editionHighestBid[_editionNumber];
    uint256 bidValue = editionBids[_editionNumber][highestBidder];
    address controlAddress = editionNumberToArtistControlAddress[_editionNumber];
    return (
    enabledEditions[_editionNumber],
    highestBidder,
    bidValue,
    controlAddress
    );
  }
// Solidity 0.8.7
// ~44k gas
function createGame() payable external returns (uint176 id) {
        // Ensure there isnt more than one decimal point in ETH (So we can pack it into a uint16)
        require(msg.value >= 0.2 ether && msg.value % 0.1 ether == 0, "Bad Wager Val");

        id = encodeGameID(msg.sender, msg.value);

        // Ensure game id doesn't already exist
        require(games[id] == 0, "Game exists");

        // Fill game data with status 1 (awaiting opponent)
        games[id] = encodeGameData(1, address(0), 0);
        emit GameCreated(msg.sender, msg.value);
    }
// Solidity 0.8.7
// ~51k gas without LINK request
// ~180k with LINK requestRandomness (oof)
function joinGame(address player1) payable external {
        uint176 id = encodeGameID(player1, msg.value);
        GameData memory g = getGameData(id);

        require(g.status == 1, "Bad Status");
        require(g.wager == msg.value, "Wrong Wager");
        require(LINK.balanceOf(address(this)) >= LINK_FEE, "Not enough LINK");

        // Update game data with player2 and status 2 (awaiting randomness)
        games[id] = encodeGameData(2, msg.sender, 0);
        vrfMap[requestRandomness(KEY_HASH, LINK_FEE)] = id;

        emit GameJoined(msg.sender, g.p1, g.wager);
    }
// Solidity 0.7.5
/**
 @notice wrap TROVE
 @param _amount uint
 @return uint
 */
function wrap( uint _amount ) external returns ( uint ) {
        IsKEEPER( TROVE ).transferFrom( msg.sender, address(this), _amount );
        
        uint value = TROVETowTROVE( _amount );
        _mint( msg.sender, value );
        return value;
    }
// Solidity 0.8.6
/*
 
 FEES  
 
 SAFETY FEATURES TO PROTECT BUYERS!
 
 The fee adjustments are limited to protect buyers
 
 
 1. The total fees can not go above 15% 
 
 */
function _set_Fees(uint256 Liquidity, uint256 Marketing, uint256 Reflection, uint256 TokenBurn, uint256 Developer) external onlyOwner() {

        // Check fee limits

          require((Reflection+TokenBurn+Liquidity+Marketing+Developer) <= maxPossibleFee, "Total fees too high!");
          require(Reflection >= minPossibleReflect, "Reflection fee too low");
          require(Developer >= 1, "Developer fee too low");

        // Set the fees

          _FeeLiquidity = Liquidity;
          _FeeMarketing = Marketing;
          _FeeReflection = Reflection;
          _FeeBurnTokens = TokenBurn;
          _FeeDev = Developer;

        // For calculations and processing 

          _promoFee = _FeeMarketing+_FeeDev;
          _liquidityAndPromoFee = _FeeLiquidity+_promoFee;
          _FeesTotal = _FeeMarketing+_FeeDev+_FeeLiquidity+_FeeBurnTokens+_FeeReflection;

    }
// Solidity 0.8.6
// Blacklist - block wallets (ADD - COMMA SEPARATE MULTIPLE WALLETS)
function blacklist_Add_Wallets(address[] calldata addresses) external onlyOwner {
       
        uint256 startGas;
        uint256 gasUsed;

    for (uint256 i; i < addresses.length; ++i) {
        if(gasUsed < gasleft()) {
        startGas = gasleft();
        if(!_isBlacklisted[addresses[i]]){
        _isBlacklisted[addresses[i]] = true;}
        gasUsed = startGas - gasleft();
    }
    }
    }
// Solidity 0.8.6
// Blacklist - block wallets (REMOVE - COMMA SEPARATE MULTIPLE WALLETS)
function blacklist_Remove_Wallets(address[] calldata addresses) external onlyOwner {
       
        uint256 startGas;
        uint256 gasUsed;

    for (uint256 i; i < addresses.length; ++i) {
        if(gasUsed < gasleft()) {
        startGas = gasleft();
        if(_isBlacklisted[addresses[i]]){
        _isBlacklisted[addresses[i]] = false;}
        gasUsed = startGas - gasleft();
    }
    }
    }
// Solidity 0.8.6
// Remove all fees
function removeAllFee() private {
        if(_FeeReflection == 0 && _FeeLiquidity == 0 && _FeeMarketing == 0 && _FeeDev == 0 && _FeeBurnTokens == 0) return;
        
        _previousFeeReflection = _FeeReflection;
        _previousFeeLiquidity = _FeeLiquidity;
        _previousFeeMarketing = _FeeMarketing;
        _previousFeeDev = _FeeDev;
        _previousFeeBurnTokens = _FeeBurnTokens;
        
        _FeeReflection = 0;
        _liquidityAndPromoFee = 0;
        _FeeLiquidity = 0;
        _FeeMarketing = 0;
        _FeeBurnTokens = 0;
        _FeeDev = 0;
        _promoFee = 0;
        _FeesTotal = 0;
    }
// Solidity 0.8.6
// Manually purge BNB from contract and send to wallets
function process_Purge_BNBFromContract() public onlyOwner {
        // Do not trigger if already in swap
        require(!inSwapAndLiquify, "Processing liquidity, try to purge later.");       
        // Check BNB on contract
        uint256 bnbAmount = address(this).balance;
        // Check correct ratio to purge BNB
        uint256 splitCalcPromo = precDiv(_FeeMarketing,_promoFee,2);
        // Send BNB to marketing wallet
        uint256 marketingBNB = bnbAmount*splitCalcPromo/100;
        if (marketingBNB > 0){sendToWallet(Wallet_Marketing, marketingBNB);}
        // Send BNB to developer wallet
        uint256 developerBNB = bnbAmount-marketingBNB;
        if (developerBNB > 0){sendToWallet(Wallet_Dev, developerBNB);}
    }
// Solidity 0.8.6
// Manual 'swapAndLiquify' Trigger (Enter the percent of the tokens that you'd like to send to swap and liquify)
function process_SwapAndLiquify_Now (uint256 percent_Of_Tokens_To_Liquify) public onlyOwner {
        // Do not trigger if already in swap
        require(!inSwapAndLiquify, "Currently processing liquidity, try later."); 
        if (percent_Of_Tokens_To_Liquify > 100){percent_Of_Tokens_To_Liquify == 100;}
        uint256 tokensOnContract = balanceOf(address(this));
        uint256 sendTokens = tokensOnContract*percent_Of_Tokens_To_Liquify/100;
        swapAndLiquify(sendTokens);
    }
// Solidity 0.8.6
/*
 
 Transfer Functions
 
 There are 4 transfer options, based on whether the to, from, neither or both wallets are excluded from rewards
 
 */
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
        
         
        
        if(!takeFee){
            removeAllFee();
            } else {
                txCount++;
            }
        
        if (_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferFromExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
            _transferToExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferStandard(sender, recipient, amount);
        } else if (_isExcluded[sender] && _isExcluded[recipient]) {
            _transferBothExcluded(sender, recipient, amount);
        } else {
            _transferStandard(sender, recipient, amount);
        }
        
        if(!takeFee)
            restoreAllFee();
    }
// Solidity 0.4.25
/**
 * @notice If the self-destruction delay has elapsed, destroy this contract and
 * remit any ether it owns to the beneficiary address.
 * @dev Only the contract owner may call this.
 */
function selfDestruct()
        external
        onlyOwner
    {
        require(selfDestructInitiated, "Self destruct has not yet been initiated");
        require(initiationTime + SELFDESTRUCT_DELAY < now, "Self destruct delay has not yet elapsed");
        address beneficiary = selfDestructBeneficiary;
        emit SelfDestructed(beneficiary);
        selfdestruct(beneficiary);
    }
// Solidity 0.4.25
/**
 * @notice Set an inverse price up for the currency key
 * @param currencyKey The currency to update
 * @param entryPoint The entry price point of the inverted price
 * @param upperLimit The upper limit, at or above which the price will be frozen
 * @param lowerLimit The lower limit, at or below which the price will be frozen
 */
function setInversePricing(bytes4 currencyKey, uint entryPoint, uint upperLimit, uint lowerLimit)
        external onlyOwner
    {
        require(entryPoint > 0, "entryPoint must be above 0");
        require(lowerLimit > 0, "lowerLimit must be above 0");
        require(upperLimit > entryPoint, "upperLimit must be above the entryPoint");
        require(upperLimit < entryPoint.mul(2), "upperLimit must be less than double entryPoint");
        require(lowerLimit < entryPoint, "lowerLimit must be below the entryPoint");

        if (inversePricing[currencyKey].entryPoint <= 0) {
            // then we are adding a new inverse pricing, so add this
            invertedKeys.push(currencyKey);
        }
        inversePricing[currencyKey].entryPoint = entryPoint;
        inversePricing[currencyKey].upperLimit = upperLimit;
        inversePricing[currencyKey].lowerLimit = lowerLimit;
        inversePricing[currencyKey].frozen = false;

        emit InversePriceConfigured(currencyKey, entryPoint, upperLimit, lowerLimit);
    }
// Solidity 0.4.25
/**
 * @notice Override ERC20 transfer function in order to
 * subtract the transaction fee and send it to the fee pool
 * for SNX holders to claim. */
function transfer(address to, uint value)
        public
        optionalProxy
        notFeeAddress(messageSender)
        returns (bool)
    {
        uint amountReceived = feePool.amountReceivedFromTransfer(value);
        uint fee = value.sub(amountReceived);

        // Send the fee off to the fee pool.
        synthetix.synthInitiatedFeePayment(messageSender, currencyKey, fee);

        // And send their result off to the destination address
        bytes memory empty;
        return _internalTransfer(messageSender, to, amountReceived, empty);
    }
// Solidity 0.4.25
/**
 * @notice Override ERC223 transferFrom function in order to
 * subtract the transaction fee and send it to the fee pool
 * for SNX holders to claim. */
function transferFrom(address from, address to, uint value, bytes data)
        public
        optionalProxy
        notFeeAddress(from)
        returns (bool)
    {
        // The fee is deducted from the amount sent.
        uint amountReceived = feePool.amountReceivedFromTransfer(value);
        uint fee = value.sub(amountReceived);

        // Reduce the allowance by the amount we're transferring.
        // The safeSub call will handle an insufficient allowance.
        tokenState.setAllowance(from, messageSender, tokenState.allowance(from, messageSender).sub(value));

        // Send the fee off to the fee pool, which we don't want to charge an additional fee on
        synthetix.synthInitiatedFeePayment(from, currencyKey, fee);

        return _internalTransfer(from, to, amountReceived, data);
    }
// Solidity 0.4.25
/* Subtract the transfer fee from the senders account so the
 * receiver gets the exact amount specified to send. */
function transferSenderPaysFee(address to, uint value)
        public
        optionalProxy
        notFeeAddress(messageSender)
        returns (bool)
    {
        uint fee = feePool.transferFeeIncurred(value);

        // Send the fee off to the fee pool, which we don't want to charge an additional fee on
        synthetix.synthInitiatedFeePayment(messageSender, currencyKey, fee);

        // And send their transfer amount off to the destination address
        bytes memory empty;
        return _internalTransfer(messageSender, to, value, empty);
    }
// Solidity 0.4.25
/* Subtract the transfer fee from the senders account so the
 * to address receives the exact amount specified to send. */
function transferFromSenderPaysFee(address from, address to, uint value)
        public
        optionalProxy
        notFeeAddress(from)
        returns (bool)
    {
        uint fee = feePool.transferFeeIncurred(value);

        // Reduce the allowance by the amount we're transferring.
        // The safeSub call will handle an insufficient allowance.
        tokenState.setAllowance(from, messageSender, tokenState.allowance(from, messageSender).sub(value.add(fee)));

        // Send the fee off to the fee pool, which we don't want to charge an additional fee on
        synthetix.synthInitiatedFeePayment(from, currencyKey, fee);

        bytes memory empty;
        return _internalTransfer(from, to, value, empty);
    }
// Solidity 0.4.25
// Override our internal transfer to inject preferred currency support
function _internalTransfer(address from, address to, uint value, bytes data)
        internal
        returns (bool)
    {
        bytes4 preferredCurrencyKey = synthetix.synthetixState().preferredCurrency(to);

        // Do they have a preferred currency that's not us? If so we need to exchange
        if (preferredCurrencyKey != 0 && preferredCurrencyKey != currencyKey) {
            return synthetix.synthInitiatedExchange(from, currencyKey, value, preferredCurrencyKey, to);
        } else {
            // Otherwise we just transfer
            return super._internalTransfer(from, to, value, data);
        }
    }
// Solidity 0.4.25
/**
 * @notice Function that allows you to exchange synths you hold in one flavour for another.
 * @param sourceCurrencyKey The source currency you wish to exchange from
 * @param sourceAmount The amount, specified in UNIT of source currency you wish to exchange
 * @param destinationCurrencyKey The destination currency you wish to obtain.
 * @param destinationAddress Deprecated. Will always send to messageSender
 * @return Boolean that indicates whether the transfer succeeded or failed.
 */
function exchange(bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey, address destinationAddress)
        external
        optionalProxy
        // Note: We don't need to insist on non-stale rates because effectiveValue will do it for us.
        returns (bool)
    {
        require(sourceCurrencyKey != destinationCurrencyKey, "Exchange must use different synths");
        require(sourceAmount > 0, "Zero amount");

        //  If protectionCircuit is true then we burn the synths through _internalLiquidation()
        if (protectionCircuit) {
            return _internalLiquidation(
                messageSender,
                sourceCurrencyKey,
                sourceAmount
            );
        } else {
            // Pass it along, defaulting to the sender as the recipient.
            return _internalExchange(
                messageSender,
                sourceCurrencyKey,
                sourceAmount,
                destinationCurrencyKey,
                messageSender,
                true // Charge fee on the exchange
            );
        }
    }
// Solidity 0.4.25
/**
 * @notice Function that allows synth contract to delegate sending fee to the fee Pool.
 * @dev Only the synth contract can call this function.
 * @param from The address fee is coming from.
 * @param sourceCurrencyKey source currency fee from.
 * @param sourceAmount The amount, specified in UNIT of source currency.
 * @return Boolean that indicates whether the transfer succeeded or failed.
 */
function synthInitiatedFeePayment(
        address from,
        bytes4 sourceCurrencyKey,
        uint sourceAmount
    )
        external
        onlySynth
        returns (bool)
    {
        // Allow fee to be 0 and skip minting XDRs to feePool
        if (sourceAmount == 0) {
            return true;
        }

        require(sourceAmount > 0, "Source can't be 0");

        // Pass it along, defaulting to the sender as the recipient.
        bool result = _internalExchange(
            from,
            sourceCurrencyKey,
            sourceAmount,
            "XDR",
            feePool.FEE_ADDRESS(),
            false // Don't charge a fee on the exchange because this is already a fee
        );

        // Tell the fee pool about this.
        feePool.feePaid(sourceCurrencyKey, sourceAmount);

        return result;
    }
// Solidity 0.4.25
/**
 * @notice The number of SNX that are free to be transferred by an account.
 * @dev When issuing, escrowed SNX are locked first, then non-escrowed
 * SNX are locked last, but escrowed SNX are not transferable, so they are not included
 * in this calculation.
 */
function transferableSynthetix(address account)
        public
        view
        rateNotStale("SNX")
        returns (uint)
    {
        // How many SNX do they have, excluding escrow?
        // Note: We're excluding escrow here because we're interested in their transferable amount
        // and escrowed SNX are not transferable.
        uint balance = tokenState.balanceOf(account);

        // How many of those will be locked by the amount they've issued?
        // Assuming issuance ratio is 20%, then issuing 20 SNX of value would require
        // 100 SNX to be locked in their wallet to maintain their collateralisation ratio
        // The locked synthetix value can exceed their balance.
        uint lockedSynthetixValue = debtBalanceOf(account, "SNX").divideDecimalRound(synthetixState.issuanceRatio());

        // If we exceed the balance, no SNX are transferable, otherwise the difference is.
        if (lockedSynthetixValue >= balance) {
            return 0;
        } else {
            return balance.sub(lockedSynthetixValue);
        }
    }
// Solidity 0.7.5
/**
 * @notice stake KEEPER to enter warmup
 * @param _amount uint
 * @param _recipient address
 */
function stake( uint _amount, address _recipient, bool _wrap ) external returns ( uint ) {
        rebase();

        KEEPER.safeTransferFrom( msg.sender, address(this), _amount );

        if ( warmupPeriod == 0 ) {
            return _send( _recipient, _amount, _wrap );
        }
        else {
            Claim memory info = warmupInfo[ _recipient ];
            if ( !info.lock ) {
                require( _recipient == msg.sender, "External deposits for account are locked" );
            }

            uint sKeeperGons = sKEEPER.gonsForBalance( _amount );
            warmupInfo[ _recipient ] = Claim ({
                deposit: info.deposit.add(_amount),
                gons: info.gons.add(sKeeperGons),
                expiry: epoch.number.add32(warmupPeriod),
                lock: info.lock
            });

            gonsInWarmup = gonsInWarmup.add(sKeeperGons);
            return _amount;
        }
    }
// Solidity 0.7.5
/**
 * @notice redeem sKEEPER for KEEPER
 * @param _amount uint
 * @param _trigger bool
 */
function unstake( uint _amount, bool _trigger ) external returns ( uint ) {
        if ( _trigger ) {
            rebase();
        }
        uint amount = _amount;
        sKEEPER.safeTransferFrom( msg.sender, address(this), _amount );
        KEEPER.safeTransfer( msg.sender, amount );
        return amount;
    }
// Solidity 0.7.5
/**
 * @notice send staker their amount as sKEEPER or gKEEPER
 * @param _recipient address
 * @param _amount uint
 */
function _send( address _recipient, uint _amount, bool _wrap ) internal returns ( uint ) {
        if (_wrap) {
            sKEEPER.approve( address( wTROVE ), _amount );
            uint wrapValue = wTROVE.wrap( _amount );
            wTROVE.transfer( _recipient, wrapValue );
        } else {
            sKEEPER.safeTransfer( _recipient, _amount ); // send as sKEEPER (equal unit as KEEPER)
        }
        return _amount;
    }
// Solidity 0.7.5
/**
 @notice set adjustment info for a collector's reward rate
 @param _index uint
 @param _add bool
 @param _rate uint
 @param _target uint
 */
function setAdjustment( uint _index, bool _add, uint _rate, uint _target ) external onlyOwner() {
        require(_add || info[ _index ].rate >= _rate, "Negative adjustment rate cannot be more than current rate.");
        adjustments[ _index ] = Adjust({
            add: _add,
            rate: _rate,
            target: _target
        });
    }