lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.4
/**
 	 * @dev `_from` Name unposition `_value` Logos from `_to` Name
 	 *
 	 * @param _from The address of the sender
 	 * @param _to The address of the recipient
 	 * @param _value the amount to unposition
 	 * @return true on success
 	 */
function unpositionFrom(address _from, address _to, uint256 _value) public isName(_from) isName(_to) nameNotCompromised(_from) nameNotCompromised(_to) onlyAdvocate(_from) senderNameNotCompromised returns (bool) {
		require (_from != _to);	// Can't unposition Logos to itself
		require (positionOnOthers[_from][_to] >= _value);

		positionOnOthers[_from][_to] = positionOnOthers[_from][_to].sub(_value);
		totalPositionOnOthers[_from] = totalPositionOnOthers[_from].sub(_value);
		positionFromOthers[_to] = positionFromOthers[_to].sub(_value);

		emit UnpositionFrom(_from, _to, _value);
		return true;
	}
// Solidity 0.5.4
/**
 	 * @dev Add `_amount` logos earned from advocating a TAO `_taoId` to its Advocate
 	 * @param _taoId The ID of the advocated TAO
 	 * @param _amount the amount to reward
 	 * @return true on success
 	 */
function addAdvocatedTAOLogos(address _taoId, uint256 _amount) public inWhitelist isTAO(_taoId) returns (bool) {
		require (_amount > 0);
		address _nameId = _nameTAOPosition.getAdvocate(_taoId);

		advocatedTAOLogos[_nameId][_taoId] = advocatedTAOLogos[_nameId][_taoId].add(_amount);
		totalAdvocatedTAOLogos[_nameId] = totalAdvocatedTAOLogos[_nameId].add(_amount);

		emit AddAdvocatedTAOLogos(_nameId, _taoId, _amount);
		return true;
	}
// Solidity 0.5.4
/**
 	 * @dev Transfer logos earned from advocating a TAO `_taoId` from `_fromNameId` to the Advocate of `_taoId`
 	 * @param _fromNameId The ID of the Name that sends the Logos
 	 * @param _taoId The ID of the advocated TAO
 	 * @return true on success
 	 */
function transferAdvocatedTAOLogos(address _fromNameId, address _taoId) public inWhitelist isName(_fromNameId) isTAO(_taoId) returns (bool) {
		address _toNameId = _nameTAOPosition.getAdvocate(_taoId);
		require (_fromNameId != _toNameId);
		require (totalAdvocatedTAOLogos[_fromNameId] >= advocatedTAOLogos[_fromNameId][_taoId]);

		uint256 _amount = advocatedTAOLogos[_fromNameId][_taoId];
		advocatedTAOLogos[_fromNameId][_taoId] = 0;
		totalAdvocatedTAOLogos[_fromNameId] = totalAdvocatedTAOLogos[_fromNameId].sub(_amount);
		advocatedTAOLogos[_toNameId][_taoId] = advocatedTAOLogos[_toNameId][_taoId].add(_amount);
		totalAdvocatedTAOLogos[_toNameId] = totalAdvocatedTAOLogos[_toNameId].add(_amount);

		emit TransferAdvocatedTAOLogos(_fromNameId, _toNameId, _taoId, _amount);
		return true;
	}
// Solidity 0.5.4
/**
 	 * @dev Create a pool for a TAO
 	 */
function createPool(
		address _taoId,
		bool _ethosCapStatus,
		uint256 _ethosCapAmount
	) external isTAO(_taoId) onlyTAOFactory returns (bool) {
		// Make sure ethos cap amount is provided if ethos cap is enabled
		if (_ethosCapStatus) {
			require (_ethosCapAmount > 0);
		}
		// Make sure the pool is not yet created
		require (pools[_taoId].taoId == address(0));

		Pool storage _pool = pools[_taoId];
		_pool.taoId = _taoId;
		_pool.status = true;
		_pool.ethosCapStatus = _ethosCapStatus;
		if (_ethosCapStatus) {
			_pool.ethosCapAmount = _ethosCapAmount;
		}

		emit CreatePool(_pool.taoId, _pool.ethosCapStatus, _pool.ethosCapAmount, _pool.status);
		return true;
	}
// Solidity 0.5.4
/**
 	 * @dev Update Ethos cap of a Pool
 	 * @param _taoId The TAO ID of the Pool
 	 * @param _ethosCapStatus The ethos cap status to set
 	 * @param _ethosCapAmount The ethos cap amount to set
 	 */
