lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.10
/**
 * @notice Change acceptAny parameter for arbitrator
 * @param _acceptAny indicates does arbitrator allow to accept any seller/choose sellers
 */
function changeAcceptAny(bool _acceptAny) public {
        require(isLicenseOwner(msg.sender), "Message sender should have a valid arbitrator license");
        require(arbitratorlicenseDetails[msg.sender].acceptAny != _acceptAny,
                "Message sender should pass parameter different from the current one");

        arbitratorlicenseDetails[msg.sender].acceptAny = _acceptAny;
    }
// Solidity 0.5.10
/**
 * @notice Allows arbitrator to accept a seller
 * @param _arbitrator address of a licensed arbitrator
 */
function requestArbitrator(address _arbitrator) public {
       require(isLicenseOwner(_arbitrator), "Arbitrator should have a valid license");
       require(!arbitratorlicenseDetails[_arbitrator].acceptAny, "Arbitrator already accepts all cases");

       bytes32 _id = keccak256(abi.encodePacked(_arbitrator, msg.sender));
       RequestStatus _status = requests[_id].status;
       require(_status != RequestStatus.AWAIT && _status != RequestStatus.ACCEPTED, "Invalid request status");

       if(_status == RequestStatus.REJECTED || _status == RequestStatus.CLOSED){
           require(requests[_id].date + 3 days < block.timestamp,
            "Must wait 3 days before requesting the arbitrator again");
       }

       requests[_id] = Request({
            seller: msg.sender,
            arbitrator: _arbitrator,
            status: RequestStatus.AWAIT,
            date: block.timestamp
       });

       emit ArbitratorRequested(_id, msg.sender, _arbitrator);
    }
// Solidity 0.5.10
/**
 * @notice Allows arbitrator to accept a seller's request
 * @param _id request id
 */
function acceptRequest(bytes32 _id) public {
        require(isLicenseOwner(msg.sender), "Arbitrator should have a valid license");
        require(requests[_id].status == RequestStatus.AWAIT, "This request is not pending");
        require(!arbitratorlicenseDetails[msg.sender].acceptAny, "Arbitrator already accepts all cases");
        require(requests[_id].arbitrator == msg.sender, "Invalid arbitrator");

        requests[_id].status = RequestStatus.ACCEPTED;

        address _seller = requests[_id].seller;
        permissions[msg.sender][_seller] = true;

        emit RequestAccepted(_id, msg.sender, requests[_id].seller);
    }
// Solidity 0.5.10
/**
 * @notice Allows arbitrator to reject a request
 * @param _id request id
 */
function rejectRequest(bytes32 _id) public {
        require(isLicenseOwner(msg.sender), "Arbitrator should have a valid license");
        require(requests[_id].status == RequestStatus.AWAIT || requests[_id].status == RequestStatus.ACCEPTED,
            "Invalid request status");
        require(!arbitratorlicenseDetails[msg.sender].acceptAny, "Arbitrator accepts all cases");
        require(requests[_id].arbitrator == msg.sender, "Invalid arbitrator");

        requests[_id].status = RequestStatus.REJECTED;
        requests[_id].date = block.timestamp;

        address _seller = requests[_id].seller;
        permissions[msg.sender][_seller] = false;

        emit RequestRejected(_id, msg.sender, requests[_id].seller);
    }
// Solidity 0.5.10
/**
 * @notice Allows seller to cancel a request
 * @param _id request id
 */
function cancelRequest(bytes32 _id) public {
        require(requests[_id].seller == msg.sender,  "This request id does not belong to the message sender");
        require(requests[_id].status == RequestStatus.AWAIT || requests[_id].status == RequestStatus.ACCEPTED, "Invalid request status");

        address arbitrator = requests[_id].arbitrator;

        requests[_id].status = RequestStatus.CLOSED;
        requests[_id].date = block.timestamp;

        address _arbitrator = requests[_id].arbitrator;
        permissions[_arbitrator][msg.sender] = false;

        emit RequestCanceled(_id, arbitrator, requests[_id].seller);
    }
// Solidity 0.5.10
/**
 * @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`
 * @param _signature Signature string
 */
function signatureSplit(bytes memory _signature)
        internal
        pure
        returns (uint8 v, bytes32 r, bytes32 s)
    {
        require(_signature.length == 65, "Bad signature length");
        // The signature format is a compact form of:
        //   {bytes32 r}{bytes32 s}{uint8 v}
        // Compact means, uint8 is not padded to 32 bytes.
        assembly {
            r := mload(add(_signature, 32))
            s := mload(add(_signature, 64))
            // Here we are loading the last 32 bytes, including 31 bytes
            // of 's'. There is no 'mload8' to do this.
            //
            // 'byte' is not working due to the Solidity parser, so lets
            // use the second best option, 'and'
            v := and(mload(add(_signature, 65)), 0xff)
        }
        if (v < 27) {
            v += 27;
        }
        require(v == 27 || v == 28, "Bad signature version");
    }
