lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * @dev Special only admin function for batch tokens assignments.
 * @param _target Array of target addresses.
 * @param _amount Array of target values.
 */
function batch(address[] _target,uint256[] _amount) onlyAdmin public { //It takes an array of addresses and an amount
        require(_target.length == _amount.length); //data must be same size
        uint256 size = _target.length;
        for (uint i=0; i<size; i++) { //It moves over the array
            transfer(_target[i],_amount[i]); //Caller must hold needed tokens, if not it will revert
        }
    }
// Solidity 0.4.24
/**
 * Returns true if the resolver implements the interface specified by the provided hash.
 * @param interfaceID The ID of the interface to check for.
 * @return True if the contract implements the requested interface.
 */
function supportsInterface(bytes4 interfaceID) public pure returns (bool) {
        return interfaceID == ADDR_INTERFACE_ID ||
               interfaceID == CONTENT_INTERFACE_ID ||
               interfaceID == NAME_INTERFACE_ID ||
               interfaceID == ABI_INTERFACE_ID ||
               interfaceID == PUBKEY_INTERFACE_ID ||
               interfaceID == TEXT_INTERFACE_ID ||
               interfaceID == INTERFACE_META_ID;
    }
// Solidity 0.8.0
/**
 * @notice Add investors.
 */
function add(
        address investor,
        uint256 allocated,
        uint256 initialRelase,
        uint256 duration_
    ) public onlyOwner {
        // solhint-disable-next-line max-line-length
        require(investor != address(0), "Vesting: investor is the zero address");
        require(investorMap[investor] == 0, "Vesting: investor exists");
        uint256 initial = allocated.mul(initialRelase).div(100);
        investors.push(Investor(
            investor,
            allocated,
            initial,
            block.timestamp,
            duration_,
            0
        ));
        investorMap[investor] = investors.length;
    }
// Solidity 0.8.0
/**
 * @notice Allows the owner to revoke the vesting. Tokens already vested
 * remain in the contract, the rest are returned to the owner.
 * @param _revoke address which is being vested
 */
function revoke(address _revoke) public onlyOwner {
        require(revocable, "Vesting: cannot revoke");
        require(!revoked[_revoke], "Vesting: token already revoked");

        uint256 balance = allocation(_revoke);
        require(balance > 0, "Vesting: no allocation");

        uint256 unreleased = _releasableAmount(_revoke);
        uint256 refund = balance.sub(unreleased);
        require(refund > 0, "Vesting: no refunds");

        revoked[_revoke] = true;

        token.safeTransfer(owner(), refund);

        emit VestingRevoked(_revoke);
    }
// Solidity 0.8.7
/**
 @notice Returns whether the operator is an OpenSea proxy for the owner, thus
 allowing it to list without the token owner paying gas.
 @dev ERC{721,1155}.isApprovedForAll should be overriden to also check if
 this function returns true.
 */
function isApprovedForAll(address owner, address operator)
        internal
        view
        returns (bool)
    {
        ProxyRegistry registry;
        assembly {
            switch chainid()
            case 1 {
                // mainnet
                registry := 0xa5409ec958c83c3f309868babaca7c86dcb077c1
            }
            case 4 {
                // rinkeby
                registry := 0xf57b2c51ded3a29e6891aba85459d600256cf317
            }
        }

        return
            address(registry) != address(0) &&
            address(registry.proxies(owner)) == operator;
    }
// Solidity 0.6.6
/**
 * Generative minting
 */
function mintTrunk(uint256 randomSeed) external payable returns (uint256 tokenId) {
    // Enforce tiered fees.
    require(msg.value >= getBaseFeeTier());
    require(msg.value >= getFeeTier());

    // Pausing mints.
    require(!_paused);

    // Update minted count.
    mintedCount[msg.sender] = (mintedCount[msg.sender] + 1);

    // Limit supply.
    require(generativeMinted.current() < generativeSupply);
    generativeMinted.increment();

    // Get current token.
    uint256 _tokenId = generativeMinted.current();

    // Mint token itself.
    _safeMint(msg.sender, _tokenId);

    // Generate art on remote URL.
    bytes32 requestId = remoteMint(randomSeed, _tokenId);

    // Store token to mapping for when request completes.
    users[requestId] = User(_tokenId, msg.sender);

    // Returned so web3 can filter on it.
    return _tokenId;
  }
