lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.6
/// @dev Withdraw ALD from treasury, swap and add liquidity.
/// @param amount The amount of ald token to withdraw.
/// @param minALDUSDCLP The minimum amount of ALD USDC LP should get.
/// @param minALDWETHLP The minimum amount of ALD USDC LP should get.
function withdrawALDAndSwapToLP(
    uint256 amount,
    uint256 minALDUSDCLP,
    uint256 minALDWETHLP
  ) external onlyWhitelist {
    require(whitelist[msg.sender], "POLExecutor: only whitelist");
    ITreasury(treasury).manage(ald, amount);

    uint256 aldusdcAmount = _swapToLP(aldusdc, ald, amount / 2);
    require(aldusdcAmount >= minALDUSDCLP, "POLExecutor: not enough ALDUSDC LP");

    uint256 aldwethAmount = _swapToLP(aldweth, ald, amount - amount / 2);
    require(aldwethAmount >= minALDWETHLP, "POLExecutor: not enough ALDWETH LP");
  }
// Solidity 0.7.6
/// @dev Withdraw ALD and token from treasury, and then add liquidity.
/// @param aldAmount The amount of ald token to withdraw.
/// @param token The address of other token, should be usdc or weth.
/// @param minLPAmount The minimum lp amount should get.
function withdrawAndAddLiquidity(
    uint256 aldAmount,
    address token,
    uint256 minLPAmount
  ) external onlyWhitelist {
    address pair;
    uint256 reserve0;
    uint256 reserve1;
    if (token == usdc) {
      (reserve0, reserve1, ) = IUniswapV2Pair(aldusdc).getReserves();
      pair = aldusdc;
    } else if (token == weth) {
      (reserve0, reserve1, ) = IUniswapV2Pair(aldweth).getReserves();
      pair = aldweth;
    } else {
      revert("POLExecutor: token not supported");
    }
    if (ald > token) {
      (reserve0, reserve1) = (reserve1, reserve0);
    }
    uint256 tokenAmount = aldAmount.mul(reserve1).div(reserve0);

    ITreasury(treasury).manage(ald, aldAmount);
    ITreasury(treasury).withdraw(token, tokenAmount);
    IERC20(ald).safeTransfer(pair, aldAmount);
    IERC20(token).safeTransfer(pair, tokenAmount);

    uint256 lpAmount = IUniswapV2Pair(pair).mint(treasury);
    require(lpAmount >= minLPAmount, "POLExecutor: not enough lp");
  }
// Solidity 0.4.24
// TODO; newly added
// @param _tokenAddress - objectOwnership
// @param _objectContract - xxxBase contract
function encodeTokenIdForOuterObjectContract(
        address _objectContract, address _nftAddress, address _originNftAddress, uint128 _objectId, uint16 _producerId, uint8 _convertType) public view returns (uint256) {
        require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist.");

        return encodeTokenIdForOuter(_nftAddress, _originNftAddress, classAddress2Id[_objectContract], _objectId, _producerId, _convertType);

    }
// Solidity 0.4.24
// TODO; newly added
function encodeTokenIdForObjectContract(
        address _tokenAddress, address _objectContract, uint128 _objectId) public view returns (uint256 _tokenId) {
        require (classAddress2Id[_objectContract] > 0, "Object class for this object contract does not exist.");

        _tokenId = encodeTokenId(_tokenAddress, classAddress2Id[_objectContract], _objectId);
    }
// Solidity 0.8.9
/**
 * @dev Encode character details as JSON attributes
 */
function assembleBaseAttributes (uint16[15] memory attributes) internal view returns (string memory, bytes memory) {
        bytes memory result = "";
        for (uint i = 0; i < 13; i++) {
            result = abi.encodePacked(result, encodeStringAttribute(Starkade.Attributes(i), Starkade.traitName(attributes[i])), ",");
        }

        (string memory regionName, string memory cityName, string memory characteristic) = Starkade.cityInfo(attributes[14]);

        return (regionName,
                abi.encodePacked(result, encodeStringAttribute(Starkade.Attributes(13), regionName), ","));
    }
// Solidity 0.8.9
/**
 * @dev Generate metadata description string
 */
function description (string memory region) internal pure returns (bytes memory) {
        return abi.encodePacked("A legend is born. This fighter from ",region," is one of a set of unique characters from the STARKADE universe, inspired by the retro '80s artwork of Signalnoise.");
    }
// Solidity 0.8.9
/**
 * @dev Assemble the imageURI for the given attributes
 */