// Solidity 0.5.10
/**
 * @dev Adds or updates user information
 * @param _user User address to update
 * @param _contactData Contact Data   ContactType:UserId
 * @param _location New location
 * @param _username New status username
 */
function _addOrUpdateUser(
        address _user,
        string memory _contactData,
        string memory _location,
        string memory _username
    ) internal {
        User storage u = users[_user];
        u.contactData = _contactData;
        u.location = _location;
        u.username = _username;
    }
// Solidity 0.5.10
/**
 * @notice Adds or updates user information via signature
 * @param _signature Signature
 * @param _contactData Contact Data   ContactType:UserId
 * @param _location New location
 * @param _username New status username
 * @return Signing user address
 */
function addOrUpdateUser(
        bytes calldata _signature,
        string calldata _contactData,
        string calldata _location,
        string calldata _username,
        uint _nonce
    ) external returns(address payable _user) {
        _user = address(uint160(_getSigner(_username, _contactData, _nonce, _signature)));

        require(_nonce == user_nonce[_user], "Invalid nonce");

        user_nonce[_user]++;
        _addOrUpdateUser(_user, _contactData, _location, _username);

        return _user;
    }
// Solidity 0.5.10
/**
 * @dev Add a new offer with a new user if needed to the list
 * @param _asset The address of the erc20 to exchange, pass 0x0 for Eth
 * @param _contactData Contact Data   ContactType:UserId
 * @param _location The location on earth
 * @param _currency The currency the user want to receive (USD, EUR...)
 * @param _username The username of the user
 * @param _paymentMethods The list of the payment methods the user accept
 * @param _limitL Lower limit accepted
 * @param _limitU Upper limit accepted
 * @param _margin The margin for the user
 * @param _arbitrator The arbitrator used by the offer
 */
function addOffer(
        address _asset,
        string memory _contactData,
        string memory _location,
        string memory _currency,
        string memory _username,
        uint[] memory _paymentMethods,
        uint _limitL,
        uint _limitU,
        int16 _margin,
        address payable _arbitrator
    ) public payable {
        //require(sellingLicenses.isLicenseOwner(msg.sender), "Not a license owner");
        // @TODO: limit number of offers if the sender is unlicensed?

        require(arbitrationLicenses.isAllowed(msg.sender, _arbitrator), "Arbitrator does not allow this transaction");

        require(_limitL <= _limitU, "Invalid limits");
        require(msg.sender != _arbitrator, "Cannot arbitrate own offers");

        _addOrUpdateUser(
            msg.sender,
            _contactData,
            _location,
            _username
        );

        Offer memory newOffer = Offer(
            _margin,
            _paymentMethods,
            _limitL,
            _limitU,
            _asset,
            _currency,
            msg.sender,
            _arbitrator,
            false
        );

        uint256 offerId = offers.push(newOffer) - 1;
        offerWhitelist[msg.sender][offerId] = true;
        addressToOffers[msg.sender].push(offerId);

        emit OfferAdded(
            msg.sender,
            offerId,
            _asset,
            _location,
            _currency,
            _username,
            _paymentMethods,
            _limitL,
            _limitU,
            _margin);

        _stake(offerId, msg.sender, _asset);
    }
// Solidity 0.5.10
/**
 * @notice Get the offer by Id
 * @dev normally we'd access the offers array, but it would not return the payment methods
 * @param _id Offer id
 * @return Offer data (see Offer struct)
 */
function offer(uint256 _id) external view returns (
        address asset,
        string memory currency,
        int16 margin,
        uint[] memory paymentMethods,
        uint limitL,
        uint limitH,
        address payable owner,
        address payable arbitrator,
        bool deleted
    ) {
        Offer memory theOffer = offers[_id];

        // In case arbitrator rejects the seller
        address payable offerArbitrator = theOffer.arbitrator;
        if(!arbitrationLicenses.isAllowed(theOffer.owner, offerArbitrator)){
            offerArbitrator = address(0);
        }

        return (
            theOffer.asset,
            theOffer.currency,
            theOffer.margin,
            theOffer.paymentMethods,
            theOffer.limitL,
            theOffer.limitU,
            theOffer.owner,
            offerArbitrator,
            theOffer.deleted
        );
    }