// Solidity 0.6.6
// https://ethereum.stackexchange.com/a/58341/68257
function toString(bytes memory data) private pure returns (string memory) {
    bytes memory alphabet = "0123456789abcdef";
    bytes memory str = new bytes(2 + data.length * 2);
    str[0] = "0";
    str[1] = "x";
    for (uint i = 0; i < data.length; i++) {
        str[2+i*2] = alphabet[uint(uint8(data[i] >> 4))];
        str[3+i*2] = alphabet[uint(uint8(data[i] & 0x0f))];
    }
    return string(str);
  }
// Solidity 0.8.9
/**
 * @inheritdoc IERC2981
 */
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view override returns (address, uint256) {
        RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];

        if (royalty.receiver == address(0)) {
            royalty = _defaultRoyaltyInfo;
        }

        uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();

        return (royalty.receiver, royaltyAmount);
    }
// Solidity 0.8.9
/**
 * @dev Sets the royalty information for a specific token id, overriding the global default.
 *
 * Requirements:
 *
 * - `tokenId` must be already minted.
 * - `receiver` cannot be the zero address.
 * - `feeNumerator` cannot be greater than the fee denominator.
 */
function _setTokenRoyalty(
        uint256 tokenId,
        address receiver,
        uint96 feeNumerator
    ) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: Invalid parameters");

        _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
    }
// Solidity 0.7.6
/**
 This methods performs the following actions:
 1. pull token for user
 2. joinswap into balancer pool, recieving lp
 3. stake lp tokens into Wrapping Contrat which mints SOV to User
 */
function deposit(
        address tokenIn,
        uint256 tokenAmountIn,
        uint256 minPoolAmountOut,
        uint256 liquidationFee
    ) public {
        // pull underlying token here
        IERC20(tokenIn).transferFrom(msg.sender, address(this), tokenAmountIn);

        //take fee before swap
        uint256 amountMinusFee = tokenAmountIn.mul(protocolFee).div(
            PROTOCOL_FEE_DECIMALS
        );

        uint256 poolAmountMinusFee = minPoolAmountOut.mul(protocolFee).div(
            PROTOCOL_FEE_DECIMALS
        );

        IERC20(tokenIn).approve(address(smartPool), amountMinusFee);

        // swap underlying token for LP
        smartPool.joinswapExternAmountIn(
            tokenIn,
            amountMinusFee,
            poolAmountMinusFee
        );

        // deposit LP for sender
        uint256 balance = smartPool.balanceOf(address(this));
        smartPool.approve(address(wrappingContract), balance);
        wrappingContract.deposit(msg.sender, balance, liquidationFee);

        // mint SOV
        sovToken.mint(msg.sender, balance);
    }
// Solidity 0.4.24
/**
 * @notice Execute '`@radspec(_target, _data)`' on `_target``_ethValue == 0 ? '' : ' (Sending' + @tokenAmount(0x0000000000000000000000000000000000000000, _ethValue) + ')'`
 * @param _target Address where the action is being executed
 * @param _ethValue Amount of ETH from the contract that is sent with the action
 * @param _data Calldata for the action
 * @return Exits call frame forwarding the return data of the executed call (either error or success data)
 */
function execute(address _target, uint256 _ethValue, bytes _data)
        external // This function MUST always be external as the function performs a low level return, exiting the Agent app execution context
        authP(EXECUTE_ROLE, arr(_target, _ethValue, uint256(_getSig(_data)))) // bytes4 casted as uint256 sets the bytes as the LSBs
    {
        bool result = _target.call.value(_ethValue)(_data);

        if (result) {
            emit Execute(msg.sender, _target, _ethValue, _data);
        }

        assembly {
            let ptr := mload(0x40)
            returndatacopy(ptr, 0, returndatasize)

            // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
            // if the call returned error data, forward it
            switch result case 0 { revert(ptr, returndatasize) }
            default { return(ptr, returndatasize) }
        }
    }
// Solidity 0.7.6
/**
 This methods performs the following actions:
 1. burn SOV from user and unstake lp
 2. exitswap lp into one of the underlyings
 3. send the underlying to the User
 */
function withdraw(
        address tokenOut,
        uint256 poolAmountIn,
        uint256 minAmountOut
    ) public {
        require(
            sovToken.balanceOf(msg.sender) >= poolAmountIn,
            "Not enought SOV tokens"
        );
        // burns SOV from sender
        sovToken.burn(msg.sender, poolAmountIn);

        //recieve LP from sender to here
        wrappingContract.withdraw(msg.sender, poolAmountIn);

        //get balance before exitswap
        uint256 balanceBefore = IERC20(tokenOut).balanceOf(address(this));

        //swaps LP for underlying
        smartPool.exitswapPoolAmountIn(tokenOut, poolAmountIn, minAmountOut);

        //get balance after exitswap
        uint256 balanceAfter = IERC20(tokenOut).balanceOf(address(this));

        //take fee before transfer out
        uint256 amountMinusFee = (balanceAfter.sub(balanceBefore))
            .mul(protocolFee)
            .div(PROTOCOL_FEE_DECIMALS);

        IERC20(tokenOut).transfer(msg.sender, amountMinusFee);
    }
