lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.17
// burn functions
function burnPool() external {
        require(totalStaked > 0, 'Stake required');
        uint _burnAmount = getBurnAmount() + toBurn;
        require(_burnAmount >= 10, "Nothing to burn...");
        lastBurnTime = now;
        toBurn = 0;

        uint _userReward = _burnAmount * 10 / 100;
        uint _stakeReward = _burnAmount * 20 / 100;
        uint _finalBurn = _burnAmount - _userReward - _stakeReward;

        _totalSupply = _totalSupply.sub(_finalBurn);
        totalBurned += _finalBurn;
        user[msg.sender].balance += _userReward;
        divsPerShare = divsPerShare.add((_stakeReward * MAG) / totalStaked);
        user[pool].balance = user[pool].balance.sub(_finalBurn);

        IUniswapV2Pair(pool).sync();

        emit PoolBurn(msg.sender, _burnAmount, _totalSupply, balanceOf(pool));
    }
// Solidity 0.6.12
/**
 * @dev Utility method which contains the logic of the constructor.
 * This is a useful trick to instantiate a contract when it is cloned.
 */
function init(
        address model,
        address source,
        string memory name,
        string memory symbol
    ) public virtual override {
        require(
            _model == address(0),
            "Init already called!"
        );

        require(
            model != address(0),
            "Model should be a valid ethereum address"
        );
        _model = model;

        _source = source;

        require(
            _source != address(0) || keccak256(bytes(name)) != keccak256(""),
            "At least a source contract or a name must be set"
        );
        require(
            _source != address(0) || keccak256(bytes(symbol)) != keccak256(""),
            "At least a source contract or a symbol must be set"
        );

        _registerInterface(this.onERC1155Received.selector);
        _registerInterface(this.onERC1155BatchReceived.selector);
        bool safeBatchTransferFrom = _checkAndInsertSelector(
            this.safeBatchTransferFrom.selector
        );
        bool cumulativeInterface = _checkAndInsertSelector(
            _INTERFACEobjectId_ERC1155
        );
        require(
            _source == address(0) ||
                safeBatchTransferFrom ||
                cumulativeInterface,
            "Looks like you're not wrapping a correct ERC1155 Token"
        );
        _checkAndInsertSelector(this.balanceOf.selector);
        _checkAndInsertSelector(this.balanceOfBatch.selector);
        _checkAndInsertSelector(this.setApprovalForAll.selector);
        _checkAndInsertSelector(this.isApprovedForAll.selector);
        _checkAndInsertSelector(this.safeTransferFrom.selector);
        _checkAndInsertSelector(this.uri.selector);
        _checkAndInsertSelector(this.totalSupply.selector);
        _supportsName = _checkAndInsertSelector(0x00ad800c); //name(uint256)
        _supportsSymbol = _checkAndInsertSelector(0x4e41a1fb); //symbol(uint256)
        _supportsDecimals = _checkAndInsertSelector(this.decimals.selector);
        _supportsDecimals = _source == address(0) ? false : _supportsDecimals;
        _setAndCheckNameAndSymbol(name, symbol);
    }
// Solidity 0.6.12
/**
 * @dev Mint
 * If the SuperSaiyanToken does not wrap a pre-existent NFT, this call is used to mint new NFTs, according to the permission rules provided by the Token creator.
 * @param amount The amount of tokens to be created. It must be greater than 1 unity.
 * @param objectUri The Uri to locate this new token's metadata.
 */
function mint(uint256 amount, string memory objectUri)
        public
        virtual
        override
        returns (uint256 objectId, address tokenAddress)
    {
        require(_source == address(0), "Cannot mint unexisting tokens");
        require(
            keccak256(bytes(objectUri)) != keccak256(""),
            "Uri cannot be empty"
        );
        (objectId, tokenAddress) = _mint(msg.sender, 0, amount, true);
        _objectUris[objectId] = objectUri;
    }
// Solidity 0.6.12
/**
 * @dev Burn
 * You can choose to burn your NFTs.
 * In case this Token wraps a pre-existent ERC1155 NFT, you will receive the wrapped NFTs.
 */
