lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.17
/**
 * @dev Calculate JackPot 
 * 40% from entryFee is going to JackPot 
 * The last investor (with 0.2 link) will receive the jackpot in 12 hours 
 */
function calculateJackPot(uint256 _incomingLink, address _customerAddress) internal {
		uint256 timer = SafeMath.div(SafeMath.sub(now, jackPotStartTime_), 12 hours);
		if (timer > 0 && jackPotPretender_ != address(0x0) && jackPot_ > 0) {
			//pay jackPot
			if (totalLinkBalance() < jackPot_) {
				jackPot_ = totalLinkBalance();
			}
				
			linkContract.transfer(jackPotPretender_, SafeMath.div(jackPot_,2));
			jackPot_ = SafeMath.div(jackPot_,2);
			jackPotStartTime_ = now;
			jackPotPretender_ = address(0x0);
		}
		
		uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingLink, entryFee()), 100);
		jackPot_ += SafeMath.div(SafeMath.mul(_undividedDividends, 40), 100);
		
		if (_incomingLink >= 10e18) { 
			jackPotPretender_ = _customerAddress;
			jackPotStartTime_ = now;
		}
	}
// Solidity 0.3.1
// Anyone can usurpation the kingship
function usurpation() {
        // Add more money for king usurpation cost
        if (msg.sender == madKing) {
            investInTheSystem(msg.value);
            kingCost += msg.value;
        } else {
            if (onThrone + PEACE_PERIOD <= block.timestamp && msg.value >= kingCost * 110 / 100) {
                // return the fees to before king
                madKing.send(kingBank);
                // offer sacrifices to the Gods
                godBank += msg.value * 5 / 100;
                investInTheSystem(msg.value);
                // new king
                kingCost = msg.value;
                madKing = msg.sender;
                onThrone = block.timestamp;
            } else {
                throw;
            }
        }
    }
// Solidity 0.4.15
/**
 * Event emitting fallback.
 *
 * Can be and only called by authorized caller.
 * Delegate calls back with provided msg.data to emit an event.
 *
 * Throws if call failed.
 */
function () {
        if (!isAuthorized[msg.sender]) {
            return;
        }
        // Internal Out Of Gas/Throw: revert this transaction too;
        // Recursive Call: safe, all changes already made.
        if (!msg.sender.delegatecall(msg.data)) {
            throw;
        }
    }
// Solidity 0.5.9
/**
 * Transfer tokens
 *
 * Send `_value` tokens to `_to` from your account
 *
 * @param _to The address of the recipient
 * @param _value the amount to send
 */
function transfer(address _to, uint256 _value) public {
        require(_to != address(0), "Cannot use zero address");
        require(_value > 0, "Cannot use zero value");

        require (balanceOf[msg.sender] >= _value, "Balance not enough");         // Check if the sender has enough
        require (balanceOf[_to] + _value >= balanceOf[_to], "Overflow" );        // Check for overflows
        
        uint previousBalances = balanceOf[msg.sender] + balanceOf[_to];          
        
        balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
        balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);               // Add the same to the recipient
        
        emit Transfer(msg.sender, _to, _value);                                  // Notify anyone listening that this transfer took place
        
        assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances);
    }
// Solidity 0.4.24
// get today current max investment
function getMaxInvestmentToday(data storage control) internal view returns (uint)
    {
        if (control.startAt == 0) {
            return 10000 ether; // disabled controlling, allow 10000 eth
        }

        if (control.startAt > now) {
            return 10000 ether; // not started, allow 10000 eth
        }

        return control.maxAmountPerDay - control.getTodayInvestment();
    }