// Solidity 0.4.24
/**
 * @notice Set `_designatedSigner` as the designated signer of the app, which will be able to sign messages on behalf of the app
 * @param _designatedSigner Address that will be able to sign messages on behalf of the app
 */
function setDesignatedSigner(address _designatedSigner)
        external
        authP(DESIGNATE_SIGNER_ROLE, arr(_designatedSigner))
    {
        // Prevent an infinite loop by setting the app itself as its designated signer.
        // An undetectable loop can be created by setting a different contract as the
        // designated signer which calls back into `isValidSignature`.
        // Given that `isValidSignature` is always called with just 50k gas, the max
        // damage of the loop is wasting 50k gas.
        require(_designatedSigner != address(this), ERROR_DESIGNATED_TO_SELF);

        address oldDesignatedSigner = designatedSigner;
        designatedSigner = _designatedSigner;

        emit SetDesignatedSigner(msg.sender, oldDesignatedSigner, _designatedSigner);
    }
// Solidity 0.4.24
/**
 * @notice Execute the script as the Agent app
 * @dev IForwarder interface conformance. Forwards any token holder action.
 * @param _evmScript Script being executed
 */
function forward(bytes _evmScript) public {
        require(canForward(msg.sender, _evmScript), ERROR_CAN_NOT_FORWARD);

        bytes memory input = ""; // no input
        address[] memory blacklist = new address[](0); // no addr blacklist, can interact with anything
        runScript(_evmScript, input, blacklist);
        // We don't need to emit an event here as EVMScriptRunner will emit ScriptResult if successful
    }
// Solidity 0.7.6
// gets all tokens currently in the pool
function getTokenWeights() public view returns (uint256[] memory) {
        address[] memory tokens = getPoolTokens();
        uint256[] memory weights = new uint256[](tokens.length);

        for (uint256 i = 0; i < tokens.length; i++) {
            weights[i] = smartPool.getDenormalizedWeight(tokens[i]);
        }
        return weights;
    }
// Solidity 0.7.6
// gets current LP exchange rate for single Asset
function getSovAmountOutSingle(
        address tokenIn,
        uint256 tokenAmountIn,
        uint256 minPoolAmountOut
    ) public view returns (uint256 poolAmountOut) {
        BPool bPool = smartPool.bPool();
        require(bPool.isBound(tokenIn), "ERR_NOT_BOUND");

        //apply protocol fee
        uint256 tokenAmountInAdj = tokenAmountIn.mul(protocolFee).div(
            PROTOCOL_FEE_DECIMALS
        );

        poolAmountOut = bPool.calcPoolOutGivenSingleIn(
            bPool.getBalance(tokenIn),
            bPool.getDenormalizedWeight(tokenIn),
            smartPool.totalSupply(),
            bPool.getTotalDenormalizedWeight(),
            tokenAmountInAdj,
            bPool.getSwapFee()
        );
        require(poolAmountOut >= minPoolAmountOut, "ERR_LIMIT_IN");
    }
// Solidity 0.7.6
// gets current LP exchange rate for single token
function getSovAmountInSingle(
        address tokenOut,
        uint256 tokenAmountOut,
        uint256 maxPoolAmountIn
    ) public view returns (uint256 poolAmountIn) {
        BPool bPool = smartPool.bPool();
        require(bPool.isBound(tokenOut), "ERR_NOT_BOUND");

        //apply protocol fee
        uint256 tokenAmountOutAdj = tokenAmountOut.mul(protocolFee).div(
            PROTOCOL_FEE_DECIMALS
        );

        require(
            tokenAmountOutAdj <=
                SafeMath.mul(bPool.getBalance(tokenOut), MAX_OUT_RATIO),
            "ERR_MAX_OUT_RATIO"
        );
        poolAmountIn = bPool.calcPoolInGivenSingleOut(
            bPool.getBalance(tokenOut),
            bPool.getDenormalizedWeight(tokenOut),
            smartPool.totalSupply(),
            bPool.getTotalDenormalizedWeight(),
            tokenAmountOutAdj,
            bPool.getSwapFee()
        );

        require(poolAmountIn != 0, "ERR_MATH_APPROX");
        require(poolAmountIn <= maxPoolAmountIn, "ERR_LIMIT_IN");
    }
