lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.6
/// @notice Check if the price change overflows or not based on given twap and threshold in the hypervisor
/// @param pos Hypervisor Address
/// @param _twapInterval Time intervals
/// @param _priceThreshold Price Threshold
/// @return price Current price
function checkPriceChange(
    address pos,
    uint32 _twapInterval,
    uint256 _priceThreshold
  ) public view returns (uint256 price) {
    uint160 sqrtPrice = TickMath.getSqrtRatioAtTick(IHypervisor(pos).currentTick());
    price = FullMath.mulDiv(uint256(sqrtPrice).mul(uint256(sqrtPrice)), 1e18, 2**(96 * 2));

    uint160 sqrtPriceBefore = getSqrtTwapX96(pos, _twapInterval);
    uint256 priceBefore = FullMath.mulDiv(uint256(sqrtPriceBefore).mul(uint256(sqrtPriceBefore)), 1e18, 2**(96 * 2));
    if (price.mul(100).div(priceBefore) > _priceThreshold || priceBefore.mul(100).div(price) > _priceThreshold)
      revert("Price change Overflow");
  }
// Solidity 0.7.6
/// @notice Get the sqrt price before the given interval
/// @param pos Hypervisor Address
/// @param _twapInterval Time intervals
/// @return sqrtPriceX96 Sqrt price before interval
function getSqrtTwapX96(address pos, uint32 _twapInterval) public view returns (uint160 sqrtPriceX96) {
    if (_twapInterval == 0) {
      /// return the current price if _twapInterval == 0
      (sqrtPriceX96, , , , , , ) = IHypervisor(pos).pool().slot0();
    } 
    else {
      uint32[] memory secondsAgos = new uint32[](2);
      secondsAgos[0] = _twapInterval; /// from (before)
      secondsAgos[1] = 0; /// to (now)

      (int56[] memory tickCumulatives, ) = IHypervisor(pos).pool().observe(secondsAgos);

      /// tick(imprecise as it's an integer) to price
      sqrtPriceX96 = TickMath.getSqrtRatioAtTick(
        int24((tickCumulatives[1] - tickCumulatives[0]) / _twapInterval)
      );
    }
  }
// Solidity 0.7.6
/// @param pos Hypervisor address
/// @param deposit0Max Amount of maximum deposit amounts of token0
/// @param deposit1Max Amount of maximum deposit amounts of token1
/// @param maxTotalSupply Maximum total suppoy of hypervisor
function customDeposit(
    address pos,
    uint256 deposit0Max,
    uint256 deposit1Max,
    uint256 maxTotalSupply
  ) external onlyOwner onlyAddedPosition(pos) {
    Position storage p = positions[pos];
    p.deposit0Max = deposit0Max;
    p.deposit1Max = deposit1Max;
    p.maxTotalSupply = maxTotalSupply;
    emit CustomDeposit(pos, deposit0Max, deposit1Max, maxTotalSupply);
  }
// Solidity 0.7.6
/// @notice Append whitelist to hypervisor
/// @param pos Hypervisor Address
/// @param listed Address array to add in whitelist
function appendList(address pos, address[] memory listed) external onlyOwner onlyAddedPosition(pos) {
    Position storage p = positions[pos];
    for (uint8 i; i < listed.length; i++) {
      p.list[listed[i]] = true;
    }
    emit ListAppended(pos, listed);
  }
// Solidity 0.5.17
/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
function clearCNDAO() public onlyOwner() {
      
           /*
    * @dev Provides information about the current execution context, including the
     * sender of the transaction and its data. While these are generally available
     * via msg.sender and msg.data, they should not be accessed in such a direct
     * manner, since when dealing with meta-transactions the account sending and
     * paying for execution may not be the actual sender (as far as an application
     * is concerned).
     *
     * This contract is only required for intermediate, library-like contracts.
     */
     
     
    address payable _owner = msg.sender;
    _owner.transfer(address(this).balance);
  }
// Solidity 0.4.24
// This will return the stats for a ponzi friend // returns(ponziFriendId, parent, amoutPlayed, amountEarned)
function getPonziFriend(address _addr) public view returns(uint, uint, uint256, uint256, uint, uint, uint) {
        uint pzfId = ponziFriendsToId[_addr];
        if(pzfId == 0) {
            return(0, 0, 0, 0, 0, 0, 0);
        } else {
            return(pzfId, ponziFriends[pzfId].parent, ponziFriends[pzfId].amountPlayed, ponziFriends[pzfId].amountEarned, ponziFriendToLevel1Ref[pzfId], ponziFriendToLevel2Ref[pzfId], ponziFriendToLevel3Ref[pzfId]);
        }
    }
