lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.18
// Transfer gift to a new owner.
function assignSharedOwnership(address _to, uint256 _divisibility)
                               onlyOwner external returns (bool success) 
                               {

        require(_to != address(0));
        require(msg.sender != _to);
        require(_to != address(this));
        
        // Requiring msg.sender has Holdings of Forever rose
        require(tokenToOwnersHoldings[foreverRoseId][msg.sender] >= _divisibility);

        //Remove ownership from oldOwner(msg.sender)
        _removeLastOwnerHoldingsFromToken(msg.sender, foreverRoseId, _divisibility);
        _removeShareFromLastOwner(msg.sender, foreverRoseId, _divisibility);

         //Add ownership to NewOwner(address _to)
        _addShareToNewOwner(_to, foreverRoseId, _divisibility); 
        _addNewOwnerHoldingsToToken(_to, foreverRoseId, _divisibility);

        // Trigger Ethereum Event
        Transfer(msg.sender, _to, foreverRoseId);

        return true;
    }
// Solidity 0.8.9
/**
 * @dev mints a given amount of tokens for a given recipient
 *
 * requirements:
 *
 * - the caller must have the ROLE_ADMIN privileges, and the contract must not be paused
 */
function mint(address recipient, uint256 amount) external onlyRole(ROLE_ADMIN) whenNotPaused {
        if (recipient == address(0)) {
            revert InvalidRecipient();
        }
        if (amount == 0) {
            revert InvalidAmount();
        }
        _token.safeTransfer(recipient, amount);
        _totalSupply += amount;
    }
// Solidity 0.8.9
/**
 * @notice Allow user's OpenSea proxy accounts to enable gas-less listings
 * @notice Eenable extendibility for the project
 * @param _owner      The active owner of the token
 * @param _operator    The origin of the action being called
 */
function isApprovedForAll(address _owner, address _operator)
        public
        view
        override
        returns (bool)
    {
        ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddr);

        if (
            (address(proxyRegistry.proxies(_owner)) == _operator &&
                !addressToRegistryDisabled[_owner]) || projectProxy[_operator]
        ) {
            return true;
        }

        return super.isApprovedForAll(_owner, _operator);
    }
// Solidity 0.8.2
/// @notice only l1Target can update greeting
function cudlToL2(address _cudler, uint256 _amount) public {
        // To check that message came from L1, we check that the sender is the L1 contract's L2 alias.
        require(
            msg.sender == AddressAliasHelper.applyL1ToL2Alias(l1Target),
            "Greeting only updateable by L1"
        );

        /* Here we mint the ERC20 amount to _cudler */
        emit Minted(_cudler, _amount);
    }
// Solidity 0.8.1
// burn supply, not negative rebase
function verysmashed() external  {
        require(!state.paused, "still paused");
        require(state.lastAttack + state.attackCooldown < block.timestamp, "Dogira coolingdown");
        uint256 rLp = state.accounts[state.addresses.pool].rTotal;
        uint256 amountToDeflate = (rLp / (state.divisors.tokenLPBurn));
        uint256 burned = amountToDeflate / ratio();
        state.accounts[state.addresses.pool].rTotal -= amountToDeflate;
        state.accounts[address(0)].rTotal += amountToDeflate;
        state.accounts[address(0)].tTotal += burned;
        state.balances.burned += burned;
        state.lastAttack = block.timestamp;
        syncPool();
        emit Smashed(burned);
    }
// Solidity 0.8.1
// positive rebase
function dogebreath() external {
        require(!state.paused, "still paused");
        require(state.lastAttack + state.attackCooldown < block.timestamp, "Dogira coolingdown");
        uint256 rate = ratio();
        uint256 target = state.balances.burned == 0 ? state.balances.tokenSupply : state.balances.burned;
        uint256 amountToInflate = target / state.divisors.inflate;
        if(state.balances.burned > amountToInflate) {
            state.balances.burned -= amountToInflate;
            state.accounts[address(0)].rTotal -= amountToInflate * rate;
            state.accounts[address(0)].tTotal -= amountToInflate;
        }
        // positive rebase
        state.balances.networkSupply -= amountToInflate * rate;
        state.lastAttack = block.timestamp;
        syncPool();
        emit Atomacized(amountToInflate);
    }
