lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/// #if_succeeds {:msg "The liquidateReserveAmount should be correct - case _amount = 0"}
/// _amount == 0 ==> $result == 0;
/// #if_succeeds {:msg "The liquidateReserveAmount should be correct - case _amount = _supply"}
/// _amount == _supply ==> $result == _removeSellTax(_reserveBalance);
/// #if_succeeds {:msg "The liquidateReserveAmount should be correct - case _reserveRatio = MAX_WEIGHT"}
/// _reserveRatio == 1000000 ==> $result == _removeSellTax(_amount.mul(_reserveBalance) / _supply);
function liquidateReserveAmount(
        uint256 _supply,
        uint256 _reserveBalance,
        uint32 _reserveRatio,
        uint256 _amount
    ) public view returns (uint256) {
        uint256 liquidateValue = _curveAddress.liquidateReserveAmount(
            _supply,
            _reserveBalance,
            _reserveRatio,
            _amount
        );
        uint256 gross = _removeSellTax(liquidateValue);
        return gross;
    }
// Solidity 0.6.12
/// #if_succeeds {:msg "The tax should go to the owner"}
/// let reserveBalance := old(_reserveAsset.balanceOf(address(this))) in
/// let reserveTokenCost := old(fundCost(totalSupply(), reserveBalance, _fixedReserveRatio, amount)) in
/// let taxDeducted := old(_removeBuyTax(reserveTokenCost)) in
/// (msg.sender != owner() && address(this) != owner()) ==> _reserveAsset.balanceOf(owner()) == old(_reserveAsset.balanceOf(owner()) + reserveTokenCost.sub(taxDeducted));
function mint(address account, uint256 amount) public returns (bool) {
        uint256 reserveBalance = _reserveAsset.balanceOf(address(this));
        uint256 reserveTokenCost = fundCost(totalSupply(), reserveBalance, _fixedReserveRatio, amount);

        uint256 taxDeducted = _removeBuyTax(reserveTokenCost);
        require(
            _reserveAsset.transferFrom(
                _msgSender(),
                address(this),
                reserveTokenCost
            ),
            "BrincToken:mint:Reserve asset transfer for mint failed"
        );
        require(
            _reserveAsset.transfer(
                owner(),
                reserveTokenCost.sub(taxDeducted)
            ),
            "BrincToken:mint:Tax transfer failed"
        );
        _mint(account, amount);
        return true;
    }
// Solidity 0.6.12
/// #if_succeeds {:msg "The caller's BrincToken balance should be increase correct"}
/// let reserveBalance := old(_reserveAsset.balanceOf(address(this))) in
/// let tokensToMint := old(purchaseTargetAmount(totalSupply(), reserveBalance, _fixedReserveRatio, amount)) in
/// msg.sender != owner() ==> this.balanceOf(account) == old(this.balanceOf(account) + tokensToMint);
/// #if_succeeds {:msg "The reserve balance should increase by exact amount"}
/// let taxDeducted := old(_removeBuyTaxFromSpecificAmount(amount)) in   
/// (msg.sender != owner() && address(this) != owner()) ==> _reserveAsset.balanceOf(address(this)) == old(_reserveAsset.balanceOf(address(this)) + amount - amount.sub(taxDeducted));
/// #if_succeeds {:msg "The tax should go to the owner"}
/// let taxDeducted := old(_removeBuyTaxFromSpecificAmount(amount)) in
/// (msg.sender != owner() && address(this) != owner()) ==> _reserveAsset.balanceOf(owner()) == old(_reserveAsset.balanceOf(owner())) + amount.sub(taxDeducted);
/// #if_succeeds {:msg "The result should be true"} $result == true;
function mintForSpecificReserveAmount(address account, uint256 amount) public returns (bool) {
        uint256 reserveBalance = _reserveAsset.balanceOf(address(this));

        uint256 taxDeducted = _removeBuyTaxFromSpecificAmount(amount);
        uint256 tokensToMint = purchaseTargetAmount(
            totalSupply(), 
            reserveBalance, 
            _fixedReserveRatio, 
            amount
        );

        require(
            _reserveAsset.transferFrom(
                _msgSender(),
                address(this),
                amount
            ),
            "BrincToken:mint:Reserve asset transfer for mint failed"
        );
        require(
            _reserveAsset.transfer(
                owner(),
                amount.sub(taxDeducted)
            ),
            "BrincToken:mint:Tax transfer failed"
        );
        _mint(account, tokensToMint);
        return true;
    }