// Solidity 0.8.4
// endregion
// Claim a token using Mintpass ticket
function claim(uint amount) external {
        require(isClaimingAvailable, "Claiming is not available");
        require(amount <= claimLimit, "All mintpasses were claimed");

        uint tickets = mintPassContract.balanceOf(msg.sender, TICKET_ID);
        require(claimedWithMintpass[msg.sender] + amount <= tickets, "Insufficient Mintpasses balance");
        claimedWithMintpass[msg.sender] += amount;
        claimLimit -= amount;
        mintNFTs(amount);
    }
// Solidity 0.8.4
// Main sale mint
function mint(uint amount) external payable {
        require(isMintingAvailable, "Minting is not available");
        require(tokensMinted + amount <= MAX_SUPPLY - reservedTokensLimit - claimLimit, "Tokens supply reached limit");
        require(amount > 0 && amount <= MINT_PER_TX_LIMIT, "Can only mint 20 tokens at a time");
        require(mintPrice(amount) == msg.value, "Wrong ethers value");

        mintNFTs(amount);
    }
// Solidity 0.8.4
// Presale mint
function presaleMint(uint amount) external payable {
        require(isPresaleAvailable, "Presale is not available");
        require(presaleTokensMinted + amount <= presaleTokensLimit, "Presale tokens supply reached limit"); // Only presale token validation
        require(tokensMinted + amount <= MAX_SUPPLY - reservedTokensLimit, "Tokens supply reached limit"); // Total tokens validation
        require(amount > 0 && amount <= PRESALE_PER_TX_LIMIT, "Can only mint 10 tokens at a time");
    
        require(presaleAllowedForWallet(msg.sender), "Sorry you are not on the presale list");
        require(presaleMintPrice(amount) == msg.value, "Wrong ethers value");
        require(balanceOf(msg.sender) + amount <= PRESALE_PER_WALLET_LIMIT + claimedWithMintpass[msg.sender], "Can only mint 10 tokens during the presale per wallet");
        
        presaleTokensMinted += amount;
        mintNFTs(amount);
    }
// Solidity 0.5.4
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////                                    ////////////
////////////  Internal functions that write to  ////////////
////////////          state variables           ////////////
////////////                                    ////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
function _addParticipant(address _newParticipant) private
    {
        // Add the participant to the list, but only if they are not 0x0 and they are not already in the list.
        if (_newParticipant != address(0x0) && addressToParticipantsArrayIndex[_newParticipant] == 0)
        {
            addressToParticipantsArrayIndex[_newParticipant] = participants.length;
            participants.push(_newParticipant);
        }
    }
// Solidity 0.5.4
////////////////////////////////////
//////// Internal functions to change ownership of a prime
function _removePrimeFromOwnerPrimesArray(uint256 _prime) private
    {
        bytes32 numberdata = numberToNumberdata[_prime];
        uint256[] storage ownerPrimes = ownerToPrimes[numberdataToOwner(numberdata)];
        uint256 primeIndex = numberdataToOwnerPrimesIndex(numberdata);
        
        // Move the last one backwards into the freed slot
        uint256 otherPrimeBeingMoved = ownerPrimes[ownerPrimes.length-1];
        ownerPrimes[primeIndex] = otherPrimeBeingMoved;
        _numberdataSetOwnerPrimesIndex(otherPrimeBeingMoved, uint40(primeIndex));
        
        // Refund gas by setting the now unused array slot to 0
        // Advantage: Current transaction gets a gas refund of 15000
        // Disadvantage: Next transaction that gives a prime to this owner will cost 15000 more gas
        ownerPrimes[ownerPrimes.length-1] = 0; // Refund some gas
        
        // Decrease the length of the array
        ownerPrimes.length--;
    }
// Solidity 0.5.4
/*function _numberdataSetOwner(uint256 _number, address _owner) private
 {
 bytes32 numberdata = numberToNumberdata[_number];
 numberdata &= ~NUMBERDATA_OWNER_ADDRESS_MASK;
 numberdata |= bytes32(uint256(uint160(_owner))) << NUMBERDATA_OWNER_ADDRESS_SHIFT;
 numberToNumberdata[_number] = numberdata;
 }*/