// Solidity 0.4.24
// remove all investors and prepare data for the new round!
function doRestart() private {
        uint txs;

        for (uint i = addresses.length - 1; i > 0; i--) {
            delete investors[addresses[i]]; // remove investor
            addresses.length -= 1; // decrease addr length
            if (txs++ == 150) { // stop on 150 investors (to prevent out of gas exception)
                return;
            }
        }

        emit NextRoundStarted(round, now, depositAmount);
        pause = false; // stop pause, play
        round += 1; // increase round number
        depositAmount = 0;
        paidAmount = 0;
        lastPaymentDate = now;
    }
// Solidity 0.4.24
// Thunderstorm!
// make the biggest investment today - and receive ref-commissions from ALL investors who not have a referrer in the next 10 days
function considerThunderstorm(uint amount) internal {
        // if current Thunderstorm dead, delete him
        if (thunderstorm.addr > 0x0 && thunderstorm.from + 10 days < now) {
            thunderstorm.addr = 0x0;
            thunderstorm.deposit = 0;
            emit ThunderstormUpdate(msg.sender, "expired");
        }

        // if the investment bigger than current Thunderstorm made - change Thunderstorm
        if (amount > thunderstorm.deposit) {
            thunderstorm = Thunderstorm(msg.sender, amount, now);
            emit ThunderstormUpdate(msg.sender, "change");
        }
    }
// Solidity 0.6.7
// Deposit LP tokens to MasterChef for Pud allocation.
function deposit(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        updatePool(_pid);
        if (user.shares > 0) {
            uint256 pending =
                user.shares.mul(pool.accPudPerShare).div(1e12).sub(
                    user.rewardDebt
                );
            safePudTransfer(msg.sender, pending);
        }

        //
        uint256 _pool = balance(_pid); //get _pid lptoken balance
        if (_amount > 0) {
            uint256 _before = pool.lpToken.balanceOf(pool.strategy);

            pool.lpToken.safeTransferFrom(
                address(msg.sender),
                pool.strategy,
                _amount
            );

            uint256 _after = pool.lpToken.balanceOf(pool.strategy);
            _amount = _after.sub(_before); // Additional check for deflationary tokens
        }
        uint256 shares = 0;
        if (pool.totalShares == 0) {
            shares = _amount;
        } else {
            shares = (_amount.mul(pool.totalShares)).div(_pool);
        }

        user.shares = user.shares.add(shares); //add shares instead of amount
        user.rewardDebt = user.shares.mul(pool.accPudPerShare).div(1e12);
        pool.totalShares = pool.totalShares.add(shares); //add shares in pool

        emit Deposit(msg.sender, _pid, _amount);
    }
// Solidity 0.5.16
// Returns true iff the specified name is available for registration.
function available(uint256 id) public view returns(bool) {
        // Not available if it's registered here or in its grace period.
        if(expiries[id] + GRACE_PERIOD >= now) {
            return false;
        }
        // Available if we're past the transfer period, or the name isn't
        // registered in the legacy registrar.
        return now > transferPeriodEnds || previousRegistrar.state(bytes32(id)) == Registrar.Mode.Open;
    }
// Solidity 0.5.16
/**
 * @dev Register a name.
 */
function _register(uint256 id, address owner, uint duration, bool updateRegistry) internal live onlyController returns(uint) {
        require(available(id));
        require(now + duration + GRACE_PERIOD > now + GRACE_PERIOD); // Prevent future overflow

        expiries[id] = now + duration;
        if(_exists(id)) {
            // Name was previously owned, and expired
            _burn(id);
        }
        _mint(owner, id);
        if(updateRegistry) {
            ens.setSubnodeOwner(baseNode, bytes32(id), owner);
        }

        emit NameRegistered(id, owner, now + duration);

        return now + duration;
    }
// Solidity 0.5.16
/**
 * @dev Transfers a registration from the initial registrar.
 * This function is called by the initial registrar when a user calls `transferRegistrars`.
 */