function updatePoolEthosCap(address _taoId, bool _ethosCapStatus, uint256 _ethosCapAmount) public isTAO(_taoId) onlyAdvocate(_taoId) senderNameNotCompromised {
		require (pools[_taoId].taoId != address(0));
		// If there is an ethos cap
		if (_ethosCapStatus) {
			require (_ethosCapAmount > 0 && _ethosCapAmount > _pathos.balanceOf(_taoId));
		}

		pools[_taoId].ethosCapStatus = _ethosCapStatus;
		if (_ethosCapStatus) {
			pools[_taoId].ethosCapAmount = _ethosCapAmount;
		}

		uint256 _nonce = _taoFactory.incrementNonce(_taoId);
		require (_nonce > 0);

		emit UpdatePoolEthosCap(_taoId, _ethosCapStatus, _ethosCapAmount, _nonce);
	}
// Solidity 0.5.4
/**
 	 * @dev A Name stakes Ethos in Pool `_taoId`
 	 * @param _taoId The TAO ID of the Pool
 	 * @param _quantity The amount of Ethos to be staked
 	 */
function stakeEthos(address _taoId, uint256 _quantity) public isTAO(_taoId) senderIsName senderNameNotCompromised {
		Pool memory _pool = pools[_taoId];
		address _nameId = _nameFactory.ethAddressToNameId(msg.sender);
		require (_pool.status == true && _quantity > 0 && _ethos.balanceOf(_nameId) >= _quantity);

		// If there is an ethos cap
		if (_pool.ethosCapStatus) {
			require (_ethos.balanceOf(_taoId).add(_quantity) <= _pool.ethosCapAmount);
		}

		// Create Ethos Lot for this transaction
		contractTotalEthosLot++;
		poolTotalEthosLot[_taoId]++;

		// Generate Ethos Lot ID
		bytes32 _ethosLotId = keccak256(abi.encodePacked(this, msg.sender, contractTotalEthosLot));

		EthosLot storage _ethosLot = ethosLots[_ethosLotId];
		_ethosLot.ethosLotId = _ethosLotId;
		_ethosLot.nameId = _nameId;
		_ethosLot.lotQuantity = _quantity;
		_ethosLot.taoId = _taoId;
		_ethosLot.poolPreStakeSnapshot = _ethos.balanceOf(_taoId);
		_ethosLot.poolStakeLotSnapshot = _ethos.balanceOf(_taoId).add(_quantity);
		_ethosLot.lotValueInLogos = _quantity;
		_ethosLot.timestamp = now;

		ownerEthosLots[_nameId].push(_ethosLotId);

		// Update contract variables
		totalEthosStaked[_nameId] = totalEthosStaked[_nameId].add(_quantity);
		namePoolEthosStaked[_nameId][_taoId] = namePoolEthosStaked[_nameId][_taoId].add(_quantity);
		contractTotalEthos = contractTotalEthos.add(_quantity);

		require (_ethos.transferFrom(_nameId, _taoId, _quantity));

		emit StakeEthos(_ethosLot.taoId, _ethosLot.ethosLotId, _ethosLot.nameId, _ethosLot.lotQuantity, _ethosLot.poolPreStakeSnapshot, _ethosLot.poolStakeLotSnapshot, _ethosLot.lotValueInLogos, _ethosLot.timestamp);
	}
// Solidity 0.5.4
/**
 	 * @dev Get list of owner's Ethos Lot IDs from `_from` to `_to` index
 	 * @param _nameId The Name Id of the Ethos Lot's owner
 	 * @param _from The starting index, (i.e 0)
 	 * @param _to The ending index, (i.e total - 1)
 	 * @return list of owner's Ethos Lot IDs
 	 */
function ownerEthosLotIds(address _nameId, uint256 _from, uint256 _to) public view returns (bytes32[] memory) {
		require (_from >= 0 && _to >= _from && ownerEthosLots[_nameId].length > _to);
		bytes32[] memory _ethosLotIds = new bytes32[](_to.sub(_from).add(1));
		for (uint256 i = _from; i <= _to; i++) {
			_ethosLotIds[i.sub(_from)] = ownerEthosLots[_nameId][i];
		}
		return _ethosLotIds;
	}
// Solidity 0.5.4
/**
 	 * @dev Name that staked Ethos withdraw Logos from Ethos Lot `_ethosLotId`
 	 * @param _ethosLotId The ID of the Ethos Lot
 	 */
