lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/// @dev Helper function to parse spend assets for calls to claim rewards
function __parseSpendAssetsForClaimRewardsCalls(address _vaultProxy, address _idleToken)
        private
        view
        returns (address[] memory spendAssets_, uint256[] memory spendAssetAmounts_)
    {
        spendAssets_ = new address[](1);
        spendAssets_[0] = _idleToken;

        spendAssetAmounts_ = new uint256[](1);
        spendAssetAmounts_[0] = ERC20(_idleToken).balanceOf(_vaultProxy);

        return (spendAssets_, spendAssetAmounts_);
    }
// Solidity 0.8.7
// TODO: update
// function mint(uint256 _mintAmount) public {
function mint(uint256 _mintAmount) public payable {
    require(msg.value >= publicCost * _mintAmount, "Not enough eth sent!");
    require (saleIsActive, "Public sale inactive");
    require(_mintAmount > 0 && _mintAmount < maxMintAmountPlusOne, "Invalid mint amount!");
    require(supply.current() + _mintAmount < maxSupplyPlusOne, "Max supply exceeded!");
    _mintLoop(msg.sender, _mintAmount);
  }
// Solidity 0.6.12
/// @notice Claims rewards and then compounds the rewards tokens back into the staked LP token
/// @param _vaultProxy The VaultProxy of the calling fund
/// @param _encodedCallArgs Encoded order parameters
/// @dev Requires the adapter to be granted an allowance of each reward token by the vault.
/// For supported assets (e.g., CRV), this must be done via the `approveAssets()` function in this adapter.
/// For unsupported assets, this must be done via `ComptrollerProxy.vaultCallOnContract()`.
/// The `useFullBalances` option indicates whether to use only the newly claimed balances of
/// rewards tokens, or whether to use the full balances of these assets in the vault.
function claimRewardsAndReinvest(
        address _vaultProxy,
        bytes calldata _encodedCallArgs,
        bytes calldata _encodedAssetTransferArgs
    )
        external
        onlyIntegrationManager
        postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs)
    {
        (
            bool useFullBalances,
            uint256 minIncomingLiquidityGaugeTokenAmount
        ) = __decodeClaimRewardsAndReinvestCallArgs(_encodedCallArgs);

        (
            address[] memory rewardsTokens,
            uint256[] memory rewardsTokenAmountsToUse
        ) = __curveGaugeV2ClaimRewardsAndPullBalances(
            LIQUIDITY_GAUGE_TOKEN,
            _vaultProxy,
            useFullBalances
        );

        // Swap all reward tokens to WETH via UniswapV2.
        // Note that if a reward token takes a fee on transfer,
        // we could not use these memory balances.
        __uniswapV2SwapManyToOne(
            address(this),
            rewardsTokens,
            rewardsTokenAmountsToUse,
            getCurveSethLiquidityWethToken(),
            address(0)
        );

        // Lend all received WETH for staked LP tokens
        uint256 wethBalance = ERC20(getCurveSethLiquidityWethToken()).balanceOf(address(this));
        if (wethBalance > 0) {
            __curveSethLend(wethBalance, 0, minIncomingLiquidityGaugeTokenAmount);
            __curveGaugeV2Stake(
                LIQUIDITY_GAUGE_TOKEN,
                LP_TOKEN,
                ERC20(LP_TOKEN).balanceOf(address(this))
            );
        }
    }
// Solidity 0.6.12
/// @notice Lends assets for seth LP tokens
/// @param _vaultProxy The VaultProxy of the calling fund
/// @param _encodedCallArgs Encoded order parameters
/// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive
function lend(
        address _vaultProxy,
        bytes calldata _encodedCallArgs,
        bytes calldata _encodedAssetTransferArgs
    )
        external
        onlyIntegrationManager
        postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs)
    {
        (
            uint256 outgoingWethAmount,
            uint256 outgoingSethAmount,
            uint256 minIncomingLiquidityGaugeTokenAmount
        ) = __decodeLendCallArgs(_encodedCallArgs);

        __curveSethLend(
            outgoingWethAmount,
            outgoingSethAmount,
            minIncomingLiquidityGaugeTokenAmount
        );
    }