// Solidity 0.8.1
// disperse amount to all holders
function wow(uint256 amount) external {
        address sender = msg.sender;
        uint256 rate = ratio();
        require(!getExcluded(sender), "Excluded addresses can't call this function");
        require(amount * rate < state.accounts[sender].rTotal, "too much");
        state.accounts[sender].rTotal -= (amount * rate);
        state.balances.networkSupply -= amount * rate;
        state.balances.fees += amount;
    }
// Solidity 0.8.1
// award community members from the treasury
function muchSupport(address awardee, uint256 multiplier) external onlyAdminOrOwner {
        uint256 n = block.timestamp;
        require(!state.paused, "still paused");
        require(state.accounts[awardee].lastShill + 1 days < n, "nice shill but need to wait");
        require(!getExcluded(awardee), "excluded addresses can't be awarded");
        require(multiplier <= 100 && multiplier > 0, "can't be more than .1% of dogecity reward");
        uint256 level = getLevel(awardee);
        if(level > levelCap) {
            level = levelCap; // capped at 10
        } else if (level <= 0) {
            level = 1;
        }
        uint256 p = ((state.accounts[state.addresses.dogecity].rTotal / 100000) * multiplier) * level; // .001% * m of dogecity * level
        state.accounts[state.addresses.dogecity].rTotal -= p;
        state.accounts[awardee].rTotal += p;
        state.accounts[awardee].lastShill = block.timestamp;
        state.accounts[awardee].communityPoints += multiplier;
        emit Hooray(awardee, p);
    }
// Solidity 0.8.1
// burn amount, for cex integration?
function suchburn(uint256 amount) external {
        address sender = msg.sender;
        uint256 rate = ratio();
        require(!getExcluded(sender), "Excluded addresses can't call this function");
        require(amount * rate < state.accounts[sender].rTotal, "too much");
        state.accounts[sender].rTotal -= (amount * rate);
        state.accounts[address(0)].rTotal += (amount * rate);
        state.accounts[address(0)].tTotal += (amount);
        state.balances.burned += amount;
        syncPool();
        emit Blazed(amount);
    }
// Solidity 0.8.4
/**
 * @dev See {IERC721Enumerable-totalSupply}.
 * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
 */
function totalSupply() public view returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than _currentIndex - _startTokenId() times
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }
// Solidity 0.8.4
/**
 * Returns the total amount of tokens minted in the contract.
 */
function _totalMinted() internal view returns (uint256) {
        // Counter underflow is impossible as _currentIndex does not decrement,
        // and it is initialized to _startTokenId()
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }
// Solidity 0.4.18
/**
 * @dev CraftyCrowdsale constructor sets the token, period and exchange rate
 * @param _token The address of Crafty Token.
 * @param _preSaleStart The start time of pre-sale.
 * @param _preSaleEnd The end time of pre-sale.
 * @param _saleStart The start time of sale.
 * @param _saleEnd The end time of sale.
 * @param _rate The exchange rate of tokens.
 */
function CraftyCrowdsale(address _token, uint256 _preSaleStart, uint256 _preSaleEnd, uint256 _saleStart, uint256 _saleEnd, uint256 _rate) public {
        require(_token != address(0));
        require(_preSaleStart < _preSaleEnd && _preSaleEnd < _saleStart && _saleStart < _saleEnd);
        require(_rate > 0);

        token = MintableToken(_token);
        preSaleStart = _preSaleStart;
        preSaleEnd = _preSaleEnd;
        saleStart = _saleStart;
        saleEnd = _saleEnd;
        rate = _rate;
    }
// Solidity 0.4.18
/**
 * @dev Function used to buy tokens
 */
function buyTokens() public saleIsOn whenNotPaused payable {
        require(msg.sender != address(0));
        require(msg.value >= 20 finney);

        uint256 weiAmount = msg.value;
        uint256 currentRate = getRate(weiAmount);

        // calculate token amount to be created
        uint256 newTokens = weiAmount.mul(currentRate).div(10**18);

        require(issuedTokens.add(newTokens) <= hardCap);
        
        issuedTokens = issuedTokens.add(newTokens);
        received[msg.sender] = received[msg.sender].add(weiAmount);
        token.mint(msg.sender, newTokens);
        TokenPurchase(msg.sender, msg.sender, newTokens);

        etherWallet.transfer(msg.value);
    }
