lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
// Transaction overview:
// 1. User approves transfer of synth to `AtomicSwap` contract (triggered by the frontend)
// 2. User calls `AtomicSwap.redeemAndSwapTokensForExact()` (triggered by the frontend)
//   2.1 `AtomicSwaps` transfers synth from user to itself (internal tx)
//   2.2 `AtomicSwaps` approves transfer of synth from itself to pool (internal tx)
//   2.3 `AtomicSwap` calls `pool.redeem()` to redeem synth for collateral (internal tx)
//   2.4 `AtomicSwap` approves transfer of collateral to `IUniswapV2Router02` (internal tx)
//   2.5 AtomicSwap checks the return amounts from the swapTokensForExactTokens() function and saves the leftover of inputTokens in a variable
//   2.6 `AtomicSwap` calls `IUniswapV2Router02.swapTokensForExactTokens` to swap collateral for token (internal tx)
//   2.7 AtomicSwap transfers the leftover amount to the user if there is any
function redeemAndSwapTokensForExact(
    uint256 amountTokenOut,
    address[] calldata tokenSwapPath,
    ISynthereumPoolOnChainPriceFeed synthereumPool,
    ISynthereumPoolOnChainPriceFeed.RedeemParams memory redeemParams,
    address recipient
  )
    public
    returns (
      uint256 collateralRedeemed,
      IERC20 outputToken,
      uint256 outputTokenAmount
    )
  {
    IERC20 collateralInstance = checkPoolRegistration(synthereumPool);
    require(
      address(collateralInstance) == tokenSwapPath[0],
      'Wrong collateral instance'
    );

    IERC20 synthToken = synthereumPool.syntheticToken();
    outputToken = IERC20(tokenSwapPath[tokenSwapPath.length - 1]);

    uint256 numTokens = redeemParams.numTokens;
    synthToken.safeTransferFrom(msg.sender, address(this), numTokens);
    synthToken.safeApprove(address(synthereumPool), numTokens);

    redeemParams.recipient = address(this);
    (collateralRedeemed, ) = synthereumPool.redeem(redeemParams);

    uint256[2] memory amounts =
      _getNeededAmountAndLeftover(
        amountTokenOut,
        tokenSwapPath,
        collateralRedeemed
      );

    collateralInstance.safeApprove(address(uniswapRouter), amounts[0]);

    outputTokenAmount = uniswapRouter.swapTokensForExactTokens(
      amountTokenOut,
      amounts[0],
      tokenSwapPath,
      recipient,
      redeemParams.expiration
    )[tokenSwapPath.length - 1];

    if (amounts[1] != 0) {
      collateralInstance.safeTransfer(recipient, amounts[1]);
    }

    emit Swap(
      address(synthToken),
      numTokens,
      address(outputToken),
      outputTokenAmount
    );
  }
// Solidity 0.4.26
// ------------------------------------------------------------------------
// 100000 FWD Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate && now <= endDate);
        uint tokens;
        if (now <= bonusEnds) {
            tokens = msg.value * 10000000000;
        } else {
            tokens = msg.value * 100000;
        }
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.6.12
// Transaction overview:
// 1. User calls AtomicSwap.swapExactETHAndMint() sending Ether (triggered by the frontend)
//    1.1 AtomicSwap calls IUniswapV2Router02.swapExactETHForTokens() to exchange ETH for collateral (internal tx)
//    1.2 AtomicSwap approves SynthereumPool (internal tx)
//    1.3 AtomicSwap calls SynthereumPool.mint() to mint synth with collateral (internal tx)
function swapExactETHAndMint(
    uint256 collateralAmountOut,
    address[] calldata tokenSwapPath,
    ISynthereumPoolOnChainPriceFeed synthereumPool,
    ISynthereumPoolOnChainPriceFeed.MintParams memory mintParams
  )
    public
    payable
    returns (
      uint256 collateralOut,
      IERC20 synthToken,
      uint256 syntheticTokensMinted
    )
  {
    IERC20 collateralInstance = checkPoolRegistration(synthereumPool);
    uint256 numberOfSwapTokens = tokenSwapPath.length - 1;
    require(
      address(collateralInstance) == tokenSwapPath[numberOfSwapTokens],
      'Wrong collateral instance'
    );
    synthToken = synthereumPool.syntheticToken();

    collateralOut = uniswapRouter.swapExactETHForTokens{value: msg.value}(
      collateralAmountOut,
      tokenSwapPath,
      address(this),
      mintParams.expiration
    )[numberOfSwapTokens];

    collateralInstance.safeApprove(address(synthereumPool), collateralOut);

    mintParams.collateralAmount = collateralOut;
    (syntheticTokensMinted, ) = synthereumPool.mint(mintParams);

    emit Swap(
      address(0),
      msg.value,
      address(synthToken),
      syntheticTokensMinted
    );
  }