// Solidity 0.4.23
//-------------------------------------------------------------------------------------
//from StandardToken
function super_transfer(address _to, uint _value) /*public*/ internal returns (bool success) {

        require(!isSendingLocked[msg.sender]);
        require(_value <= oneTransferLimit);
        require(balances[msg.sender] >= _value);

        if(msg.sender == contrInitiator) {
            //no restricton
        } else {
            require(!isAllTransfersLocked);  
            require(safeAdd(getLast24hSendingValue(msg.sender), _value) <= oneDayTransferLimit);
        }


        balances[msg.sender] = safeSub(balances[msg.sender], _value);
        balances[_to] = safeAdd(balances[_to], _value);
    
        uint tc=transferInfo[msg.sender].tc;
        transferInfo[msg.sender].ti[tc].value = _value;
        transferInfo[msg.sender].ti[tc].time = now;
        transferInfo[msg.sender].tc = safeAdd(transferInfo[msg.sender].tc, 1);

        emit Transfer(msg.sender, _to, _value);
        return true;
    }
// Solidity 0.4.23
/*
 function getTransferInfoValue(address _from, uint index) public view returns (uint value) {
 return transferInfo[_from].ti[index].value;
 }
 */
function getLast24hSendingValue(address _from) public view returns (uint totVal) {
      
        totVal = 0;  //declared above;
        uint tc = transferInfo[_from].tc;
      
        if(tc > 0) {
            for(uint i = tc-1 ; i >= 0 ; i--) {
//              if(now - transferInfo[_from].ti[i].time < 10 minutes) {
//              if(now - transferInfo[_from].ti[i].time < 1 hours) {
                if(now - transferInfo[_from].ti[i].time < 1 days) {
                    totVal = safeAdd(totVal, transferInfo[_from].ti[i].value );
                } else {
                    break;
                }
            }
        }
    }
// Solidity 0.8.7
// Issue a new amount of tokens
// these tokens are deposited into the owner address
//
// @param _amount Number of tokens to be issued
function mint(address _to, uint256 amount) public {

        if (msg.sender != owner()) {
          require(AssociatedContracts[msg.sender] == true, "Function is just for contract owner...");
        }

        require(canMint == true, "Mint Function is Disabled!");
        require(totalSupply() + amount > totalSupply());
        require(totalSupply() + amount < (MaxSupply * (10 ** _decimals)));
        require(balanceOf(msg.sender)  + amount > balanceOf(msg.sender));
        

        _mint(_to, amount);
        emit Minted(_to, amount);
    }
// Solidity 0.8.7
// Redeem tokens.
// These tokens are withdrawn from the owner address
// if the balance must be enough to cover the redeem
// or the call will fail.
// @param _amount Number of tokens to be issued
function redeem(uint amount) public {

      if (msg.sender != owner()) {
          require(AssociatedContracts[msg.sender] == true, "Function is just for contract owner...");
        }
        require(totalSupply() >= amount);
        require(balanceOf(msg.sender) >= amount);

        _burn(msg.sender, amount);
        emit Redeem(amount);
    }
// Solidity 0.6.7
/*
 * @notice Get the SF reward that can be sent to a function caller right now
 */
function getCallerReward(uint256 timeOfLastUpdate, uint256 defaultDelayBetweenCalls) public view returns (uint256) {
        bool nullRewards = (baseUpdateCallerReward == 0 && maxUpdateCallerReward == 0);
        if (either(timeOfLastUpdate >= now, nullRewards)) return 0;
        uint256 timeElapsed = (timeOfLastUpdate == 0) ? defaultDelayBetweenCalls : subtract(now, timeOfLastUpdate);
        if (either(timeElapsed < defaultDelayBetweenCalls, baseUpdateCallerReward == 0)) {
            return 0;
        }
        uint256 adjustedTime      = subtract(timeElapsed, defaultDelayBetweenCalls);
        uint256 maxPossibleReward = minimum(maxUpdateCallerReward, treasuryAllowance() / RAY);
        if (adjustedTime > maxRewardIncreaseDelay) {
            return maxPossibleReward;
        }
        uint256 calculatedReward = baseUpdateCallerReward;
        if (adjustedTime > 0) {
            calculatedReward = rmultiply(rpower(perSecondCallerRewardIncrease, adjustedTime, RAY), calculatedReward);
        }
        if (calculatedReward > maxPossibleReward) {
            calculatedReward = maxPossibleReward;
        }
        return calculatedReward;
    }
// Solidity 0.6.7
/**
 * @notice Send a stability fee reward to an address
 * @param proposedFeeReceiver The SF receiver
 * @param reward The system coin amount to send
 **/