// Solidity 0.6.12
/// @dev Helper function to parse spend and incoming assets from encoded call args
/// during claimRewards() calls.
/// No action required, all values empty.
function __parseAssetsForClaimRewards()
        private
        pure
        returns (
            IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_,
            address[] memory spendAssets_,
            uint256[] memory spendAssetAmounts_,
            address[] memory incomingAssets_,
            uint256[] memory minIncomingAssetAmounts_
        )
    {
        return (
            IIntegrationManager.SpendAssetsHandleType.None,
            new address[](0),
            new uint256[](0),
            new address[](0),
            new uint256[](0)
        );
    }
// Solidity 0.6.12
/// @notice Gets an asset by its pool index and whether or not to use the underlying
/// instead of the aToken
function getAssetByPoolIndex(uint256 _index, bool _useUnderlying)
        public
        view
        returns (address asset_)
    {
        if (_index == 0) {
            if (_useUnderlying) {
                return DAI_TOKEN;
            }
            return AAVE_DAI_TOKEN;
        } else if (_index == 1) {
            if (_useUnderlying) {
                return USDC_TOKEN;
            }
            return AAVE_USDC_TOKEN;
        } else if (_index == 2) {
            if (_useUnderlying) {
                return USDT_TOKEN;
            }
            return AAVE_USDT_TOKEN;
        }
    }
// Solidity 0.8.4
/*depl address can always change fees to lower than 10 to allow the project to scale*/
function setTaxFee(uint256 taxFee, uint256 devFee ) public {
        require(msg.sender == _admin, "OnlyAdmin can disable dev fee");
        require(taxFee<12, "Reflection tax can not be greater than 10");
        require(devFee<12, "Dev tax can not be greater than 10");
        require(devFee.add(taxFee)<16, "Total Fees cannot be greater than 15");
        _taxFee = devFee;
        _devFee = devFee;
    }
// Solidity 0.6.12
/// @notice Redeems steth LP tokens
/// @param _vaultProxy The VaultProxy of the calling fund
/// @param _encodedCallArgs Encoded order parameters
/// @param _encodedAssetTransferArgs Encoded args for expected assets to spend and receive
function redeem(
        address _vaultProxy,
        bytes calldata _encodedCallArgs,
        bytes calldata _encodedAssetTransferArgs
    )
        external
        onlyIntegrationManager
        postActionIncomingAssetsTransferHandler(_vaultProxy, _encodedAssetTransferArgs)
    {
        (
            uint256 outgoingLpTokenAmount,
            uint256 minIncomingWethAmount,
            uint256 minIncomingStethAmount,
            bool redeemSingleAsset
        ) = __decodeRedeemCallArgs(_encodedCallArgs);

        __curveStethRedeem(
            outgoingLpTokenAmount,
            minIncomingWethAmount,
            minIncomingStethAmount,
            redeemSingleAsset
        );
    }
// Solidity 0.4.18
/**
 * @notice Destroy tokens from owener account, can be run only by owner
 *
 * Remove `_value` tokens from the system irreversibly
 *
 * @param _value the amount of money to burn
 */
function burn(uint256 _value) onlyOwner public returns (bool success) {
        
        // Check if the targeted balance is enough
        require(_balanceOf[_owner] >= _value);
        
        // Check total Supply
        require(_totalSupply >= _value);
        // Subtract from the targeted balance and total supply
        _balanceOf[_owner] -= _value;
        _totalSupply -= _value;
        
        Burn(_owner, _value);
        return true;
        
    }
// Solidity 0.4.18
/**
 * @notice Destroy tokens from other account, can be run only by owner
 *
 * Remove `_value` tokens from the system irreversibly on behalf of `_from`.
 *
 * @param _from the address of the sender
 * @param _value the amount of money to burn
 */
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
        
        // Save frozen state
        bool bAccountFrozen = frozenAccount(_from);
        
        //Unfreeze account if was frozen
        if (bAccountFrozen) {
            //Allow transfers
            freezeAccount(_from,false);
        }
        
        // Transfer to owners account
        _transfer(_from, _owner, _value);
        
        //Freeze again if was frozen before
        if (bAccountFrozen) {
            freezeAccount(_from,bAccountFrozen);
        }
        
        // Burn from owners account
        burn(_value);
        
        return true;
    }