// Solidity 0.6.12
// Transaction overview:
// 1. User calls AtomicSwap.swapETHForExactAndMint() sending Ether (triggered by the frontend)
//    1.1 AtomicSwap checks the return amounts from the IUniswapV2Router02.swapETHForExactTokens()
//    1.2 AtomicSwap saves the leftover ETH that won't be used in a variable
//    1.3 AtomicSwap calls IUniswapV2Router02.swapETHForExactTokens() to exchange ETH for collateral (internal tx)
//    1.4 AtomicSwap approves SynthereumPool (internal tx)
//    1.5 AtomicSwap calls SynthereumPool.mint() to mint synth with collateral (internal tx)
//    1.6 AtomicSwap transfers the remaining ETH from the transactions to the user
function swapETHForExactAndMint(
    uint256 collateralAmountOut,
    address[] calldata tokenSwapPath,
    ISynthereumPoolOnChainPriceFeed synthereumPool,
    ISynthereumPoolOnChainPriceFeed.MintParams memory mintParams
  )
    public
    payable
    returns (
      uint256 collateralOut,
      IERC20 synthToken,
      uint256 syntheticTokensMinted
    )
  {
    IERC20 collateralInstance = checkPoolRegistration(synthereumPool);
    uint256 numberOfSwapTokens = tokenSwapPath.length - 1;
    require(
      address(collateralInstance) == tokenSwapPath[numberOfSwapTokens],
      'Wrong collateral instance'
    );
    synthToken = synthereumPool.syntheticToken();

    collateralOut = uniswapRouter.swapETHForExactTokens{value: msg.value}(
      collateralAmountOut,
      tokenSwapPath,
      address(this),
      mintParams.expiration
    )[numberOfSwapTokens];

    collateralInstance.safeApprove(address(synthereumPool), collateralOut);

    mintParams.collateralAmount = collateralOut;
    (syntheticTokensMinted, ) = synthereumPool.mint(mintParams);

    if (address(this).balance != 0) {
      msg.sender.transfer(address(this).balance);
    }

    emit Swap(
      address(0),
      msg.value,
      address(synthToken),
      syntheticTokensMinted
    );
  }