function burn(
        uint256 objectId,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        asERC20(objectId).burn(msg.sender, toDecimals(objectId, amount));
        if (_source != address(0)) {
            IERC1155(_source).safeTransferFrom(
                address(this),
                msg.sender,
                objectId,
                amount,
                data
            );
        }
    }
// Solidity 0.6.12
/**
 * @dev Burn Batch
 * Same as burn, but for multiple NFTs at the same time
 */
function burnBatch(
        uint256[] memory objectIds,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        for (uint256 i = 0; i < objectIds.length; i++) {
            asERC20(objectIds[i]).burn(
                msg.sender,
                toDecimals(objectIds[i], amounts[i])
            );
        }
        if (_source != address(0)) {
            IERC1155(_source).safeBatchTransferFrom(
                address(this),
                msg.sender,
                objectIds,
                amounts,
                data
            );
        }
    }
// Solidity 0.6.12
/**
 * @dev classic ERC-1155 onERC1155BatchReceived hook.
 * Same as onERC1155Received, but for multiple tokens at the same time
 */
function onERC1155BatchReceived(
        address,
        address owner,
        uint256[] memory objectIds,
        uint256[] memory amounts,
        bytes memory
    ) public virtual override returns (bytes4) {
        require(msg.sender == _source, "Unauthorized action!");
        for (uint256 i = 0; i < objectIds.length; i++) {
            _mint(owner, objectIds[i], amounts[i], false);
        }
        return this.onERC1155BatchReceived.selector;
    }
// Solidity 0.6.12
/**
 * @dev this method sends the correct creation parameters for the new ERC-20 to be minted.
 * It takes thata from the wrapped ERC1155 NFT or from the parameters passed at construction time.
 */
function getMintData(uint256 objectId)
        public
        virtual
        override
        view
        returns (
            string memory name,
            string memory symbol,
            uint256 decimals
        )
    {
        name = _name;
        symbol = _symbol;
        decimals = 18;
        if (
            _source != address(0) &&
            (_supportsName || _supportsSymbol || _supportsDecimals)
        ) {
            IERC1155Views views = IERC1155Views(_source);
            name = _supportsName ? views.name(objectId) : name;
            symbol = _supportsSymbol ? views.symbol(objectId) : symbol;
            decimals = _supportsDecimals ? views.decimals(objectId) : decimals;
        }
    }
// Solidity 0.6.7
/*
 * @notice Modify the stability fee for a collateral type; revert if the new fee is not within bounds
 * @param collateralType The collateral type to change the fee for
 * @param parameter Must be "stabilityFee"
 * @param data The new fee
 */
function modifyParameters(
        bytes32 collateralType,
        bytes32 parameter,
        uint256 data
    ) external isAuthorized {
        // Fetch the bounds
        uint256 lowerBound = stabilityFeeBounds[collateralType].lowerBound;
        uint256 upperBound = stabilityFeeBounds[collateralType].upperBound;
        // Check that the collateral type has bounds
        require(
          upperBound >= lowerBound,
          "MinimalTaxCollectorOverlay/bounds-improperly-set"
        );
        // Check that the new fee is within bounds
        require(both(data <= upperBound, data >= lowerBound), "MinimalTaxCollectorOverlay/fee-exceeds-bounds");
        // Check that the parameter name is correct
        require(parameter == "stabilityFee", "MinimalTaxCollectorOverlay/invalid-parameter");
        // Collect the fee up until now
        taxCollector.taxSingle(collateralType);
        // Finally set the new fee
        taxCollector.modifyParameters(collateralType, parameter, data);
    }
// Solidity 0.8.4
/**
 * @dev Spend `amount` form the allowance of `owner` toward `spender`.
 *
 * Does not update the allowance amount in case of infinite allowance.
 * Revert if not enough allowance is available.
 *
 * Might emit an {Approval} event.
 */
function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }
// Solidity 0.8.7
/**
 * Submit statement to be added to Historical Record. There is no fee to
 * add the 1st statement, but a fee is required for all subsequent
 * statements.
 * @param tokenId Unix time representation of a Historical Record date
 * @param _statement string statement that sender wants added to Record
 * @dev statementCount[tokenId] is set to 100 + the current number of
 * statements to lock the Record and prevent owner from adding multiple
 * statements. statementCount[tokenId] is set back equal to the current
 * number of statements in _beforeTokenTransfer() hook. Submitted
 * statements are mapped by statement[_statementId].
 */