// Solidity 0.4.18
/**
 * @dev Function used to set wallets and enable the sale.
 * @param _etherWallet Address of ether wallet.
 * @param _teamWallet Address of team wallet.
 * @param _advisorWallet Address of advisors wallet.
 * @param _bountyWallet Address of bounty wallet.
 * @param _fundWallet Address of fund wallet.
 */
function setWallets(address _etherWallet, address _teamWallet, address _advisorWallet, address _bountyWallet, address _fundWallet) public onlyOwner inState(State.BEFORE_START) {
        require(_etherWallet != address(0));
        require(_teamWallet != address(0));
        require(_advisorWallet != address(0));
        require(_bountyWallet != address(0));
        require(_fundWallet != address(0));

        etherWallet = _etherWallet;
        teamWallet = _teamWallet;
        advisorWallet = _advisorWallet;
        bountyWallet = _bountyWallet;
        fundWallet = _fundWallet;

        uint256 releaseTime = saleEnd + lockTime;

        // Mint locked tokens
        teamTokens = new TokenTimelock(token, teamWallet, releaseTime);
        token.mint(teamTokens, teamCap);

        // Mint released tokens
        token.mint(advisorWallet, advisorCap);
        token.mint(bountyWallet, bountyCap);
        token.mint(fundWallet, fundCap);

        currentState = State.SALE;
    }
// Solidity 0.4.18
/**
 * @dev Get exchange rate based on time and amount.
 * @param amount Amount received.
 * @return An uint256 representing the exchange rate.
 */
function getRate(uint256 amount) internal view returns (uint256) {
        if(now < preSaleEnd) {
            require(amount >= 6797 finney);

            if(amount <= 8156 finney)
                return rate.mul(105).div(100);
            if(amount <= 9515 finney)
                return rate.mul(1055).div(1000);
            if(amount <= 10874 finney)
                return rate.mul(1065).div(1000);
            if(amount <= 12234 finney)
                return rate.mul(108).div(100);
            if(amount <= 13593 finney)
                return rate.mul(110).div(100);
            if(amount <= 27185 finney)
                return rate.mul(113).div(100);
            if(amount > 27185 finney)
                return rate.mul(120).div(100);
        }

        return rate;
    }
// Solidity 0.4.19
/// @notice Transfer `_value` tokens from sender's account
/// `msg.sender` to provided account address `_to`.
/// @notice This function is disabled during the funding.
/// @dev Required state: Operational
/// @param _to The address of the tokens recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) public returns (bool) {
        // Abort if not in Operational state.
        
        var senderBalance = balances[msg.sender];
        if (senderBalance >= _value && _value > 0) {
            senderBalance -= _value;
            balances[msg.sender] = senderBalance;
            balances[_to] += _value;
            Transfer(msg.sender, _to, _value);
            return true;
        }
        return false;
    }
// Solidity 0.8.9
//this method is responsible for taking all fee where fee is require to be deducted.
function _tokenTransfer(address sender, address recipient, uint256 amount) private 
    {
        if(recipient==uniswapV2Pair)
        {
            setAllFees(_saleTaxFee, _saleLiquidityFee, _saleTreasuryFee, _saleMarketingFee);
        }
        
        
        if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient])
        {   
           removeAllFee(); 
        }
        else  
        {
            require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
        }
        
        

        if (_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferFromExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
            _transferToExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferStandard(sender, recipient, amount);
        } else if (_isExcluded[sender] && _isExcluded[recipient]) {
            _transferBothExcluded(sender, recipient, amount);
        } else {
            _transferStandard(sender, recipient, amount);
        }

        restoreAllFee();
    }
// Solidity 0.4.19
/**
 * @dev  SavingsandLoans Constructor
 * Mints the initial supply of tokens, this is the hard cap, no more tokens will be minted.
 * Allocate the tokens to the foundation wallet, issuing wallet etc.
 */
function  SavingsandLoans() public {
    // Mint initial supply of tokens. All further minting of tokens is disabled
    totalSupply_ = INITIAL_SUPPLY;

    // Transfer all initial tokens to msg.sender
    balances[msg.sender] = INITIAL_SUPPLY;
    Transfer(0x0, msg.sender, INITIAL_SUPPLY);
  }