// Solidity 0.6.12
// Transaction overview:
// 1. User approves transfer of synth to `AtomicSwap` contract (triggered by the frontend)
// 2. User calls `AtomicSwap.redeemAndSwapExactTokensForETH()` (triggered by the frontend)
//   2.1 `AtomicSwaps` transfers synth from user to itself (internal tx)
//   2.2 `AtomicSwaps` approves transfer of synth from itself to pool (internal tx)
//   2.3 `AtomicSwap` calls `pool.redeem()` to redeem synth for collateral (internal tx)
//   2.4 `AtomicSwap` approves transfer of collateral to `IUniswapV2Router02` (internal tx)
//   2.5 `AtomicSwap` calls `IUniswapV2Router02.swapExactTokensForETH` to swap collateral for ETH (internal tx)
function redeemAndSwapExactTokensForETH(
    uint256 amountTokenOut,
    address[] calldata tokenSwapPath,
    ISynthereumPoolOnChainPriceFeed synthereumPool,
    ISynthereumPoolOnChainPriceFeed.RedeemParams memory redeemParams,
    address recipient
  )
    public
    returns (
      uint256 collateralRedeemed,
      IERC20 outputToken,
      uint256 outputTokenAmount
    )
  {
    IERC20 collateralInstance = checkPoolRegistration(synthereumPool);
    require(
      address(collateralInstance) == tokenSwapPath[0],
      'Wrong collateral instance'
    );

    IERC20 synthToken = synthereumPool.syntheticToken();

    uint256 numTokens = redeemParams.numTokens;
    synthToken.safeTransferFrom(msg.sender, address(this), numTokens);
    synthToken.safeApprove(address(synthereumPool), numTokens);

    redeemParams.recipient = address(this);
    (collateralRedeemed, ) = synthereumPool.redeem(redeemParams);

    collateralInstance.safeApprove(address(uniswapRouter), collateralRedeemed);

    outputTokenAmount = uniswapRouter.swapExactTokensForETH(
      collateralRedeemed,
      amountTokenOut,
      tokenSwapPath,
      recipient,
      redeemParams.expiration
    )[tokenSwapPath.length - 1];

    emit Swap(
      address(synthToken),
      numTokens,
      address(outputToken),
      outputTokenAmount
    );
  }
// Solidity 0.6.12
// Transaction overview:
// 1. User approves transfer of synth to `AtomicSwap` contract (triggered by the frontend)
// 2. User calls `AtomicSwap.redeemAndSwapTokensForExactETH()` (triggered by the frontend)
//   2.1 `AtomicSwaps` transfers synth from user to itself (internal tx)
//   2.2 `AtomicSwaps` approves transfer of synth from itself to pool (internal tx)
//   2.3 `AtomicSwap` calls `pool.redeem()` to redeem synth for collateral (internal tx)
//   2.4 `AtomicSwap` approves transfer of collateral to `IUniswapV2Router02` (internal tx)
//   2.5 AtomicSwap checks what would be the leftover of tokens after the swap and saves it in a variable
//   2.6 `AtomicSwap` calls `IUniswapV2Router02.swapTokensForExactETH` to swap collateral for ETH (internal tx)
//   2.7 AtomicSwap transfers the leftover tokens to the user if there are any
function redeemAndSwapTokensForExactETH(
    uint256 amountTokenOut,
    address[] calldata tokenSwapPath,
    ISynthereumPoolOnChainPriceFeed synthereumPool,
    ISynthereumPoolOnChainPriceFeed.RedeemParams memory redeemParams,
    address recipient
  )
    public
    returns (
      uint256 collateralRedeemed,
      IERC20 outputToken,
      uint256 outputTokenAmount
    )
  {
    IERC20 collateralInstance = checkPoolRegistration(synthereumPool);
    require(
      address(collateralInstance) == tokenSwapPath[0],
      'Wrong collateral instance'
    );

    IERC20 synthToken = synthereumPool.syntheticToken();

    uint256 numTokens = redeemParams.numTokens;
    synthToken.safeTransferFrom(msg.sender, address(this), numTokens);
    synthToken.safeApprove(address(synthereumPool), numTokens);

    redeemParams.recipient = address(this);
    (collateralRedeemed, ) = synthereumPool.redeem(redeemParams);

    uint256[2] memory amounts =
      _getNeededAmountAndLeftover(
        amountTokenOut,
        tokenSwapPath,
        collateralRedeemed
      );

    collateralInstance.safeApprove(address(uniswapRouter), amounts[0]);

    outputTokenAmount = uniswapRouter.swapTokensForExactETH(
      amountTokenOut,
      amounts[0],
      tokenSwapPath,
      recipient,
      redeemParams.expiration
    )[tokenSwapPath.length - 1];

    if (amounts[1] != 0) {
      collateralInstance.safeTransfer(recipient, amounts[1]);
    }

    emit Swap(
      address(synthToken),
      numTokens,
      address(outputToken),
      outputTokenAmount
    );
  }