function imageURI (uint16[15] memory attributes) internal view returns (bytes memory) {
        bytes memory uri = bytes(BASE_IMAGE_URI);
        for (uint i = 1; i < 12; i++) {
            uri = abi.encodePacked(uri, MoonCatSVGS.uint2str(attributes[i]), "-");
        }
        return abi.encodePacked(uri, MoonCatSVGS.uint2str(attributes[12]), ".png");
    }
// Solidity 0.8.9
/**
 * @dev Generate full BASE64-encoded JSON metadata for a STARKADE legion character. Use static IPFS image if available.
 */
function legionMetadata (uint256 tokenId) public view returns (string memory) {
        (uint16[15] memory attributes, uint8[5] memory boosts) = Starkade.getTraitIndexes(tokenId);
        string memory tokenIdString = MoonCatSVGS.uint2str(tokenId);
        (string memory regionName, bytes memory baseAttributes) = assembleBaseAttributes(attributes);
        bytes memory boostAttributes = assembleBoosts(boosts);
        bytes memory img;
        if (bytes(IPFS_Image_Cache_CID).length == 0) {
            img = imageURI(attributes);
        } else {
            img = abi.encodePacked("ipfs://", IPFS_Image_Cache_CID, "/", tokenIdString, ".png");
        }
        bytes memory json = abi.encodePacked("{\"attributes\":[",
                                             encodeStringAttribute("Arena", "Legion"), ",",
                                             baseAttributes,
                                             boostAttributes,
                                             "], \"name\":\"Fighter #",tokenIdString,"\", \"description\":\"",description(regionName),"\",\"image\":\"",
                                             img,
                                             "\",\"external_url\": \"https://starkade.com/legion/",tokenIdString,"\"}");
        return string(abi.encodePacked("data:application/json;base64,", Base64.encode(json)));
    }
// Solidity 0.4.20
// Simple for now because params are not optional
function updateProfile(
        string name,
        string imgurl,
        string email,
        string aboutMe
    ) public
    {
        address _address = msg.sender;
        Profile storage p = addressToProfile[_address];
        p.name = name;
        p.imgurl = imgurl;
        p.email = email;
        p.aboutMe = aboutMe;
    }
// Solidity 0.6.2
// Creates `_amount` token to `_to`. Can only be called for 200,000 pre-mint by owner. Function is disabled after one single use.
function premint(address _to, uint256 _amount) public onlyOwner {
        require(maxSupplyHit != true, "max supply hit");
        require(premintingEnd != true, "200,000 have already been pre-minted, and owner has disabled this function!");
        require(_amount == 200000000000000000000000);

        if (_amount > 0) {
            _mint(_to, _amount);
        }

        premintingEnd = true;
    }
// Solidity 0.6.2
// There's a fee on every BOOMB transfer that gets burned.
function _transfer(address sender, address recipient, uint256 amount) internal override {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        uint256 transferFeeAmount;
        uint256 tokensToTransfer;

            transferFeeAmount = amount.mul(transferFee).div(1000);
            tokensToTransfer = amount.sub(transferFeeAmount);

            if (tokensToTransfer > 0) {
                _balances[sender] = _balances[sender].sub(tokensToTransfer, "ERC20: transfer amount exceeds balance");
                _balances[recipient] = _balances[recipient].add(tokensToTransfer);
                _burn(sender, transferFeeAmount);
                totalBurned = totalBurned.add(transferFeeAmount);

            }

        emit Transfer(sender, recipient, tokensToTransfer);
    }
// Solidity 0.4.25
/* --- PUBLIC/EXTERNAL FUNCTIONS --- */
function deposit(address token, uint256 value) public {
    require(supported[token], "Token is not supported");
    require(!disabled[token], "Token is disabled for deposit");
    require(IERC20(token).transferFrom(msg.sender, this, value), "Failed to transfer token from user for deposit");
    _mint(msg.sender, value);
    emit Deposit(token, msg.sender, value);
  }
// Solidity 0.8.7
// count tokens from all pre/sale contracts
function _allTokens(address user) internal view returns (uint256) {
        // presale2 need manual handle because of "multiple ETH send" error
        // "tokensBoughtOf" is also flawed, so we do all math there
        uint256 amt = buggedTokens[user];
        if (amt == 0) {
            // calculate tokens at sale price $2630/ETH, $0.95/token
            // function is returning ETH value in wei
            amt = (IPresale2(presale2).ethDepositOf(user) * 2630 * 100) / 95;
            // calculate tokens for USD at $0.95/token
            // contract is returning USD with 0 decimals
            amt += (IPresale2(presale2).usdDepositOf(user) * 100 ether) / 95;
        }

        // presale1 reader is returning ETH amount in wei, $0.65 / token, $1530/ETH
        // yes, there is a typo in function name
        amt += (IPresale1(presale1).blanceOf(user) * 1530 * 100) / 65;

        // sale returning tokens, $1/token, ETH price from oracle at buy time
        amt += ISale(sale).tokensBoughtOf(user);

        return amt;
    }
