lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/// @dev adds dividends to the account _to
function payDividendsTo(address _to) internal {
        (bool hasNewDividends, uint256 dividends, uint256 lastProcessedEmissionNum) = calculateDividendsFor(_to);
        if (!hasNewDividends)
            return;

        if (0 != dividends) {
            bool res = _to.send(dividends);
            if (res) {
                emit PayDividend(_to, dividends);
            }
            else{
                // _to probably is a contract not able to receive ether
                emit HangingDividend(_to, dividends);
                m_totalHangingDividends = m_totalHangingDividends.add(dividends);
            }
        }

        m_lastAccountEmission[_to] = lastProcessedEmissionNum;
        if (lastProcessedEmissionNum == getLastEmissionNum()) {
            m_lastDividends[_to] = m_totalDividends;
        }
        else {
            m_lastDividends[_to] = m_emissions[lastProcessedEmissionNum.add(1)].totalBalanceWas;
        }
    }
// Solidity 0.8.7
/// @notice Claim Breadsticks for a given NFOG ID
/// @param tokenId The tokenId of the NFOG NFT
function claimById(uint256 tokenId) external {
        // Follow the Checks-Effects-Interactions pattern to prevent reentrancy
        // attacks

        // Checks

        // Check that the msgSender owns the token that is being claimed
        require(
            _msgSender() == oliveGardenContract.ownerOf(tokenId),
            "MUST_OWN_TOKEN_ID"
        );

        // Further Checks, Effects, and Interactions are contained within the
        // _claim() function
        _claim(tokenId, _msgSender());
    }
// Solidity 0.8.7
/// @dev Internal function to mint Breadsticks upon claiming
function _claim(uint256 tokenId, address tokenOwner) internal {
        // Checks
        // Check that the token ID is in range
        // We use >= and <= to here because all of the token IDs are 0-indexed
        require(
            tokenId >= tokenIdStart && tokenId <= tokenIdEnd,
            "TOKEN_ID_OUT_OF_RANGE"
        );

        // Check that Breadsticks have not already been claimed this season
        // for a given tokenId
        require(
            !seasonClaimedByTokenId[season][tokenId],
            "BSTICKS_CLAIMED_FOR_TOKEN_ID"
        );

        // Effects

        // Mark that Breadsticks has been claimed for this season for the
        // given tokenId
        seasonClaimedByTokenId[season][tokenId] = true;

        // Interactions

        // Send Breadsticks to the owner of the token ID
        _mint(tokenOwner, breadsticksPerTokenId);
    }
// Solidity 0.8.0
/**
 * @notice Presale wallet list mint
 */
function mintPresale(uint256 numberOfTokens, bytes32[] calldata _merkleProof) external payable nonReentrant{
        require(mintIsActivePresale, "Presale mint is not active");
        require(
            numberOfTokens <= maxTokensPerTransactionPresale, 
            "You went over max tokens per transaction"
        );
        require(
	        msg.value >= tokenPricePresale * numberOfTokens,
            "You sent the incorrect amount of ETH"
        );
        require(
            !presaleMerkleWalletList[mintingTokenID][msg.sender], 
            "You are not on the presale wallet list or have already minted"
        );
        require(
            numberMintedPresale + numberOfTokens <= maxTokensPresale, 
            "Not enough tokens left to mint that many"
        );
        require(
            numberMintedTotal + numberOfTokens <= maxTokens, 
            "Not enough tokens left to mint that many"
        );

        bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
        require(MerkleProof.verify(_merkleProof, presaleMerkleRoot, leaf), "Invalid Proof");
        numberMintedPresale += numberOfTokens;
        numberMintedTotal += numberOfTokens;
        presaleMerkleWalletList[mintingTokenID][msg.sender] = true;

        _mint(msg.sender, mintingTokenID, numberOfTokens, "");
    }
// Solidity 0.8.0
/**
 * @notice Free mint for wallets in freeWalletList
 */
function mintFreeWalletList() external nonReentrant {
        require(mintIsActiveFree, "Free mint is not active");
        require(
            numberMintedTotal + numberFreeToMint <= maxTokens, 
            "Not enough tokens left to mint that many"
        );
	    require(
            freeWalletList[msg.sender] == true, 
            "You are not on the free wallet list or have already minted"
        );

        numberMintedTotal += numberFreeToMint;
        freeWalletList[msg.sender] = false;
        _mint(msg.sender, mintingTokenID, numberFreeToMint, "");
    }
// Solidity 0.8.0
/**
 *  @notice Set the current token ID minting and reset all counters and active mints to 0 and false respectively
 */