// Solidity 0.6.12
// Checks if a pool is registered with the SynthereumRegistry
function checkPoolRegistration(ISynthereumPoolOnChainPriceFeed synthereumPool)
    internal
    view
    returns (IERC20 collateralInstance)
  {
    ISynthereumRegistry poolRegistry =
      ISynthereumRegistry(
        synthereumFinder.getImplementationAddress(
          SynthereumInterfaces.PoolRegistry
        )
      );
    string memory synthTokenSymbol = synthereumPool.syntheticTokenSymbol();
    collateralInstance = synthereumPool.collateralToken();
    uint8 version = synthereumPool.version();
    require(
      poolRegistry.isDeployed(
        synthTokenSymbol,
        collateralInstance,
        version,
        address(synthereumPool)
      ),
      'Pool not registred'
    );
  }
// Solidity 0.8.7
/**
 * @notice requestRandomness initiates a request for VRF output given _seed
 *
 * @dev The fulfillRandomness method receives the output, once it's provided
 * @dev by the Oracle, and verified by the vrfCoordinator.
 *
 * @dev The _keyHash must already be registered with the VRFCoordinator, and
 * @dev the _fee must exceed the fee specified during registration of the
 * @dev _keyHash.
 *
 * @dev The _seed parameter is vestigial, and is kept only for API
 * @dev compatibility with older versions. It can't *hurt* to mix in some of
 * @dev your own randomness, here, but it's not necessary because the VRF
 * @dev oracle will mix the hash of the block containing your request into the
 * @dev VRF seed it ultimately uses.
 *
 * @param _keyHash ID of public key against which randomness is generated
 * @param _fee The amount of LINK to send with the request
 *
 * @return requestId unique ID for this request
 *
 * @dev The returned requestId can be used to distinguish responses to
 * @dev concurrent requests. It is passed as the first argument to
 * @dev fulfillRandomness.
 */
function requestRandomness(
    bytes32 _keyHash,
    uint256 _fee
  )
    internal
    returns (
      bytes32 requestId
    )
  {
    LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER));
    // This is the seed passed to VRFCoordinator. The oracle will mix this with
    // the hash of the block containing this request to obtain the seed/input
    // which is finally passed to the VRF cryptographic machinery.
    uint256 vRFSeed  = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]);
    // nonces[_keyHash] must stay in sync with
    // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
    // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
    // This provides protection against the user repeating their input seed,
    // which would result in a predictable/duplicate output, if multiple such
    // requests appeared in the same block.
    nonces[_keyHash] = nonces[_keyHash] + 1;
    return makeRequestId(_keyHash, vRFSeed);
  }
// Solidity 0.6.12
// Sends all avaibile balances and creates LP tokens
// Possible ways this could break addressed
// 1) Multiple calls and resetting amounts - addressed with boolean
// 2) Failed WETH wrapping/unwrapping addressed with checks
// 3) Failure to create LP tokens, addressed with checks
// 4) Unacceptable division errors . Addressed with multiplications by 1e18
// 5) Pair not set - impossible since its set in constructor
function addLiquidityToUniswapPxWETHPair() public {
        require(liquidityGenerationOngoing() == false, "Liquidity generation onging");
        require(LPGenerationCompleted == false, "Liquidity generation already finished");
        totalETHContributed = address(this).balance;
        IUniswapV2Pair pair = IUniswapV2Pair(tokenUniswapPair);
        Console.log("Balance of this", totalETHContributed / 1e18);
        //Wrap eth
        address WETH = uniswapRouterV2.WETH();
        IWETH(WETH).deposit{value : totalETHContributed}();
        require(address(this).balance == 0 , "Transfer Failed");
        IWETH(WETH).transfer(address(pair),totalETHContributed);
        emit Transfer(address(this), address(pair), _balances[address(this)]);
        _balances[address(pair)] = _balances[address(this)];
        _balances[address(this)] = 0;
        pair.mint(address(this));
        totalLPTokensCreated = pair.balanceOf(address(this));
        Console.log("Total tokens created",totalLPTokensCreated);
        require(totalLPTokensCreated != 0 , "LP creation failed");
        LPperETHUnit = totalLPTokensCreated.mul(1e18).div(totalETHContributed); // 1e18x for  change
        Console.log("Total per LP token", LPperETHUnit);
        require(LPperETHUnit != 0 , "LP creation failed");
        LPGenerationCompleted = true;

    }
