lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.10
/** @notice  Confirms a pending increase in the token supply.
 *
 * @dev  When called by the custodian with a lock id associated with a
 * pending ceiling increase, the amount requested is added to the
 * current supply ceiling.
 * NOTE: this function will not execute any raise that would overflow the
 * supply ceiling, but it will not revert either.
 *
 * @param  _lockId  The identifier of a pending ceiling raise request.
 */
function confirmCeilingRaise(bytes32 _lockId) public onlyCustodian {
        PendingCeilingRaise storage pendingRaise = pendingRaiseMap[_lockId];

        // copy locals of references to struct members
        uint256 raiseBy = pendingRaise.raiseBy;
        // accounts for a gibberish _lockId
        require(raiseBy != 0);

        delete pendingRaiseMap[_lockId];

        uint256 newCeiling = totalSupplyCeiling + raiseBy;
        // overflow check
        if (newCeiling >= totalSupplyCeiling) {
            totalSupplyCeiling = newCeiling;

            emit CeilingRaiseConfirmed(_lockId, raiseBy, newCeiling);
        }
    }
// Solidity 0.4.24
// Transfer token to team 
function transferToTeam(address _team) external onlyOwner returns(bool) {
        require(_team != address(0), "Address is not valid");
        require(!teamRelease, "Team release has already done");
        if (now > contractDeployed.add(365 days) && team_1_release == false) {
            balances[_team] = balances[_team].add(_teamLockedTokens);
            
            team_1_release = true;
            teamRelease = true;
            emit TransferTokenToTeam(_team, _teamLockedTokens);
            _teamLockedTokens = 0;
            return true;
        }
    }
// Solidity 0.4.24
/**
 * @dev Function to Release Bounty and Bonus token to Bounty address after Locking period is over
 * @param _bounty The address of the Bounty
 * @return A boolean that indicates if the operation was successful.
 */
function transferToBounty(address _bounty) external onlyOwner returns(bool) {
        require(_bounty != address(0), "Address is not valid");
        require(!bountyrelase, "Bounty release already done");
        if (now > contractDeployed.add(180 days) && bounty_1_release == false) {
            balances[_bounty] = balances[_bounty].add(_bountyLockedTokens);
            bounty_1_release = true;
            bountyrelase = true;
            emit TransferTokenToBounty(_bounty, _bountyLockedTokens);
            _bountyLockedTokens = 0;
            return true;
        }
  }
// Solidity 0.6.6
/**
 * @notice Get the current price of a supported cToken underlying
 * @param cToken The address of the market (token)
 * @return USD price mantissa or failure for unsupported markets
 */
function getUnderlyingPrice(address cToken) public view returns (uint256) {
        string memory cTokenSymbol = CTokenInterface(cToken).symbol();
        if (compareStrings(cTokenSymbol, "sETH")) {
            return getETHUSDCPrice();
        } else if (compareStrings(cTokenSymbol, "sUSDC")) {
            return
                getETHUSDCPrice().mul(getUSDCETHPrice()).div(
                    10**mantissaDecimals
                );
        } else if (compareStrings(cTokenSymbol, "sSUKU")) {
            return SUKUPrice;
        } else {
            revert("This is not a supported market address.");
        }
    }
// Solidity 0.4.24
//Init Parameter.
function initialParameter(
        // address _manager,
        address _secretSigner,
        address _erc20tokenAddress ,
        address _refunder,
        
        uint _MIN_BET,
        uint _MAX_BET,
        uint _maxProfit, 
        uint _MAX_AMOUNT, 
        
        uint8 _platformFeePercentage,
        uint8 _jackpotFeePercentage,
        uint8 _ERC20rewardMultiple,
        uint8 _currencyType,
        
        address[] _signerList,
        uint32[] _withdrawalMode)public onlyOwner{
            
        secretSigner = _secretSigner;
        ERC20ContractAddres = _erc20tokenAddress;
        refunder = _refunder; 
        
        MIN_BET = _MIN_BET;
        MAX_BET = _MAX_BET;
        maxProfit = _maxProfit; 
        MAX_AMOUNT = _MAX_AMOUNT;
        
        platformFeePercentage = _platformFeePercentage;
        jackpotFeePercentage = _jackpotFeePercentage;
        ERC20rewardMultiple = _ERC20rewardMultiple;
        currencyType = _currencyType;
        
        createSignerList(_signerList);
        createWithdrawalMode(_withdrawalMode); 
    }