function submitStatement(
        uint256 tokenId, 
        string memory _statement
    ) 
        public 
        payable 
    {
        uint256 _statementCount = statementCount[tokenId];
        if (_statementCount > 0) {
            require(msg.value == STATE_FEE, "Incorrect fee");
        }
        require(
            ERC721.ownerOf(tokenId) == msg.sender, 
            "Only owner can add statement"
        );
        require(_statementCount < 10, "Record locked");
        uint256 _statementId = tokenId + _statementCount + 1;
        statement[_statementId] = _statement;
        emit NewStatement(_statementId, _statement);
        if (_statementCount == 9) {
            emit Locked(tokenId, "Record complete");
        }
        statementCount[tokenId] = _statementCount + 101;
    }
// Solidity 0.8.7
/**
 * Mint a Historical Record with options to credit a referrer and/or to
 * submit a statement.
 * @param to is the receiver address of the Historical Record
 * @param _tokenId is rounded down to whole day intervals based on Unix
 * time resulting in tokenID
 * @param _ref is the referrer address. _ref must be a Historical record
 * owner and may not be "to" nor msg.sender
 * @param _statement string statement that sender wants added to Record
 * @dev tokenID corresponding to dates after 1970 must be less than or
 * equal to the current block timestamp. tokenID corresponding to dates
 * before 1970 must be less than or equal to the current limit on oldest
 * Historical Record date, oldestRec.
 */
function safeMintRefStatement(
        address to, 
        uint256 _tokenId, 
        address _ref,
        string memory _statement
    ) 
        public 
        payable 
    {
        require(
            msg.value == MINT_FEE ||
            msg.sender == owner(), 
            "Incorrect fee"
        );
        require(
            block.timestamp > 1632326400 || 
            msg.sender == owner(), 
            "Minting not yet open"
        ); //2021.09.22 16:00 UTC
        uint256 tokenId = _tokenId - _tokenId % 43200;
        if (tokenId % 86400 == 0) {
            require(
                tokenId <= block.timestamp, 
                "Cannot mint a Record in future"
            );
        } else {
            require(
                tokenId <= oldestRec, 
                "Record too far in past to mint"
            );
        }
        if (
            _ref != address(0) &&
            _ref != to &&
            _ref != msg.sender &&
            balanceOf(_ref) > 0
        ) 
        {
            uint256 _amount = msg.value / REF_FEE;
            fees[_ref] += _amount;
            feeBal += _amount;
        }
        _safeMint(to, tokenId);
        if (bytes(_statement).length != 0) {
            uint256 _statementId = tokenId + 1;
            statement[_statementId] = _statement;
            emit NewStatement(_statementId, _statement);
            statementCount[tokenId] = 101;
        }
    }
// Solidity 0.8.11
/**
 * Mint the hybrid being worked on by the specified artist
 */
function mintArtistCreation(uint _artistId) public returns (uint) {
    require(monaTokens.tokenOwner(_artistId) == msg.sender, "You do not own this artist");

    ArtistStatus memory status = artistStatus[_artistId];

    require(status.creationReadyAt > 0, "Artist is not working");
    // block.timestamp is always going to lag "now" by a certain amount of time due to
    // the time it takes to mine a block, so add on a bit of buffer to it. This prevents
    // situation where the client thinks a mint is ready but the contract still doesn't
    // until the next block.
    require((block.timestamp + 1 minutes) >= status.creationReadyAt, "Creation not ready");

    uint id;
    bool isHybrid = status.isHybrid;
    if (isHybrid) {
      id = monaHybrids.mintHybrid(msg.sender, status.creationId);
    } else {
      id = monaTokens.mintArt(msg.sender, status.creationId);
    }

    // Reset artist state back to "idle"
    artistStatus[_artistId].isHybrid = false;
    artistStatus[_artistId].creationReadyAt = 0;
    artistStatus[_artistId].creationId = 0;

    emit MintArtistCreation(_artistId, id, isHybrid);

    return id;
  }