// Solidity 0.6.12
/// #if_succeeds {:msg "The overridden burn should decrease caller's BrincToken balance"}
/// this.balanceOf(_msgSender()) == old(this.balanceOf(_msgSender()) - amount);
/// #if_succeeds {:msg "burn should add burn tax to the owner's balance"}
/// let reserveBalance := old(_reserveAsset.balanceOf(address(this))) in
/// let reserveTokenNet := old(liquidateReserveAmount(totalSupply(), reserveBalance, _fixedReserveRatio, amount)) in
/// let taxAdded := old(_addSellTax(reserveTokenNet)) in
/// (msg.sender != owner() && address(this) != owner()) ==> _reserveAsset.balanceOf(owner()) == old(_reserveAsset.balanceOf(owner()) + taxAdded.sub(reserveTokenNet));
/// #if_succeeds {:msg "burn should decrease BrincToken reserve balance by exact amount"}
/// let reserveBalance := old(_reserveAsset.balanceOf(address(this))) in
/// let reserveTokenNet := old(liquidateReserveAmount(totalSupply(), reserveBalance, _fixedReserveRatio, amount)) in
/// let taxAdded := old(_addSellTax(reserveTokenNet)) in
/// (msg.sender != owner() && address(this) != owner()) ==> _reserveAsset.balanceOf(address(this)) == old(_reserveAsset.balanceOf(address(this)) - reserveTokenNet - taxAdded.sub(reserveTokenNet));
/// #if_succeeds {:msg "burn should increase user's reserve balance by exact amount"}
/// let reserveBalance := old(_reserveAsset.balanceOf(address(this))) in
/// let reserveTokenNet := old(liquidateReserveAmount(totalSupply(), reserveBalance, _fixedReserveRatio, amount)) in
/// msg.sender != owner() ==> _reserveAsset.balanceOf(_msgSender()) == old(_reserveAsset.balanceOf(_msgSender()) + reserveTokenNet);
function burn(uint256 amount) public override {
        uint256 reserveBalance = _reserveAsset.balanceOf(address(this));
        uint256 reserveTokenNet = liquidateReserveAmount(totalSupply(), reserveBalance, _fixedReserveRatio, amount);
        _burn(_msgSender(), amount);

        uint256 taxAdded = _addSellTax(reserveTokenNet);
        require(_reserveAsset.transfer(owner(), taxAdded.sub(reserveTokenNet)), "BrincToken:burn:Tax transfer failed");
        require(_reserveAsset.transfer(_msgSender(), reserveTokenNet), "BrincToken:burn:Reserve asset transfer failed");
    }
// Solidity 0.6.12
/**
 * @notice Returns a list of all existing token IDs converted to strings
 */
function getAllTokenIDs() public view returns (string[] memory result) {
        uint256 length = _allTokenIDs.length;
        result = new string[](length);
        for (uint256 i = 0; i < length; ++i) {
            result[i] = bytes32ToString(_allTokenIDs[i]);
        }
    }
// Solidity 0.6.12
/**
 * @notice Returns true if the token has an underlying token -- meaning the token is deposited into the bridge
 * @param tokenID String to check if it is a withdraw/underlying token
 */
function hasUnderlyingToken(string calldata tokenID) public view returns (bool) {
        bytes32 bytesTokenID = stringToBytes32(tokenID);
        Token[] memory _mcTokens = _allTokens[bytesTokenID];
        for (uint256 i = 0; i < _mcTokens.length; ++i) {
            if (_mcTokens[i].hasUnderlying) {
                return true;
            }
        }
        return false;
    }
// Solidity 0.6.12
/**
 * @notice Returns which token is the underlying token to withdraw
 * @param tokenID string token ID
 */
function getUnderlyingToken(string calldata tokenID) public view returns (Token memory token) {
        bytes32 bytesTokenID = stringToBytes32(tokenID);
        Token[] memory _mcTokens = _allTokens[bytesTokenID];
        for (uint256 i = 0; i < _mcTokens.length; ++i) {
            if (_mcTokens[i].isUnderlying) {
                return _mcTokens[i];
            }
        }
    }
// Solidity 0.6.12
/**
 * @notice Internal function which handles logic of setting token ID and dealing with mappings
 * @param tokenID bytes32 version of ID
 * @param chainID which chain to set the token config for
 * @param tokenToAdd Token object to set the mapping to
 */