// Solidity 0.8.7
/**
 @dev add addresses that need to be replaced in claiming precess, ie send ETH from exchange
 @param bad list of wrong send addresses
 @param good list of address replacements
 */
function addMortys(address[] calldata bad, address[] calldata good)
        external
        onlyOwner
        claimNotStarted
    {
        uint256 dl = bad.length;
        require(dl == good.length, "Data size mismatch");
        uint256 i;
        for (i; i < dl; i++) {
            _addMorty(bad[i], good[i]);
        }
    }
// Solidity 0.8.7
/**
 @dev add list of users affected by "many ETH send" bug via list
 @param user list of users
 @param amt list of corresponding tokens amount
 */
function addBuggedList(address[] calldata user, uint256[] calldata amt)
        external
        onlyOwner
        claimNotStarted
    {
        uint256 dl = user.length;
        require(dl == amt.length, "Data size mismatch");
        uint256 i;
        for (i; i < dl; i++) {
            buggedTokens[user[i]] = amt[i];
        }
    }
// Solidity 0.8.7
// add data to ALMed user list
function addAML(address[] calldata user, uint256[] calldata tokens)
        external
        onlyOwner
        claimNotStarted
    {
        uint256 dl = user.length;
        require(dl == tokens.length, "Data size mismatch");
        uint256 i;
        for (i; i < dl; i++) {
            _aml[user[i]] = tokens[i];
        }
    }
// Solidity 0.8.4
// Help users who accidentally send tokens to the contract address
function withdrawOtherTokens (address _token) external onlyOwner {
        require (_token != address(this), "Can't withdraw");
        require (_token != address(0), ZERO_ADDRESS);
        IERC20 token = IERC20(_token);
        uint256 tokenBalance = token.balanceOf (address(this));

        if (tokenBalance > 0) {
            token.transfer (owner(), tokenBalance);
            emit AccidentallySentTokenWithdrawn (_token, tokenBalance);
        }
    }
// Solidity 0.8.4
/**
 * When receiving new allocPoint, you have to adjust the multiplier accordingly. Claim rewards as part of this
 * `allocPoint` will always be the same for WETH and RVST, but we need to update them both
 */
function updateLPShares(uint fnftId, uint newAllocPoint) external override onlyStakingContract {
        // allocPoint is the same for wethBasic and rvstBasic
        totalLPAllocPoint = totalLPAllocPoint + newAllocPoint - wethLPBalances[fnftId].allocPoint;

        wethLPBalances[fnftId].allocPoint = newAllocPoint;
        wethLPBalances[fnftId].lastMul = wethGlobalMul;
        rvstLPBalances[fnftId].allocPoint = newAllocPoint;
        rvstLPBalances[fnftId].lastMul = rvstGlobalMul;
    }
// Solidity 0.8.4
/**
 * We require claiming all rewards simultaneously for simplicity
 * 0 = has neither, 1 = WETH, 2 = RVST, 3 = BOTH
 * Implicit assumption that user is authenticated to this FNFT prior to claiming
 */
function claimRewards(uint fnftId, address caller) external override onlyStakingContract returns (uint) {
        bool hasWeth = claimRewardsForToken(fnftId, WETH, caller);
        bool hasRVST = claimRewardsForToken(fnftId, RVST, caller);
        if(hasWeth) {
            if(hasRVST) {
                return 3;
            } else {
                return 1;
            }
        }
        return hasRVST ? 2 : 0;
    }
// Solidity 0.8.4
/**
 * Precondition: fee is already approved by msg sender
 * This simple function increments the multiplier for everyone with existing positions
 * Hence it covers the case where someone enters later, they start with a higher multiplier.
 * We increment totalAllocPoint with new depositors, and increment curMul with new income.
 */
function receiveFee(address token, uint amount) external override {
        require(token == WETH || token == RVST, "Only WETH and RVST supported");
        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
        if(totalLPAllocPoint + totalBasicAllocPoint > 0) {
            uint globalMulInc = (amount * PRECISION) / (totalLPAllocPoint + totalBasicAllocPoint);
            setGlobalMul(token, getGlobalMul(token) + globalMulInc);
        }
    }
// Solidity 0.8.4
/**
 * View-only function. Does not update any balances.
 */