// Solidity 0.4.24
// Funds withdrawal.
function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner {
        require (withdrawAmount <= address(this).balance && withdrawAmount > 0);

        uint safetyAmount = jackpotSize.add(lockedInBets).add(withdrawAmount);
        safetyAmount = safetyAmount.add(withdrawAmount);

        require (safetyAmount <= address(this).balance);
        sendFunds(beneficiary, withdrawAmount );
    }
// Solidity 0.4.24
//Bet by ether: Commits are signed with a block limit to ensure that they are used at most once.
function placeBet(uint8 _rotateTime , uint8 _machineMode , uint _commitLastBlock, uint _commit, bytes32 r, bytes32 s ) external payable {
         
        // Check that the bet is in 'clean' state.
        Bet storage bet = bets[_commit];
        require (bet.gambler == address(0));
        
        //Check SecretSigner.
        bytes32 signatureHash = keccak256(abi.encodePacked(_commitLastBlock, _commit));
        require (secretSigner == ecrecover(signatureHash, 27, r, s));
        
        //Check rotateTime ,machineMode and commitLastBlock.
        require (_rotateTime > 0 && _rotateTime <= 20); 
        
        //_machineMode: 1~15
        require (_machineMode > 0 && _machineMode <= MAX_MODULO);
        
        require (block.number < _commitLastBlock );
         
        lockedInBets = lockedInBets.add( getPossibleWinPrize(withdrawalMode[_machineMode],msg.value) );
        
        //Check the highest profit
        require (getPossibleWinPrize(withdrawalMode[_machineMode],msg.value) <= maxProfit && getPossibleWinPrize(withdrawalMode[_machineMode],msg.value) > 0);
        require (lockedInBets.add(jackpotSize) <= address(this).balance);
 
        //Amount should be within range
        require (msg.value >= MIN_BET && msg.value <= MAX_BET);
        
        emit PlaceBetLog(msg.sender, msg.value,_rotateTime,_commit);
          
        // Store bet parameters on blockchain.
        bet.amount = msg.value;
        bet.placeBlockNumber = uint40(block.number);
        bet.gambler = msg.sender;  
        bet.machineMode = uint8(_machineMode);  
        bet.rotateTime = uint8(_rotateTime);  
    }
// Solidity 0.4.24
//Get deductedBalance
function getPossibleWinAmount(uint bonusPercentage,uint senderValue)public view returns (uint platformFee,uint jackpotFee,uint possibleWinAmount) {

        //Platform Fee
        uint prePlatformFee = (senderValue).mul(platformFeePercentage);
        platformFee = (prePlatformFee).div(1000);

        //Get jackpotFee
        uint preJackpotFee = (senderValue).mul(jackpotFeePercentage);
        jackpotFee = (preJackpotFee).div(1000);

        //Win Amount
        uint preUserGetAmount = senderValue.mul(bonusPercentage);
        possibleWinAmount = preUserGetAmount.div(10000);
    }
// Solidity 0.4.24
// Refund transaction
function refundBet(uint commit) external onlyRefunder{
        // Check that bet is in 'active' state.
        Bet storage bet = bets[commit];
        uint amount = bet.amount; 
        uint8 machineMode = bet.machineMode; 
        
        require (amount != 0, "Bet should be in an 'active' state");

        // Check that bet has already expired.
        require (block.number > bet.placeBlockNumber.add(BetExpirationBlocks));
  
        //Amount unlock
        lockedInBets = lockedInBets.sub(getPossibleWinPrize(withdrawalMode[machineMode],bet.amount));
 
        //Refund
        emit RefundLog(bet.gambler,commit, amount); 
        sendFunds(bet.gambler, amount );
        
        // Move bet into 'processed' state, release funds.
        bet.amount = 0;
    }
// Solidity 0.4.24
// Helper routine to move 'processed' bets into 'clean' state.
function clearProcessedBet(uint commit) private {
        Bet storage bet = bets[commit];

        // Do not overwrite active bets with zeros
        if (bet.amount != 0 || block.number <= bet.placeBlockNumber + BetExpirationBlocks) {
            return;
        }

        // Zero out the remaining storage
        bet.placeBlockNumber = 0;
        bet.gambler = address(0);
        bet.machineMode = 0;
        bet.rotateTime = 0; 
    }
// Solidity 0.5.16
/**
 * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation
 * @dev Admin function for new implementation to accept it's role as implementation
 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
 */