function withdrawLogos(bytes32 _ethosLotId) public senderIsName senderNameNotCompromised {
		EthosLot storage _ethosLot = ethosLots[_ethosLotId];
		address _nameId = _nameFactory.ethAddressToNameId(msg.sender);
		require (_ethosLot.nameId == _nameId && _ethosLot.lotValueInLogos > 0);

		uint256 logosAvailableToWithdraw = lotLogosAvailableToWithdraw(_ethosLotId);

		require (logosAvailableToWithdraw > 0 && logosAvailableToWithdraw <= _ethosLot.lotValueInLogos);

		// Update lot variables
		_ethosLot.logosWithdrawn = _ethosLot.logosWithdrawn.add(logosAvailableToWithdraw);
		_ethosLot.lotValueInLogos = _ethosLot.lotValueInLogos.sub(logosAvailableToWithdraw);

		// Update contract variables
		contractTotalLogosWithdrawn = contractTotalLogosWithdrawn.add(logosAvailableToWithdraw);
		poolTotalLogosWithdrawn[_ethosLot.taoId] = poolTotalLogosWithdrawn[_ethosLot.taoId].add(logosAvailableToWithdraw);
		totalLogosWithdrawn[_ethosLot.nameId] = totalLogosWithdrawn[_ethosLot.nameId].add(logosAvailableToWithdraw);
		namePoolLogosWithdrawn[_ethosLot.nameId][_ethosLot.taoId] = namePoolLogosWithdrawn[_ethosLot.nameId][_ethosLot.taoId].add(logosAvailableToWithdraw);

		// Mint logos to seller
		require (_logos.mint(_nameId, logosAvailableToWithdraw));

		emit WithdrawLogos(_ethosLot.nameId, _ethosLot.ethosLotId, _ethosLot.taoId, logosAvailableToWithdraw, _ethosLot.lotValueInLogos, _ethosLot.logosWithdrawn, now);
	}
// Solidity 0.5.4
/**
 	 * @dev Name gets Ethos Lot `_ethosLotId` available Logos to withdraw
 	 * @param _ethosLotId The ID of the Ethos Lot
 	 * @return The amount of Logos available to withdraw
 	 */
function lotLogosAvailableToWithdraw(bytes32 _ethosLotId) public view returns (uint256) {
		EthosLot memory _ethosLot = ethosLots[_ethosLotId];
		require (_ethosLot.nameId != address(0));

		uint256 logosAvailableToWithdraw = 0;

		if (_pathos.balanceOf(_ethosLot.taoId) > _ethosLot.poolPreStakeSnapshot && _ethosLot.lotValueInLogos > 0) {
			logosAvailableToWithdraw = (_pathos.balanceOf(_ethosLot.taoId) >= _ethosLot.poolStakeLotSnapshot) ? _ethosLot.lotQuantity : _pathos.balanceOf(_ethosLot.taoId).sub(_ethosLot.poolPreStakeSnapshot);
			if (logosAvailableToWithdraw > 0) {
				logosAvailableToWithdraw = logosAvailableToWithdraw.sub(_ethosLot.logosWithdrawn);
			}
		}
		return logosAvailableToWithdraw;
	}
// Solidity 0.4.13
/* Constructor function - initialize Kitten Coins */
function KittenCoin() {
    totalSupply = 400000000 * (10 ** uint256(decimals)); // So many kittens on earth
    balances[msg.sender] = totalSupply / 10; // To help kittens grow safely
    kittensIssued = totalSupply / 10;
    kittenTalk = "Meow";
  }
// Solidity 0.4.24
// Other functions
function PRNG() internal view returns (uint256) {
        uint256 initialize1 = block.timestamp;
        uint256 initialize2 = uint256(block.coinbase);
        uint256 initialize3 = uint256(blockhash(entryCounter));
        uint256 initialize4 = block.number;
        uint256 initialize5 = block.gaslimit;
        uint256 initialize6 = block.difficulty;

        uint256 calc1 = uint256(keccak256(abi.encodePacked((initialize1 * 5),initialize5,initialize6)));
        uint256 calc2 = 1-calc1;
        int256 ov = int8(calc2);
        uint256 calc3 = uint256(sha256(abi.encodePacked(initialize1,ov,initialize3,initialize4)));
        uint256 PRN = uint256(keccak256(abi.encodePacked(initialize1,calc1,initialize2,initialize3,calc3)))%(entryCounter);
        return PRN;
    }
