lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
/**
 * @dev Mint edition to a wallet
 * @param _to wallet receiving the edition(s).
 * @param _mintAmount number of editions to mint.
 */
function mint(address _to, uint256 _mintAmount) public payable {
        require(!paused, "Minting is Paused.");
        require(_mintAmount <= maxMintAmount, "Only 10 DieHardDinos are Allowed Per Transaction");
        require(
            tokenId + _mintAmount <= maxSupply,
            "Dinosphere is at Max Capacity"
        );
        
        if(freeMint[_to] < _mintAmount)
            require(
                msg.value >= cost * _mintAmount,
                "Uh Oh Not Enough ETH Paid"
            );
        else
            freeMint[_to] -= _mintAmount;
        
        for (uint256 i = 0; i < _mintAmount; i++) {
            tokenId++;
            _mint(_to, tokenId, 1, "");
            totalSupply++;
        }
    }
// Solidity 0.4.19
/// @dev Allows anyone to execute a confirmed transaction or ether withdraws until daily limit is reached.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
        public
        ownerExists(msg.sender)
        confirmed(transactionId, msg.sender)
        notExecuted(transactionId)
    {
        Transaction storage txn = transactions[transactionId];
        bool _confirmed = isConfirmed(transactionId);
        if (_confirmed || txn.data.length == 0 && isUnderLimit(txn.value)) {
            txn.executed = true;
            if (!_confirmed)
                spentToday += txn.value;
            if (txn.destination.call.value(txn.value)(txn.data))
                Execution(transactionId);
            else {
                ExecutionFailure(transactionId);
                txn.executed = false;
                if (!_confirmed)
                    spentToday -= txn.value;
            }
        }
    }
// Solidity 0.4.19
/// @dev Returns if amount is within daily limit and resets spentToday after one day.
/// @param amount Amount to withdraw.
/// @return Returns if amount is under daily limit.
function isUnderLimit(uint amount)
        internal
        returns (bool)
    {
        if (now > lastDay + 24 hours) {
            lastDay = now;
            spentToday = 0;
        }
        if (spentToday + amount > dailyLimit || spentToday + amount < spentToday)
            return false;
        return true;
    }
// Solidity 0.6.7
/**
 * @notice Modify auction parameters
 * @param parameter The name of the parameter modified
 * @param data New value for the parameter
 */
function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized {
        require(data > 0, "StakedTokenAuctionHouse/null-data");
        require(contractEnabled == 1, "StakedTokenAuctionHouse/contract-not-enabled");

        if (parameter == "bidIncrease") {
          require(data > ONE, "StakedTokenAuctionHouse/invalid-bid-increase");
          bidIncrease = data;
        }
        else if (parameter == "bidDuration") bidDuration = uint48(data);
        else if (parameter == "totalAuctionLength") totalAuctionLength = uint48(data);
        else if (parameter == "minBidDecrease") {
          require(data < ONE, "StakedTokenAuctionHouse/invalid-min-bid-decrease");
          minBidDecrease = data;
        }
        else if (parameter == "minBid") {
          minBid = data;
        }
        else revert("StakedTokenAuctionHouse/modify-unrecognized-param");
        emit ModifyParameters(parameter, data);
    }
// Solidity 0.6.7
/**
 * @notice Modify an address parameter
 * @param parameter The name of the oracle contract modified
 * @param addr New contract address
 */
function modifyParameters(bytes32 parameter, address addr) external isAuthorized {
        require(addr != address(0), "StakedTokenAuctionHouse/null-addr");
        require(contractEnabled == 1, "StakedTokenAuctionHouse/contract-not-enabled");
        if (parameter == "accountingEngine") accountingEngine = addr;
        else if (parameter == "tokenBurner") tokenBurner = addr;
        else revert("StakedTokenAuctionHouse/modify-unrecognized-param");
        emit ModifyParameters(parameter, addr);
    }
// Solidity 0.6.7
/**
 * @notice Start a new staked token auction
 * @param amountToSell Amount of staked tokens to sell (wad)
 */