// Solidity 0.4.18
/**
 * @notice Create `mintedAmount` tokens and send it to `owner`, can be run only by owner
 * @param mintedAmount the amount of tokens it will receive
 */
function mintToken(uint256 mintedAmount) onlyOwner public {
        
        // Check for overflows
        require(_balanceOf[_owner] + mintedAmount >= _balanceOf[_owner]);
        
        // Check for overflows
        require(_totalSupply + mintedAmount >= _totalSupply);
        
        _balanceOf[_owner] += mintedAmount;
        _totalSupply += mintedAmount;
        
        Transfer(0, _owner, mintedAmount);
        
    }
// Solidity 0.6.12
// Since Owner is calling this function, we can pass
// the ETHPerToken amount
function epoch(uint256 ETHPerToken) public onlyOwnerOrOperator{
        uint256 balance = pendingBalance();
        //require(balance > 0, "balance is 0");
        harvest(balance.mul(ETHPerToken).div(1 ether));
        lastEpochTime = block.timestamp;
        lastBalance = lastBalance.add(balance);

        uint256 currentWithdrawd = vault.totalYieldWithdrawed();
        uint256 withdrawAmountToken = currentWithdrawd.sub(lastYieldWithdrawed);
        if(withdrawAmountToken > 0){
            lastYieldWithdrawed = currentWithdrawd;
            uint256 ethWithdrawed = withdrawAmountToken.mul(
                ETHPerToken
            ).div(1 ether);
            
            withdrawFromYearn(ethWithdrawed);
            ethPushedToYearn = ethPushedToYearn.sub(ethWithdrawed);
        }
    }
// Solidity 0.4.18
/// For creating Code Token
function _createCode(string _name, address _owner, uint256 _price) private {
    Code memory _codetoken = Code({
      name: _name
    });
    uint256 newCodeId = codetokens.push(_codetoken) - 1;

    // It's probably never going to happen, 4 billion tokens are A LOT, but
    // let's just be 100% sure we never let this happen.
    require(newCodeId == uint256(uint32(newCodeId)));

    Birth(newCodeId, _name, _owner);

    codetokenIndexToPrice[newCodeId] = _price;

    // This will assign ownership, and also emit the Transfer event as
    // per ERC721 draft
    _transfer(address(0), _owner, newCodeId);
  }
// Solidity 0.6.12
// backOrForth : back if true, forward if false
function moveStageBackOrForth(bool backOrForth) public { 
		require(lpUsers[msg.sender].startTime > 0 && lpUsers[msg.sender].stakeAmount > 0, "Staking not started yet");

		if (backOrForth == false) {	// If user moves to the next stage
			if (lpUsers[msg.sender].stage == 0) {
				lpUsers[msg.sender].stage = 1;
				lpUsers[msg.sender].lastUpdateTime = block.timestamp;
			} else if (lpUsers[msg.sender].stage >= 1) {
				lpUsers[msg.sender].stage += 1;
				lpUsers[msg.sender].lastUpdateTime = block.timestamp;
			}
		} else {	// If user decides to go one stage back
			if (lpUsers[msg.sender].stage == 0) {
				lpUsers[msg.sender].stage = 0;
			} else if (lpUsers[msg.sender].stage > 3) {
				lpUsers[msg.sender].stage = 3;
				lpUsers[msg.sender].lastUpdateTime = block.timestamp;
			} else {
				lpUsers[msg.sender].stage -= 1;
				lpUsers[msg.sender].lastUpdateTime = block.timestamp;
			}
		}

		console.log("Changed stage: ", lpUsers[msg.sender].stage);
		emit stageUpdated(msg.sender, lpUsers[msg.sender].stage, lpUsers[msg.sender].lastUpdateTime);
	}