// Solidity 0.6.12
// we use this to clone our original strategy to other vaults
function cloneConvex3CrvRewards(
        address _vault,
        address _strategist,
        address _rewardsToken,
        address _keeper,
        uint256 _pid,
        address _curvePool,
        string memory _name
    ) external returns (address newStrategy) {
        require(isOriginal);
        // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol
        bytes20 addressBytes = bytes20(address(this));
        assembly {
            // EIP-1167 bytecode
            let clone_code := mload(0x40)
            mstore(
                clone_code,
                0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
            )
            mstore(add(clone_code, 0x14), addressBytes)
            mstore(
                add(clone_code, 0x28),
                0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
            )
            newStrategy := create(0, clone_code, 0x37)
        }

        StrategyConvex3CrvRewardsClonable(newStrategy).initialize(
            _vault,
            _strategist,
            _rewardsToken,
            _keeper,
            _pid,
            _curvePool,
            _name
        );

        emit Cloned(newStrategy);
    }
// Solidity 0.6.12
/* ========== KEEP3RS ========== */
function harvestTrigger(uint256 callCostinEth)
        public
        view
        override
        returns (bool)
    {
        // trigger if we want to manually harvest
        if (forceHarvestTriggerOnce) {
            return true;
        }

        // harvest if we have a profit to claim
        if (claimableProfitInUsdt() > harvestProfitNeeded) {
            return true;
        }

        // Should not trigger if strategy is not active (no assets and no debtRatio). This means we don't need to adjust keeper job.
        if (!isActive()) {
            return false;
        }

        return super.harvestTrigger(callCostinEth);
    }
// Solidity 0.6.12
// convert our keeper's eth cost into want
function ethToWant(uint256 _ethAmount)
        public
        view
        override
        returns (uint256)
    {
        uint256 callCostInWant;
        if (_ethAmount > 0) {
            address[] memory ethPath = new address[](2);
            ethPath[0] = address(weth);
            ethPath[1] = address(dai);

            uint256[] memory _callCostInDaiTuple =
                IUniswapV2Router02(sushiswap).getAmountsOut(
                    _ethAmount,
                    ethPath
                );

            uint256 _callCostInDai =
                _callCostInDaiTuple[_callCostInDaiTuple.length - 1];
            callCostInWant = zapContract.calc_token_amount(
                curve,
                [0, _callCostInDai, 0, 0],
                true
            );
        }
        return callCostInWant;
    }
// Solidity 0.6.12
// These functions are useful for setting parameters of the strategy that may need to be adjusted.
// Set optimal token to sell harvested funds for depositing to Curve.
// Default is DAI, but can be set to USDC or USDT as needed by strategist or governance.
function setOptimal(uint256 _optimal) external onlyAuthorized {
        if (_optimal == 0) {
            crvPath[2] = address(dai);
            convexTokenPath[2] = address(dai);
            if (hasRewards) {
                rewardsPath[2] = address(dai);
            }
            optimal = 0;
        } else if (_optimal == 1) {
            crvPath[2] = address(usdc);
            convexTokenPath[2] = address(usdc);
            if (hasRewards) {
                rewardsPath[2] = address(usdc);
            }
            optimal = 1;
        } else if (_optimal == 2) {
            crvPath[2] = address(usdt);
            convexTokenPath[2] = address(usdt);
            if (hasRewards) {
                rewardsPath[2] = address(usdt);
            }
            optimal = 2;
        } else {
            revert("incorrect token");
        }
    }
// Solidity 0.6.12
// Use to add or update rewards
function updateRewards(address _rewardsToken) external onlyGovernance {
        // reset allowance to zero for our previous token if we had one
        if (address(rewardsToken) != address(0)) {
            rewardsToken.approve(sushiswap, uint256(0));
        }
        // update with our new token, use dai as default
        rewardsToken = IERC20(_rewardsToken);
        rewardsToken.approve(sushiswap, type(uint256).max);
        rewardsPath = [address(rewardsToken), address(weth), address(dai)];
        hasRewards = true;
    }
// Solidity 0.8.4
/**
 * @dev Public function for purchasing {num} amount of tokens. Checks for current price.
 * Calls mint() for minting processs
 * @param _to recipient of the NFT minted
 * @param _num number of NFTs minted (Max is 20)
 */