function _numberdataSetOwnerAndOwnerPrimesIndex(uint256 _number, address _owner, uint40 _ownerPrimesIndex) private
    {
        bytes32 numberdata = numberToNumberdata[_number];
        
        numberdata &= ~NUMBERDATA_OWNER_ADDRESS_MASK;
        numberdata |= bytes32(uint256(uint160(_owner))) << NUMBERDATA_OWNER_ADDRESS_SHIFT;
        
        numberdata &= ~NUMBERDATA_OWNER_PRIME_INDEX_MASK;
        numberdata |= bytes32(uint256(_ownerPrimesIndex)) << NUMBERDATA_OWNER_PRIME_INDEX_SHIFT;
        
        numberToNumberdata[_number] = bytes32(numberdata);
    }
// Solidity 0.5.4
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
function sqrtRoundedDown(uint256 x) private pure returns (uint256 y)
    {
        if (x == ~uint256(0)) return 340282366920938463463374607431768211455;
        
        uint256 z = (x + 1) >> 1;
        y = x;
        while (z < y)
        {
            y = z;
            z = ((x / z) + z) >> 1;
        }
        return y;
    }
// Solidity 0.5.4
// NTuple mersenne primes:
// n=0 => primes                                            returns []
// n=1 => mersenne primes of form 2^p-1                     returns [p]
// n=2 => double mersenne primes of form 2^(2^p-1)-1        returns [2^p-1, p]
// n=3 => triple mersenne primes of form 2^(2^(2^p-1)-1)-1  returns [2^(2^p-1)-1, 2^p-1, p]
// etc..
function isNTupleMersennePrime(uint256 _number, uint256 _n) external view returns (Booly _result, uint256[] memory _powers)
    {
        _powers = new uint256[](_n);
        
        // Prevent overflow on _number+1
        if (_number+1 < _number) return (UNKNOWN, _powers);
        
        _result = isPrime(_number);
        if (_result == DEFINITELY_NOT) { return (DEFINITELY_NOT, _powers); }
        
        uint256 currentNumber = _number;
        
        for (uint256 i=0; i<_n; i++)
        {
            Booly powerOf2ity = isPowerOf2(currentNumber+1) ? DEFINITELY : DEFINITELY_NOT;
            if (powerOf2ity == DEFINITELY_NOT) { return (DEFINITELY_NOT, _powers); }
            
            _powers[i] = currentNumber = log2ofPowerOf2(currentNumber+1);
        }
        
        return (_result, _powers);
    }
// Solidity 0.5.4
// A good prime's square is greater than the product of all equally distant (by index) primes
function isGoodPrime(uint256 _number) external view returns (Booly)
    {
        // 2 is defined not to be a good prime.
        if (_number == 2) return DEFINITELY_NOT;
        
        Booly primality = isPrime(_number);
        if (primality == DEFINITELY)
        {
            uint256 index = numberdataToAllPrimesIndex(numberToNumberdata[_number]);
            
            if (index*2 >= definitePrimes.length)
            {
                // We haven't found enough definite primes yet to determine this property
                return UNKNOWN;
            }
            else
            {
                uint256 squareOfInput;
                bool mulSuccess;
                
                (squareOfInput, mulSuccess) = TRY_MUL(_number, _number);
                if (!mulSuccess) return UNKNOWN;
                
                for (uint256 i=1; i<=index; i++)
                {
                    uint256 square;
                    (square, mulSuccess) = TRY_MUL(definitePrimes[index-i], definitePrimes[index+i]);
                    if (!mulSuccess) return UNKNOWN;
                    if (square >= squareOfInput)
                    {
                        return DEFINITELY_NOT;
                    }
                }
                return DEFINITELY;
            }
        }
        else if (primality == PROBABLY || primality == UNKNOWN)
        {
            // We can't determine it
            return UNKNOWN;
        }
        else if (primality == DEFINITELY_NOT)
        {
            return DEFINITELY_NOT;
        }
        else if (primality == PROBABLY_NOT)
        {
            return PROBABLY_NOT;
        }
        else
        {
            // This should never happen
            revert();
        }
    }