// Solidity 0.4.24
// Choose a winner and pay him
function payWinner() internal returns (address) {
        uint256 balance = address(this).balance;
        uint256 number = PRNG(); // generates a pseudorandom number
        address winner = entries[number]; // choose the winner with the pseudorandom number
        winner.transfer(balance); // payout winner
        entryCounter = 0; // Zero entries again => Lottery resetted

        emit WinnerPaid(balance, winner);
        return winner;
    }
// Solidity 0.4.24
// change the Threshold
function changeThreshold(uint newThreshold) onlyOwner() public {
        // Owner is only able to change the threshold when no one bought (otherwise it would be unfair)
        require(entryCounter == 0);
        automaticThreshold = newThreshold;
    }
// Solidity 0.6.8
/**
 * Extracts the timestamp component of a Version 1 UUID. Used to make time-based assertions
 * against a wallet-privided nonce
 */
function getTimestampInMsFromUuidV1(uint128 uuid)
    internal
    pure
    returns (uint64 msSinceUnixEpoch)
  {
    // https://tools.ietf.org/html/rfc4122#section-4.1.2
    uint128 version = (uuid >> 76) & 0x0000000000000000000000000000000F;
    require(version == 1, 'Must be v1 UUID');

    // Time components are in reverse order so shift+mask each to reassemble
    uint128 timeHigh = (uuid >> 16) & 0x00000000000000000FFF000000000000;
    uint128 timeMid = (uuid >> 48) & 0x00000000000000000000FFFF00000000;
    uint128 timeLow = (uuid >> 96) & 0x000000000000000000000000FFFFFFFF;
    uint128 nsSinceGregorianEpoch = (timeHigh | timeMid | timeLow);
    // Gregorian offset given in seconds by https://www.wolframalpha.com/input/?i=convert+1582-10-15+UTC+to+unix+time
    msSinceUnixEpoch = uint64(nsSinceGregorianEpoch / 10000).sub(
      12219292800000
    );

    return msSinceUnixEpoch;
  }
// Solidity 0.8.0
// Adapted from https://github.com/albertocuestacanada/ERC20Permit/blob/master/contracts/ERC20Permit.sol
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {
        require(block.timestamp <= deadline, "expired");
        bytes32 hashStruct = keccak256(abi.encode(
                PERMIT_TYPEHASH,
                owner,
                spender,
                amount,
                nonces[owner]++,
                deadline));
        bytes32 hash = keccak256(abi.encodePacked(
                '\x19\x01',
                DOMAIN_SEPARATOR,
                hashStruct));
        address signer = ecrecover(hash, v, r, s);
        require(signer != address(0) && signer == owner, "!signer");
        _approve(owner, spender, amount);
    }
// Solidity 0.5.17
/**
 * @notice Find the number of tokens to burn from `value`. Approximated at 0.3125%.
 * @param value The value to find the burn amount from
 * @return The found burn amount
 */
function findBurnAmount(uint256 value) public view returns(uint256) {
        //Allow transfers of 0.000000000000000001
        if (value == 1) {
            return 0;
        }
        uint256 roundValue = value.ceil(basePercent);
        //Gas optimized
        uint256 burnAmount = roundValue.mul(100).div(32000);
        return burnAmount;
    }
// Solidity 0.5.17
/**
 * @notice Transfer `value` minus `findBurnAmount(value)` tokens from `msg.sender` to `to`, 
 * while subtracting `findBurnAmount(value)` tokens from `_totalSupply`. This performs a transfer with an approximated fee of 0.3125%
 * @param to The address of the destination account
 * @param value The number of tokens to transfer
 * @return Whether or not the transfer succeeded
 */
function transfer(address to, uint256 value) public returns(bool) {
        require(to != address(0));

        uint256 tokensToBurn = findBurnAmount(value);
        uint256 tokensToTransfer = value.sub(tokensToBurn);

        _balances[msg.sender] = _balances[msg.sender].sub(value);
        _balances[to] = _balances[to].add(tokensToTransfer);

        _totalSupply = _totalSupply.sub(tokensToBurn);

        emit Transfer(msg.sender, to, tokensToTransfer);
        emit Transfer(msg.sender, address(0), tokensToBurn);
        return true;
    }