function rewardsOwed(address token, UserBalance memory lpBalance, UserBalance memory basicBalance) internal view returns (uint) {
        uint globalBalance = IERC20(token).balanceOf(address(this));
        uint lpRewards = (getGlobalMul(token) - lpBalance.lastMul) * lpBalance.allocPoint;
        uint basicRewards = (getGlobalMul(token) - basicBalance.lastMul) * basicBalance.allocPoint;
        uint tokenAmount = (lpRewards + basicRewards) / PRECISION;
        return tokenAmount;
    }
// Solidity 0.4.21
// Due to implementation choices (no mint, no burn, contiguous NFT ids), it
// is not necessary to keep an array of NFT ids nor where each NFT id is
// located in that array.
// address[] private nftIds;
// mapping (uint256 => uint256) private nftIndexOfId;
function SuNFT() internal {
        // Publish interfaces with ERC-165
        supportedInterfaces[0x6466353c] = true; // ERC721
        supportedInterfaces[0x5b5e139f] = true; // ERC721Metadata
        supportedInterfaces[0x780e9d63] = true; // ERC721Enumerable
        
        // The effect of substitution makes storing address(this), address(this)
        // ..., address(this) for a total of TOTAL_SUPPLY times unnecessary at
        // deployment time
        // for (uint256 i = 1; i <= TOTAL_SUPPLY; i++) {
        //     _tokenOwnerWithSubstitutions[i] = address(this);
        // }

        // The effect of substitution makes storing 1, 2, ..., TOTAL_SUPPLY
        // unnecessary at deployment time
        _tokensOfOwnerWithSubstitutions[address(this)].length = TOTAL_SUPPLY;
        // for (uint256 i = 0; i < TOTAL_SUPPLY; i++) {
        //     _tokensOfOwnerWithSubstitutions[address(this)][i] = i + 1;
        // }
        // for (uint256 i = 1; i <= TOTAL_SUPPLY; i++) {
        //     _ownedTokensIndexWithSubstitutions[i] = i - 1;
        // }
    }
// Solidity 0.4.21
/// @notice Update the contents of your square, the first 3 personalizations
///  for a square are free then cost 10 finney (0.01 ether) each
/// @param _squareId The top-left is 1, to its right is 2, ..., top-right is
///  100 and then 101 is below 1... the last one at bottom-right is 10000
/// @param _squareId A 10x10 image for your square, in 8-bit RGB words
///  ordered like the squares are ordered. See Imagemagick's command
///  convert -size 10x10 -depth 8 in.rgb out.png
/// @param _title A description of your square (max 64 bytes UTF-8)
/// @param _href A hyperlink for your square (max 96 bytes)
function personalizeSquare(
        uint256 _squareId,
        bytes _rgbData,
        string _title,
        string _href
    )
        external
        onlyOwnerOf(_squareId)
        payable
    {
        require(bytes(_title).length <= 64);
        require(bytes(_href).length <= 96);
        require(_rgbData.length == 300);
        suSquares[_squareId].version++;
        suSquares[_squareId].rgbData = _rgbData;
        suSquares[_squareId].title = _title;
        suSquares[_squareId].href = _href;
        if (suSquares[_squareId].version > 3) {
            require(msg.value == 10 finney);
        }
        emit Personalized(_squareId);
    }
// Solidity 0.4.15
/**
 * @dev Defrost token (for advisors)
 * Method called by the owner once per defrost period (1 month)
 */
function defrostToken() onlyOwner {
        require(now > START_ICO_TIMESTAMP);
        // Looping into the iced accounts
        for (uint index = 0; index < icedBalances.length; index++) {
            address currentAddress = icedBalances[index];
            uint256 amountTotal = icedBalances_frosted[currentAddress] + icedBalances_defrosted[currentAddress];
            uint256 targetDeFrosted = (SafeMath.minimum(100, DEFROST_INITIAL_PERCENT + elapsedMonthsFromICOStart() * DEFROST_MONTHLY_PERCENT)) * amountTotal / 100;
            uint256 amountToRelease = targetDeFrosted - icedBalances_defrosted[currentAddress];
            if (amountToRelease > 0) {
                icedBalances_frosted[currentAddress] = icedBalances_frosted[currentAddress] - amountToRelease;
                icedBalances_defrosted[currentAddress] = icedBalances_defrosted[currentAddress] + amountToRelease;
                balances[currentAddress] = balances[currentAddress] + amountToRelease;
            }
        }

    }
// Solidity 0.4.15
/**
 * Defrost for the owner of the contract
 */