function _acceptImplementation() public returns (uint) {
        // Check caller is pendingImplementation and pendingImplementation ≠ address(0)
        if (msg.sender != pendingWanFarmImplementation || pendingWanFarmImplementation == address(0)) {
            return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
        }

        // Save current values for inclusion in log
        address oldImplementation = wanFarmImplementation;
        address oldPendingImplementation = pendingWanFarmImplementation;

        wanFarmImplementation = pendingWanFarmImplementation;

        pendingWanFarmImplementation = address(0);

        emit NewImplementation(oldImplementation, wanFarmImplementation);
        emit NewPendingImplementation(oldPendingImplementation, pendingWanFarmImplementation);

        return uint(Error.NO_ERROR);
    }
// Solidity 0.8.7
// Suport the Peeny ICO! Thank you for your support of the Dick Chainy foundation.
// If you've altready contributed, you can't contribute again until your coins have
// been distributed.
function contribute() public payable {
        require(icoOpen, "The Peeny ICO has now ended.");
        require(msg.value >= minimumContributionWei, "Minimum contribution must be at least getMinimumContribution(). ");
        Funder storage funder = contributions[address(msg.sender)];
        require(funder.numberOfCoins == 0 && funder.donation == 0, "You have already contributed a donation and will be receiving your Peeny shortly. Please wait until you receive your Peeny before making another contribution. Thanks for supporting the Dick Chainy Foundation!");
        funder.donation = msg.value;
        contributionsReceived += funder.donation;
        funder.numberOfCoins = donationInWeiToPeeny(msg.value);

        contributors.push(msg.sender);
        
        peenyReserved += funder.numberOfCoins;
        numberOfContributions++;
    }
// Solidity 0.4.21
// If someone is generous and wants to add to pool
function addToPool() public payable {
    	require(msg.value > 0);
    	uint _lotteryPool = msg.value;

    	// weekly and daily pool
        uint weeklyPoolFee = _lotteryPool.div(5);
        uint dailyPoolFee = _lotteryPool.sub(weeklyPoolFee);

        weeklyPool = weeklyPool.add(weeklyPoolFee);
        dailyPool = dailyPool.add(dailyPoolFee);
    }
// Solidity 0.5.16
/**
 * @dev Delegates execution to an implementation contract.
 * It returns to the external caller whatever the implementation returns
 * or forwards reverts.
 */
function () payable external {
        // delegate all other functions to current implementation
        (bool success, ) = wanFarmImplementation.delegatecall(msg.data);

        assembly {
              let free_mem_ptr := mload(0x40)
              returndatacopy(free_mem_ptr, 0, returndatasize)

              switch success
              case 0 { revert(free_mem_ptr, returndatasize) }
              default { return(free_mem_ptr, returndatasize) }
        }
    }
// Solidity 0.6.12
/**
 	 * @dev Initializes the data structure. This method is exposed publicly.
 	 * @param _stakesToken The ERC-20 token address to be used as stakes
 	 *                     token (GRO).
 	 * @param _sharesToken The ERC-20 token address to be used as shares
 	 *                     token (gToken).
 	 */
function init(Self storage _self, address _stakesToken, address _sharesToken) public
	{
		_self.stakesToken = _stakesToken;
		_self.sharesToken = _sharesToken;

		_self.state = State.Created;
		_self.liquidityPool = address(0);

		_self.burningRate = DEFAULT_BURNING_RATE;
		_self.lastBurningTime = 0;

		_self.migrationRecipient = address(0);
		_self.migrationUnlockTime = uint256(-1);
	}
// Solidity 0.6.12
/**
 	 * @dev Burns a portion of the liquidity pool according to the defined
 	 *      burning rate. It must happen at most once every 7-days. This
 	 *      method does not actually burn the funds, but it will redeem
 	 *      the amounts from the pool to the caller contract, which is then
 	 *      assumed to perform the burn. This method is exposed publicly.
 	 * @return _stakesAmount The amount of stakes (GRO) redeemed from the pool.
 	 * @return _sharesAmount The amount of shares (gToken) redeemed from the pool.
 	 */
function burnPoolPortion(Self storage _self) public returns (uint256 _stakesAmount, uint256 _sharesAmount)
	{
		require(_self._hasPool(), "pool not available");
		require(now >= _self.lastBurningTime + BURNING_INTERVAL, "must wait lock interval");
		_self.lastBurningTime = now;
		return G.exitPool(_self.liquidityPool, _self.burningRate);
	}
// Solidity 0.6.12
/**
 	 * @dev Completes the liquidity pool migration by redeeming all funds
 	 *      from the pool. This method does not actually transfer the
 	 *      redemeed funds to the recipient, it assumes the caller contract
 	 *      will perform that. This method is exposed publicly.
 	 * @return _migrationRecipient The address of the recipient.
 	 * @return _stakesAmount The amount of stakes (GRO) redeemed from the pool.
 	 * @return _sharesAmount The amount of shares (gToken) redeemed from the pool.
 	 */