function acceptRegistrarTransfer(bytes32 label, Deed deed, uint) external live {
        uint256 id = uint256(label);

        require(msg.sender == address(previousRegistrar));
        require(expiries[id] == 0);
        require(transferPeriodEnds > now);

        uint registrationDate;
        (,,registrationDate,,) = previousRegistrar.entries(label);
        require(registrationDate < now - MIGRATION_LOCK_PERIOD);

        address owner = deed.owner();

        // Destroy the deed and transfer the funds back to the registrant.
        deed.closeDeed(1000);

        // Register the name
        expiries[id] = transferPeriodEnds;
        _mint(owner, id);

        ens.setSubnodeOwner(baseNode, label, owner);

        emit NameMigrated(id, owner, transferPeriodEnds);
        emit NameRegistered(id, owner, transferPeriodEnds);
    }
// Solidity 0.4.26
/**
 *  to update an split holder ratio at the index
 *  index ranges from 0..totalHolders -1
 */
function setMintSplitHolder(uint256 index, address _wallet, uint256 _ratio) public onlyOwner returns (bool) {
        if (index > totalHolders - 1)
          return false;

        holders[ index ] = _wallet;
        MintSplitHolderRatios[ index ] = _ratio;

        return true;
    }
// Solidity 0.8.1
/// @dev checks if required parameters are set for the contract
function _checkFee(uint256 _fee) internal view returns(bool) {
        if(_fee > 0) {
            require( msg.value >= _fee, "Value less than fee" );
        }
        return(true);
        //return ( (_fee == 0 && msg.value == 0) || (registratorAddress != address(0) && msg.value >= _fee ));
    }
// Solidity 0.8.1
// @dev New Word register.
function memorialize(
        string memory _words,
        string memory _author,
        uint64 _dob
    )
        external
        payable
        returns (uint256)
    {


        require( _checkFee(fee) );

        Word memory _word = Word({
            id: 0,
            words: _words,
            author: _author,
            dob: _dob
        });

        uint256 _id = _storeWords(
            _word
        );

        // This will assign ownership, and also emit the Transfer event as
        // per ERC721 draft
        _mint(msg.sender, _id);
        
        emit Words(
            msg.sender,
            _words,
            _author,
            _dob
        );

        _payFee( fee );
        
        return _id;
    }
// Solidity 0.4.11
/**
 * Construct the token.
 *
 * This token must be created through a team multisig wallet, so that it is owned by that wallet.
 *
 * @param _name Token name
 * @param _symbol Token symbol - should be all caps
 * @param _initialSupply How many tokens we start with
 * @param _decimals Number of decimal places
 * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
 */
function CrowdsaleTokenExt(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable, uint _globalMinCap)
    UpgradeableToken(msg.sender) {
    // Create any address, can be transferred
    // to team multisig via changeOwner(),
    // also remember to call setUpgradeMaster()
    owner = msg.sender;
    name = _name;
    symbol = _symbol;
    totalSupply = _initialSupply;
    decimals = _decimals;
    minCap = _globalMinCap;
    // Create initially all balance on the team multisig
    balances[owner] = totalSupply;
    if(totalSupply > 0) {
      Minted(owner, totalSupply);
    }
    // No more new supply allowed after the token creation
    if(!_mintable) {
      mintingFinished = true;
      if(totalSupply == 0) {
        throw; // Cannot create a token without supply and no minting
      }
    }
  }
// Solidity 0.8.7
/**
 * This is an internal function, and it is the real operator to mint NFT to user,
 * it will return an array of tokenID after minting.
 */
function mintSpeficiedAmount(address owner, uint256 amount) internal returns (uint256[] memory) {
        uint256[] memory minted_ = new uint256[](amount);

        for(uint256 i = 0; i < amount; i ++) {
            uint256 tokenIdToMint = _currentTokenId_ + i + 1;
            _safeMint(owner, tokenIdToMint);
            minted_[i] = tokenIdToMint;
        }

        _currentTokenId_ += amount;

        return minted_;
    }