function startAuction(
        uint256 amountToSell,
        uint256 systemCoinsRequested
    ) external isAuthorized returns (uint256 id) {
        require(contractEnabled == 1, "StakedTokenAuctionHouse/contract-not-enabled");
        require(auctionsStarted < uint256(-1), "StakedTokenAuctionHouse/overflow");
        require(accountingEngine != address(0), "StakedTokenAuctionHouse/null-accounting-engine");
        require(both(amountToSell > 0, systemCoinsRequested > 0), "StakedTokenAuctionHouse/null-amounts");
        require(systemCoinsRequested <= uint256(-1) / ONE, "StakedTokenAuctionHouse/large-sys-coin-request");

        id = ++auctionsStarted;

        bids[id].amountToSell     = amountToSell;
        bids[id].bidAmount        = systemCoinsRequested;
        bids[id].highBidder       = address(0);
        bids[id].auctionDeadline  = addUint48(uint48(now), totalAuctionLength);

        activeStakedTokenAuctions = addUint256(activeStakedTokenAuctions, 1);

        // get staked tokens
        require(stakedToken.transferFrom(msg.sender, address(this), amountToSell), "StakedTokenAuctionHouse/cannot-transfer-staked-tokens");

        emit StartAuction(
          id, auctionsStarted, amountToSell, systemCoinsRequested, accountingEngine, bids[id].auctionDeadline, activeStakedTokenAuctions
        );
    }
// Solidity 0.6.7
/**
 * @notice Restart an auction if no bids were submitted for it
 * @param id ID of the auction to restart
 */
function restartAuction(uint256 id) external {
        require(id <= auctionsStarted, "StakedTokenAuctionHouse/auction-never-started");
        require(bids[id].auctionDeadline < now, "StakedTokenAuctionHouse/not-finished");
        require(bids[id].bidExpiry == 0, "StakedTokenAuctionHouse/bid-already-placed");

        uint256 newMinBid        = multiply(minBidDecrease, bids[id].bidAmount) / ONE;
        newMinBid                = (newMinBid < minBid) ? minBid : newMinBid;

        bids[id].bidAmount       = newMinBid;
        bids[id].auctionDeadline = addUint48(uint48(now), totalAuctionLength);

        emit RestartAuction(id, newMinBid, bids[id].auctionDeadline);
    }
// Solidity 0.6.7
/**
 * @notice Submit a higher system coin bid for the same amount of staked tokens
 * @param id ID of the auction you want to submit the bid for
 * @param amountToBuy Amount of staked tokens to buy (wad)
 * @param bid New bid submitted (rad)
 */
function increaseBidSize(uint256 id, uint256 amountToBuy, uint256 bid) external {
        require(contractEnabled == 1, "StakedTokenAuctionHouse/contract-not-enabled");
        require(bids[id].bidExpiry > now || bids[id].bidExpiry == 0, "StakedTokenAuctionHouse/bid-already-expired");
        require(bids[id].auctionDeadline > now, "StakedTokenAuctionHouse/auction-already-expired");

        require(amountToBuy == bids[id].amountToSell, "StakedTokenAuctionHouse/not-matching-amount-bought");
        require(bid > bids[id].bidAmount, "StakedTokenAuctionHouse/bid-not-higher");
        require(multiply(bid, ONE) > multiply(bidIncrease, bids[id].bidAmount), "StakedTokenAuctionHouse/insufficient-increase");

        if (bids[id].highBidder == msg.sender) {
            safeEngine.transferInternalCoins(msg.sender, address(this), subtract(bid, bids[id].bidAmount));
        } else {
            safeEngine.transferInternalCoins(msg.sender, address(this), bid);
            if (bids[id].highBidder != address(0)) // not first bid
                safeEngine.transferInternalCoins(address(this), bids[id].highBidder, bids[id].bidAmount);

            bids[id].highBidder = msg.sender;
        }

        bids[id].bidAmount  = bid;
        bids[id].bidExpiry  = addUint48(uint48(now), bidDuration);

        emit IncreaseBidSize(id, msg.sender, amountToBuy, bid, bids[id].bidExpiry);
    }
// Solidity 0.6.7
/**
 * @notice Settle/finish an auction
 * @param id ID of the auction to settle
 */
function settleAuction(uint256 id) external {
        require(contractEnabled == 1, "StakedTokenAuctionHouse/not-live");
        require(both(bids[id].bidExpiry != 0, either(bids[id].bidExpiry < now, bids[id].auctionDeadline < now)), "StakedTokenAuctionHouse/not-finished");

        // get the bid, the amount to sell and the high bidder
        uint256 bid          = bids[id].bidAmount;
        uint256 amountToSell = bids[id].amountToSell;
        address highBidder   = bids[id].highBidder;

        // clear storage
        activeStakedTokenAuctions = subtract(activeStakedTokenAuctions, 1);
        delete bids[id];

        // transfer the surplus to the accounting engine
        safeEngine.transferInternalCoins(address(this), accountingEngine, bid);

        // clear as much bad debt as possible
        uint256 totalOnAuctionDebt = AccountingEngineLike(accountingEngine).totalOnAuctionDebt();
        AccountingEngineLike(accountingEngine).cancelAuctionedDebtWithSurplus(minimum(bid, totalOnAuctionDebt));

        // transfer staked tokens to the high bidder
        require(stakedToken.transfer(highBidder, amountToSell), "StakedTokenAuctionHouse/failed-transfer");

        emit SettleAuction(id, activeStakedTokenAuctions);
    }