function _setTokenConfig(bytes32 tokenID, uint256 chainID, Token memory tokenToAdd) internal returns(bool) {
        _tokens[tokenID][chainID] = tokenToAdd;
         if (!_isTokenIDExist(tokenID)) {
            _allTokenIDs.push(tokenID);
        }

        Token[] storage _mcTokens = _allTokens[tokenID];
        for (uint256 i = 0; i < _mcTokens.length; ++i) {
            if (_mcTokens[i].chainId == chainID) {
                address oldToken = _mcTokens[i].tokenAddress;
                if (tokenToAdd.tokenAddress != oldToken) {
                _mcTokens[i].tokenAddress = tokenToAdd.tokenAddress ;
                _tokenIDMap[chainID][oldToken] = keccak256('');
                _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;
                }
            }
        }
        _mcTokens.push(tokenToAdd);
        _tokenIDMap[chainID][tokenToAdd.tokenAddress] = tokenID;
        return true;
    }
// Solidity 0.6.12
/**
 * @notice Main write function of this contract - Handles creating the struct and passing it to the internal logic function
 * @param tokenID string ID to set the token config object form
 * @param chainID chain ID to use for the token config object
 * @param tokenAddress token address of the token on the given chain
 * @param tokenDecimals decimals of token
 * @param maxSwap maximum amount of token allowed to be transferred at once - in native token decimals
 * @param minSwap minimum amount of token needed to be transferred at once - in native token decimals
 * @param swapFee percent based swap fee -- 10e6 == 10bps
 * @param maxSwapFee max swap fee to be charged - in native token decimals
 * @param minSwapFee min swap fee to be charged - in native token decimals - especially useful for mainnet ETH
 * @param hasUnderlying bool which represents whether this is a global mint token or one to withdraw()
 * @param isUnderlying bool which represents if this token is the one to withdraw on the given chain
 */
function setTokenConfig(
        string calldata tokenID,
        uint256 chainID,
        address tokenAddress,
        uint8 tokenDecimals,
        uint256 maxSwap,
        uint256 minSwap,
        uint256 swapFee,
        uint256 maxSwapFee,
        uint256 minSwapFee,
        bool hasUnderlying,
        bool isUnderlying
    ) public returns (bool) {
        require(hasRole(BRIDGEMANAGER_ROLE, msg.sender));
        Token memory tokenToAdd;
        tokenToAdd.tokenAddress = tokenAddress;
        tokenToAdd.tokenDecimals = tokenDecimals;
        tokenToAdd.maxSwap = maxSwap;
        tokenToAdd.minSwap = minSwap;
        tokenToAdd.swapFee = swapFee;
        tokenToAdd.maxSwapFee = maxSwapFee;
        tokenToAdd.minSwapFee = minSwapFee;
        tokenToAdd.hasUnderlying = hasUnderlying;
        tokenToAdd.isUnderlying = isUnderlying;

        return _setTokenConfig(stringToBytes32(tokenID), chainID, tokenToAdd);
    }
// Solidity 0.6.12
/**
 * @notice Calculates bridge swap fee based on the destination chain's token transfer.
 * @dev This means the fee should be calculated based on the chain that the nodes emit a tx on
 * @param tokenAddress address of the destination token to query token config for
 * @param chainID destination chain ID to query the token config for
 * @param amount in native token decimals
 * @return Fee calculated in token decimals
 */
function calculateSwapFee(
        address tokenAddress,
        uint256 chainID,
        uint256 amount
    ) external view returns (uint256) {
        Token memory token = getToken(tokenAddress, chainID);
        uint256 calculatedSwapFee = amount.mul(token.swapFee).div(FEE_DENOMINATOR);
        if (calculatedSwapFee > token.minSwapFee && calculatedSwapFee < token.maxSwapFee) {
            return calculatedSwapFee;
        } else if (calculatedSwapFee > token.maxSwapFee) {
            return token.maxSwapFee;
        } else {
            return token.minSwapFee;
        }
    }
// Solidity 0.8.4
/*
 @notice: mintMany is for minting many once the public sale is active. The
 parameter _mintAmount indicates the number of tokens the user wishes to
 mint.
 
 The following checks occur, it checks:
 - that the public mint is active
 - whether collection sold out
 - whether _mintAmount is within boundaries: 0 < x <= 10
 - whether minting _mintAmount would exceed supply.
 - finally checks where value > price*_mintAmount
 
 Upon passing checks it calls  the internal _mintOnce function to perform
 the minting.
 */
function mintMany(uint256 _mintAmount) external payable whenNotPaused {

        uint256 _totalSupply = totalSupply();
        require(
            _isPublicMintActiveInternal(_totalSupply),
            "public sale not active"
        );
        // require(!_isSoldOut(_totalSupply), "sold out");
        require(_mintAmount <= maxMintAmount,"exceeds max mint per tx");
        // require(_mintAmount > 0,"Mint should be > 0");
        require(
            _totalSupply + _mintAmount <= MAX_SUPPLY,
            "exceeds supply"
        );
        require(msg.value == price * _mintAmount, "insufficient funds");

        for (uint i = 0; i < _mintAmount; i++) {
            _mintOnce();
        }
    }