// Solidity 0.4.24
/*
 * @notice Fallback function that will execute code from the target contract to process a function call.
 * @dev Will use the delegatecall opcode to retain the current state of the Proxy contract and use the logic
 * from the target contract to process it.
 */
function () payable public {
        bytes memory data = msg.data;
        address impl = target;

        assembly {
            let result := delegatecall(gas, impl, add(data, 0x20), mload(data), 0, 0)
            let size := returndatasize

            let ptr := mload(0x40)
            returndatacopy(ptr, 0, size)

            switch result
            case 0 { revert(ptr, size) }
            default { return(ptr, size) }
        }
    }
// Solidity 0.6.12
/*
 * Perform any strategy unwinding or other calls necessary to capture
 * the "free return" this strategy has generated since the last time it's
 * core position(s) were adusted. Examples include unwrapping extra rewards.
 * This call is only used during "normal operation" of a Strategy, and should
 * be optimized to minimize losses as much as possible. It is okay to report
 * "no returns", however this will affect the credit limit extended to the
 * strategy and reduce it's overall position if lower than expected returns
 * are sustained for long periods of time.
 */
function prepareReturn(uint256 _debtOutstanding) internal override returns (uint256 _profit, uint256 _loss, uint256 _debtPayment) {
        if (_debtOutstanding > 0) {
            _debtPayment = liquidatePosition(_debtOutstanding);
        }

        // Figure out how much want we have
        uint256 _before = want.balanceOf(address(this));

        // Withdraw all our xSushi
        xSushi(xsushi).leave(IERC20(xsushi).balanceOf(address(this)));
        // Get how much sushi we have earned from xSushi
        uint256 _earned = 0;
        if (IERC20(reward).balanceOf(address(this)) > staking) {
            _earned = IERC20(reward).balanceOf(address(this)).sub(staking);
        }

        if (_earned > 0) {
            swap(reward, token0, _earned / 2);
            _earned = IERC20(reward).balanceOf(address(this));
            swap(reward, token1, _earned);
            add_liquidity();
            
            // How much want we got from xSushi
            _profit = want.balanceOf(address(this)).sub(_before);
        }
    }
// Solidity 0.6.12
// ******** HELPER METHODS ************
// Quote want token in ether.
function wantPrice() public view returns (uint256) {
        require(token0 == weth || token1 == weth);  // dev: can only quote weth pairs
        (uint112 _reserve0, uint112 _reserve1, ) = SushiswapPair(address(want)).getReserves();
        uint256 _supply = IERC20(want).totalSupply();
        return 2e18 * uint256(token0 == weth ? _reserve0 : _reserve1) / _supply;
    }
// Solidity 0.6.12
/**
 * @dev Migrate tokens from a pair to a Kyber Dmm Pool
 *   Supporting both normal tokens and tokens with fee on transfer
 *   Support create new pool with received tokens from removing, or
 *       add tokens to a given pool address
 * @param uniPair pair for token that user wants to migrate from
 *   it should be compatible with UniswapPair's interface
 * @param tokenA first token of the pool
 * @param tokenB second token of the pool
 * @param liquidity amount of LP tokens to migrate
 * @param amountAMin min amount for tokenA when removing
 * @param amountBMin min amount for tokenB when removing
 * @param dmmAmountAMin min amount for tokenA when adding
 * @param dmmAmountBMin min amount for tokenB when adding
 * @param poolInfo info the the Kyber DMM Pool - (poolAddress, poolAmp)
 *   if poolAddress is 0x0 -> create new pool with amp factor of poolAmp
 *   otherwise add liquidity to poolAddress
 * @param deadline only allow transaction to be executed before the deadline
 */
function migrateLpToDmmPool(
        address uniPair,
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        uint256 dmmAmountAMin,
        uint256 dmmAmountBMin,
        PoolInfo calldata poolInfo,
        uint256 deadline
    )
        external
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 addedLiquidity
        );
// Solidity 0.6.12
/**
 * @dev Use only for some special tokens
 */
function manualApproveAllowance(
        IERC20[] calldata tokens,
        address[] calldata spenders,
        uint256 allowance
    ) external onlyOwner {
        for (uint256 i = 0; i < tokens.length; i++) {
            for (uint256 j = 0; j < spenders.length; j++) {
                tokens[i].safeApprove(spenders[j], allowance);
            }
        }
    }