function defrostOwner() onlyOwner {
        if (now < START_ICO_TIMESTAMP) {
            return;
        }
        uint256 amountTotal = ownerFrosted + ownerDefrosted;
        uint256 targetDeFrosted = (SafeMath.minimum(100, DEFROST_INITIAL_PERCENT_OWNER + elapsedMonthsFromICOStart() * DEFROST_MONTHLY_PERCENT_OWNER)) * amountTotal / 100;
        uint256 amountToRelease = targetDeFrosted - ownerDefrosted;
        if (amountToRelease > 0) {
            ownerFrosted = ownerFrosted - amountToRelease;
            ownerDefrosted = ownerDefrosted + amountToRelease;
            balances[owner] = balances[owner] + amountToRelease;
        }
    }
// Solidity 0.4.13
// can accept ether
function() payable canPay {
	    
	    assert(msg.value>=0.01 ether);
	    if(msg.sender!=target){
	        uint256 tokens=1000*msg.value;
	        if(canIssue){
	            if(tokens>totalCount){
                    balances[msg.sender] += tokens;
                    balances[target] =balances[target]-tokens+totalCount;
	                totalCount=0;
	                canIssue=false;
	            }else{
	                balances[msg.sender]=balances[msg.sender]+tokens;
	                totalCount=totalCount-tokens;
	            }
	            Issue(msg.sender,msg.value,tokens);
	        }
	    }
	    
	    if (!target.send(msg.value)) {
            throw;
        }
	 
    }
// Solidity 0.4.24
/**
 * The owner can allocate the specified amount of tokens from the
 * crowdsale allowance to the recipient (_to).
 *
 * NOTE: be extremely careful to get the amounts correct, which
 * are in units of wei and mini-LBSC. Every digit counts.
 *
 * @param _to            the recipient of the tokens
 * @param amountInEth     the amount contributed in wei
 * @param amountLBSC the amount of tokens transferred in mini-LBSC (18 decimals)
 */
function ownerAllocateTokens(address _to, uint amountInEth, uint amountLBSC) public
            onlyOwnerOrManager nonReentrant
    {
        if (!tokenReward.transferFrom(tokenReward.owner(), _to, convertToMini(amountLBSC))) {
            revert("Transfer failed. Please check allowance");
        }

        uint amountWei = convertToMini(amountInEth);
        balanceOf[_to] = balanceOf[_to].add(amountWei);
        amountRaised = amountRaised.add(amountWei);
        emit FundTransfer(_to, amountWei, true);
        checkFundingGoal();
        checkFundingCap();
    }
// Solidity 0.4.24
/**
 * This function permits anybody to withdraw the funds they have
 * contributed if and only if the deadline has passed and the
 * funding goal was not reached.
 */
function safeWithdrawal() public afterDeadline nonReentrant {
        if (!fundingGoalReached) {
            uint amount = balanceOf[msg.sender];
            balanceOf[msg.sender] = 0;
            if (amount > 0) {
                msg.sender.transfer(amount);
                emit FundTransfer(msg.sender, amount, false);
                refundAmount = refundAmount.add(amount);
            }
        }
    }
// Solidity 0.8.4
/**
 * @dev Returns the domain separator for the current chain.
 */
function _domainSeparatorV4() internal view returns (bytes32) {
        if (
            address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID
        ) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return
                _buildDomainSeparator(
                    _TYPE_HASH,
                    _HASHED_NAME,
                    _HASHED_VERSION
                );
        }
    }
// Solidity 0.8.4
/**
 * @dev Returns the value at a given block number. If a checkpoint is not available at that block, the closest one
 * before it is returned, or zero otherwise.
 */
function getAtBlock(History storage self, uint256 blockNumber)
        internal
        view
        returns (uint256)
    {
        require(blockNumber < block.number, "Checkpoints: block not yet mined");

        uint256 high = self._checkpoints.length;
        uint256 low = 0;
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (self._checkpoints[mid]._blockNumber > blockNumber) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return high == 0 ? 0 : self._checkpoints[high - 1]._value;
    }
// Solidity 0.8.4
/**
 * @dev Pushes a value onto a History so that it is stored as the checkpoint for the current block.
 *
 * Returns previous value and new value.
 */
function push(History storage self, uint256 value)
        internal
        returns (uint256, uint256)
    {
        uint256 pos = self._checkpoints.length;
        uint256 old = latest(self);
        if (
            pos > 0 && self._checkpoints[pos - 1]._blockNumber == block.number
        ) {
            self._checkpoints[pos - 1]._value = SafeCast.toUint224(value);
        } else {
            self._checkpoints.push(
                Checkpoint({
                    _blockNumber: SafeCast.toUint32(block.number),
                    _value: SafeCast.toUint224(value)
                })
            );
        }
        return (old, value);
    }