// Solidity 0.8.7
/**
 * This function overrides the function defined in ERC721 contract,
 * before revealing or baseURI has not been set, it will always return the placeholder.
 * otherwise, the sequenceId will be calculated and combined to tokenURI.
 */
function tokenURI(uint256 tokenId_) public view override returns (string memory) {
        require(_exists(tokenId_), "ERC721Metadata: URI query for nonexistent token");

        if (!_isRevealed_) {
            return bytes(_placeholderBaseURI_).length > 0 ? 
                string(abi.encodePacked(_placeholderBaseURI_, Strings.toString(tokenId_), ".json")) : "";
        }

        return bytes(_baseURI_).length > 0 ? 
            string(abi.encodePacked(_baseURI_, Strings.toString(_sequenceId(tokenId_)), ".json")) : "";
    }
// Solidity 0.5.17
/// @notice Burns TBTC and transfers the tBTC Deposit Token to the caller
///         as long as it is qualified.
/// @dev    We burn the lotSize of the Deposit in order to maintain
///         the TBTC supply peg in the Vending Machine. VendingMachine must be approved
///         by the caller to burn the required amount.
/// @param _tdtId ID of tBTC Deposit Token to buy.
function tbtcToTdt(uint256 _tdtId) public {
        require(tbtcDepositToken.exists(_tdtId), "tBTC Deposit Token does not exist");
        require(isQualified(address(_tdtId)), "Deposit must be qualified");

        uint256 depositValue = Deposit(address(uint160(_tdtId))).lotSizeTbtc();
        require(tbtcToken.balanceOf(msg.sender) >= depositValue, "Not enough TBTC for TDT exchange");
        tbtcToken.burnFrom(msg.sender, depositValue);

        // TODO do we need the owner check below? transferFrom can be approved for a user, which might be an interesting use case.
        require(tbtcDepositToken.ownerOf(_tdtId) == address(this), "Deposit is locked");
        tbtcDepositToken.transferFrom(address(this), msg.sender, _tdtId);
    }
// Solidity 0.5.17
/// @notice Transfer the tBTC Deposit Token and mint TBTC.
/// @dev    Transfers TDT from caller to vending machine, and mints TBTC to caller.
///         Vending Machine must be approved to transfer TDT by the caller.
/// @param _tdtId ID of tBTC Deposit Token to sell.
function tdtToTbtc(uint256 _tdtId) public {
        require(tbtcDepositToken.exists(_tdtId), "tBTC Deposit Token does not exist");
        require(isQualified(address(_tdtId)), "Deposit must be qualified");

        tbtcDepositToken.transferFrom(msg.sender, address(this), _tdtId);

        // If the backing Deposit does not have a signer fee in escrow, mint it.
        Deposit deposit = Deposit(address(uint160(_tdtId)));
        uint256 signerFee = deposit.signerFee();
        uint256 depositValue = deposit.lotSizeTbtc();

        if(tbtcToken.balanceOf(address(_tdtId)) < signerFee) {
            tbtcToken.mint(msg.sender, depositValue.sub(signerFee));
            tbtcToken.mint(address(_tdtId), signerFee);
        }
        else{
            tbtcToken.mint(msg.sender, depositValue);
        }

        // owner of the TDT during first TBTC mint receives the FRT
        if(!feeRebateToken.exists(_tdtId)){
            feeRebateToken.mint(msg.sender, _tdtId);
        }
    }
// Solidity 0.5.17
/// @notice Qualifies a deposit and mints TBTC.
/// @dev User must allow VendingManchine to transfer TDT.
function unqualifiedDepositToTbtc(
        address payable _depositAddress,
        bytes4 _txVersion,
        bytes memory _txInputVector,
        bytes memory _txOutputVector,
        bytes4 _txLocktime,
        uint8 _fundingOutputIndex,
        bytes memory _merkleProof,
        uint256 _txIndexInBlock,
        bytes memory _bitcoinHeaders
    ) public {
        Deposit _d = Deposit(_depositAddress);
        require(
            _d.provideBTCFundingProof(
                _txVersion,
                _txInputVector,
                _txOutputVector,
                _txLocktime,
                _fundingOutputIndex,
                _merkleProof,
                _txIndexInBlock,
                _bitcoinHeaders
            ),
            "failed to provide funding proof");

        tdtToTbtc(uint256(_depositAddress));
    }