function setMintingTokenIdAndResetState(uint256 tokenID) external onlyOwner {
	    require(tokenID >= 0, "Invalid token id");
	    mintingTokenID = tokenID;

	    mintIsActivePublic = false;
	    mintIsActivePresale = false;
	    mintIsActiveFree = false;

        numberMintedTotal = 0;
	    numberMintedPresale = 0;
	    numberMintedPublic = 0;
    }
// Solidity 0.5.7
/*
 * Fetches TradingPool details. Compatible with:
 * - RebalancingSetTokenV2/V3
 * - Any Fee Calculator
 * - Any Liquidator
 *
 * @param  _rebalancingSetToken           RebalancingSetToken contract instance
 * @return RebalancingLibrary.State       Current rebalance state on the RebalancingSetToken
 * @return uint256[]                      Starting current set, start time, minimum bid, and remaining current sets
 */
function fetchNewTradingPoolDetails(
        IRebalancingSetTokenV2 _tradingPool
    )
        external
        view
        returns (SocialTradingLibrary.PoolInfo memory, RebalancingSetCreateInfo memory, CollateralSetInfo memory)
    {
        RebalancingSetCreateInfo memory tradingPoolInfo = getRebalancingSetInfo(
            address(_tradingPool)
        );

        SocialTradingLibrary.PoolInfo memory poolInfo = ISocialTradingManager(tradingPoolInfo.manager).pools(
            address(_tradingPool)
        );

        CollateralSetInfo memory collateralSetInfo = getCollateralSetInfo(
            tradingPoolInfo.currentSet
        );

        return (poolInfo, tradingPoolInfo, collateralSetInfo);
    }
// Solidity 0.5.7
/*
 * Fetches all TradingPool state associated with a new TWAP rebalance auction. Compatible with:
 * - RebalancingSetTokenV2/V3
 * - Any Fee Calculator
 * - TWAP Liquidator
 *
 * @param  _rebalancingSetToken           RebalancingSetToken contract instance
 * @return RebalancingLibrary.State       Current rebalance state on the RebalancingSetToken
 * @return uint256[]                      Starting current set, start time, minimum bid, and remaining current sets
 */
function fetchTradingPoolTWAPRebalanceDetails(
        IRebalancingSetTokenV2 _tradingPool
    )
        external
        view
        returns (SocialTradingLibrary.PoolInfo memory, TWAPRebalanceInfo memory, CollateralSetInfo memory)
    {
        (
            TWAPRebalanceInfo memory tradingPoolInfo,
            CollateralSetInfo memory collateralSetInfo
        ) = fetchRBSetTWAPRebalanceDetails(_tradingPool);

        address manager = _tradingPool.manager();

        SocialTradingLibrary.PoolInfo memory poolInfo = ISocialTradingManager(manager).pools(
            address(_tradingPool)
        );

        return (poolInfo, tradingPoolInfo, collateralSetInfo);
    }
// Solidity 0.5.17
/// @return the number of the month based on its name.
/// @param _month the first three letters of a month's name e.g. "Jan".
function _monthToNumber(string memory _month) internal pure returns (uint8) {
        bytes32 month = keccak256(abi.encodePacked(_month));
        if (month == _JANUARY) {
            return 1;
        } else if (month == _FEBRUARY) {
            return 2;
        } else if (month == _MARCH) {
            return 3;
        } else if (month == _APRIL) {
            return 4;
        } else if (month == _MAY) {
            return 5;
        } else if (month == _JUNE) {
            return 6;
        } else if (month == _JULY) {
            return 7;
        } else if (month == _AUGUST) {
            return 8;
        } else if (month == _SEPTEMBER) {
            return 9;
        } else if (month == _OCTOBER) {
            return 10;
        } else if (month == _NOVEMBER) {
            return 11;
        } else if (month == _DECEMBER) {
            return 12;
        } else {
            revert("not a valid month");
        }
    }
// Solidity 0.8.4
// Calculate fees 
function calculatePerformanceFees() external onlyManager {
        require(PERFORMANCE_FEES == 0, "Formation.Fi: performance fees pending minting");
        uint256 _deltaPrice = 0;
        if (ALPHA_PRICE > ALPHA_PRICE_WAVG) {
            _deltaPrice = ALPHA_PRICE - ALPHA_PRICE_WAVG;
            ALPHA_PRICE_WAVG = ALPHA_PRICE;
            PERFORMANCE_FEES = (alphaToken.totalSupply() *
            _deltaPrice * PERFORMANCE_FEE_RATE) / (ALPHA_PRICE * COEFF_SCALE_DECIMALS_F); 
        }
    }