// Solidity 0.6.7
/**
 * @notice Terminate an auction prematurely
 * @param id ID of the auction to terminate
 */
function terminateAuctionPrematurely(uint256 id) external {
        require(contractEnabled == 0, "StakedTokenAuctionHouse/contract-still-enabled");
        require(bids[id].highBidder != address(0), "StakedTokenAuctionHouse/high-bidder-not-set");

        // decrease amount of active auctions
        activeStakedTokenAuctions = subtract(activeStakedTokenAuctions, 1);

        // send the system coin bid back to the high bidder in case there was at least one bid
        safeEngine.transferInternalCoins(address(this), bids[id].highBidder, bids[id].bidAmount);

        // send the staked tokens to the token burner
        require(stakedToken.transfer(tokenBurner, bids[id].amountToSell), "StakedTokenAuctionHouse/failed-transfer");

        emit TerminateAuctionPrematurely(id, msg.sender, bids[id].highBidder, bids[id].bidAmount, activeStakedTokenAuctions);
        delete bids[id];
    }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// 1 YAR Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate);
        uint tokens;
        if (now <= bonusEnds) {
            tokens = msg.value * 12;
        } else {
            tokens = msg.value * 10;
        }
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.8.0
/**
 * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
 * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
 */
function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
        
        emit Transfer(address(0), to, tokenId);
        
    }
// Solidity 0.6.10
/**
 * @param A The input array to search
 * @param a The address to remove
 */
function removeStorage(address[] storage A, address a)
        internal
    {
        (uint256 index, bool isIn) = indexOf(A, a);
        if (!isIn) {
            revert("Address not in array.");
        } else {
            uint256 lastIndex = A.length - 1; // If the array would be empty, the previous line would throw, so no underflow here
            if (index != lastIndex) { A[index] = A[lastIndex]; }
            A.pop();
        }
    }
// Solidity 0.6.10
/**
 * Returns the combination of the two arrays
 * @param A The first array
 * @param B The second array
 * @return Returns A extended by B
 */
function extend(address[] memory A, address[] memory B) internal pure returns (address[] memory) {
        uint256 aLength = A.length;
        uint256 bLength = B.length;
        address[] memory newAddresses = new address[](aLength + bLength);
        for (uint256 i = 0; i < aLength; i++) {
            newAddresses[i] = A[i];
        }
        for (uint256 j = 0; j < bLength; j++) {
            newAddresses[aLength + j] = B[j];
        }
        return newAddresses;
    }
// Solidity 0.6.10
/**
 * Instructs the SetToken to transfer the ERC20 token to a recipient.
 * The new SetToken balance must equal the existing balance less the quantity transferred
 *
 * @param _setToken        SetToken instance to invoke
 * @param _token           ERC20 token to transfer
 * @param _to              The recipient account
 * @param _quantity        The quantity to transfer
 */
function strictInvokeTransfer(
        ISetToken _setToken,
        address _token,
        address _to,
        uint256 _quantity
    )
        internal
    {
        if (_quantity > 0) {
            // Retrieve current balance of token for the SetToken
            uint256 existingBalance = IERC20(_token).balanceOf(address(_setToken));

            Invoke.invokeTransfer(_setToken, _token, _to, _quantity);

            // Get new balance of transferred token for SetToken
            uint256 newBalance = IERC20(_token).balanceOf(address(_setToken));

            // Verify only the transfer quantity is subtracted
            require(
                newBalance == existingBalance.sub(_quantity),
                "Invalid post transfer balance"
            );
        }
    }
// Solidity 0.6.10
/**
 * @dev Performs the power on a specified value, reverts on overflow.
 */