// Solidity 0.5.17
/// @notice Redeems a Deposit by purchasing a TDT with TBTC for _finalRecipient,
///         and using the TDT to redeem corresponding Deposit as _finalRecipient.
///         This function will revert if the Deposit is not in ACTIVE state.
/// @dev Vending Machine transfers TBTC allowance to Deposit.
/// @param  _depositAddress     The address of the Deposit to redeem.
/// @param  _outputValueBytes   The 8-byte Bitcoin transaction output size in Little Endian.
/// @param  _redeemerOutputScript The redeemer's length-prefixed output script.
/// @param  _finalRecipient     The deposit redeemer. This address will receive the TDT.
function tbtcToBtc(
        address payable _depositAddress,
        bytes8 _outputValueBytes,
        bytes memory _redeemerOutputScript,
        address payable _finalRecipient
    ) public {
        require(tbtcDepositToken.exists(uint256(_depositAddress)), "tBTC Deposit Token does not exist");
        Deposit _d = Deposit(_depositAddress);

        tbtcToken.burnFrom(msg.sender, _d.lotSizeTbtc());
        tbtcDepositToken.approve(_depositAddress, uint256(_depositAddress));

        uint256 tbtcOwed = _d.getOwnerRedemptionTbtcRequirement(msg.sender);

        if(tbtcOwed != 0){
            tbtcToken.transferFrom(msg.sender, address(this), tbtcOwed);
            tbtcToken.approve(_depositAddress, tbtcOwed);
        }

        _d.transferAndRequestRedemption(_outputValueBytes, _redeemerOutputScript, _finalRecipient);
    }
// Solidity 0.8.4
/**
 * @notice Updates set of permissions (role) for a given user,
 *      taking into account sender's permissions.
 *
 * @dev Setting role to zero is equivalent to removing an all permissions
 * @dev Setting role to `FULL_PRIVILEGES_MASK` is equivalent to
 *      copying senders' permissions (role) to the user
 * @dev Requires transaction sender to have `ROLE_ACCESS_MANAGER` permission
 *
 * @param operator address of a user to alter permissions for or zero
 *      to alter global features of the smart contract
 * @param role bitmask representing a set of permissions to
 *      enable/disable for a user specified
 */
function updateRole(address operator, uint256 role) public {
    // caller must have a permission to update user roles
    require(isSenderInRole(ROLE_ACCESS_MANAGER), "insufficient privileges (ROLE_ACCESS_MANAGER required)");

    // evaluate the role and reassign it
    userRoles[operator] = evaluateBy(msg.sender, userRoles[operator], role);

    // fire an event
    emit RoleUpdated(msg.sender, operator, role, userRoles[operator]);
  }
// Solidity 0.8.4
/**
 * @notice Determines the permission bitmask an operator can set on the
 *      target permission set
 * @notice Used to calculate the permission bitmask to be set when requested
 *     in `updateRole` and `updateFeatures` functions
 *
 * @dev Calculated based on:
 *      1) operator's own permission set read from userRoles[operator]
 *      2) target permission set - what is already set on the target
 *      3) desired permission set - what do we want set target to
 *
 * @dev Corner cases:
 *      1) Operator is super admin and its permission set is `FULL_PRIVILEGES_MASK`:
 *        `desired` bitset is returned regardless of the `target` permission set value
 *        (what operator sets is what they get)
 *      2) Operator with no permissions (zero bitset):
 *        `target` bitset is returned regardless of the `desired` value
 *        (operator has no authority and cannot modify anything)
 *
 * @dev Example:
 *      Consider an operator with the permissions bitmask     00001111
 *      is about to modify the target permission set          01010101
 *      Operator wants to set that permission set to          00110011
 *      Based on their role, an operator has the permissions
 *      to update only lowest 4 bits on the target, meaning that
 *      high 4 bits of the target set in this example is left
 *      unchanged and low 4 bits get changed as desired:      01010011
 *
 * @param operator address of the contract operator which is about to set the permissions
 * @param target input set of permissions to operator is going to modify
 * @param desired desired set of permissions operator would like to set
 * @return resulting set of permissions given operator will set
 */