function rewardCaller(address proposedFeeReceiver, uint256 reward) internal {
        if (address(treasury) == proposedFeeReceiver) return;
        if (either(address(treasury) == address(0), reward == 0)) return;
        address finalFeeReceiver = (proposedFeeReceiver == address(0)) ? msg.sender : proposedFeeReceiver;
        try treasury.pullFunds(finalFeeReceiver, treasury.systemCoin(), reward) {}
        catch(bytes memory revertReason) {
            emit FailRewardCaller(revertReason, finalFeeReceiver, reward);
        }
    }
// Solidity 0.6.7
// --- Management ---
function modifyParameters(bytes32 parameter, address addr) external isAuthorized {
        require(contractEnabled == 1, "RateSetter/contract-not-enabled");
        if (parameter == "orcl") orcl = OracleLike(addr);
        else if (parameter == "oracleRelayer") oracleRelayer = OracleRelayerLike(addr);
        else if (parameter == "treasury") {
          require(StabilityFeeTreasuryLike(addr).systemCoin() != address(0), "RateSetter/treasury-coin-not-set");
          treasury = StabilityFeeTreasuryLike(addr);
        }
        else if (parameter == "pidCalculator") {
          pidCalculator = PIDCalculator(addr);
        }
        else revert("RateSetter/modify-unrecognized-param");
        emit ModifyParameters(
          parameter,
          addr
        );
    }
// Solidity 0.8.4
/**
 * @dev See {IERC165-supportsInterface}.
 */
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(ICreatorCore).interfaceId || super.supportsInterface(interfaceId)
            || interfaceId == _INTERFACE_ID_ROYALTIES_CREATORCORE || interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981 
            || interfaceId == _INTERFACE_ID_ROYALTIES_FOUNDATION || interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981;
    }
// Solidity 0.8.4
/**
 * @dev Retrieve a token's URI
 */
function _tokenURI(uint256 tokenId) internal view returns (string memory) {
        if (bytes(_tokenURIs[tokenId]).length != 0) {
            return _tokenURIs[tokenId];
        }

        uint256 creatorId;
        if(tokenId > MAX_TOKEN_ID) {
            creatorId = _creatorTokens[tokenId];
        } else {
            creatorId = tokenId / CREATOR_SCALE;
        } 
        if (bytes(_creatorURIs[creatorId]).length != 0) {
            return string(abi.encodePacked(_creatorURIs[creatorId], tokenId.toString()));
        }
            
        return string(abi.encodePacked(_creatorURIs[0], tokenId.toString()));
    }
// Solidity 0.8.4
/**
 * Helper to get royalty receivers for a token
 */
function _getRoyaltyReceivers(uint256 tokenId) view internal returns (address payable[] storage) {
        uint256 creatorId;
        if(tokenId > MAX_TOKEN_ID) {
            creatorId = _creatorTokens[tokenId];
        } else {
            creatorId = tokenId / CREATOR_SCALE;
        }         

        if (_tokenRoyaltyReceivers[tokenId].length > 0) {
            return _tokenRoyaltyReceivers[tokenId];
        } else if (_creatorRoyaltyReceivers[creatorId].length > 0) {
            return _creatorRoyaltyReceivers[creatorId];
        }
        return _creatorRoyaltyReceivers[0];        
    }
// Solidity 0.8.4
/**
 * Helper to get royalty basis points for a token
 */
function _getRoyaltyBPS(uint256 tokenId) view internal returns (uint256[] storage) {
        uint256 creatorId;
        if(tokenId > MAX_TOKEN_ID) {
            creatorId = _creatorTokens[tokenId];
        } else {
            creatorId = tokenId / CREATOR_SCALE;
        }   

        if (_tokenRoyaltyBPS[tokenId].length > 0) {
            return _tokenRoyaltyBPS[tokenId];
        } else if (_creatorRoyaltyBPS[creatorId].length > 0) {
            return _creatorRoyaltyBPS[creatorId];
        }
        return _creatorRoyaltyBPS[0];        
    }
// Solidity 0.8.4
/**
 * Helper to shorten royalties arrays if it is too long
 */
function _shortenRoyalties(address payable[] storage receivers, uint256[] storage basisPoints, uint256 targetLength) internal {
        require(receivers.length == basisPoints.length, "CreatorCore: Invalid input");
        if (targetLength < receivers.length) {
            for (uint i = receivers.length; i > targetLength; i--) {
                receivers.pop();
                basisPoints.pop();
            }
        }
    }
// Solidity 0.8.4
/**
 * Helper to update royalites
 */