// Solidity 0.8.4
// view function to calculate claimable tokens
function calculateClaimAmount(address _recipient) internal view returns (uint amount) {
        uint newClaimAmount;
        if (block.timestamp >= allocations[_recipient].endVesting) {
            newClaimAmount = allocations[_recipient].totalAllocated;
        }
        else if (block.timestamp >= allocations[_recipient].endCliff) {
                newClaimAmount += ((allocations[_recipient].totalAllocated)
                	* (block.timestamp - allocations[_recipient].endCliff))
                    / (allocations[_recipient].endVesting - allocations[_recipient].endCliff);
            }
        return newClaimAmount;
    }
// Solidity 0.8.4
/**
 * @dev Set the minters and their corresponding allocations. Each mint gets 40000 Path Tokens with a vesting schedule
 * @param _addresses The recipient of the allocation
 * @param _totalAllocated The total number of minted NFT
 */
function setAllocation(
        address[] memory _addresses,
        uint[] memory _totalAllocated,
        uint[] memory _endCliff,
        uint[] memory _endVesting) onlyOwner external {
        //make sure that the length of address and total minted is the same
        require(_addresses.length == _totalAllocated.length, "length of array should be the same");
        require(_addresses.length == _endCliff.length, "length of array should be the same");
        require(_addresses.length == _endVesting.length, "length of array should be the same");
        uint amountToTransfer;
        for (uint i = 0; i < _addresses.length; i++ ) {
            require(_endCliff[i] <= _endVesting[i], "End cliff should be earlier than end vesting");
            allocations[_addresses[i]] = Allocation(
                _endCliff[i],
                _endVesting[i],
                _totalAllocated[i],
                0);
            amountToTransfer += _totalAllocated[i];
            totalAllocated += _totalAllocated[i];
        }
        require(token.transferFrom(msg.sender, address(this), amountToTransfer), "Token transfer failed");
    }
// Solidity 0.8.4
/**
 * @dev transfers allocated tokens to recipient to their address
 * @param _recipient the addresss to withdraw tokens for
 */
function transferTokens(address _recipient) external {
        require(allocations[_recipient].amountClaimed < allocations[_recipient].totalAllocated, "Address should have some allocated tokens");
        require(startTime <= block.timestamp, "Start time of claim should be earlier than current time");
        //transfer tokens after subtracting tokens claimed
        uint newClaimAmount = calculateClaimAmount(_recipient);
        uint tokensToClaim = getClaimTotal(_recipient);
        require(tokensToClaim > 0, "Recipient should have more than 0 tokens to claim");
        allocations[_recipient].amountClaimed = newClaimAmount;
        grandTotalClaimed += tokensToClaim;
        require(token.transfer(_recipient, tokensToClaim), "Token transfer failed");
        emit claimedToken(_recipient, tokensToClaim, allocations[_recipient].amountClaimed);
    }
// Solidity 0.6.8
/**
 * @dev Combines base and quote asset symbols into the market symbol originally signed by the
 * wallet. For example if base is 'IDEX' and quote is 'ETH', the resulting market symbol is
 * 'IDEX-ETH'. This approach is used rather than passing in the market symbol and splitting it
 * since the latter incurs a higher gas cost
 */
function getMarketSymbol(string memory baseSymbol, string memory quoteSymbol)
    private
    pure
    returns (string memory)
  {
    bytes memory baseSymbolBytes = bytes(baseSymbol);
    bytes memory hyphenBytes = bytes('-');
    bytes memory quoteSymbolBytes = bytes(quoteSymbol);

    bytes memory marketSymbolBytes = bytes(
      new string(
        baseSymbolBytes.length + quoteSymbolBytes.length + hyphenBytes.length
      )
    );

    uint256 i;
    uint256 j;

    for (i = 0; i < baseSymbolBytes.length; i++) {
      marketSymbolBytes[j++] = baseSymbolBytes[i];
    }

    // Hyphen is one byte
    marketSymbolBytes[j++] = hyphenBytes[0];

    for (i = 0; i < quoteSymbolBytes.length; i++) {
      marketSymbolBytes[j++] = quoteSymbolBytes[i];
    }

    return string(marketSymbolBytes);
  }
// Solidity 0.6.8
/**
 * @dev Converts an integer pip quantity back into the fixed-precision decimal pip string
 * originally signed by the wallet. For example, 1234567890 becomes '12.34567890'
 */