// Solidity 0.8.4
// Calculate protfolio deposit indicator 
function calculateNetDepositInd(uint256 _depositAmountTotal, uint256 _withdrawAmountTotal)
     public onlyAlphaStrategy returns( uint) {
        if ( _depositAmountTotal >= 
        ((_withdrawAmountTotal * ALPHA_PRICE) / COEFF_SCALE_DECIMALS_P)){
            netDepositInd = 1 ;
        }
        else {
            netDepositInd = 0;
        }
        return netDepositInd;
    }
// Solidity 0.8.4
// Calculate protfolio Amount
function calculateNetAmountEvent(uint256 _depositAmountTotal, uint256 _withdrawAmountTotal,
        uint256 _MAX_AMOUNT_DEPOSIT, uint256 _MAX_AMOUNT_WITHDRAW) 
        public onlyAlphaStrategy returns(uint256) {
        uint256 _netDeposit;
        if (netDepositInd == 1) {
             _netDeposit = _depositAmountTotal - 
             (_withdrawAmountTotal * ALPHA_PRICE) / COEFF_SCALE_DECIMALS_P;
             netAmountEvent = Math.min( _netDeposit, _MAX_AMOUNT_DEPOSIT);
        }
        else {
            _netDeposit= ((_withdrawAmountTotal * ALPHA_PRICE) / COEFF_SCALE_DECIMALS_P) -
            _depositAmountTotal;
            netAmountEvent = Math.min(_netDeposit, _MAX_AMOUNT_WITHDRAW);
        }
        return netAmountEvent;
    }