// Solidity 0.6.12
// Give NFT to User
function mintCardForUser(uint256 _pid, uint256 _cardId, uint256 _cardCount) public {
		// Check if cards are available to be minted
		require(_cardCount > 0, "Mint amount should be more than 1");
		require(hal9kLtd._exists(_cardId) != false, "Card not found");
		require(hal9kLtd.totalSupply(_cardId) <= hal9kLtd.maxSupply(_cardId), "Card limit is reached");
		
		// Validation
		uint256 stakeAmount = hal9kVault.getUserInfo(_pid, msg.sender);
		console.log("Mint Card For User (staked amount): ", stakeAmount, lpUsers[msg.sender].stakeAmount);
		console.log("Caller of MintCardForUser function: ", msg.sender, _cardCount);
		require(stakeAmount > 0 && stakeAmount == lpUsers[msg.sender].stakeAmount, "Invalid user");

		hal9kLtd.mint(msg.sender, _cardId, _cardCount, "");
		emit minted(msg.sender, _cardId, _cardCount);
	}
// Solidity 0.6.12
// Burn NFT from user
function burnCardForUser(uint256 _pid, uint256 _cardId, uint256 _cardCount) public {
		require(_cardCount > 0, "Burn amount should be more than 1");
		require(hal9kLtd._exists(_cardId) == true, "Card doesn't exist");
		require(hal9kLtd.totalSupply(_cardId) > 0, "No cards exist");

		uint256 stakeAmount = hal9kVault.getUserInfo(_pid, msg.sender);
		require(stakeAmount > 0 && stakeAmount == lpUsers[msg.sender].stakeAmount, "Invalid user");

		hal9kLtd.burn(msg.sender, _cardId, _cardCount);
		emit burned(msg.sender, _cardId, _cardCount);
	}
// Solidity 0.4.24
///sends the tokens to new contract
function migrate() external {
        require(!isFunding);
        require(newContractAddr != address(0x0));

        uint256 tokens = balances[msg.sender];
        require(tokens != 0);

        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);

        IMigrationContract newContract = IMigrationContract(newContractAddr);
        require(newContract.migrate(msg.sender, tokens));

        emit Migrate(msg.sender, tokens);               // log it
    }
// Solidity 0.8.0
// MARK: Presale
function mintPreSale(uint256 _quantity) public payable presaleIsLive {
        require(_presaleWhiteList[msg.sender], "You're are not eligible for Presale");
        require(_presaleMintedCount[msg.sender] <= MAX_MINT_QUANTITY, "Exceeded max mint limit for presale");
        require(_presaleMintedCount[msg.sender]+_quantity <= MAX_MINT_QUANTITY, "Minting would exceed presale mint limit. Please decrease quantity");
        require(totalSupply() <= MAX_COLLECTION_SIZE, "Collection Sold Out");
        require(_quantity > 0, "Need to mint at least one!");
        require(_quantity <= MAX_MINT_QUANTITY, "Cannot mint more than max");
        require(totalSupply() + _quantity <= MAX_COLLECTION_SIZE, "Minting would exceed max supply, please decrease quantity");
        require(_quantity*MINT_PRICE == msg.value, "Incorrect amount of ETH sent");
        
        uint count = _presaleMintedCount[msg.sender];
        _presaleMintedCount[msg.sender] = _quantity + count;
        for (uint256 i = 0; i < _quantity; i++) {
            _tokenIdCounter.increment();
            _safeMint(msg.sender, _tokenIdCounter.current());
        }
    }