function pipToDecimal(uint256 pips) private pure returns (string memory) {
    // Inspired by https://github.com/provable-things/ethereum-api/blob/831f4123816f7a3e57ebea171a3cdcf3b528e475/oraclizeAPI_0.5.sol#L1045-L1062
    uint256 copy = pips;
    uint256 length;
    while (copy != 0) {
      length++;
      copy /= 10;
    }
    if (length < 9) {
      length = 9; // a zero before the decimal point plus 8 decimals
    }
    length++; // for the decimal point

    bytes memory decimal = new bytes(length);
    for (uint256 i = length; i > 0; i--) {
      if (length - i == 8) {
        decimal[i - 1] = bytes1(uint8(46)); // period
      } else {
        decimal[i - 1] = bytes1(uint8(48 + (pips % 10)));
        pips /= 10;
      }
    }
    return string(decimal);
  }
// Solidity 0.6.8
/**
 * @dev Resolves an asset address into corresponding Asset struct
 *
 * @param assetAddress Ethereum address of asset
 */
function loadAssetByAddress(Storage storage self, address assetAddress)
    internal
    view
    returns (Structs.Asset memory)
  {
    if (assetAddress == address(0x0)) {
      return getEthAsset();
    }

    Structs.Asset memory asset = self.assetsByAddress[assetAddress];
    require(
      asset.exists && asset.isConfirmed,
      'No confirmed asset found for address'
    );

    return asset;
  }
// Solidity 0.6.8
/**
 * @dev Resolves a asset symbol into corresponding Asset struct
 *
 * @param symbol Asset symbol, e.g. 'IDEX'
 * @param timestampInMs Milliseconds since Unix epoch, usually parsed from a UUID v1 order nonce.
 * Constrains symbol resolution to the asset most recently confirmed prior to timestampInMs. Reverts
 * if no such asset exists
 */
function loadAssetBySymbol(
    Storage storage self,
    string memory symbol,
    uint64 timestampInMs
  ) internal view returns (Structs.Asset memory) {
    if (isStringEqual('ETH', symbol)) {
      return getEthAsset();
    }

    Structs.Asset memory asset;
    if (self.assetsBySymbol[symbol].length > 0) {
      for (uint8 i = 0; i < self.assetsBySymbol[symbol].length; i++) {
        if (
          self.assetsBySymbol[symbol][i].confirmedTimestampInMs <= timestampInMs
        ) {
          asset = self.assetsBySymbol[symbol][i];
        }
      }
    }
    require(
      asset.exists && asset.isConfirmed,
      'No confirmed asset found for symbol'
    );

    return asset;
  }
// Solidity 0.4.24
/**
 * @notice Used to add a delegate
 * @param _delegate Ethereum address of the delegate
 * @param _details Details about the delegate i.e `Belongs to financial firm`
 */
function addDelegate(address _delegate, bytes32 _details) external withPerm(CHANGE_PERMISSION) {
        require(_delegate != address(0), "Invalid address");
        require(_details != bytes32(0), "0 value not allowed");
        require(delegateDetails[_delegate] == bytes32(0), "Already present");
        delegateDetails[_delegate] = _details;
        allDelegates.push(_delegate);
        /*solium-disable-next-line security/no-block-members*/
        emit AddDelegate(_delegate, _details, now);
    }
// Solidity 0.4.24
/**
 * @notice Used to delete a delegate
 * @param _delegate Ethereum address of the delegate
 */
function deleteDelegate(address _delegate) external withPerm(CHANGE_PERMISSION) {
        require(delegateDetails[_delegate] != bytes32(0), "delegate does not exist");
        for (uint256 i = 0; i < allDelegates.length; i++) {
            if (allDelegates[i] == _delegate) {
                allDelegates[i] = allDelegates[allDelegates.length - 1];
                allDelegates.length = allDelegates.length - 1;
            }
        }
        delete delegateDetails[_delegate];
    }
// Solidity 0.4.24
/**
 * @notice Used to change one or more permissions for a single delegate at once
 * @param _delegate Ethereum address of the delegate
 * @param _modules Multiple module matching the multiperms, needs to be same length
 * @param _perms Multiple permission flag needs to be changed
 * @param _valids Bool array consist the flag to switch on/off the permission
 * @return nothing
 */
function changePermissionMulti(
        address _delegate,
        address[] _modules,
        bytes32[] _perms,
        bool[] _valids
    )
    external
    withPerm(CHANGE_PERMISSION)
    {
        require(_delegate != address(0), "invalid address");
        require(_modules.length > 0, "0 length is not allowed");
        require(_modules.length == _perms.length, "Array length mismatch");
        require(_valids.length == _perms.length, "Array length mismatch");
        for(uint256 i = 0; i < _perms.length; i++) {
            _changePermission(_delegate, _modules[i], _perms[i], _valids[i]);
        }
    }