lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.25
//Investor account statistics
function getInvestorInfo(address addr) public view returns (address, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
		Investor memory investor_info = investors[addr];
		return (investor_info.referer,
		investor_info.investment,
		investor_info.investment_time,
		investor_info.investment_first_time_in_day,
		investor_info.investments_daily,
		investor_info.investment_profit,
		investor_info.referals_profit,
		investor_info.cashback_profit,
		investor_info.investment_profit_balance,
		investor_info.referals_profit_balance,
		investor_info.cashback_profit_balance);
	}
// Solidity 0.8.1
/**
 * @notice Given an amount of EToken, how much TokenA and TokenB have to be deposited, withdrawn for it
 * initial issuance / last redemption: sqrt(amountA * amountB) -> such that the inverse := EToken amount ** 2
 * subsequent issuances / non nullifying redemptions: claim on EToken supply * reserveA/B
 */
function tokenATokenBForEToken(
        IEPool.Tranche memory t,
        uint256 amount,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal view returns (uint256 amountA, uint256 amountB) {
        if (t.reserveA + t.reserveB == 0) {
            uint256 amountsA = amount * sFactorA / t.sFactorE;
            (amountA, amountB) = tokenATokenBForTokenA(
                amountsA * amountsA / sFactorA , t.targetRatio, rate, sFactorA, sFactorB
            );
        } else {
            uint256 eTokenTotalSupply = t.eToken.totalSupply();
            if (eTokenTotalSupply == 0) return(0, 0);
            uint256 share = amount * t.sFactorE / eTokenTotalSupply;
            amountA = share * t.reserveA / t.sFactorE;
            amountB = share * t.reserveB / t.sFactorE;
        }
    }
// Solidity 0.7.0
/**
 * @dev See {IStaking-setStakingOptions}
 *
 * Requirements:
 *
 * - `stakeDurations` and `stakePercentageBasisPoints` arrays passed to
 * this function cannot be empty or have a different length.
 */
function setStakingOptions(
    uint256[] memory stakeDurations,
    uint16[] memory stakePercentageBasisPoints
  ) external override onlyOwner {
    require(
      stakeDurations.length == stakePercentageBasisPoints.length && stakeDurations.length > 0,
      "Staking: stake duration and percentage basis points arrays should be equal in size and non-empty"
    );

    _currentStakeOptionArrayIndex = _currentStakeOptionArrayIndex.add(1);
    for (uint256 i = 0; i < stakeDurations.length; i++) {
      _stakeOptions[_currentStakeOptionArrayIndex].push(
        StakeOption(stakeDurations[i], stakePercentageBasisPoints[i])
      );
    }
  }
// Solidity 0.7.0
/**
 * @dev See {IStaking-getStakingOptions}
 */
function getStakingOptions()
    external
    override
    view
    returns (
      uint256[] memory stakeOptionIndexes,
      uint256[] memory stakeDurations,
      uint16[] memory stakePercentageBasisPoints
    )
  {
    stakeOptionIndexes = new uint256[](_stakeOptions[_currentStakeOptionArrayIndex].length);
    stakeDurations = new uint256[](_stakeOptions[_currentStakeOptionArrayIndex].length);
    stakePercentageBasisPoints = new uint16[](_stakeOptions[_currentStakeOptionArrayIndex].length);

    for (uint256 i = 0; i < _stakeOptions[_currentStakeOptionArrayIndex].length; i++) {
      stakeOptionIndexes[i] = i;
      stakeDurations[i] = _stakeOptions[_currentStakeOptionArrayIndex][i].stakeDuration;
      stakePercentageBasisPoints[i] = _stakeOptions[_currentStakeOptionArrayIndex][i]
        .stakePercentageBasisPoints;
    }

    return (stakeOptionIndexes, stakeDurations, stakePercentageBasisPoints);
  }
// Solidity 0.7.0
/**
 * @dev See {IStaking-getPersonalStakeIndexes}
 */
function getPersonalStakeIndexes(
    address user,
    uint256 amountToRetrieve,
    uint256 offset
  ) external override view returns (uint256[] memory) {
    uint256[] memory indexes;
    (indexes, , , , ) = getPersonalStakes(user, amountToRetrieve, offset);

    return indexes;
  }
// Solidity 0.7.0
/**
 * @dev See {IStaking-getPersonalStakeUnlockedTimestamps}
 */
function getPersonalStakeUnlockedTimestamps(
    address user,
    uint256 amountToRetrieve,
    uint256 offset
  ) external override view returns (uint256[] memory) {
    uint256[] memory timestamps;
    (, timestamps, , , ) = getPersonalStakes(user, amountToRetrieve, offset);

    return timestamps;
  }
// Solidity 0.7.0
/**
 * @dev See {IStaking-getPersonalStakeActualAmounts}
 */
function getPersonalStakeActualAmounts(
    address user,
    uint256 amountToRetrieve,
    uint256 offset
  ) external override view returns (uint256[] memory) {
    uint256[] memory actualAmounts;
    (, , actualAmounts, , ) = getPersonalStakes(user, amountToRetrieve, offset);

    return actualAmounts;
  }
// Solidity 0.7.0
/**
 * @dev See {IStaking-getPersonalStakeForAddresses}
 */
function getPersonalStakeForAddresses(
    address user,
    uint256 amountToRetrieve,
    uint256 offset
  ) external override view returns (address[] memory) {
    address[] memory stakedFor;
    (, , , stakedFor, ) = getPersonalStakes(user, amountToRetrieve, offset);

    return stakedFor;
  }
// Solidity 0.7.0
/**
 * @dev See {IStaking-getPersonalStakePercentageBasisPoints}
 */
function getPersonalStakePercentageBasisPoints(
    address user,
    uint256 amountToRetrieve,
    uint256 offset
  ) external override view returns (uint256[] memory) {
    uint256[] memory stakePercentageBasisPoints;
    (, , , , stakePercentageBasisPoints) = getPersonalStakes(user, amountToRetrieve, offset);

    return stakePercentageBasisPoints;
  }
// Solidity 0.7.0
/**
 * @dev Helper function to get specific properties of all of the personal stakes created by the `user`
 * @param user address The address to query
 * @return (uint256[], uint256[], address[], uint256[] memory)
 *  timestamps array, actualAmounts array, stakedFor array, stakePercentageBasisPoints array
 */
function getPersonalStakes(
    address user,
    uint256 amountToRetrieve,
    uint256 offset
  )
    public
    view
    returns (
      uint256[] memory,
      uint256[] memory,
      uint256[] memory,
      address[] memory,
      uint256[] memory
    )
  {
    StakeContract storage stakeContract = _stakeHolders[user];

    uint256 offsetStakeAmount = stakeContract.personalStakesLastIndex.sub(offset);
    if (amountToRetrieve > offsetStakeAmount) {
      amountToRetrieve = offsetStakeAmount;
    }
    uint256[] memory stakeIndexes = new uint256[](amountToRetrieve);
    uint256[] memory unlockedTimestamps = new uint256[](amountToRetrieve);
    uint256[] memory actualAmounts = new uint256[](amountToRetrieve);
    address[] memory stakedFor = new address[](amountToRetrieve);
    uint256[] memory stakePercentageBasisPoints = new uint256[](amountToRetrieve);

    uint256 retrieved;
    for (uint256 i = stakeContract.personalStakesLastIndex.sub(1).sub(offset); i >= 0; i--) {
      stakeIndexes[retrieved] = i;
      unlockedTimestamps[retrieved] = stakeContract.personalStakes[i].unlockedTimestamp;
      actualAmounts[retrieved] = stakeContract.personalStakes[i].actualAmount;
      stakedFor[retrieved] = stakeContract.personalStakes[i].stakedFor;
      stakePercentageBasisPoints[retrieved] = stakeContract.personalStakes[i]
        .stakePercentageBasisPoints;

      if (++retrieved >= amountToRetrieve) {
        break;
      }
    }

    return (stakeIndexes, unlockedTimestamps, actualAmounts, stakedFor, stakePercentageBasisPoints);
  }
// Solidity 0.7.0
/**
 * @dev Helper function to create stakes for a given address
 * @param user address The address the stake is being created for
 * @param amount uint256 The number of tokens being staked
 * @param lockInDuration uint256 The duration to lock the tokens for
 * @param data bytes optional data to include in the Stake event
 * @param stakePercentageBasisPoints uint16 stake reward percentage (basis points)
 *
 * Requirements:
 *
 * - `_stakingToken` allowance should be granted to {Staking} contract
 * address in order for the stake creation to be successful.
 */
function createStake(
    address user,
    uint256 amount,
    uint256 lockInDuration,
    uint16 stakePercentageBasisPoints,
    bytes calldata data
  ) internal {
    require(
      _stakingToken.transferFrom(_msgSender(), address(this), amount),
      "Staking: stake required"
    );

    if (!_stakeHolders[user].exists) {
      _stakeHolders[user].exists = true;
    }

    uint256 unlockedTimestamp = block.timestamp.add(lockInDuration);
    _stakeHolders[user].totalStakedFor = _stakeHolders[user].totalStakedFor.add(amount);
    _stakeHolders[user].personalStakes[_stakeHolders[user].personalStakesLastIndex] = Stake({
      unlockedTimestamp: unlockedTimestamp,
      actualAmount: amount,
      stakedFor: user,
      stakePercentageBasisPoints: stakePercentageBasisPoints
    });

    emit LogStaked(
      user,
      amount,
      _stakeHolders[user].personalStakesLastIndex,
      unlockedTimestamp,
      stakePercentageBasisPoints,
      totalStakedFor(user),
      data
    );
    _stakeHolders[user].personalStakesLastIndex = _stakeHolders[user].personalStakesLastIndex.add(
      1
    );
  }
// Solidity 0.7.0
/**
 * @dev Helper function to withdraw stakes for the msg.sender
 * @param personalStakeIndex uint256 index of the stake to withdraw in the personalStakes mapping
 * @param data bytes optional data to include in the Unstake event
 *
 * Requirements:
 *
 * - valid personal stake index is passed.
 * - stake should not be already withdrawn.
 * - `_stakingToken` should transfer the stake amount successfully.
 * - `_stakingToken` should {mint} the stake reward successfully
 * if function is called after the stake's `unlockTimestamp`.
 */
function withdrawStake(uint256 personalStakeIndex, bytes calldata data) internal {
    require(
      personalStakeIndex <= _stakeHolders[_msgSender()].personalStakesLastIndex.sub(1),
      "Staking: passed the wrong personal stake index"
    );

    Stake storage personalStake = _stakeHolders[_msgSender()].personalStakes[personalStakeIndex];

    require(personalStake.actualAmount > 0, "Staking: already withdrawn this stake");

    require(
      _stakingToken.transfer(_msgSender(), personalStake.actualAmount),
      "Staking: unable to withdraw the stake"
    );

    uint256 stakeReward = 0;
    if (personalStake.unlockedTimestamp <= block.timestamp) {
      stakeReward = personalStake.actualAmount.mul(personalStake.stakePercentageBasisPoints).div(
        uint256(10000)
      );
      require(
        _stakingToken.mint(_msgSender(), stakeReward),
        "Staking: unable to mint the stake reward"
      );
    }

    _stakeHolders[personalStake.stakedFor].totalStakedFor = _stakeHolders[personalStake.stakedFor]
      .totalStakedFor
      .sub(personalStake.actualAmount);

    emit LogUnstaked(
      personalStake.stakedFor,
      personalStake.actualAmount,
      personalStakeIndex,
      stakeReward,
      totalStakedFor(personalStake.stakedFor),
      data
    );

    personalStake.actualAmount = 0;
  }
// Solidity 0.8.1
/**
 * @notice Given amountB, which amountA is required such that amountB / amountA is equal to the ratio
 * amountA := amountBInTokenA * ratio
 */
function tokenAForTokenB(
        uint256 amountB,
        uint256 ratio,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns(uint256) {
        return (((amountB * sFactorI / sFactorB) * ratio) / rate) * sFactorA / sFactorI;
    }
// Solidity 0.8.1
/**
 * @notice Given an amount of TokenA, how can it be split up proportionally into amountA and amountB
 * according to the ratio
 * amountA := total - (total / (1 + ratio)) == (total * ratio) / (1 + ratio)
 * amountB := (total / (1 + ratio)) * rate
 */
function tokenATokenBForTokenA(
        uint256 _totalA,
        uint256 ratio,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns (uint256 amountA, uint256 amountB) {
        amountA = _totalA - (_totalA * sFactorI / (sFactorI + ratio));
        amountB = (((_totalA * sFactorI / sFactorA) * rate) / (sFactorI + ratio)) * sFactorB / sFactorI;
    }
// Solidity 0.4.18
/**
 * @notice Create a crowdsale contract, a token and initialize them
 * @param _ownerTokens Amount of tokens that will be mint to owner during the sale
 */
function UP1KCrowdsale(uint256 _startTimestamp, uint256 _endTimestamp, uint256 _rate, uint256 _hardCap, 
        uint256 _ownerTokens, uint32 _buyFeeMilliPercent, uint32 _sellFeeMilliPercent, uint256 _minBuyAmount, uint256 _minSellAmount) public {
        require(_startTimestamp < _endTimestamp);
        require(_rate > 0);

        startTimestamp = _startTimestamp;
        endTimestamp = _endTimestamp;
        rate = _rate;
        hardCap = _hardCap;

        token = new UP1KToken();
        token.init(msg.sender, _buyFeeMilliPercent, _sellFeeMilliPercent, _minBuyAmount, _minSellAmount);
        token.mint(msg.sender, _ownerTokens);
    }
// Solidity 0.4.19
/*
 Airdrop function which take up a array of address and amount and call the
 transfer function to send the token
 */
function doAirDrop(address[] _address, uint256 _amount) onlyOwner public returns (bool) {
    uint256 count = _address.length;
    for (uint256 i = 0; i < count; i++)
    {
      /* calling transfer function from contract */
      tokenInstance.transfer(_address [i],_amount);
    }
  }
// Solidity 0.6.6
/**
 * @dev Initializes a buffer with an initial capacity.
 * @param buf The buffer to initialize.
 * @param capacity The number of bytes of space to allocate the buffer.
 * @return The buffer, for chaining.
 */
function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
    if (capacity % 32 != 0) {
      capacity += 32 - (capacity % 32);
    }
    // Allocate space for the buffer data
    buf.capacity = capacity;
    assembly {
      let ptr := mload(0x40)
      mstore(buf, ptr)
      mstore(ptr, 0)
      mstore(0x40, add(32, add(ptr, capacity)))
    }
    return buf;
  }
// Solidity 0.6.6
/**
 * @dev Writes a byte to the buffer. Resizes if doing so would exceed the
 *      capacity of the buffer.
 * @param buf The buffer to append to.
 * @param off The offset to write the byte at.
 * @param data The data to append.
 * @return The original buffer, for chaining.
 */
function writeUint8(buffer memory buf, uint off, uint8 data) internal pure returns(buffer memory) {
    if (off >= buf.capacity) {
      resize(buf, buf.capacity * 2);
    }

    assembly {
      // Memory address of the buffer data
      let bufptr := mload(buf)
      // Length of existing buffer data
      let buflen := mload(bufptr)
      // Address = buffer address + sizeof(buffer length) + off
      let dest := add(add(bufptr, off), 32)
      mstore8(dest, data)
      // Update buffer length if we extended it
      if eq(off, buflen) {
        mstore(bufptr, add(buflen, 1))
      }
    }
    return buf;
  }
// Solidity 0.6.6
/**
 * @dev Writes an integer to the buffer. Resizes if doing so would exceed
 *      the capacity of the buffer.
 * @param buf The buffer to append to.
 * @param off The offset to write at.
 * @param data The data to append.
 * @param len The number of bytes to write (right-aligned).
 * @return The original buffer, for chaining.
 */
function writeInt(buffer memory buf, uint off, uint data, uint len) private pure returns(buffer memory) {
    if (len + off > buf.capacity) {
      resize(buf, (len + off) * 2);
    }

    uint mask = 256 ** len - 1;
    assembly {
      // Memory address of the buffer data
      let bufptr := mload(buf)
      // Address = buffer address + off + sizeof(buffer length) + len
      let dest := add(add(bufptr, off), len)
      mstore(dest, or(and(mload(dest), not(mask)), data))
      // Update buffer length if we extended it
      if gt(add(off, len), mload(bufptr)) {
        mstore(bufptr, add(off, len))
      }
    }
    return buf;
  }
// Solidity 0.6.6
/**
 * @notice Initializes a Chainlink request
 * @dev Sets the ID, callback address, and callback function signature on the request
 * @param self The uninitialized request
 * @param _id The Job Specification ID
 * @param _callbackAddress The callback address
 * @param _callbackFunction The callback function signature
 * @return The initialized request
 */
function initialize(
    Request memory self,
    bytes32 _id,
    address _callbackAddress,
    bytes4 _callbackFunction
  ) internal pure returns (Chainlink.Request memory) {
    Buffer_Chainlink.init(self.buf, defaultBufferSize);
    self.id = _id;
    self.callbackAddress = _callbackAddress;
    self.callbackFunctionId = _callbackFunction;
    return self;
  }
// Solidity 0.6.6
/**
 * @notice Creates a Chainlink request to the specified oracle address
 * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to
 * send LINK which creates a request on the target oracle contract.
 * Emits ChainlinkRequested event.
 * @param _oracle The address of the oracle for the request
 * @param _req The initialized Chainlink Request
 * @param _payment The amount of LINK to send for the request
 * @return requestId The request ID
 */
function sendChainlinkRequestTo(address _oracle, Chainlink.Request memory _req, uint256 _payment)
    internal
    returns (bytes32 requestId)
  {
    requestId = keccak256(abi.encodePacked(this, requestCount));
    _req.nonce = requestCount;
    pendingRequests[requestId] = _oracle;
    emit ChainlinkRequested(requestId);
    require(link.transferAndCall(_oracle, _payment, encodeRequest(_req)), "unable to transferAndCall to oracle");
    requestCount += 1;

    return requestId;
  }
// Solidity 0.6.6
/**
 * @notice Encodes the request to be sent to the oracle contract
 * @dev The Chainlink node expects values to be in order for the request to be picked up. Order of types
 * will be validated in the oracle contract.
 * @param _req The initialized Chainlink Request
 * @return The bytes payload for the `transferAndCall` method
 */
function encodeRequest(Chainlink.Request memory _req)
    private
    view
    returns (bytes memory)
  {
    return abi.encodeWithSelector(
      oracle.oracleRequest.selector,
      SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address
      AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent
      _req.id,
      _req.callbackAddress,
      _req.callbackFunctionId,
      _req.nonce,
      ARGS_VERSION,
      _req.buf.buf);
  }
// Solidity 0.6.6
/**
 		* @dev  This function can be executed by any user out there to calculate the amount of UNP they can claim.
 		*       The function creates a Chainlink Request to get a single user's total claimable tokens (tokens_to_claim) using the BASE_URL + the user's address
 		*
 		*       Example URL: https://BASE_URL/ADDRESS
 		*
 		*       and saves the request ID mapped to the users address to get users address back in the callback function setTokensToClaim()
 	*/
function getTokensToClaimByAddress() public payable {
		require(msg.value >= gasCosts, "You have to send more eth to cover gas costs");
		Chainlink.Request memory req = buildChainlinkRequest(stringToBytes32(jobId), address(this), this.setTokensToClaim.selector);
		req.add("get", BASE_URL);
		req.add("extPath", addressToString(msg.sender));
		req.add("path", "tokens_to_claim");

		bytes32 requestId = sendChainlinkRequestTo(oracle, req, 0);
		requestIdByAddress[requestId] = msg.sender;

		nodeAddress.transfer(msg.value);
	}
// Solidity 0.6.6
/**
 		* @dev              Convertes a String to Bytes32
 		* @param source     source string to be converted
 	*/
function stringToBytes32(string memory source) private pure returns (bytes32 result) {
		bytes memory tempEmptyStringTest = bytes(source);
		if (tempEmptyStringTest.length == 0) {
			return 0x0;
		}

		assembly {// solhint-disable-line no-inline-assembly
			result := mload(add(source, 32))
		}
	}
// Solidity 0.6.6
/**
 		* @dev      Convertes an address to string
 		* @param x  address you want to converte
 	*/
function addressToString(address x) internal pure returns (string memory) {
		bytes memory s = new bytes(40);
		for (uint i = 0; i < 20; i++) {
			byte b = byte(uint8(uint(x) / (2 ** (8 * (19 - i)))));
			byte hi = byte(uint8(b) / 16);
			byte lo = byte(uint8(b) - 16 * uint8(hi));
			s[2 * i] = char(hi);
			s[2 * i + 1] = char(lo);
		}
		return string(s);
	}
// Solidity 0.4.25
// =============
// ==================
// Crowdsale Stage Management
// =========================================================
// Change Crowdsale Stage. Available Options: PrivateSale, ICOFirstStage, ICOSecondStage, ICOThirdStage
function setCrowdsaleStage(uint value) public onlyOwner {
      CrowdsaleStage _stage;
      if (uint(CrowdsaleStage.PrivateSale) == value) {
        _stage = CrowdsaleStage.PrivateSale;
      } else if (uint(CrowdsaleStage.ICOFirstStage) == value) {
        _stage = CrowdsaleStage.ICOFirstStage;
      } else if (uint(CrowdsaleStage.ICOSecondStage) == value) {
        _stage = CrowdsaleStage.ICOSecondStage;
      } else if (uint(CrowdsaleStage.ICOThirdStage) == value) {
        _stage = CrowdsaleStage.ICOThirdStage;
      }
      stage = _stage;
      if (stage == CrowdsaleStage.PrivateSale) {
        setCurrentBonusPercent(30);
      } else if (stage == CrowdsaleStage.ICOFirstStage) {
        setCurrentBonusPercent(15);
      } else if (stage == CrowdsaleStage.ICOSecondStage) {
        setCurrentBonusPercent(5);
      } else if (stage == CrowdsaleStage.ICOThirdStage) {
        setCurrentBonusPercent(0);
      }
   }
// Solidity 0.4.25
// ===========================
// Final distribution and crowdsale finalization
// ====================================================================
function finish(address _teamFund, address _reserveFund, address _bountyFund, address _advisoryFund) public onlyOwner {
      require(!isFinalized);
      uint256 alreadyMinted = token.totalSupply();
      uint256 tokensForTeam = alreadyMinted.mul(15).div(100);
      uint256 tokensForBounty = alreadyMinted.mul(2).div(100);
      uint256 tokensForReserve = alreadyMinted.mul(175).div(1000);
      uint256 tokensForAdvisors = alreadyMinted.mul(35).div(1000);
      token.mint(_teamFund,tokensForTeam);
      token.mint(_bountyFund,tokensForBounty);
      token.mint(_reserveFund,tokensForReserve);
      token.mint(_advisoryFund,tokensForAdvisors);
      finalize();
  }
// Solidity 0.7.3
/**
 * @dev Set the fee divisor for the specified token
 */
function setFeeDivisor(address token, uint256 _feeDivisor) external override returns (uint256 oldDivisor) {
        require(operator == msg.sender, "UNAUTHORIZED");
        require(_feeDivisor != 0, "DIVISIONBYZERO");
        oldDivisor = feeDivisors[token];
        feeDivisors[token] = _feeDivisor;
        emit FeeDivisorChanged(operator, token, oldDivisor, _feeDivisor);
    }
// Solidity 0.8.7
//minting a new NFT
function mint(uint number) payable public {
        require(saleState_ == State.OpenSale, 'Sale is not open yet!');
        require(totalSupply() + number <= maxTokens, 'No more NFTs left to mint!');
        require(msg.value >= mintCost() * number, 'Insufficient Funds, Check current price to Mint');
        require(mintsPerAddress[msg.sender] + number <= maxMint, 'Maximum Mints per Address reached!');
        
        for (uint i = 0; i < number; i++) {
            uint tid = tokenId();
            _safeMint(msg.sender, tid);
            mintsPerAddress[msg.sender] += 1;
        }
        
    }