// Solidity 0.6.12
// Possible ways this could break addressed
// 1) No ageement to terms - added require
// 2) Adding liquidity after generaion is over - added require
// 3) Overflow from uint - impossible there isnt that much ETH aviable
// 4) Depositing 0 - not an issue it will just add 0 to tally
function addLiquidity(bool IreadParticipationAgreementInReadSectionAndIagreeFalseOrTrue) public payable {
        require(liquidityGenerationOngoing(), "Liquidity Generation Event over");
        require(IreadParticipationAgreementInReadSectionAndIagreeFalseOrTrue, "No agreement provided");
        ethContributed[msg.sender] += msg.value; // Overflow protection from safemath is not neded here
        totalETHContributed = totalETHContributed.add(msg.value); // for front end display during LGE. This resets with definietly correct balance while calling pair.
        emit LiquidityAddition(msg.sender, msg.value);
    }
// Solidity 0.6.12
// Possible ways this could break addressed
// 1) Accessing before event is over and resetting eth contributed -- added require
// 2) No uniswap pair - impossible at this moment because of the LPGenerationCompleted bool
// 3) LP per unit is 0 - impossible checked at generation function
function claimLPTokens() public {
        require(LPGenerationCompleted, "Event not over yet");
        require(ethContributed[msg.sender] > 0 , "Nothing to claim, move along");
        IUniswapV2Pair pair = IUniswapV2Pair(tokenUniswapPair);
        uint256 amountLPToTransfer = ethContributed[msg.sender].mul(LPperETHUnit).div(1e18);
        pair.transfer(msg.sender, amountLPToTransfer); // stored as 1e18x value for change
        ethContributed[msg.sender] = 0;
        emit LPTokenClaimed(msg.sender, amountLPToTransfer);
    }
// Solidity 0.8.7
// CHECK WHICH SERIES 2 ID CAN BE CLAIMED WITH SERIES 0 OR SERIES 1 TOKENS
function series2_token(CollectionToClaim _collection, uint256[] memory tokenIds) public view returns(uint256[] memory) {
        require(mintStartIndexDrawn);
       
        uint256[] memory ids = new uint256[](tokenIds.length);

        if (_collection == CollectionToClaim.Series0) {
            for(uint i = 0; i<tokenIds.length;i++) {
                uint tokenId = tokenIds[i];
                require(tokenId < 18);
                require(tokenId > 0);
                ids[i] = (tokenId + Series0start + mintStartIndex) % Series2total;
            }
        }
        else if (_collection == CollectionToClaim.Series1) {
            for(uint i = 0; i<tokenIds.length;i++) {
                uint tokenId = tokenIds[i];
                require(tokenId < 221);
                require(tokenId > 0);
                ids[i] = (tokenId + Series1start + mintStartIndex) % Series2total;
            }
        }
        else {
            revert();
        }
       
        return ids;      
       
    }
// Solidity 0.8.7
// CHECK IF SERIES 2 TOKEN IS CLAIMED
function check_claim(CollectionToClaim _collection, uint256[] memory tokenIds) public view returns(bool[] memory) {
        uint256[] memory ids = series2_token(_collection, tokenIds);
        bool[] memory isit = new bool[](tokenIds.length);
        for(uint i = 0; i<tokenIds.length;i++) {
            isit[i] = _exists(ids[i]);
        }
        return isit;
    }
