lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.17
// ------------------------
// Address 0x000000000000000000000000000000000000dEaD represents Ethereums global token burn address
// ------------------------
function transfer(address to, uint tokens) public returns (bool success)
    {
    require(tokens < ((balances[msg.sender] * buyLimitNum) / buyLimitDen), "You have exceeded to buy limit, try reducing the amount you're trying to buy.");
    balances[msg.sender] = safeSub(balances[msg.sender], tokens);
    balances[to] = safeAdd(balances[to], tokens - ((tokens * burnPRCNTNum) / burnPRCNTDen));
    
    _burn(burnaddress, tokens);
    emit Transfer(msg.sender, to, tokens - ((tokens * burnPRCNTNum) / burnPRCNTDen));
    emit Transfer(msg.sender, burnaddress, ((tokens * burnPRCNTNum) / burnPRCNTDen));
    return true;
    }
// Solidity 0.6.8
/*
 * @nonce Calls by HegicPutOptions to unlock funds
 * @param amount Amount of funds that should be unlocked in an expired option
 */
function unlock(uint256 amount) external override onlyOwner {
        require(lockedAmount >= amount, "Pool Error: You are trying to unlock more funds than have been locked for your contract. Please lower the amount.");
        lockedAmount = lockedAmount.sub(amount);
    }
// Solidity 0.6.8
/*
 * @nonce Calls by HegicPutOptions to unlock premium after an option expiraton
 * @param amount Amount of premiums that should be locked
 */
function unlockPremium(uint256 amount) external override onlyOwner {
        require(lockedPremium >= amount, "Pool Error: You are trying to unlock more premiums than have been locked for the contract. Please lower the amount.");
        lockedPremium = lockedPremium.sub(amount);
    }
// Solidity 0.6.8
/*
 * @nonce calls by HegicPutOptions to unlock the premiums after an option's expiraton
 * @param to Provider
 * @param amount Amount of premiums that should be unlocked
 */
function send(address payable to, uint256 amount)
        external
        override
        onlyOwner
    {
        require(to != address(0));
        require(lockedAmount >= amount, "Pool Error: You are trying to unlock more premiums than have been locked for the contract. Please lower the amount.");
        require(token.transfer(to, amount), "Token transfer error: Please lower the amount of premiums that you want to send.");
    }
// Solidity 0.6.8
/*
 * @nonce A provider supplies DAI to the pool and receives writeDAI tokens
 * @param amount Provided tokens
 * @param minMint Minimum amount of tokens that should be received by a provider.
 Calling the provide function will require the minimum amount of tokens to be minted.
 The actual amount that will be minted could vary but can only be higher (not lower) than the minimum value.
 * @return mint Amount of tokens to be received
 */
function provide(uint256 amount, uint256 minMint) external returns (uint256 mint) {
        lastProvideTimestamp[msg.sender] = now;
        uint supply = totalSupply();
        uint balance = totalBalance();
        if (supply > 0 && balance > 0)
            mint = amount.mul(supply).div(balance);
        else
            mint = amount.mul(1000);

        require(mint >= minMint, "Pool: Mint limit is too large");
        require(mint > 0, "Pool: Amount is too small");
        _mint(msg.sender, mint);
        emit Provide(msg.sender, amount, mint);

        require(
            token.transferFrom(msg.sender, address(this), amount),
            "Token transfer error: Please lower the amount of premiums that you want to send."
        );
    }
// Solidity 0.6.8
/*
 * @nonce Provider burns writeDAI and receives DAI from the pool
 * @param amount Amount of DAI to receive
 * @param maxBurn Maximum amount of tokens that can be burned
 * @return mint Amount of tokens to be burnt
 */
function withdraw(uint256 amount, uint256 maxBurn) external returns (uint256 burn) {
        require(
            lastProvideTimestamp[msg.sender].add(lockupPeriod) <= now,
            "Pool: Withdrawal is locked up"
        );
        require(
            amount <= availableBalance(),
            "Pool Error: You are trying to unlock more funds than have been locked for your contract. Please lower the amount."
        );
        burn = amount.mul(totalSupply()).div(totalBalance());

        require(burn <= maxBurn, "Pool: Burn limit is too small");
        require(burn <= balanceOf(msg.sender), "Pool: Amount is too large");
        require(burn > 0, "Pool: Amount is too small");

        _burn(msg.sender, burn);
        emit Withdraw(msg.sender, amount, burn);
        require(token.transfer(msg.sender, amount), "Insufficient funds");
    }