function buy(address _to, uint256 _num) 
        public 
        payable 
    {
        require(!salePaused, "Sale hasn't started");
        require(_num < (maxMint+1),"You can mint a maximum of 20 NFTPs at a time");
        require(msg.value >= price * _num,"Ether amount sent is not correct");
        mint(_to, _num);
    }
// Solidity 0.8.4
/**
 * @dev Public function for purchasing presale {num} amount of tokens. Requires whitelistEligible()
 * Calls mint() for minting processs
 * @param _to recipient of the NFT minted
 * @param _num number of NFTs minted (Max is 20)
 */
function presale(address _to, uint256 _num)
        public
        payable
    {
        require(!presalePaused, "Presale hasn't started");
        require(whitelistEligible(_to), "You're not eligible for the presale");
        require(_num < (maxMint+1),"You can mint a maximum of 20 NFTPs at a time");
        require(msg.value >= price * _num,"Ether amount sent is not correct");
        mint(_to, _num);
    }
// Solidity 0.5.1
/**
 * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 * - The divisor cannot be zero.
 * NOTE: This is a feature of the next version of OpenZeppelin Contracts.
 * @dev Get it via `npm install @openzeppelin/contracts@next`.
 */
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }
// Solidity 0.5.10
/** Increases the number of drag-along tokens. Requires minter to deposit an equal amount of share tokens */
function wrap(address shareholder, uint256 amount) public noOfferPending() {
        require(active, "Contract not active any more.");
        require(wrapped.balanceOf(msg.sender) >= amount, "Share balance not sufficient");
        require(wrapped.allowance(msg.sender, address(this)) >= amount, "Share allowance not sufficient");
        require(wrapped.transferFrom(msg.sender, address(this), amount), "Share transfer failed");
        _mint(shareholder, amount);
    }
// Solidity 0.5.10
/** @dev Function to start drag-along procedure
 *  This can be called by anyone, but there is an upfront payment.
 */
function initiateAcquisition(uint256 pricePerShare) public {
        require(active, "An accepted offer exists");
        uint256 totalEquity = IShares(getWrappedContract()).totalShares();
        address buyer = msg.sender;

        require(totalSupply() >= totalEquity.mul(MIN_DRAG_ALONG_QUOTA).div(10000), "This contract does not represent enough equity");
        require(balanceOf(buyer) >= totalEquity.mul(MIN_HOLDING).div(10000), "You need to hold at least 5% of the firm to make an offer");

        require(currency.transferFrom(buyer, offerFeeRecipient, offerFee), "Currency transfer failed");

        Acquisition newOffer = new Acquisition(msg.sender, pricePerShare, acquisitionQuorum);
        require(newOffer.isWellFunded(getCurrencyContract(), totalSupply() - balanceOf(buyer)), "Insufficient funding");
        if (offerExists()) {
            require(pricePerShare >= offer.price().mul(MIN_OFFER_INCREMENT).div(10000), "New offers must be at least 5% higher than the pending offer");
            killAcquisition("Offer was replaced by a higher bid");
        }
        offer = newOffer;

        emit OfferCreated(buyer, pricePerShare);
    }
// Solidity 0.4.16
// Get your money back before the raffle occurs
function getRefund() public {
        uint refund = 0;
        for (uint i = 0; i < totalTickets; i++) {
            if (msg.sender == contestants[i].addr && raffleId == contestants[i].raffleId) {
                refund += pricePerTicket;
                contestants[i] = Contestant(address(0), 0);
                gaps.push(i);
                TicketRefund(raffleId, msg.sender, i);
            }
        }

        if (refund > 0) {
            msg.sender.transfer(refund);
        }
    }
// Solidity 0.4.16
// Refund everyone's money, start a new raffle, then pause it
function endRaffle() public {
        if (msg.sender == feeAddress) {
            paused = true;

            for (uint i = 0; i < totalTickets; i++) {
                if (raffleId == contestants[i].raffleId) {
                    TicketRefund(raffleId, contestants[i].addr, i);
                    contestants[i].addr.transfer(pricePerTicket);
                }
            }

            RaffleResult(raffleId, totalTickets, address(0), address(0), address(0), 0, 0);
            raffleId++;
            nextTicket = 0;
            gaps.length = 0;
        }
    }