function safePower(
        uint256 a,
        uint256 pow
    )
        internal
        pure
        returns (uint256)
    {
        require(a > 0, "Value must be positive");

        uint256 result = 1;
        for (uint256 i = 0; i < pow; i++){
            uint256 previousResult = result;

            // Using safemath multiplication prevents overflows
            result = previousResult.mul(a);
        }

        return result;
    }
// Solidity 0.6.10
/**
 * Calculates the new default position unit and performs the edit with the new unit
 *
 * @param _setToken                 Address of the SetToken
 * @param _component                Address of the component
 * @param _setTotalSupply           Current SetToken supply
 * @param _componentPreviousBalance Pre-action component balance
 * @return                          Current component balance
 * @return                          Previous position unit
 * @return                          New position unit
 */
function calculateAndEditDefaultPosition(
        ISetToken _setToken,
        address _component,
        uint256 _setTotalSupply,
        uint256 _componentPreviousBalance
    )
        internal
        returns(uint256, uint256, uint256)
    {
        uint256 currentBalance = IERC20(_component).balanceOf(address(_setToken));
        uint256 positionUnit = _setToken.getDefaultPositionRealUnit(_component).toUint256();

        uint256 newTokenUnit;
        if (currentBalance > 0) {
            newTokenUnit = calculateDefaultEditPositionUnit(
                _setTotalSupply,
                _componentPreviousBalance,
                currentBalance,
                positionUnit
            );
        } else {
            newTokenUnit = 0;
        }

        editDefaultPosition(_setToken, _component, newTokenUnit);

        return (currentBalance, positionUnit, newTokenUnit);
    }
// Solidity 0.6.10
/**
 * ONLY MANAGER: Remove stored component from array. Checks to see if there's a duplicate component and
 * that module has not been previously used. Calls remove component which will remove first instance
 * of component in the array and set used to true to make sure removeComponent() cannot be called again.
 */
function removeComponent() external onlyManagerAndValidSet(setToken) {
        require(!used, "Module has been used");

        address[] memory components = setToken.getComponents();
        uint256 componentCount;
        for (uint256 i = 0; i < components.length; i++) {
            if (component == components[i]) {
                componentCount = componentCount.add(1);
            }
        }
        require(componentCount > 0, "Component does not have duplicate");

        setToken.removeComponent(component);

        used = true;
    }
// Solidity 0.5.16
// called by factory to set interest rate redirection for Aave tokens
function claim(address _token, address _to) external {
        require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
        require(_token != token0 && _token != token1, 'UniswapV2: FORBIDDEN'); // sufficient check
        _safeTransfer(_token, _to, IERC20(_token).balanceOf(address(this)));
    }
// Solidity 0.6.12
// Withdraw staked tokens
// First withdraws unlocked tokens, then earned tokens. Withdrawing earned tokens
// incurs a 50% penalty which will be burnt
function withdrawEarning(uint256 amount) public {
        require(amount > 0, "Cannot withdraw 0");
        Balances storage bal = userBalances[msg.sender];
        uint256 penaltyAmount = 0;

        uint256 remaining = amount;
        bal.earned = bal.earned.sub(remaining);
        for (uint i = 0; ; i++) {
            uint256 earnedAmount = _userEarnings[msg.sender][i].amount;
            if (earnedAmount == 0) {
                continue;
            }
            if (penaltyAmount == 0 && _userEarnings[msg.sender][i].unlockTime > block.timestamp) {
                penaltyAmount = remaining;
                require(bal.earned >= remaining, "Insufficient balance after penalty");
                bal.earned = bal.earned.sub(remaining);
                if (bal.earned == 0) {
                    delete _userEarnings[msg.sender];
                    break;
                }
                remaining = remaining.mul(2);
            }
            if (remaining <= earnedAmount) {
                _userEarnings[msg.sender][i].amount = earnedAmount.sub(remaining);
                break;
            } else {
                delete _userEarnings[msg.sender][i];
                remaining = remaining.sub(earnedAmount);
            }
        }


        wasabi.safeTransfer(msg.sender, amount);

        accumulatedPenalty = accumulatedPenalty + penaltyAmount;

        emit EarningWithdraw(msg.sender, amount, penaltyAmount);
    }