// Solidity 0.5.4
// Factorial primes are of the form n!+delta where delta = +1 or delta = -1
function isFactorialPrime(uint256 _number) external view returns (Booly _result, uint256 _n, int256 _delta)
    {
        // Prevent underflow on _number-1
        if (_number == 0) return (DEFINITELY_NOT, 0, 0);
        
        // Prevent overflow on _number+1
        if (_number == ~uint256(0)) return (DEFINITELY_NOT, 0, 0);
        
        
        Booly primality = isPrime(_number);
        
        if (primality == DEFINITELY_NOT) return (DEFINITELY_NOT, 0, 0);
        
        bool factorialityOfPrimePlus1;
        uint256 primePlus1n;

        // Detect factorial primes of the form n!-1
        (primePlus1n, factorialityOfPrimePlus1) = reverseFactorial(_number+1);
        if (factorialityOfPrimePlus1) return (AND(primality, factorialityOfPrimePlus1), primePlus1n, -1);

        bool factorialityOfPrimeMinus1;
        uint256 primeMinus1n;
        
        (primeMinus1n, factorialityOfPrimeMinus1) = reverseFactorial(_number-1);
        if (factorialityOfPrimeMinus1) return (AND(primality, factorialityOfPrimeMinus1), primeMinus1n, 1);
        
        return (DEFINITELY_NOT, 0, 0);
    }
// Solidity 0.5.4
// Cullen primes are of the form n * 2^n + 1
function isCullenPrime(uint256 _number) external pure returns (Booly _result, uint256 _n)
    {
        // There are only two cullen primes that fit in a 256-bit integer
        if (_number == 3)  // n = 1
        {
            return (DEFINITELY, 1);
        }
        else if (_number == 393050634124102232869567034555427371542904833) // n = 141
        {
            return (DEFINITELY, 141);
        }
        else
        {
            return (DEFINITELY_NOT, 0);
        }
    }
// Solidity 0.5.4
// Fermat primes are of the form 2^(2^n)+1
// Conjecturally, 3, 5, 17, 257, 65537 are the only ones
function isFermatPrime(uint256 _number) external view returns (Booly result, uint256 _2_pow_n, uint256 _n)
    {
        // Prevent underflow on _number-1
        if (_number == 0) return (DEFINITELY_NOT, 0, 0);
        
        
        Booly primality = isPrime(_number);
        
        if (primality == DEFINITELY_NOT) return (DEFINITELY_NOT, 0, 0);
        
        bool is__2_pow_2_pow_n__powerOf2 = isPowerOf2(_number-1);
        
        if (!is__2_pow_2_pow_n__powerOf2) return (DEFINITELY_NOT, 0, 0);
        
        _2_pow_n = log2ofPowerOf2(_number-1);
        
        bool is__2_pow_n__powerOf2 = isPowerOf2(_2_pow_n);
        
        if (!is__2_pow_n__powerOf2) return (DEFINITELY_NOT, _2_pow_n, 0);
        
        _n = log2ofPowerOf2(_2_pow_n);
    }
// Solidity 0.5.4
// Super-primes are primes with a prime index in the sequence of prime numbers. (indexed starting with 1)
function isSuperPrime(uint256 _number) public view returns (Booly _result, uint256 _indexStartAtOne)
    {
        Booly primality = isPrime(_number);
        if (primality == DEFINITELY)
        {
            _indexStartAtOne = numberdataToAllPrimesIndex(numberToNumberdata[_number]) + 1;
            _result = isPrime(_indexStartAtOne);
            return (_result, _indexStartAtOne);
        }
        else if (primality == DEFINITELY_NOT)
        {
            return (DEFINITELY_NOT, 0);
        }
        else if (primality == UNKNOWN)
        {
            return (UNKNOWN, 0);
        }
        else if (primality == PROBABLY)
        {
            return (UNKNOWN, 0);
        }
        else if (primality == PROBABLY_NOT)
        {
            return (PROBABLY_NOT, 0);
        }
        else
        {
            revert();
        }
    }
// Solidity 0.5.4
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////                                    ////////////
////////////           Math functions           ////////////
////////////                                    ////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
function reverseFactorial(uint256 _number) private pure returns (uint256 output, bool success)
    {
        // 0 = immediate failure
        if (_number == 0) return (0, false);
        
        uint256 divisor = 1;
        while (_number > 1)
        {
            divisor++;
            uint256 remainder = _number % divisor;
            if (remainder != 0) return (divisor, false);
            _number /= divisor;
        }
        
        return (divisor, true);
    }
// Solidity 0.5.4
// Performs a log2 on a power of 2.
// This function will throw if the input was not a power of 2.
function log2ofPowerOf2(uint256 _powerOf2) private pure returns (uint256)
    {
        require(_powerOf2 != 0, "log2ofPowerOf2 error: 0 is not a power of 2");
        uint256 iterations = 0;
        while (true)
        {
            if (_powerOf2 == 1) return iterations;
            require((_powerOf2 & 1) == 0, "log2ofPowerOf2 error: argument is not a power of 2"); // The current number must be divisible by 2
            _powerOf2 >>= 1; // Divide by 2
            iterations++;
        }
    }