// Solidity 0.6.12
/**
 * @dev Add liquidity to Kyber dmm pool, support adding to new pool or an existing pool
 */
function _addLiquidityToDmmPool(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        PoolInfo memory poolInfo,
        uint256 deadline
    )
        internal
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        )
    {
        // safe approve only if needed
        _safeApproveAllowance(IERC20(tokenA), address(dmmRouter));
        _safeApproveAllowance(IERC20(tokenB), address(dmmRouter));
        if (poolInfo.poolAddress == address(0)) {
            // add to new pool
            (amountA, amountB, liquidity) = _addLiquidityNewPool(
                tokenA,
                tokenB,
                amountADesired,
                amountBDesired,
                amountAMin,
                amountBMin,
                poolInfo.poolAmp,
                deadline
            );
        } else {
            (amountA, amountB, liquidity) = _addLiquidityExistingPool(
                tokenA,
                tokenB,
                amountADesired,
                amountBDesired,
                amountAMin,
                amountBMin,
                poolInfo.poolAddress,
                deadline
            );
        }
    }
// Solidity 0.6.12
/**
 * @dev Add liquidity to an existing pool, and return back tokens to users if any
 */
function _addLiquidityExistingPool(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address dmmPool,
        uint256 deadline
    )
        internal
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        )
    {
        (amountA, amountB, liquidity) = IDMMLiquidityRouter(dmmRouter).addLiquidity(
            IERC20(tokenA),
            IERC20(tokenB),
            dmmPool,
            amountADesired,
            amountBDesired,
            amountAMin,
            amountBMin,
            msg.sender,
            deadline
        );
        // return back token if needed
        if (amountA < amountADesired) {
            IERC20(tokenA).safeTransfer(msg.sender, amountADesired - amountA);
        }
        if (amountB < amountBDesired) {
            IERC20(tokenB).safeTransfer(msg.sender, amountBDesired - amountB);
        }
    }
// Solidity 0.6.12
/**
 * @dev Add liquidity to a new pool, and return back tokens to users if any
 */
function _addLiquidityNewPool(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        uint32 amps,
        uint256 deadline
    )
        internal
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        )
    {
        (amountA, amountB, liquidity) = IDMMLiquidityRouter(dmmRouter).addLiquidityNewPool(
            IERC20(tokenA),
            IERC20(tokenB),
            amps,
            amountADesired,
            amountBDesired,
            amountAMin,
            amountBMin,
            msg.sender,
            deadline
        );
        // return back token if needed
        if (amountA < amountADesired) {
            IERC20(tokenA).safeTransfer(msg.sender, amountADesired - amountA);
        }
        if (amountB < amountBDesired) {
            IERC20(tokenB).safeTransfer(msg.sender, amountBDesired - amountB);
        }
    }
// Solidity 0.6.12
/**
 * @dev Re-write remove liquidity function from Uniswap
 */
function _removeUniLiquidity(
        address pair,
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        uint256 deadline
    ) internal {
        require(deadline >= block.timestamp, "Migratior: EXPIRED");
        IERC20(pair).safeTransferFrom(msg.sender, pair, liquidity); // send liquidity to pair
        (uint256 amount0, uint256 amount1) = IUniswapV2Pair(pair).burn(address(this));
        (address token0, ) = _sortTokens(tokenA, tokenB);
        (uint256 amountA, uint256 amountB) = tokenA == token0
            ? (amount0, amount1)
            : (amount1, amount0);
        require(amountA >= amountAMin, "Migratior: UNI_INSUFFICIENT_A_AMOUNT");
        require(amountB >= amountBMin, "Migratior: UNI_INSUFFICIENT_B_AMOUNT");
    }
// Solidity 0.6.12
/**
 * @dev Copy logic of sort token from Uniswap lib
 */
function _sortTokens(address tokenA, address tokenB)
        internal
        pure
        returns (address token0, address token1)
    {
        require(tokenA != tokenB, "Migrator: IDENTICAL_ADDRESSES");
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), "Migrator: ZERO_ADDRESS");
    }