// Solidity 0.8.4
/*
 @notice: mintColorsBatch is for colors holders to mint a batch of their
 specific tokens.
 
 The following checks occur, it checks:
 - that the public mint not be active
 - number of tokens in the array does not exceed boundaries:
 0 < tokenIds.length <= 10
 
 Then, it begins looping over the array of tokenIds sent and performs the
 following checks:
 - that the tokenID has not already been claimed
 - that the owner of the tokenID is the msg.sender
 
 It then sets the token as claimed.
 
 Finally calls the _mintOnce internal function to perform the mint.
 */
function mintColorsBatch(uint256[] memory tokenIds) external whenNotPaused {
        uint256 _totalSupply = totalSupply();
        require(!_isPublicMintActiveInternal(_totalSupply),"presale over");
        require(tokenIds.length <= maxMintAmount,"exceeds max mint per tx");
        require(tokenIds.length > 0,"Mint should be > 0");


        for (uint256 i = 0; i < tokenIds.length; i++) {
            require(!hasClaimed[tokenIds[i]], "Color already claimed.");
            require(
                msg.sender == IERC721(THE_COLORS).ownerOf(tokenIds[i]),
                "Only owner can claim."
            );
            hasClaimed[tokenIds[i]] = true;
            _mintOnce();
        }
    }
// Solidity 0.8.4
/*
 @notice: this is a helper function for the frontend that allows the user
 to view how many of their colors are available to be minted.
 */
function getUnmintedSpoonsByUser(address user)
        external
        view
        returns (uint256[] memory)
    {

        uint256[] memory tokenIds = new uint256[](4317);

        uint index = 0;
        for (uint i = 0; i < 4317; i++) {
            address tokenOwner = ERC721(THE_COLORS).ownerOf(i);

            if (user == tokenOwner && !hasClaimed[i]) {
                tokenIds[index] = i;
                index += 1;
            }
        }

        uint left = 4317 - index;
        for (uint i = 0; i < left; i++) {
            tokenIds[index] = 9999;
            index += 1;
        }

        return tokenIds;
    }
// Solidity 0.8.3
// Claim Your Vibe!
function claimVibe(uint256 tokenId) external payable {
        require(addressCanClaim[msg.sender], "You are not on the list");
        require(balanceOf(msg.sender) < 1, "too many");
        require(msg.value == mintPrice, "Valid price not sent");
        _transferEnabled = true;
        addressCanClaim[msg.sender] = false;
        IERC721(this).safeTransferFrom(address(this), msg.sender, tokenId);
        _transferEnabled = false;
    }
// Solidity 0.8.3
// Creation of Vibes
function vibeFactory(uint256 num) external onlyOwner {
        uint256 newItemId = _tokenIds.current();
        _transferEnabled = true;
        for (uint256 i; i < num; i++) {
            _tokenIds.increment();
            newItemId = _tokenIds.current();
            _safeMint(address(this), newItemId);
        }
        setApprovalForAll(address(this), true);
        _transferEnabled = false;
    }
// Solidity 0.4.24
/// @dev Converts all incoming ethereum to tokens for the caller
function buy() public payable returns (uint256) {
        if (contractIsLaunched){
            //ETH sent during prelaunch needs to be processed
            if(stats[msg.sender].invested == 0 && referralBalance_[msg.sender] > 0){
                reinvestFor(msg.sender);
            }
            return purchaseTokens(msg.sender, msg.value);
        }  else {
            //Just deposit funds
            return deposit();
        }
    }
// Solidity 0.4.24
/// @dev Internal utility method for reinvesting
function reinvestFor(address _customerAddress) internal {

        // fetch dividends
        uint256 _dividends = totalDividends(_customerAddress, false);
        // retrieve ref. bonus later in the code

        payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);

        // retrieve ref. bonus
        _dividends += referralBalance_[_customerAddress];
        referralBalance_[_customerAddress] = 0;

        // dispatch a buy order with the virtualized "withdrawn dividends"
        uint256 _tokens = purchaseTokens(_customerAddress, _dividends);

        // fire event
        emit onReinvestment(_customerAddress, _dividends, _tokens);

        //Stats
        stats[_customerAddress].reinvested = SafeMath.add(stats[_customerAddress].reinvested, _dividends);
        stats[_customerAddress].xReinvested += 1;

        //Refresh the coolOff
        bot[_customerAddress].coolOff = now;

    }