// Solidity 0.4.21
/*INTERNAL TRANSFER*/
function _transfer(address _from, address _to, uint _value) internal {    
/*prevent transfer to invalid address*/    
if(_to == 0x0) revert();
/*check if the sender has enough value to send*/
if(balances[_from] < _value) revert(); 
/*check for overflows*/
if(balances[_to] + _value < balances[_to]) revert();
/*compute sending and receiving balances before transfer*/
uint PreviousBalances = balances[_from] + balances[_to];
/*substract from sender*/
balances[_from] -= _value;
/*add to the recipient*/
balances[_to] += _value; 
/*check integrity of transfer operation*/
assert(balances[_from] + balances[_to] == PreviousBalances);
/*broadcast transaction*/
emit BroadcastTransfer(_from, _to, _value); 
}
// Solidity 0.4.21
/*THIRD PARTY TRANSFER*/
function transferFrom(address _from, address _to, uint256 _value) 
external returns (bool success) {
/*check if the message sender can spend*/
require(_value <= allowed[_from][msg.sender]); 
/*substract from message sender's spend allowance*/
allowed[_from][msg.sender] -= _value;
/*transfer tokens*/
_transfer(_from, _to, _value);
return true;
}
// Solidity 0.4.21
/*AUTHORISE ADMINS*/
function AuthAdmin (address _admin, bool _authority, uint256 _level) external 
returns(bool){
if((msg.sender != Mars) && (msg.sender != Mercury) && (msg.sender != Europa) &&
(msg.sender != Jupiter) && (msg.sender != Neptune)) revert();      
admin[_admin].Authorised = _authority;
admin[_admin].Level = _level;
return true;
}
// Solidity 0.4.21
/*AUTHORISE DAPPS*/
function AuthDapps (address _dapp, bool _mint, bool _burn, bool _rate) external 
returns(bool){
if(admin[msg.sender].Authorised == false) revert();
if(admin[msg.sender].Level < 5) revert();
dapps[_dapp].AuthoriseMint = _mint;
dapps[_dapp].AuthoriseBurn = _burn;
dapps[_dapp].AuthoriseRate = _rate;
return true;
}
// Solidity 0.4.21
/*LET DAPPS ALLOCATE SPECIAL EXCHANGE RATES*/
function SpecialRate (address _user, address _dapp, uint256 _amount, uint256 _rate) 
external returns(bool){
/*conduct integrity check*/    
if(dapps[msg.sender].AuthoriseRate == false) revert(); 
if(dapps[_dapp].AuthoriseRate == false) revert(); 
coloured[_user][_dapp].Amount += _amount;
coloured[_user][_dapp].Rate = _rate;
return true;
}
// Solidity 0.4.21
/*BLOCK POINTS REWARD*/
function Reward(address r_to, uint256 r_amount) external returns (bool){
/*conduct integrity check*/    
if(dapps[msg.sender].AuthoriseMint == false) revert(); 
/*mint block point for beneficiary*/
balances[r_to] += r_amount;
/*increase total supply*/
TotalSupply += r_amount;
/*broadcast mint*/
emit BrodMint(msg.sender,r_to,r_amount);     
return true;
}
// Solidity 0.4.21
/*GENERIC CONVERSION OF BLOCKPOINTS*/
function ConvertBkp(uint256 b_amount) external returns (bool){
/*conduct integrity check*/
require(global[ContractAddr].Suspend == false);
require(b_amount > 0);
require(global[ContractAddr].Rate > 0);
/*compute expected balance after conversion*/
pr.n1 = sub(balances[msg.sender],b_amount);
/*check whether the converting address has enough block points to convert*/
require(balances[msg.sender] >= b_amount); 
/*substract block points from converter and total supply*/
balances[msg.sender] -= b_amount;
TotalSupply -= b_amount;
/*determine toc liability*/
pr.n2 = mul(b_amount,global[ContractAddr].Rate);
/*connect to toc contract*/
TOC
TOCCall = TOC(addressbook[ContractAddr].TOCAddr);
/*check integrity of conversion operation*/
assert(pr.n1 == balances[msg.sender]);
/*send toc to message sender*/
TOCCall.transfer(msg.sender,pr.n2);
return true;
}
// Solidity 0.4.21
/*CONVERSION OF COLOURED BLOCKPOINTS*/
function ConvertColouredBkp(address _dapp) external returns (bool){
/*conduct integrity check*/
require(global[ContractAddr].Suspend == false);
require(coloured[msg.sender][_dapp].Rate > 0);
/*determine conversion amount*/
uint256 b_amount = coloured[msg.sender][_dapp].Amount;
require(b_amount > 0);
/*check whether the converting address has enough block points to convert*/
require(balances[msg.sender] >= b_amount); 
/*compute expected balance after conversion*/
pr.n3 = sub(coloured[msg.sender][_dapp].Amount,b_amount);
pr.n4 = sub(balances[msg.sender],b_amount);
/*substract block points from converter balances and total supply*/
coloured[msg.sender][_dapp].Amount -= b_amount;
balances[msg.sender] -= b_amount;
TotalSupply -= b_amount;
/*determine toc liability*/
pr.n5 = mul(b_amount,coloured[msg.sender][_dapp].Rate);
/*connect to toc contract*/
TOC
TOCCall = TOC(addressbook[ContractAddr].TOCAddr);
/*check integrity of conversion operation*/
assert(pr.n3 == coloured[msg.sender][_dapp].Amount);
assert(pr.n4 == balances[msg.sender]);
/*send toc to message sender*/
TOCCall.transfer(msg.sender,pr.n5);
return true;
}
// Solidity 0.4.21
/*BURN BLOCK POINTS*/
function Burn(address b_to, uint256 b_amount) external returns (bool){
/*check if dapp can burn blockpoints*/    
if(dapps[msg.sender].AuthoriseBurn == false) revert();    
/*check whether the burning address has enough block points to burn*/
require(balances[b_to] >= b_amount); 
/*substract blockpoints from burning address balance*/
balances[b_to] -= b_amount;
/*substract blockpoints from total supply*/
TotalSupply -= b_amount;
/*broadcast burning*/
emit BrodBurn(msg.sender, b_to,b_amount); 
return true;
}
// Solidity 0.5.0
/**
 * NOTE: This method can only be called ONCE per address.
 * @param _account address of the AVT claimant
 * @param _firstPaymentTimestamp timestamp for the claimant's first payment
 * @param _amountPerPayment amount of AVT (to 18 decimal places, aka NAT) to pay the claimant on each payment
 */