// Solidity 0.8.7
// MINT THEM
function mint_series2(CollectionToClaim _collection, uint256[] memory tokenIds) public {
       
        require(claimRunning && mintStartIndexDrawn);
        require(tokenIds.length > 0 && tokenIds.length <= 15);

        if (_collection == CollectionToClaim.Series0) {
            for(uint i = 0; i<tokenIds.length;i++) {
                uint tokenId = tokenIds[i];
                require(tokenId < 18);
                require(tokenId > 0);
                require(ClaimFromERC721(Series0Address).ownerOf(tokenId) == msg.sender);
                uint Series2idBeingMinted = (tokenId + Series0start + mintStartIndex) % Series2total;
                _safeMint(msg.sender, Series2idBeingMinted);
                emit Series2Claimed(_collection, tokenId, Series2idBeingMinted, msg.sender);
            }
        }
       
        else if (_collection == CollectionToClaim.Series1) {
            for(uint i = 0; i<tokenIds.length;i++) {
                uint tokenId = tokenIds[i];
                require(tokenId < 221);
                require(tokenId > 0);
                require(ClaimFromERC721(Series1Address).ownerOf(tokenId) == msg.sender);
                uint Series2idBeingMinted = (tokenId + Series1start + mintStartIndex) % Series2total;
                _safeMint(msg.sender, Series2idBeingMinted);
                emit Series2Claimed(_collection, tokenId, Series2idBeingMinted, msg.sender);
            }
        }
       
        else {
            revert();
        }
   
    }
// Solidity 0.8.10
/**
 * @notice Determine winner by tallying votes
 */
function _determineWinner(uint256 counter) internal view returns (uint256) {
        uint256 winner = currentAxonsNumbersForVotes[counter][0];
        uint256 highestVoteCount = 0;

        for (uint i=0; i<10; i++) {
            uint256 currentAxonNumber = currentAxonsNumbersForVotes[counter][i];
            uint256 currentVotesCount = currentVotesForAxonNumbers[counter][i];

            if (currentVotesCount > highestVoteCount) {
                winner = currentAxonNumber;
                highestVoteCount = currentVotesCount;
            }
        }

        return winner;
    }
// Solidity 0.4.24
/**
 * @dev Subtracts two signed integers, reverts on overflow.
 */
function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        require((b >= 0 && c <= a) || (b < 0 && c > a));

        return c;
    }
// Solidity 0.4.24
/**
 * @dev Adds two signed integers, reverts on overflow.
 */
function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        require((b >= 0 && c >= a) || (b < 0 && c < a));

        return c;
    }
// Solidity 0.8.4
// Minting reserved tokens to the treasury wallet
function mintReserved(uint256 _mintAmount) external onlyOwner {
        require(_mintAmount > 0, "amount to mint should be a positive number");
        require(
            reservedMinted + _mintAmount <= WT_MAX_RESERVED_COUNT,
            "cannot mint the amount requested"
        );

        uint256 supply = currentIndex;
        require(
            supply + _mintAmount <= WT_TOTAL_SUPPLY,
            "the collection is sold out"
        );

        _mint(WALLET_TREASURY, _mintAmount, "", false);
    }
// Solidity 0.8.4
// ------------------------------------------
// ASSETS ACCESS MANAGEMENT
function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );

        if (revealed == false) {
            return notRevealedUri;
        }
        uint256 assetIndex = tokenId + 1;

        string memory currentBaseURI = baseURI;
        return
            bytes(currentBaseURI).length > 0
                ? string(
                    abi.encodePacked(
                        currentBaseURI,
                        assetIndex.toString(),
                        baseExtension
                    )
                )
                : "";
    }
// Solidity 0.4.11
/// Convert from a pixel's x, y coordinates to its section index
/// This is a helper function
function getSectionIndexFromRaw(
        uint _x,
        uint _y
    ) returns (uint) {
        if (_x >= mapWidth) throw;
        if (_y >= mapHeight) throw;
        // Convert raw x, y to section identifer x y
        _x = _x / 10;
        _y = _y / 10;
        //Get section_identifier from coords
        return _x + (_y * 100);
    }
// Solidity 0.4.11
/// Get Section index based on its upper left x,y coordinates or "identifier"
/// coordinates
/// This is a helper function
function getSectionIndexFromIdentifier (
        uint _x_section_identifier,
        uint _y_section_identifier
    ) returns (uint) {
        if (_x_section_identifier >= (mapWidth / 10)) throw;
        if (_y_section_identifier >= (mapHeight / 10)) throw;
        uint index = _x_section_identifier + (_y_section_identifier * 100);
        return index;
    }