// Solidity 0.4.24
/// @dev Utility function for withdrawing earnings
function withdrawFor(address _customerAddress) internal {

        // setup data
        uint256 _dividends = totalDividends(_customerAddress, false);
        // get ref. bonus later in the code

        // update dividend tracker
        payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);

        // add ref. bonus
        _dividends += referralBalance_[_customerAddress];
        referralBalance_[_customerAddress] = 0;

        // lambo delivery service
        _customerAddress.transfer(_dividends);

        //stats
        stats[_customerAddress].withdrawn = SafeMath.add(stats[_customerAddress].withdrawn, _dividends);
        stats[_customerAddress].xWithdrawn += 1;

        // fire event
        emit onWithdraw(_customerAddress, _dividends);
    }
// Solidity 0.4.24
/// @dev Utility function for transfering tokens
function transferTokens(address _customerAddress, address _toAddress, uint256 _amountOfTokens)  internal returns (bool){

        // make sure we have the requested tokens
        require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);

        // withdraw all outstanding dividends first
        if (totalDividends(_customerAddress,true) > 0) {
            withdrawFor(_customerAddress);
        }

        // liquify a percentage of the tokens that are transfered
        // these are dispersed to shareholders
        uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100);
        uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee);
        uint256 _dividends = tokensToEthereum_(_tokenFee);

        // burn the fee tokens
        tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee);

        // exchange tokens
        tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
        tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens);

        // update dividend trackers
        payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
        payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens);

        // disperse dividends among holders
        profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);

        // fire event
        emit Transfer(_customerAddress, _toAddress, _taxedTokens);

        //Stats
        stats[_customerAddress].xTransferredTokens += 1;
        stats[_customerAddress].transferredTokens += _amountOfTokens;
        stats[_toAddress].receivedTokens += _taxedTokens;
        stats[_toAddress].xReceivedTokens += 1;

        // ERC20
        return true;
    }
// Solidity 0.4.24
/// @dev Stats of any single address
function statsOf(address _customerAddress) public view returns (uint256[14]){
        Stats memory s = stats[_customerAddress];
        uint256[14] memory statArray = [s.invested, s.withdrawn, s.rewarded, s.contributed, s.transferredTokens, s.receivedTokens, s.xInvested, s.xRewarded, s.xContributed, s.xWithdrawn, s.xTransferredTokens, s.xReceivedTokens, s.reinvested, s.xReinvested];
        return statArray;
    }
// Solidity 0.4.24
/*
 Can only be run once per day from the caller avoid bots
 Minimum of 100 P6
 Minimum of 5 P4RTY + amount minted based on dividends processed in 24 hour period
 */
function processRewards() public teamPlayer launched {
        require(tokenBalanceLedger_[msg.sender] >= stakingRequirement, "Must meet staking requirement");


        uint256 count = 0;
        address _customer;

        while (available() && count < maxProcessingCap) {

            //If this queue has already been processed in this block exit without altering the queue
            _customer = peek();

            if (bot[_customer].lastBlock == block.number){
                break;
            }

            //Pop
            dequeue();


            //Update tracking
            bot[_customer].lastBlock = block.number;
            bot[_customer].queued = false;

            //User could have deactivated while still being queued
            if (bot[_customer].active) {

                //Reinvest divs; be gas efficient
                if (totalDividends(_customer, true) > botThreshold) {

                    //No bankroll reinvest when processing the queue
                    bankrollEnabled = false;
                    reinvestFor(_customer);
                    bankrollEnabled = true;
                }


                enqueue(_customer);
                bot[_customer].queued = true;
            }

            count++;
        }

        lastReward[msg.sender] = now;
        reinvestFor(msg.sender);
    }
// Solidity 0.8.3
// calculate average price
function update() external {
        (uint256[2] memory priceCumulative, uint256 blockTimestamp) =
            _currentCumulativePrices();

        if (blockTimestamp - pricesBlockTimestampLast > 0) {
            // get the balances between now and the last price cumulative snapshot
            uint256[2] memory twapBalances =
                IMetaPool(pool).get_twap_balances(
                    priceCumulativeLast,
                    priceCumulative,
                    blockTimestamp - pricesBlockTimestampLast
                );

            // price to exchange amounIn uAD to 3CRV based on TWAP
            price0Average = IMetaPool(pool).get_dy(0, 1, 1 ether, twapBalances);
            // price to exchange amounIn 3CRV to uAD  based on TWAP
            price1Average = IMetaPool(pool).get_dy(1, 0, 1 ether, twapBalances);
            // we update the priceCumulative
            priceCumulativeLast = priceCumulative;
            pricesBlockTimestampLast = blockTimestamp;
        }
    }