// Solidity 0.6.8
/**
 * @notice Creates a new option
 * @param period Option period in seconds (1 days <= period <= 4 weeks)
 * @param amount Option amount
 * @param strike Strike price of the option
 * @return optionID Created option's ID
 */
function create(
        uint256 period,
        uint256 amount,
        uint256 strike
    ) external payable returns (uint256 optionID) {
        (uint256 total, uint256 settlementFee, , ) = fees(
            period,
            amount,
            strike
        );
        uint256 strikeAmount = strike.mul(amount) / PRICE_DECIMALS;

        require(strikeAmount > 0, "Amount is too small");
        require(settlementFee < total, "Premium is too small");
        require(period >= 1 days, "Period is too short");
        require(period <= 4 weeks, "Period is too long");
        require(msg.value == total, "Wrong value");

        uint256 premium = sendPremium(total.sub(settlementFee));
        optionID = options.length;
        options.push(
            Option(
                State.Active,
                msg.sender,
                strike,
                amount,
                premium,
                now + period
            )
        );

        emit Create(optionID, msg.sender, settlementFee, total);
        lockFunds(options[optionID]);
        settlementFeeRecipient.transfer(settlementFee);
    }
// Solidity 0.6.8
/**
 * @notice Exercises an active option
 * @param optionID ID of your option
 */
function exercise(uint256 optionID) external {
        Option storage option = options[optionID];

        require(option.expiration >= now, "Option has expired");
        require(option.holder == msg.sender, "Wrong msg.sender");
        require(option.state == State.Active, "Wrong state");

        option.state = State.Exercised;
        uint256 profit = payProfit(option);

        emit Exercise(optionID, profit);
    }
// Solidity 0.6.8
/**
 * @notice Used for getting the actual options prices
 * @param period Option period in seconds (1 days <= period <= 4 weeks)
 * @param amount Option amount
 * @param strike Strike price of the option
 * @return total Total price to be paid
 * @return settlementFee Amount to be distributed to the HEGIC token holders
 * @return strikeFee Amount that covers the price difference in the ITM options
 * @return periodFee Option period fee amount
 */
function fees(
        uint256 period,
        uint256 amount,
        uint256 strike
    )
        public
        view
        returns (
            uint256 total,
            uint256 settlementFee,
            uint256 strikeFee,
            uint256 periodFee
        )
    {
        uint256 currentPrice = uint256(priceProvider.latestAnswer());
        settlementFee = getSettlementFee(amount);
        periodFee = getPeriodFee(amount, period, strike, currentPrice);
        strikeFee = getStrikeFee(amount, strike, currentPrice);
        total = periodFee.add(strikeFee);
    }
// Solidity 0.6.8
/**
 * @notice Unlock funds locked in the expired options
 * @param optionID ID of the option
 */
function unlock(uint256 optionID) public {
        Option storage option = options[optionID];
        require(option.expiration < now, "Option has not expired yet");
        require(option.state == State.Active, "Option is not active");
        option.state = State.Expired;
        unlockFunds(option);
        emit Expire(optionID, option.premium);
    }
// Solidity 0.6.8
/**
 * @notice Calculates periodFee
 * @param amount Option amount
 * @param period Option period in seconds (1 days <= period <= 4 weeks)
 * @param strike Strike price of the option
 * @param currentPrice Current price of ETH
 * @return fee Period fee amount
 *
 * amount < 1e30        |
 * impliedVolRate < 1e10| => amount * impliedVolRate * strike < 1e60 < 2^uint256
 * strike < 1e20 ($1T)  |
 *
 * in case amount * impliedVolRate * strike >= 2^256
 * transaction will be reverted by the SafeMath
 */
function getPeriodFee(
        uint256 amount,
        uint256 period,
        uint256 strike,
        uint256 currentPrice
    ) internal view returns (uint256 fee) {
        if (optionType == OptionType.Put)
            return amount
                .mul(sqrt(period))
                .mul(impliedVolRate)
                .mul(strike)
                .div(currentPrice)
                .div(PRICE_DECIMALS);
        else
            return amount
                .mul(sqrt(period))
                .mul(impliedVolRate)
                .mul(currentPrice)
                .div(strike)
                .div(PRICE_DECIMALS);
    }
// Solidity 0.6.8
/**
 * @notice Calculates strikeFee
 * @param amount Option amount
 * @param strike Strike price of the option
 * @param currentPrice Current price of ETH
 * @return fee Strike fee amount
 */