function evaluateBy(address operator, uint256 target, uint256 desired) public view returns(uint256) {
    // read operator's permissions
    uint256 p = userRoles[operator];

    // taking into account operator's permissions,
    // 1) enable the permissions desired on the `target`
    target |= p & desired;
    // 2) disable the permissions desired on the `target`
    target &= FULL_PRIVILEGES_MASK ^ (p & (FULL_PRIVILEGES_MASK ^ desired));

    // return calculated result
    return target;
  }
// Solidity 0.6.12
// for swap form
function GetCurrentPriceForETH() public view returns (uint256) {
            uint256 tokens;
            int ethusd;
            uint256 ethprice;
            
            ethusd = getLatestPrice();
            ethprice = uint256(ethusd) / priceZero;
            
            if (now <= bonusEnds) {tokens = ethprice / 25 * 10;}  // PHASE 1: 1ADR = 2.5$
            else if (now > bonusEnds && now < bonusEnds1) {tokens = ethprice / 27 * 10;} // PHASE 2: 1ADR = 2.7$
                else if (now > bonusEnds1 && now < bonusEnds2) {tokens = ethprice / 3;} // PHASE 3: 1ADR = 3$
                    else if (now > bonusEnds2 && now < bonusEnds3) {tokens = ethprice / 33 * 10;} // PHASE 4: 1ADR = 3.3$
        return tokens;
  }
// Solidity 0.6.12
// for swap form (/10)
function GetCurrentPrice() public view returns (uint256) {
            uint256 tokens;
            
            if (now <= bonusEnds) {tokens = 25;}  // PHASE 1: 1ADR = 2.5$
            else if (now > bonusEnds && now < bonusEnds1) {tokens = 27;} // PHASE 2: 1ADR = 2.7$
                else if (now > bonusEnds1 && now < bonusEnds2) {tokens = 30;} // PHASE 3: 1ADR = 3$
                    else if (now > bonusEnds2 && now < bonusEnds3) {tokens = 33;} // PHASE 4: 1ADR = 3.3$
        return tokens;
  }
// Solidity 0.6.12
// Only Dev. Pre-sale info.
function PreSale(uint _bonusEnds, uint _bonusEnds1, uint _bonusEnds2, uint _bonusEnds3, uint _endDate, uint _priceZero) public {
        require(msg.sender == devaddr, "dev: wtf?");
        bonusEnds = _bonusEnds;
        bonusEnds1 = _bonusEnds1;
        bonusEnds2 = _bonusEnds2;
        bonusEnds3 = _bonusEnds3;
        endDate = _endDate;
        priceZero = _priceZero;
    }
// Solidity 0.4.24
/**
 * @dev XRT emission value for utilized gas
 */
function wnFromGas(uint256 _gas) view returns (uint256) {
        // Just return wn=gas when auction isn't finish
        if (auction.finalPrice() == 0)
            return _gas;

        // Current gas utilization epoch
        uint256 epoch = totalGasUtilizing / gasEpoch;

        // XRT emission with addition coefficient by gas utilzation epoch
        uint256 wn = _gas * 10**9 * gasPrice * 2**epoch / 3**epoch / auction.finalPrice();

        // Check to not permit emission decrease below wn=gas
        return wn < _gas ? _gas : wn;
    }