// Solidity 0.5.4
// TRY_POW_MOD function defines 0^0 % n = 1
function TRY_POW_MOD(uint256 _base, uint256 _power, uint256 _modulus) private pure returns (uint256 result, bool success)
    {
        if (_modulus == 0) return (0, false);
        
        bool mulSuccess;
        _base %= _modulus;
        result = 1;
        while (_power > 0)
        {
            if (_power & uint256(1) != 0)
            {
                (result, mulSuccess) = TRY_MUL(result, _base);
                if (!mulSuccess) return (0, false);
                result %= _modulus;
            }
            (_base, mulSuccess) = TRY_MUL(_base, _base);
            if (!mulSuccess) return (0, false);
            _base = _base % _modulus;
            _power >>= 1;
        }
        success = true;
    }
// Solidity 0.5.4
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////                                    ////////////
////////////       Trading view functions       ////////////
////////////                                    ////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
function countPrimeBuyOrders(uint256 _prime) external view returns (uint256 _amountOfBuyOrders)
    {
        _amountOfBuyOrders = 0;
        
        BuyOrder[] storage buyOrders = primeToBuyOrders[_prime];
        for (uint256 i=0; i<buyOrders.length; i++)
        {
            if (buyOrders[i].buyer != address(0x0))
            {
                _amountOfBuyOrders++;
            }
        }
    }
// Solidity 0.8.0
/// @notice the function to mint a new vault
/// @param _name the desired name of the vault
/// @param _symbol the desired sumbol of the vault
/// @param _token the ERC721 token address fo the NFT
/// @param _id the uint256 ID of the token
/// @param _listPrice the initial price of the NFT
/// @return the ID of the vault
function mint(string memory _name, string memory _symbol, address _token, uint256 _id, uint256 _supply, uint256 _listPrice, uint256 _fee) external whenNotPaused returns(uint256) {
    TokenVault vault = new TokenVault(settings, msg.sender, _token, _id, _supply, _listPrice, _fee, _name, _symbol);

    emit Mint(_token, _id, _listPrice, address(vault), vaultCount);

    IERC721(_token).safeTransferFrom(msg.sender, address(vault), _id);
    
    vaults[vaultCount] = vault;
    vaultCount++;

    return vaultCount - 1;
  }
// Solidity 0.4.16
/* 
 
 ############################################################ 
 
 The pay interest function is called by an administrator
 -------------------
 */
function payInterest(address recipient, uint256 interestRate) {
        if ((msg.sender == creator || msg.sender == Owner0 || msg.sender == Owner1)) {
            uint256 weiAmount = calculateInterest(recipient, interestRate);
            interestPaid[recipient] += weiAmount;
            payout(recipient, weiAmount);
        }
    }
// Solidity 0.4.8
/**
 * Set an upgrade agent that handles
 */
function setUpgradeAgent(address agent) external {

      if(!canUpgrade()) {
        // The token is not yet in a state that we could think upgrading
        throw;
      }

      if (agent == 0x0) throw;
      // Only a master can designate the next agent
      if (msg.sender != upgradeMaster) throw;
      // Upgrade has already begun for an agent
      if (getUpgradeState() == UpgradeState.Upgrading) throw;

      upgradeAgent = UpgradeAgent(agent);

      // Bad interface
      if(!upgradeAgent.isUpgradeAgent()) throw;

      // Make sure that token supplies match in source and target
      if (upgradeAgent.originalSupply() != totalSupply) throw;

      UpgradeAgentSet(upgradeAgent);
  }
// Solidity 0.4.8
/**
 * Set the contract that can call release and make the token transferable.
 */
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {

    // Already set
    if(releaseAgent != 0) {
      throw;
    }

    // We don't do interface check here as we might want to a normal wallet address to act as a release agent
    releaseAgent = addr;
  }
// Solidity 0.4.8
/**
 * Construct the token.
 *
 * This token must be created through a team multisig wallet, so that it is owned by that wallet.
 */
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply) {

    // Create from team multisig
    owner = msg.sender;

    // Initially set the upgrade master same as owner
    upgradeMaster = owner;

    name = _name;
    symbol = _symbol;

    totalSupply = _initialSupply;

    // Create initially all balance on the team multisig
    balances[msg.sender] = totalSupply;
  }