// Solidity 0.8.4
// function claim(uint256 tokenId) public nonReentrant {
//     require(tokenId > 0 && tokenId < 7778, "Token ID invalid");
//     _safeMint(_msgSender(), tokenId);
// }
// function ownerClaim(uint256 tokenId) public nonReentrant onlyOwner {
//     require(tokenId > 7777 && tokenId < 8001, "Token ID invalid");
//     _safeMint(owner(), tokenId);
// }
function toString(uint256 value) internal pure returns (string memory) {
    // Inspired by OraclizeAPI's implementation - MIT license
    // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }
// Solidity 0.5.17
/// @notice Burn handles disbursing a share of tokens in this contract to a given address.
/// @param _to The address to disburse to
/// @param _amount The amount of TKN that will be burned if this succeeds
function burn(address payable _to, uint256 _amount) external onlyBurner returns (bool) {
        if (_amount == 0) {
            return true;
        }
        // The burner token deducts from the supply before calling.
        uint256 supply = IBurner(_burner).currentSupply().add(_amount);
        address[] memory redeemableAddresses = _redeemableTokens();
        for (uint256 i = 0; i < redeemableAddresses.length; i++) {
            uint256 redeemableBalance = _balance(address(this), redeemableAddresses[i]);
            if (redeemableBalance > 0) {
                uint256 redeemableAmount = redeemableBalance.mul(_amount).div(supply);
                _safeTransfer(_to, redeemableAddresses[i], redeemableAmount);
                emit CashAndBurned(_to, redeemableAddresses[i], redeemableAmount);
            }
        }

        return true;
    }
// Solidity 0.5.17
/// @notice This allows for the admin to reclaim the non-redeemableTokens.
/// @param _to this is the address which the reclaimed tokens will be sent to.
/// @param _nonRedeemableAddresses this is the array of tokens to be claimed.
function nonRedeemableTokenClaim(address payable _to, address[] calldata _nonRedeemableAddresses) external onlyAdmin returns (bool) {
        for (uint256 i = 0; i < _nonRedeemableAddresses.length; i++) {
            //revert if token is redeemable
            require(!_isTokenRedeemable(_nonRedeemableAddresses[i]), "redeemables cannot be claimed");
            uint256 claimBalance = _balance(address(this), _nonRedeemableAddresses[i]);
            if (claimBalance > 0) {
                _safeTransfer(_to, _nonRedeemableAddresses[i], claimBalance);
                emit Claimed(_to, _nonRedeemableAddresses[i], claimBalance);
            }
        }

        return true;
    }
// Solidity 0.6.6
/**
 * @notice Rescue any non-reward token that was airdropped to this contract
 * @dev Can only be called by the owner
 */
function rescueAirdroppedTokens(address _token, address to)
        external
        override
        onlyOwner
    {
        require(_token != address(0), "token_0x0");
        require(to != address(0), "to_0x0");
        require(_token != farmToken, "rescue_reward_error");

        uint256 balanceOfToken = IERC20(_token).balanceOf(address(this));
        require(balanceOfToken > 0, "balance_0");

        require(IERC20(_token).transfer(to, balanceOfToken), "rescue_failed");
    }
// Solidity 0.6.6
/**
 * @notice View function to see pending rewards for account.
 * @param account user account to check
 * @return pending rewards
 */
function getPendingRewards(address account) public view returns (uint256) {
        if (account != address(0)) {
            if (userInfo[account].amountfToken == 0) {
                return 0;
            }
            return
                _earned(
                    userInfo[account].amountfToken,
                    userInfo[account].userRewardPerTokenPaid,
                    userInfo[account].rewards
                );
        }
        return 0;
    }
// Solidity 0.6.6
/**
 * @notice Deposit to this strategy for rewards
 * @param tokenAmount Amount of Token investment
 * @param deadline Number of blocks until transaction expires
 * @return Amount of fToken
 */
function deposit(
        uint256 tokenAmount,
        uint256 deadline,
        uint256 slippage
    ) public nonReentrant returns (uint256) {
        // -----
        // validate
        // -----
        _validateDeposit(deadline, tokenAmount, totalToken, slippage);

        _updateRewards(msg.sender);

        IERC20(token).safeTransferFrom(msg.sender, address(this), tokenAmount);

        DepositData memory results;
        UserInfo storage user = userInfo[msg.sender];

        if (user.amountfToken == 0) {
            user.wasUserBlacklisted = blacklisted[msg.sender];
        }
        if (user.timestamp == 0) {
            user.timestamp = block.timestamp;
        }

        totalToken = totalToken.add(tokenAmount);
        user.amountToken = user.amountToken.add(tokenAmount);
        results.obtainedToken = tokenAmount;

        // -----
        // deposit Token into harvest and get fToken
        // -----
        results.obtainedfToken = _depositTokenToHarvestVault(
            results.obtainedToken
        );

        // -----
        // stake fToken into the NoMintRewardPool
        // -----
        _stakefTokenToHarvestPool(results.obtainedfToken);
        user.amountfToken = user.amountfToken.add(results.obtainedfToken);

        // -----
        // mint parachain tokens if user is not blacklisted
        // -----
        if (!user.wasUserBlacklisted) {
            user.amountReceiptToken = user.amountReceiptToken.add(
                results.obtainedfToken
            );
            _mintParachainAuctionTokens(results.obtainedfToken);
        }

        emit Deposit(
            msg.sender,
            tx.origin,
            results.obtainedToken,
            results.obtainedfToken
        );


        totalDeposits = totalDeposits.add(results.obtainedfToken);

        user.underlyingRatio = _getRatio(
            user.amountfToken,
            user.amountToken,
            18
        );

        return results.obtainedfToken;
    }
// Solidity 0.4.25
// @dev initialize delegator address and rewards
function updateDelegatorRewards(address[] delegatorAddress, uint[] rewards) onlyOwner public returns (bool) {
        for (uint i=0; i<delegatorAddress.length; i++) {
            Delegator memory delegator = Delegator(delegatorAddress[i], rewards[i] * 10 ** 14 , false);
            rewardDelegators[delegatorAddress[i]] = delegator;
            delegatorAddressList.push(delegatorAddress[i]);
        }
        return true;
    }
// Solidity 0.4.25
// @dev transfer the reward to the delegator
function claimRewards() external haltInEmergency returns (bool) {
        require(!rewardDelegators[msg.sender].hasClaimed);
        require(rewardDelegators[msg.sender].delegator == msg.sender);
        require((ERC20(livePeerContractAddress).balanceOf(this) - this.checkRewards()) > 0);
        require(claimCounter < this.getAllDelegatorAddress().length);
        
        rewardDelegators[msg.sender].hasClaimed = true;
        claimCounter += 1;
        ERC20(livePeerContractAddress).transfer(msg.sender, rewardDelegators[msg.sender].rewards);
        
        emit LogClaimReward(msg.sender, rewardDelegators[msg.sender].rewards);
        
        return true;
    }
// Solidity 0.5.7
/*
 * Fetches all RebalancingSetToken state associated with a rebalance proposal
 *
 * @param  _rebalancingSetToken           RebalancingSetToken contract instance
 * @return RebalancingLibrary.State       Current rebalance state on the RebalancingSetToken
 * @return address[]                      Auction proposal library and next allocation SetToken addresses
 * @return uint256[]                      Auction time to pivot, start price, and pivot price
 */
function fetchRebalanceProposalStateAsync(
        IRebalancingSetToken _rebalancingSetToken
    )
        external
        returns (RebalancingLibrary.State, address[] memory, uint256[] memory)
    {
        // Fetch the RebalancingSetToken's current rebalance state
        RebalancingLibrary.State rebalanceState = _rebalancingSetToken.rebalanceState();

        // Create return address arrays
        address[] memory auctionAddressParams = new address[](2);
        // Fetch the addresses associated with the current rebalance
        auctionAddressParams[0] = _rebalancingSetToken.nextSet();
        auctionAddressParams[1] = _rebalancingSetToken.auctionLibrary();

        // Create return integer array
        uint256[] memory auctionIntegerParams = new uint256[](4);
        auctionIntegerParams[0] = _rebalancingSetToken.proposalStartTime();

        // Fetch the current rebalance's proposal parameters
        uint256[] memory auctionParameters = _rebalancingSetToken.getAuctionPriceParameters();
        auctionIntegerParams[1] = auctionParameters[1]; // auctionTimeToPivot
        auctionIntegerParams[2] = auctionParameters[2]; // auctionStartPrice
        auctionIntegerParams[3] = auctionParameters[3]; // auctionPivotPrice

        return (rebalanceState, auctionAddressParams, auctionIntegerParams);
    }
// Solidity 0.5.7
/*
 * Fetches all RebalancingSetToken state associated with a new rebalance auction
 *
 * @param  _rebalancingSetToken           RebalancingSetToken contract instance
 * @return RebalancingLibrary.State       Current rebalance state on the RebalancingSetToken
 * @return uint256[]                      Starting current set, start time, minimum bid, and remaining current sets
 */
function fetchRebalanceAuctionStateAsync(
        IRebalancingSetToken _rebalancingSetToken
    )
        external
        returns (RebalancingLibrary.State, uint256[] memory)
    {
        // Fetch the RebalancingSetToken's current rebalance state
        RebalancingLibrary.State rebalanceState = _rebalancingSetToken.rebalanceState();

        // Fetch the current rebalance's startingCurrentSetAmount
        uint256[] memory auctionIntegerParams = new uint256[](4);
        auctionIntegerParams[0] = _rebalancingSetToken.startingCurrentSetAmount();

        // Fetch the current rebalance's auction parameters which are made up of various auction times and prices
        uint256[] memory auctionParameters = _rebalancingSetToken.getAuctionPriceParameters();
        auctionIntegerParams[1] = auctionParameters[0]; // auctionStartTime

        // Fetch the current rebalance's bidding parameters which includes the minimum bid and the remaining shares
        uint256[] memory biddingParameters = _rebalancingSetToken.getBiddingParameters();
        auctionIntegerParams[2] = biddingParameters[0]; // minimumBid
        auctionIntegerParams[3] = biddingParameters[1]; // remainingCurrentSets

        return (rebalanceState, auctionIntegerParams);
    }
// Solidity 0.5.7
/*
 * Fetches RebalancingSetToken states for an array of RebalancingSetToken instances
 *
 * @param  _rebalancingSetTokens[]       RebalancingSetToken contract instances
 * @return RebalancingLibrary.State[]    Current rebalance states on the RebalancingSetToken
 */
function batchFetchRebalanceStateAsync(
        IRebalancingSetToken[] calldata _rebalancingSetTokens
    )
        external
        returns (RebalancingLibrary.State[] memory)
    {
        // Cache length of addresses to fetch states for
        uint256 _addressesCount = _rebalancingSetTokens.length;

        // Instantiate output array in memory
        RebalancingLibrary.State[] memory states = new RebalancingLibrary.State[](_addressesCount);

        // Cycle through contract addresses array and fetching the rebalance state of each RebalancingSet
        for (uint256 i = 0; i < _addressesCount; i++) {
            states[i] = _rebalancingSetTokens[i].rebalanceState();
        }

        return states;
    }
// Solidity 0.5.7
/*
 * Fetches RebalancingSetToken unitShares for an array of RebalancingSetToken instances
 *
 * @param  _rebalancingSetTokens[]       RebalancingSetToken contract instances
 * @return uint256[]                     Current unitShares on the RebalancingSetToken
 */
function batchFetchUnitSharesAsync(
        IRebalancingSetToken[] calldata _rebalancingSetTokens
    )
        external
        returns (uint256[] memory)
    {
        // Cache length of addresses to fetch states for
        uint256 _addressesCount = _rebalancingSetTokens.length;

        // Instantiate output array in memory
        uint256[] memory unitShares = new uint256[](_addressesCount);

        // Cycles through contract addresses array and fetches the unitShares of each RebalancingSet
        for (uint256 i = 0; i < _addressesCount; i++) {
            unitShares[i] = _rebalancingSetTokens[i].unitShares();
        }

        return unitShares;
    }