function getStrikeFee(
        uint256 amount,
        uint256 strike,
        uint256 currentPrice
    ) internal view returns (uint256 fee) {
        if (strike > currentPrice && optionType == OptionType.Put)
            return strike.sub(currentPrice).mul(amount).div(currentPrice);
        if (strike < currentPrice && optionType == OptionType.Call)
            return currentPrice.sub(strike).mul(amount).div(currentPrice);
        return 0;
    }
// Solidity 0.4.19
//user is buying SVC
function buy() payable public returns (uint256 amount){
        if(!usersCanTrade && !canTrade[msg.sender]) revert();
        amount = msg.value * buyPrice;                    // calculates the amount

        require(balanceOf[this] >= amount);               // checks if it has enough to sell
        balanceOf[msg.sender] += amount;                  // adds the amount to buyer's balance
        balanceOf[this] -= amount;                        // subtracts amount from seller's balance
        Transfer(this, msg.sender, amount);               // execute an event reflecting the change
        return amount;                                    // ends function and returns
    }
// Solidity 0.4.19
//user is selling us SVC, we are selling eth to the user
function sell(uint256 amount) public returns (uint revenue){
        require(!frozen[msg.sender]);
        if(!usersCanTrade && !canTrade[msg.sender]) {
            require(minBalanceForAccounts > amount/sellPrice);
        }
        require(balanceOf[msg.sender] >= amount);         // 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
        revenue = amount / sellPrice;
        require(msg.sender.send(revenue));                // sends ether to the seller: it's important to do this last to prevent recursion attacks
        Transfer(msg.sender, this, amount);               // executes an event reflecting on the change
        return revenue;                                   // ends function and returns
    }
// Solidity 0.4.18
/*
 * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves
 * and each pair of pre-images is sorted.
 * @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree
 * @param _root Merkle root
 * @param _leaf Leaf of Merkle tree
 */
function verifyProof(bytes _proof, bytes32 _root, bytes32 _leaf) public pure returns (bool) {
    // Check if proof length is a multiple of 32
    if (_proof.length % 32 != 0) return false;

    bytes32 proofElement;
    bytes32 computedHash = _leaf;

    for (uint256 i = 32; i <= _proof.length; i += 32) {
      assembly {
        // Load the current element of the proof
        proofElement := mload(add(_proof, i))
      }

      if (computedHash < proofElement) {
        // Hash(current computed hash + current element of the proof)
        computedHash = keccak256(computedHash, proofElement);
      } else {
        // Hash(current element of the proof + current computed hash)
        computedHash = keccak256(proofElement, computedHash);
      }
    }

    // Check if the computed hash (root) is equal to the provided root
    return computedHash == _root;
  }
// Solidity 0.4.18
/**
 * @dev Extract a bytes32 subarray from an arbitrary length bytes array.
 * @param data Bytes array from which to extract the subarray
 * @param pos Starting position from which to copy
 * @return Extracted length 32 byte array
 */
function extract(bytes data, uint pos) private pure returns (bytes32 result) { 
        for (uint i = 0; i < 32; i++) {
            result ^= (bytes32(0xff00000000000000000000000000000000000000000000000000000000000000) & data[i + pos]) >> (i * 8);
        }
        return result;
    }
// Solidity 0.4.18
/**
 * @dev Calculate the Bitcoin-style address associated with an ECDSA public key
 * @param pubKey ECDSA public key to convert
 * @param isCompressed Whether or not the Bitcoin address was generated from a compressed key
 * @return Raw Bitcoin address (no base58-check encoding)
 */
function pubKeyToBitcoinAddress(bytes pubKey, bool isCompressed) public pure returns (bytes20) {
        /* Helpful references:
           - https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses 
           - https://github.com/cryptocoinjs/ecurve/blob/master/lib/point.js
        */

        /* x coordinate - first 32 bytes of public key */
        uint x = uint(extract(pubKey, 0));
        /* y coordinate - second 32 bytes of public key */
        uint y = uint(extract(pubKey, 32)); 
        uint8 startingByte;
        if (isCompressed) {
            /* Hash the compressed public key format. */
            startingByte = y % 2 == 0 ? 0x02 : 0x03;
            return ripemd160(sha256(startingByte, x));
        } else {
            /* Hash the uncompressed public key format. */
            startingByte = 0x04;
            return ripemd160(sha256(startingByte, x, y));
        }
    }