// Solidity 0.5.11
/// @dev Override unpause so it requires all external contract addresses
///  to be set before contract can be unpaused. Also, we can't have
///  newContractAddress set either, because then the contract was upgraded.
/// @notice This is public rather than external so we can call super.unpause
///  without using an expensive CALL.
function unpause() public onlyCEO whenPaused {
        require(newContractAddress == address(0), "set newContractAddress first");
        require(authorAddress != address(0), "set authorAddress first");
        require(foundationAddress != address(0), "set foundationAddress first");

        // Actually unpause the contract.
        super.unpause();
    }
// Solidity 0.7.6
// gets current LP exchange rate for all
function getTokensAmountOut(
        uint256 poolAmountIn,
        uint256[] calldata minAmountsOut
    ) public view returns (uint256[] memory actualAmountsOut) {
        BPool bPool = smartPool.bPool();
        address[] memory tokens = bPool.getCurrentTokens();

        require(minAmountsOut.length == tokens.length, "ERR_AMOUNTS_MISMATCH");

        uint256 poolTotal = smartPool.totalSupply();

        uint256 ratio = SafeMath.div(
            poolAmountIn.mul(10**18),
            SafeMath.add(poolTotal, 1)
        );

        require(ratio != 0, "ERR_MATH_APPROX");

        actualAmountsOut = new uint256[](tokens.length);

        // This loop contains external calls
        // External calls are to math libraries or the underlying pool, so low risk
        for (uint256 i = 0; i < tokens.length; i++) {
            address t = tokens[i];
            uint256 bal = bPool.getBalance(t);
            // Subtract 1 to ensure any rounding errors favor the pool
            uint256 tokenAmountOut = SafeMath
                .mul(ratio, SafeMath.sub(bal, 1))
                .div(10**18);

            //apply protocol fee
            tokenAmountOut = tokenAmountOut.mul(protocolFee).div(
                PROTOCOL_FEE_DECIMALS
            );

            require(tokenAmountOut != 0, "ERR_MATH_APPROX");
            require(tokenAmountOut >= minAmountsOut[i], "ERR_LIMIT_OUT");

            actualAmountsOut[i] = tokenAmountOut;
        }
    }
// Solidity 0.6.11
/// @notice Confirm the next unresolved node
function confirmNextNode(
        bytes32 beforeSendAcc,
        bytes calldata sendsData,
        uint256[] calldata sendLengths,
        uint256 afterSendCount,
        bytes32 afterLogAcc,
        uint256 afterLogCount,
        IOutbox outbox,
        RollupEventBridge rollupEventBridge
    ) internal {
        confirmNode(
            _firstUnresolvedNode,
            beforeSendAcc,
            sendsData,
            sendLengths,
            afterSendCount,
            afterLogAcc,
            afterLogCount,
            outbox,
            rollupEventBridge
        );
    }
// Solidity 0.8.9
/**
 * @dev Added nonce and contract address in sig to guard against replay attacks
 */
function checkSig(
        uint256 mintList,
        uint256 numTokens,
        uint256 nonceSeq,
        address user,
        uint256 price,
        bytes memory sig
    ) internal view returns (bool) {
        bytes32 hash = keccak256(
            abi.encodePacked(
                "\x19Ethereum Signed Message:\n32",
                keccak256(abi.encode(mintList, numTokens, nonceSeq, address(this), user, price))
            )
        );
        return _signerAddress == hash.recover(sig);
    }
// Solidity 0.5.10
/**
 * @notice Register an identity contract corresponding to a user address.
 * Requires that the user doesn't have an identity contract already registered.
 * Only agent can call.
 *
 * @param _user The address of the user
 * @param _identity The address of the user's identity contract
 * @param _country The country of the investor
 */
function registerIdentity(address _user, Identity _identity, uint16 _country) public onlyAgent {
        require(address(_identity) != address(0), "contract address can't be a zero address");
        require(address(identity[_user]) == address(0), "identity contract already exists, please use update");
        identity[_user] = _identity;
        investorCountry[_user] = _country;

        emit IdentityRegistered(_user, _identity);
    }
// Solidity 0.5.10
/**
 * @notice This functions checks whether an identity contract
 * corresponding to the provided user address has the required claims or not based
 * on the security token.
 *
 * @param _userAddress The address of the user to be verified.
 *
 * @return 'True' if the address is verified, 'false' if not.
 */