// Solidity 0.6.12
// Final balance received and penalty balance paid by user upon calling exit
function withdrawableEarning(
        address user
    )
        public
        view
        returns (uint256 amount, uint256 penaltyAmount, uint256 amountWithoutPenalty)
    {
        Balances storage bal = userBalances[user];

        if (bal.earned > 0) {
            uint256 length = _userEarnings[user].length;
            for (uint i = 0; i < length; i++) {
                uint256 earnedAmount = _userEarnings[user][i].amount;
                if (earnedAmount == 0) {
                    continue;
                }
                if (_userEarnings[user][i].unlockTime > block.timestamp) {
                    break;
                }
                amountWithoutPenalty = amountWithoutPenalty.add(earnedAmount);
            }

            if (bal.earned.sub(amountWithoutPenalty) % 2 == 0) {
                penaltyAmount = bal.earned.sub(amountWithoutPenalty).div(2);
            } else {
                penaltyAmount = bal.earned.sub(amountWithoutPenalty).div(2) + 1;
            }
        }
        amount = bal.earned.sub(penaltyAmount);

        return (amount, penaltyAmount, amountWithoutPenalty);
    }
// Solidity 0.8.4
// Returns a boolean if this oracle can provide data for the requested pair, used during FNFT creation
// If the oracle does not exist, this will revert the transaction
function getPairHasOracle(address asset, address compareTo) public view override returns (bool) {
        //First, check if standard ERC20 with decimals() method
        uint decimals = ERC20(asset).decimals();
        uint price = oracle.assetToAsset(asset, 10**decimals, compareTo, TWAP_PERIOD);
        return true;
    }
// Solidity 0.8.0
// @dev Presale Mint
// @param tokenCount The tokens a user wants to purchase
// @param presaleMaxMint The max tokens a user can mint from the presale
// @param factionId Community: 0 and Theos: 1
// @param sig Server side signature authorizing user to use the presale
function mintPresale(
        uint256 tokenCount, 
        uint256 presaleMaxMint, 
        uint256 factionId,
        bytes memory sig
    ) external nonReentrant payable {
        require(factionId == 0 || factionId == 1, "Faction is not valid");
        require(_isPresaleActive, "Presale not active");
        require(!_isSaleActive, "Cannot mint while main sale is active");
        require(tokenCount > 0, "Must mint at least 1 token");
        require(tokenCount <= presaleMaxMint, "Token count exceeds limit");
        require((MINT_PRICE * tokenCount) == msg.value, "ETH sent does not match required payment");
        require(presaleMaxMint <= 6, "The max that a random user can mint in the presale is 6");
        require(!presaleClaimed[msg.sender], "Already minted in the presale with this address");
        
        // Verify signature
        bytes32 message = getPresaleSigningHash(msg.sender, tokenCount, presaleMaxMint, factionId).toEthSignedMessageHash();
        require(ECDSA.recover(message, sig) == signVerifier, "Permission to call this function failed");

        presaleClaimed[msg.sender] = true;

        // Mint
        _handleFactionMint(
            tokenCount, 
            factionId, 
            msg.sender, 
            COMMUNITY_MINT_SUPPLY,
            THEOS_MINT_SUPPLY
        );
    }
// Solidity 0.8.0
// @dev Main sale mint
// @param tokensCount The tokens a user wants to purchase
// @param factionId Community: 0 and Theos: 1
function mint(uint256 tokenCount, uint256 factionId) 
    external nonReentrant payable {
        require(factionId == 0 || factionId == 1, "Faction is not valid");
        require(_isSaleActive, "Sale not active");
        require(tokenCount > 0, "Must mint at least 1 token");
        require(tokenCount <= maxMintPerTransaction, "Token count exceeds limit");
        require((MINT_PRICE * tokenCount) == msg.value, "ETH sent does not match required payment");

        _handleFactionMint(
            tokenCount, 
            factionId, 
            msg.sender, 
            COMMUNITY_MINT_SUPPLY,
            THEOS_MINT_SUPPLY
        );
    }
// Solidity 0.8.0
// @dev Private mint function reserved for company.
// 44 Community and 44 Theos are reserved.
// @param recipient The user receiving the tokens
// @param tokenCount The number of tokens to distribute
// @param factionId Community: 0 and Theos: 1
function mintToAddress(address recipient, uint256 tokenCount, uint256 factionId) 
    external onlyOwner {
        require(isSaleFinished(), "Sale has not concluded");
        require(factionId == 0 || factionId == 1, "Faction does not exist");
        require(tokenCount > 0, "You can only mint more than 0 tokens");

        _handleFactionMint(
            tokenCount, 
            factionId, 
            recipient, 
            COMMUNITY_MINT_SUPPLY + COMMUNITY_STAFF_SUPPLY,
            THEOS_MINT_SUPPLY + THEOS_STAFF_SUPPLY
        );
    }