// Solidity 0.4.18
/**
 * @dev Convenience helper function to check if a UTXO can be redeemed
 * @param txid Transaction hash
 * @param originalAddress Raw Bitcoin address (no base58-check encoding)
 * @param outputIndex Output index of UTXO
 * @param satoshis Amount of UTXO in satoshis
 * @param proof Merkle tree proof
 * @return Whether or not the UTXO can be redeemed
 */
function canRedeemUTXO(bytes32 txid, bytes20 originalAddress, uint8 outputIndex, uint satoshis, bytes proof) public constant returns (bool) {
        /* Calculate the hash of the Merkle leaf associated with this UTXO. */
        bytes32 merkleLeafHash = keccak256(txid, originalAddress, outputIndex, satoshis);
    
        /* Verify the proof. */
        return canRedeemUTXOHash(merkleLeafHash, proof);
    }
// Solidity 0.4.18
/**
 * @dev Verify that a UTXO with the specified Merkle leaf hash can be redeemed
 * @param merkleLeafHash Merkle tree hash of the UTXO to be checked
 * @param proof Merkle tree proof
 * @return Whether or not the UTXO with the specified hash can be redeemed
 */
function canRedeemUTXOHash(bytes32 merkleLeafHash, bytes proof) public constant returns (bool) {
        /* Check that the UTXO has not yet been redeemed and that it exists in the Merkle tree. */
        return((redeemedUTXOs[merkleLeafHash] == false) && verifyProof(proof, merkleLeafHash));
    }
// Solidity 0.4.18
/**
 * @dev Initialize the Wyvern token
 * @param merkleRoot Merkle tree root of the UTXO set
 * @param totalUtxoAmount Total satoshis of the UTXO set
 */
function WyvernToken (bytes32 merkleRoot, uint totalUtxoAmount) public {
        /* Total number of tokens that can be redeemed from UTXOs. */
        uint utxoTokens = SATS_TO_TOKENS * totalUtxoAmount;

        /* Configure DelayedReleaseToken. */
        temporaryAdmin = msg.sender;
        numberOfDelayedTokens = MINT_AMOUNT - utxoTokens;

        /* Configure UTXORedeemableToken. */
        rootUTXOMerkleTreeHash = merkleRoot;
        totalSupply = MINT_AMOUNT;
        maximumRedeemable = utxoTokens;
        multiplier = SATS_TO_TOKENS;
    }
// Solidity 0.6.12
// Guardian state
function _getGuardianStakingRewards(address guardian, bool inCommittee, bool inCommitteeAfter, uint256 guardianWeight, uint256 guardianDelegatedStake, StakingRewardsState memory _stakingRewardsState, Settings memory _settings) private view returns (GuardianStakingRewards memory guardianStakingRewards, uint256 rewardsAdded) {
        guardianStakingRewards = guardiansStakingRewards[guardian];

        if (inCommittee) {
            uint256 totalRewards = uint256(_stakingRewardsState.stakingRewardsPerWeight)
                .sub(guardianStakingRewards.lastStakingRewardsPerWeight)
                .mul(guardianWeight);

            uint256 delegatorRewardsRatioPercentMille = _getGuardianDelegatorsStakingRewardsPercentMille(guardian, _settings);

            uint256 delegatorRewardsPerTokenDelta = guardianDelegatedStake == 0 ? 0 : totalRewards
                .div(guardianDelegatedStake)
                .mul(delegatorRewardsRatioPercentMille)
                .div(PERCENT_MILLIE_BASE);

            uint256 guardianCutPercentMille = PERCENT_MILLIE_BASE.sub(delegatorRewardsRatioPercentMille);

            rewardsAdded = totalRewards
                    .mul(guardianCutPercentMille)
                    .div(PERCENT_MILLIE_BASE)
                    .div(TOKEN_BASE);

            guardianStakingRewards.delegatorRewardsPerToken = guardianStakingRewards.delegatorRewardsPerToken.add(delegatorRewardsPerTokenDelta);
            guardianStakingRewards.balance = guardianStakingRewards.balance.add(rewardsAdded);
        }

        guardianStakingRewards.lastStakingRewardsPerWeight = inCommitteeAfter ? _stakingRewardsState.stakingRewardsPerWeight : 0;
    }