function isVerified(address _userAddress) public view returns (bool) {
        if (address(identity[_userAddress]) == address(0)){
            return false;
        }

        uint256[] memory claimTopics = topicsRegistry.getClaimTopics();
        uint length = claimTopics.length;
        if (length == 0) {
            return true;
        }

        uint256 foundClaimTopic;
        uint256 scheme;
        address issuer;
        bytes memory sig;
        bytes memory data;
        uint256 claimTopic;
        for (claimTopic = 0; claimTopic < length; claimTopic++) {
            bytes32[] memory claimIds = identity[_userAddress].getClaimIdsByTopic(claimTopics[claimTopic]);
            if (claimIds.length == 0) {
                return false;
            }
            for (uint j = 0; j < claimIds.length; j++) {
                // Fetch claim from user
                ( foundClaimTopic, scheme, issuer, sig, data, ) = identity[_userAddress].getClaim(claimIds[j]);
                if (!issuersRegistry.isTrustedIssuer(issuer)) {
                    return false;
                }
                if (!issuersRegistry.hasClaimTopic(issuer, claimTopics[claimTopic])) {
                    return false;
                }
                if (!ClaimIssuer(issuer).isClaimValid(identity[_userAddress], claimIds[j], claimTopics[claimTopic], sig, data)) {
                    return false;
                }
            }
        }
    
        return true;
    }
// Solidity 0.5.17
/// @notice Calculate expected returning amount of `destToken`
/// @param fromToken (IERC20) Address of token or `address(0)` for Ether
/// @param destToken (IERC20) Address of token or `address(0)` for Ether
/// @param amount (uint256) Amount for `fromToken`
/// @param parts (uint256) Number of pieces source volume could be splitted,
/// works like granularity, higly affects gas usage. Should be called offchain,
/// but could be called onchain if user swaps not his own funds, but this is still considered as not safe.
/// @param flags (uint256) Flags for enabling and disabling some features, default 0
function getExpectedReturn(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 parts,
        uint256 flags // See contants in IOneSplit.sol
    )
        public
        view
        returns(
            uint256 returnAmount,
            uint256[] memory distribution
        )
    {
        (returnAmount, , distribution) = getExpectedReturnWithGas(
            fromToken,
            destToken,
            amount,
            parts,
            flags,
            0
        );
    }
// Solidity 0.5.17
/// @notice Swap `amount` of `fromToken` to `destToken`
/// @param fromToken (IERC20) Address of token or `address(0)` for Ether
/// @param destToken (IERC20) Address of token or `address(0)` for Ether
/// @param amount (uint256) Amount for `fromToken`
/// @param minReturn (uint256) Minimum expected return, else revert
/// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn`
/// @param flags (uint256) Flags for enabling and disabling some features, default 0
function swap(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 minReturn,
        uint256[] memory distribution,
        uint256 flags // See contants in IOneSplit.sol
    ) public payable returns(uint256 returnAmount) {
        return swapWithReferral(
            fromToken,
            destToken,
            amount,
            minReturn,
            distribution,
            flags,
            address(0),
            0
        );
    }
// Solidity 0.5.16
/*
 * @dev: Deploys a new BridgeToken contract
 *
 * @param _symbol: The BridgeToken's symbol
 */
function deployNewBridgeToken(string memory _symbol)
        internal
        returns (address)
    {
        bridgeTokenCount = bridgeTokenCount.add(1);

        // Deploy new bridge token contract
        BridgeToken newBridgeToken = (new BridgeToken)(_symbol);

        // Set address in tokens mapping
        address newBridgeTokenAddress = address(newBridgeToken);
        controlledBridgeTokens[_symbol] = newBridgeTokenAddress;
        lowerToUpperTokens[toLower(_symbol)] = _symbol;

        emit LogNewBridgeToken(newBridgeTokenAddress, _symbol);
        return newBridgeTokenAddress;
    }
// Solidity 0.5.16
/*
 * @dev: Deploys a new BridgeToken contract
 *
 * @param _symbol: The BridgeToken's symbol
 *
 * @note the Rowan token symbol needs to be "Rowan" so that it integrates correctly with the cosmos bridge
 */
function useExistingBridgeToken(address _contractAddress)
        internal
        returns (address)
    {
        bridgeTokenCount = bridgeTokenCount.add(1);

        string memory _symbol = BridgeToken(_contractAddress).symbol();
        // Set address in tokens mapping
        address newBridgeTokenAddress = _contractAddress;
        controlledBridgeTokens[_symbol] = newBridgeTokenAddress;
        lowerToUpperTokens[toLower(_symbol)] = _symbol;

        emit LogNewBridgeToken(newBridgeTokenAddress, _symbol);
        return newBridgeTokenAddress;
    }