function _updateRoyalties(address payable[] storage receivers, uint256[] storage basisPoints, address payable[] calldata newReceivers, uint256[] calldata newBPS) internal {
        require(receivers.length == basisPoints.length, "CreatorCore: Invalid input");
        require(newReceivers.length == newBPS.length, "CreatorCore: Invalid input");
        uint256 totalRoyalties;
        for (uint i = 0; i < newReceivers.length; i++) {
            if (i < receivers.length) {
                receivers[i] = newReceivers[i];
                basisPoints[i] = newBPS[i];
            } else {
                receivers.push(newReceivers[i]);
                basisPoints.push(newBPS[i]);
            }
            totalRoyalties += newBPS[i];
        }
        require(totalRoyalties < 10000, "CreatorCore: Invalid total royalties");
    }
// Solidity 0.8.4
/**
 * Set royalties for all tokens of an extension
 */
function _setRoyaltiesCreator(uint256 creatorId, address payable[] calldata receivers, uint256[] calldata basisPoints) internal {
        require(receivers.length == basisPoints.length, "CreatorCore: Invalid input");
        _shortenRoyalties(_creatorRoyaltyReceivers[creatorId], _creatorRoyaltyBPS[creatorId], receivers.length);
        _updateRoyalties(_creatorRoyaltyReceivers[creatorId], _creatorRoyaltyBPS[creatorId], receivers, basisPoints);
        if (creatorId == 0) {
            emit DefaultRoyaltiesUpdated(receivers, basisPoints);
        } else {
            emit CreatorRoyaltiesUpdated(creatorId, receivers, basisPoints);
        }
    }
// Solidity 0.5.12
// Quick swap low gas method for pool swaps
function deposit(uint256 _amount)
      external
      nonReentrant
  {
      require(_amount > 0, "deposit must be greater than 0");
      pool = _calcPoolValueInToken();

      IERC20(token).safeTransferFrom(msg.sender, address(this), _amount);

      // Calculate pool shares
      uint256 shares = 0;
      if (pool == 0) {
        shares = _amount;
        pool = _amount;
      } else {
        shares = (_amount.mul(_totalSupply)).div(pool);
      }
      pool = _calcPoolValueInToken();
      _mint(msg.sender, shares);
  }
// Solidity 0.5.12
// 1999999614570950845
function _withdrawSomeFulcrum(uint256 _amount) internal {
    // Balance of fulcrum tokens, 1 iDAI = 1.00x DAI
    uint256 b = balanceFulcrum(); // 1970469086655766652
    // Balance of token in fulcrum
    uint256 bT = balanceFulcrumInToken(); // 2000000803224344406
    require(bT >= _amount, "insufficient funds");
    // can have unintentional rounding errors
    uint256 amount = (b.mul(_amount)).div(bT).add(1);
    _withdrawFulcrum(amount);
  }
// Solidity 0.5.12
// Internal only rebalance for better gas in redeem
function _rebalance(Lender newProvider) internal {
    if (_balance() > 0) {
      if (newProvider == Lender.DYDX) {
        supplyDydx(_balance());
      } else if (newProvider == Lender.FULCRUM) {
        supplyFulcrum(_balance());
      } else if (newProvider == Lender.COMPOUND) {
        supplyCompound(_balance());
      } else if (newProvider == Lender.AAVE) {
        supplyAave(_balance());
      }
    }
    provider = newProvider;
  }
// Solidity 0.7.0
/**
 * Set some Moai aside
 */
function reserveMoai() public onlyOwner {        
        uint supply = totalSupply();
        require(supply.add(50) <= MAX_MOAI , "would exceed max supply of Moai");
        uint i;
        for (i = 0; i < 50; i++) {
            _safeMint(msg.sender, supply + i);
        }
    }
// Solidity 0.7.0
/**
 * Mints Moai
 */
function mintMoai(uint numberOfTokens) public payable {
        require(saleIsActive, "Sale must be active to mint Moai");
        require(numberOfTokens <= maxMoaiPurchase, "Can only mint 8 tokens at a time");
        require(totalSupply().add(numberOfTokens) <= MAX_MOAI, "Purchase would exceed max supply of Moai");
        require(moaiPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
        
        for(uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply();
            if (totalSupply() < MAX_MOAI) {
                _safeMint(msg.sender, mintIndex);
            }
        }
    }
// Solidity 0.8.4
/**
 * @dev See {ICreatorCore-setTokenURI}.
 */
function setTokenURI(uint256[] memory tokenIds, string[] calldata uris) external override adminRequired {
        require(tokenIds.length == uris.length, "LGND: Invalid input");
        for (uint i = 0; i < tokenIds.length; i++) {
            _setTokenURI(tokenIds[i], uris[i]);            
        }
    }