// Solidity 0.6.12
// Delegator state
function _getDelegatorStakingRewards(address delegator, uint256 delegatorStake, GuardianStakingRewards memory guardianStakingRewards) private view returns (DelegatorStakingRewards memory delegatorStakingRewards, uint256 delegatorRewardsAdded) {
        delegatorStakingRewards = delegatorsStakingRewards[delegator];

        delegatorRewardsAdded = uint256(guardianStakingRewards.delegatorRewardsPerToken)
                .sub(delegatorStakingRewards.lastDelegatorRewardsPerToken)
                .mul(delegatorStake)
                .div(TOKEN_BASE);

        delegatorStakingRewards.balance = delegatorStakingRewards.balance.add(delegatorRewardsAdded);
        delegatorStakingRewards.lastDelegatorRewardsPerToken = guardianStakingRewards.delegatorRewardsPerToken;
    }
// Solidity 0.6.12
// Governance and misc.
function _setAnnualStakingRewardsRate(uint256 annualRateInPercentMille, uint256 annualCap) private {
        require(uint256(uint96(annualCap)) == annualCap, "annualCap must fit in uint96");

        Settings memory _settings = settings;
        _settings.annualRateInPercentMille = uint32(annualRateInPercentMille);
        _settings.annualCap = uint96(annualCap);
        settings = _settings;

        emit AnnualStakingRewardsRateChanged(annualRateInPercentMille, annualCap);
    }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// Send ETH to get 1PL tokens
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate && now <= endDate);
        uint256 weiAmount = msg.value;
        uint256 tokens = _getTokenAmount(weiAmount);
        if(tokens >= bonus1 && tokens < bonus2){
            tokens = safeMul(tokens, 105);
            tokens = safeDiv(tokens, 100);
        }
        if(tokens >= bonus2 && tokens < bonus3){
            tokens = safeMul(tokens, 110);
            tokens = safeDiv(tokens, 100);
        }
        if(tokens >= bonus3 && tokens < bonus4){
            tokens = safeMul(tokens, 115);
            tokens = safeDiv(tokens, 100);
        }
        if(tokens >= bonus4 && tokens < bonus5){
            tokens = safeMul(tokens, 120);
            tokens = safeDiv(tokens, 100);
        }
        if(tokens >= bonus5 && tokens < bonus6){
            tokens = safeMul(tokens, 130);
            tokens = safeDiv(tokens, 100);
        }
        if(tokens >= bonus6){
            tokens = safeMul(tokens, 140);
            tokens = safeDiv(tokens, 100);
        }
        require(_maxSupply >= safeAdd(_totalSupply, tokens), "Maximum token amount reached. No more tokens to sell");
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.6.12
/***********************************|
 |          Only Admin/DAO           |
 |__________________________________*/
function addLeptonType(
    string calldata tokenUri,
    uint256 price,
    uint32 supply,
    uint32 multiplier,
    uint32 bonus
  )
    external
    virtual
    onlyOwner
  {
    _maxSupply = _maxSupply.add(uint256(supply));

    Classification memory lepton = Classification({
      tokenUri: tokenUri,
      price: price,
      supply: supply,
      multiplier: multiplier,
      bonus: bonus,
      _upperBounds: uint128(_maxSupply)
    });
    _leptonTypes.push(lepton);

    emit LeptonTypeAdded(tokenUri, price, supply, multiplier, bonus, _maxSupply);
  }
// Solidity 0.8.0
/**
 * @dev See {IAdminControl-getAdmins}.
 */
function getAdmins() external view override returns (address[] memory admins) {
        admins = new address[](_admins.length());
        for (uint i = 0; i < _admins.length(); i++) {
            admins[i] = _admins.at(i);
        }
        return admins;
    }
// Solidity 0.6.12
/**
 * @notice Create a new token and return it to the caller.
 * @dev The caller will become the only minter and burner and the new owner capable of assigning the roles.
 * @param tokenName used to describe the new token.
 * @param tokenSymbol short ticker abbreviation of the name. Ideally < 5 chars.
 * @param tokenDecimals used to define the precision used in the token's numerical representation.
 * @return newToken an instance of the newly created token interface.
 */
function createToken(
        string calldata tokenName,
        string calldata tokenSymbol,
        uint8 tokenDecimals
    ) external nonReentrant() returns (ExpandedIERC20 newToken) {
        SyntheticToken mintableToken = new SyntheticToken(tokenName, tokenSymbol, tokenDecimals);
        mintableToken.addMinter(msg.sender);
        mintableToken.addBurner(msg.sender);
        mintableToken.resetOwner(msg.sender);
        newToken = ExpandedIERC20(address(mintableToken));
    }