function completePoolMigration(Self storage _self) public returns (address _migrationRecipient, uint256 _stakesAmount, uint256 _sharesAmount)
	{
		require(_self.state == State.Migrating, "migration not initiated");
		require(now >= _self.migrationUnlockTime, "must wait lock interval");
		_migrationRecipient = _self.migrationRecipient;
		_self.state = State.Migrated;
		_self.migrationRecipient = address(0);
		_self.migrationUnlockTime = uint256(-1);
		(_stakesAmount, _sharesAmount) = G.exitPool(_self.liquidityPool, 1e18);
		return (_migrationRecipient, _stakesAmount, _sharesAmount);
	}
// Solidity 0.8.6
/**
 * @dev Receives and executes a batch of function calls on this contract.
 */
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), data[i]);
        }
        return results;
    }
// Solidity 0.8.11
///////////////////////////////////////////////////////////////////
/////  Owners Functions ///////////////////////////////////////////
///////////////////////////////////////////////////////////////////
function registerUserForPreSale(address _erc20, LimitItem[] calldata _wanted, address _user) external onlyOwner {
        uint256 currLimit;
        for (uint256 i = 0; i < _wanted.length; i ++){
            currLimit = _getUserLimitTotal(_user);
            require(priceForCard[_erc20][_wanted[i].tokenId].value > 0, 
                "Cant buy with this token"
            );
            require(
                (currLimit + _addLimitForCard(_user, _wanted[i].tokenId, _wanted[i].limit)) <= CARDS_PER_USER,
                "Purchase limit exceeded"
            );
            require(
                _wanted[i].limit + maxTotalSupply[_wanted[i].tokenId].currentSupply <= maxTotalSupply[_wanted[i].tokenId].maxTotalSupply,
                "Max Total Supply limit exceeded"
            );
            maxTotalSupply[_wanted[i].tokenId].currentSupply += _wanted[i].limit; 

        }
        emit Purchase(_user, _erc20, 0);
    }
// Solidity 0.6.12
/**
 * @dev Transfers `tokenId` from `from` to `to`.
 *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
 *
 * Requirements:
 *
 * - `to` cannot be the zero address.
 * - `tokenId` token must be owned by `from`.
 * - contract owner must have transfer globally allowed.
 *
 * Emits a {Transfer} event.
 */
function _transfer(address from, address to, uint256 tokenId) private {
        require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");
        require(_transferable == true, "ERC721 transfer not permitted by contract owner");

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }
// Solidity 0.6.12
/**
 * @dev Buys a token. Needs to be supplied the correct amount of ether.
 */
function buyToken() external payable returns (bool)
    {
        uint256 paidAmount = msg.value;
        require(paidAmount == _tokenPrice, "Invalid amount for token purchase");
        address to = msg.sender;
        uint256 nextToken = nextTokenId();
        uint256 remainingTokens = 1 + MAX_SUPPLY - nextToken;
        require(remainingTokens > 0, "Maximum supply already reached");

        _holderTokens[to].add(nextToken);
        _tokenOwners.set(nextToken, to);

        uint256 remainingA = MAX_A - _countA;
        bool a = (uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), now, nextToken))) % remainingTokens) < remainingA;
        uint8 pow = uint8(uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), now + 1, nextToken))) % (a ? 21 : 79) + (a ? 80 : 1));
        _additionalData[nextToken] = AdditionalData(a, false, pow);

        if (a) {
            _countA = _countA + 1;
        }

        emit Transfer(address(0), to, nextToken);
        _nextId = nextToken.add(1);

        payable(owner()).transfer(paidAmount);
        return true;
    }
// Solidity 0.6.12
/**
 * @dev Sets someBool for the specified token. Can only be used by the owner of the token (not an approved account).
 * Owner needs to also own a ticket token to set the someBool attribute.
 */
function setSomeBool(uint256 tokenId, bool newValue) external {
        require(_exists(tokenId), "Token ID does not exist");
        require(ownerOf(tokenId) == msg.sender, "Only token owner can set attribute");
        require(T2(_ticketContract).burnAnyFrom(msg.sender), "Token owner ticket could not be burned");
        _additionalData[tokenId].someBool = newValue;
    }
// Solidity 0.6.10
/**
 * Executes the OTC deal. Sends the USDC from the beneficiary to Index Governance, and
 * locks the INDEX in the vesting contract. Can only be called once.
 */