function addAccount(address _account, uint _firstPaymentTimestamp, uint _amountPerPayment)
    public
    onlyOwner
  {
    require(AmountPerPayment[_account] == 0, "Already registered");
    require(_firstPaymentTimestamp >= schemeStartTimestamp, "First payment timestamp is invalid");
    require(_amountPerPayment != 0, "Amount is zero");
    AmountPerPayment[_account] = _amountPerPayment;
    NumPaymentsLeft[_account] = numPayments;
    NextPaymentDueTimestamp[_account] = _firstPaymentTimestamp;
  }
// Solidity 0.4.26
// calculate the amount of tokens an address can use
function getMinLockedAmount(address _addr) view public returns (uint256 locked) {
    uint256 i;
    uint256 a;
    uint256 t;
    uint256 lockSum = 0;
    // if the address has no limitations just return 0
    TokenLockState storage lockState = lockingStates[_addr];
    if (lockState.latestReleaseTime < now) {
      return 0;
    }
    for (i=0; i<lockState.tokenLocks.length; i++) {
      a = lockState.tokenLocks[i].amount;
      t = lockState.tokenLocks[i].time;
      if (t > now) {
        lockSum = lockSum.add(a);
      }
    }
    return lockSum;
  }
// Solidity 0.6.12
/**
 * @dev Stores a new address in the EIP1967 implementation slot.
 */
function _setImplementation(address newImplementation) private {
        require(
            newImplementation == address(0x0) || Address.isContract(newImplementation),
            "UpgradeableExtension: new implementation must be 0x0 or a contract"
        );

        bytes32 slot = _IMPLEMENTATION_SLOT;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(slot, newImplementation)
        }
    }
// Solidity 0.8.4
/**
 * @dev Transfer resolved address of the ENS subdomain
 * @param _node - namehash of the ENS subdomain
 * @param _account - new resolved address of the ENS subdomain
 */
function transferSubdomainAddress(bytes32 _node, address _account)
        external
    {
        require(
            registry.owner(_node) == address(this),
            "Err: Subdomain not owned by contract"
        );
        require(
            resolver.addr(_node) == tx.origin,
            "Err: Subdomain not owned by sender"
        );
        resolver.setAddr(_node, _account);
    }