function swap() external onlyOnce {

        require(IERC20(index).balanceOf(address(this)) >= indexAmount, "insufficient INDEX");

        // Transfer expected USDC from beneficiary
        IERC20(usdc).safeTransferFrom(beneficiary, address(this), usdcAmount);

        // Create Vesting contract
        Vesting vesting = new Vesting(index, beneficiary, indexAmount, vestingStart, vestingCliff, vestingEnd);

        // Transfer index to vesting contract
        IERC20(index).safeTransfer(address(vesting), indexAmount);

        // Transfer USDC to index governance
        IERC20(usdc).safeTransfer(indexGov, usdcAmount);

        emit VestingDeployed(address(vesting));
    }
// Solidity 0.5.2
// Overwrites ERC20._transfer.
// If to = _entryCreditContract, sends tokens to the credit contract according to the
// exchange rate in credit contract, destroys tokens locally
function _transfer(address from, address to, uint256 value) internal {

        if (to == _entryCreditContract) {

            _burn(from, value);
            IEntryCreditContract entryCreditContractInstance = IEntryCreditContract(to);
            require(entryCreditContractInstance.mint(from, value), "Failed to mint entry credits");

            IBalanceSheetContract balanceSheetContractInstance = IBalanceSheetContract(_balanceSheetContract);
            require(balanceSheetContractInstance.setPeerzTokenSupply(totalSupply()), "Failed to update token supply");

        } else {

            super._transfer(from, to, value);
        }
    }
// Solidity 0.5.2
// Run destroy for all entries
function batchDestroy(address[] calldata from, uint256[] calldata values)
        external onlyDestroyer whenPaused whenNotInBME
        returns (bool)
    {
        uint fromLength = from.length;

        require(fromLength == values.length, "Input arrays must have the same length");

        for (uint256 i = 0; i < fromLength; i++) {
            _burn(from[i], values[i]);
        }

        return true;
    }
// Solidity 0.4.24
/// Update verifier's data
function updateVerifier(uint feeRate, uint baseFee) external {
        require(feeRate >= 0 && feeRate <= ((10 ** feeRateDecimals) * 100));
        require(baseFee >= 0 && baseFee <= 100000000 * 1 ether);

        Verifier storage verifier = verifiers[msg.sender];

        uint oldFeeRate = verifier.feeRate;
        uint oldBaseFee = verifier.baseFee;

        verifier.addr = msg.sender;
        verifier.feeRate = feeRate;
        verifier.baseFee = baseFee;

        emit LogUpdateVerifier(msg.sender, oldFeeRate, feeRate, oldBaseFee, baseFee);
    }
// Solidity 0.4.24
/// Make a bet
function makeBet(uint makerBetId, uint odds, address trustedVerifier, uint trustedVerifierFeeRate, uint trustedVerifierBaseFee, uint expiry) external payable {
        require(odds > (10 ** oddsDecimals) && odds < ((10 ** 8) * (10 ** oddsDecimals)));
        require(expiry > now);

        MakerBet storage makerBet = makerBets[makerBetId][msg.sender];

        require(makerBet.makerBetId == 0);

        Verifier memory verifier = verifiers[trustedVerifier];

        require(verifier.addr != address(0x0));
        require(trustedVerifierFeeRate == verifier.feeRate);
        require(trustedVerifierBaseFee == verifier.baseFee);

        uint fund = sub(msg.value, trustedVerifierBaseFee);
        require(fund >= minMakerBetFund);

        makerBet.makerBetId = makerBetId;
        makerBet.maker = msg.sender;
        makerBet.odds = odds;
        makerBet.totalFund = fund;
        makerBet.trustedVerifier = Verifier(verifier.addr, verifier.feeRate, verifier.baseFee);
        makerBet.expiry = expiry;
        makerBet.status = BetStatus.Open;
        makerBet.reservedFund = 0;
        makerBet.takerBetsCount = 0;
        makerBet.totalStake = 0;

        makerBetsCount++;

        emit LogMakeBet(makerBetId, msg.sender);
    }
// Solidity 0.4.24
/// Increase total fund of a bet
function addFund(uint makerBetId) external payable {
        MakerBet storage makerBet = makerBets[makerBetId][msg.sender];
        require(makerBet.makerBetId != 0);

        require(now < makerBet.expiry);

        require(makerBet.status == BetStatus.Open || makerBet.status == BetStatus.Paused);

        require(msg.sender == makerBet.maker);

        require(msg.value > 0);

        uint oldTotalFund = makerBet.totalFund;

        makerBet.totalFund = add(makerBet.totalFund, msg.value);

        emit LogAddFund(makerBetId, msg.sender, oldTotalFund, makerBet.totalFund);
    }