lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
// View function to see rewardPer YFBTC block  on frontend.
function rewardPerBlock(uint256 _pid) external view returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        uint256 accYfbtcPerShare = pool.accYfbtcPerShare;
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        if (block.number > pool.lastRewardBlock && lpSupply != 0) {

            uint256 yfbtcReward = getMultiplier(pool.lastRewardBlock, block.number);
            uint totalPoolsEligible = getEligiblePools();

            uint distribution = yfbtcMultiplier + totalPoolsEligible - 1;
            uint256 rewardPerPool = yfbtcReward.div(distribution);
        
            if (address(pool.lpToken) == token1){
              accYfbtcPerShare = accYfbtcPerShare.add(rewardPerPool.mul(yfbtcMultiplier).mul(1e12).div(lpSupply));
            }else{
              accYfbtcPerShare = accYfbtcPerShare.add(rewardPerPool.mul(1e12).div(lpSupply));
            }
        }
        return accYfbtcPerShare;
    }
// Solidity 0.4.24
//  findEmptySlot(): find the index of the first empty claim slot
//
//    returns the index of the slot, throws if there are no empty slots
//
function findEmptySlot(uint32 _whose)
    internal
    view
    returns (uint8 index)
  {
    Claim[maxClaims] storage theirClaims = claims[_whose];
    for (uint8 i = 0; i < maxClaims; i++)
    {
      Claim storage thisClaim = theirClaims[i];
      if ( (0 == bytes(thisClaim.protocol).length) &&
           (0 == bytes(thisClaim.claim).length) )
      {
        return i;
      }
    }
    revert();
  }
// Solidity 0.6.12
// let user exist in case of emergency
function emergencyWithdraw(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        uint256 amount = user.amount;
        user.amount = 0;
        user.rewardDebt = 0;
        pool.lpToken.safeTransfer(address(msg.sender), amount);
        pool.totalSupply = pool.totalSupply.sub(amount);
        emit EmergencyWithdraw(msg.sender, _pid, amount);
    }
// Solidity 0.8.4
// this rerolls all the slots of a pet besides skin/type
function rerollPet(uint256 serialId) public {
    require(isRerollAllEnabled, "Reroll is not enabled");
    require(msg.sender == ownerOf(serialId), "Only owner can reroll.");
    require(
      block.timestamp - serialIdToTimeRedeemed[serialId] <= ONE_DAY,
      "Can not reroll after one day"
    );

    string memory pet = serialIdToPet[serialId];
    string memory petSkinAsString = substring(pet, 0, 2);
    string memory petTypeAsString = substring(pet, 2, 4);
    uint256 petSkin = convertToUint(petSkinAsString);
    uint256 petType = convertToUint(petTypeAsString);

    Attributes memory attributes = generateAttributes(serialId);
    string memory rerolledPet = createPetStringRepresentation(
      petSkin,
      petType,
      attributes
    );

    if (existingPets[rerolledPet]) {
      uint256[] memory validSlots = getValidSlotsForReroll(attributes);
      uint256 randomSlotIndex = getRandomNumber(petType, petSkin, serialId) %
        validSlots.length;
      rerolledPet = _rerollPet(
        serialId,
        petSkin,
        petType,
        attributes,
        validSlots[randomSlotIndex],
        rerolledPet,
        false
      );
    }
    require(
      !existingPets[rerolledPet],
      "Could not reroll into a valid pet, please try again."
    );
    serialIdToPet[serialId] = rerolledPet;
    existingPets[rerolledPet] = true;
    existingPets[pet] = false;
    emit ZPet(msg.sender, serialId, rerolledPet, true);
  }
// Solidity 0.5.12
/// @dev ISavingStrategy.investUnderlying implementation
function investUnderlying(uint256 investAmount) external onlyOwner returns (uint256) {
        token.transferFrom(msg.sender, address(this), investAmount);
        token.approve(address(cToken), investAmount);
        uint256 cTotalBefore = cToken.totalSupply();
        // TODO should we handle mint failure?
        require(cToken.mint(investAmount) == 0, "mint failed");
        uint256 cTotalAfter = cToken.totalSupply();
        uint256 cCreatedAmount;
        require (cTotalAfter >= cTotalBefore, "Compound minted negative amount!?");
        cCreatedAmount = cTotalAfter - cTotalBefore;
        return cCreatedAmount;
    }
// Solidity 0.5.12
/// @dev ISavingStrategy.redeemUnderlying implementation
function redeemUnderlying(uint256 redeemAmount) external onlyOwner returns (uint256) {
        uint256 cTotalBefore = cToken.totalSupply();
        // TODO should we handle redeem failure?
        require(cToken.redeemUnderlying(redeemAmount) == 0, "cToken.redeemUnderlying failed");
        uint256 cTotalAfter = cToken.totalSupply();
        uint256 cBurnedAmount;
        require(cTotalAfter <= cTotalBefore, "Compound redeemed negative amount!?");
        cBurnedAmount = cTotalBefore - cTotalAfter;
        token.transfer(msg.sender, redeemAmount);
        return cBurnedAmount;
    }
// Solidity 0.8.7
/**
 * @notice Claim ERC20-compliant tokens other than locked token.
 * @param tokenToClaim Token to claim balance of.
 */
function claimToken(IERC20 tokenToClaim) external onlyBeneficiary() nonReentrant() {
        require(address(tokenToClaim) != address(token()), "smart-timelock/no-locked-token-claim");
        uint256 preAmount = token().balanceOf(address(this));

        uint256 claimableTokenAmount = tokenToClaim.balanceOf(address(this));
        require(claimableTokenAmount > 0, "smart-timelock/no-token-balance-to-claim");

        tokenToClaim.transfer(beneficiary(), claimableTokenAmount);

        uint256 postAmount = token().balanceOf(address(this));
        require(postAmount >= preAmount, "smart-timelock/locked-balance-check");

        emit ClaimToken(tokenToClaim, claimableTokenAmount);
    }
// Solidity 0.5.2
/**
 * @dev change AdminTols deployer address
 * @param _newATD new AT deployer address
 */
function changeATFactoryAddress(address _newATD) external onlyOwner {
        require(block.number < 8850000, "Time expired!");
        require(_newATD != address(0), "Address not suitable!");
        require(_newATD != ATDAddress, "AT factory address not changed!");
        ATDAddress = _newATD;
        deployerAT = IATDeployer(ATDAddress);
        emit ATFactoryAddressChanged();
    }
// Solidity 0.5.2
/**
 * @dev change Token deployer address
 * @param _newTD new T deployer address
 */
function changeTDeployerAddress(address _newTD) external onlyOwner {
        require(block.number < 8850000, "Time expired!");
        require(_newTD != address(0), "Address not suitable!");
        require(_newTD != TDAddress, "AT factory address not changed!");
        TDAddress = _newTD;
        deployerT = ITDeployer(TDAddress);
        emit TFactoryAddressChanged();
    }
// Solidity 0.5.2
/**
 * @dev change Funding Panel deployer address
 * @param _newFPD new FP deployer address
 */
function changeFPDeployerAddress(address _newFPD) external onlyOwner {
        require(block.number < 8850000, "Time expired!");
        require(_newFPD != address(0), "Address not suitable!");
        require(_newFPD != ATDAddress, "AT factory address not changed!");
        FPDAddress = _newFPD;
        deployerFP = IFPDeployer(FPDAddress);
        emit FPFactoryAddressChanged();
    }
// Solidity 0.5.2
/**
 * @dev set internal DEX address
 * @param _dexAddress internal DEX address
 */
function setInternalDEXAddress(address _dexAddress) external onlyOwner {
        require(block.number < 8850000, "Time expired!");
        require(_dexAddress != address(0), "Address not suitable!");
        require(_dexAddress != internalDEXAddress, "AT factory address not changed!");
        internalDEXAddress = _dexAddress;
        emit InternalDEXAddressChanged();
    }
// Solidity 0.7.6
/**
 * @dev getSaleData : SaleData Return
 */
function getSaleData(uint256 id) external view 
        returns (
            address         
            ,bool
            ,uint256
            ,uint256
            ,address
            ,uint256
            ,uint256
            ,address
            ,uint256
            ,uint256
            ,bool
            ,bool 
        ) {        
            SaleData memory sd = _sales[id];
            return (
                sd.seller            
                ,sd.isAuction
                ,sd.nftId
                ,sd.volume
                ,sd.erc20
                ,sd.price
                ,sd.bid
                ,sd.buyer
                ,sd.start
                ,sd.end
                ,sd.isCanceled
                ,sd.isSettled
            );
    }
// Solidity 0.4.20
/// @dev Adds an auction to the list of open auctions. Also fires the
///  AuctionCreated event.
/// @param _tokenId The ID of the token to be put on auction.
/// @param _auction Auction to add.
function _addAuction(address _nft, uint256 _tokenId, Auction _auction) internal {
        // Require that all auctions have a duration of
        // at least one minute. (Keeps our math from getting hairy!)
        require(_auction.duration >= 1 minutes);

        nftToTokenIdToAuction[_nft][_tokenId] = _auction;
        
        AuctionCreated(
            address(_nft),
            uint256(_tokenId),
            uint256(_auction.startingPrice),
            uint256(_auction.endingPrice),
            uint256(_auction.duration)
        );
    }
// Solidity 0.4.20
/// @dev Returns current price of an NFT on auction. Broken into two
///  functions (this one, that computes the duration from the auction
///  structure, and the other that does the price computation) so we
///  can easily test that the price computation works correctly.
function _currentPrice(Auction storage _auction)
        internal
        view
        returns (uint256)
    {
        uint256 secondsPassed = 0;
        
        // A bit of insurance against negative values (or wraparound).
        // Probably not necessary (since Ethereum guarnatees that the
        // now variable doesn't ever go backwards).
        if (now > _auction.startedAt) {
            secondsPassed = now - _auction.startedAt;
        }

        return _computeCurrentPrice(
            _auction.startingPrice,
            _auction.endingPrice,
            _auction.duration,
            secondsPassed
        );
    }
// Solidity 0.4.20
/// @dev Computes owner's cut of a sale.
/// @param _price - Sale price of NFT.
function _computeCut(uint256 _price) internal view returns (uint256) {
        // NOTE: We don't use SafeMath (or similar) in this function because
        //  all of our entry functions carefully cap the maximum values for
        //  currency (at 128-bits), and ownerCut <= 10000 (see the require()
        //  statement in the ClockAuction constructor). The result of this
        //  function is always guaranteed to be <= _price.
        return _price * ownerCut / 10000;
    }
// Solidity 0.4.20
/// @dev Creates and begins a new auction.
/// @param _nftAddress - address of a deployed contract implementing
///  the Nonfungible Interface.
/// @param _tokenId - ID of token to auction, sender must be owner.
/// @param _startingPrice - Price of item (in wei) at beginning of auction.
/// @param _endingPrice - Price of item (in wei) at end of auction.
/// @param _duration - Length of time to move between starting
///  price and ending price (in seconds).
/// @param _seller - Seller, if not the message sender
function createAuction(
        address _nftAddress,
        uint256 _tokenId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration,
        address _seller
    )
        public
        whenNotPaused
        canBeStoredWith128Bits(_startingPrice)
        canBeStoredWith128Bits(_endingPrice)
        canBeStoredWith64Bits(_duration)
    {
        require(_owns(_nftAddress, msg.sender, _tokenId));
        _escrow(_nftAddress, msg.sender, _tokenId);
        Auction memory auction = Auction(
            _nftAddress,
            _seller,
            uint128(_startingPrice),
            uint128(_endingPrice),
            uint64(_duration),
            uint64(now)
        );
        _addAuction(_nftAddress, _tokenId, auction);
    }
// Solidity 0.4.20
/// @dev Returns auction info for an NFT on auction.
/// @param _nftAddress - Address of the NFT.
/// @param _tokenId - ID of NFT on auction.
function getAuction(address _nftAddress, uint256 _tokenId)
        public
        view
        returns
    (
        address seller,
        uint256 startingPrice,
        uint256 endingPrice,
        uint256 duration,
        uint256 startedAt
    ) {
        Auction storage auction = nftToTokenIdToAuction[_nftAddress][_tokenId];
        require(_isOnAuction(auction));
        return (
            auction.seller,
            auction.startingPrice,
            auction.endingPrice,
            auction.duration,
            auction.startedAt
        );
    }
// Solidity 0.4.20
/// @dev Creates and begins a new auction.
/// @param _nftAddress - The address of the NFT.
/// @param _tokenId - ID of token to auction, sender must be owner.
/// @param _startingPrice - Price of item (in wei) at beginning of auction.
/// @param _endingPrice - Price of item (in wei) at end of auction.
/// @param _duration - Length of auction (in seconds).
function createAuction(
        address _nftAddress,
        uint256 _tokenId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration
    )
        public
        canBeStoredWith128Bits(_startingPrice)
        canBeStoredWith128Bits(_endingPrice)
        canBeStoredWith64Bits(_duration)
    {
        address seller = msg.sender;
        _escrow(_nftAddress, seller, _tokenId);
        Auction memory auction = Auction(
            _nftAddress,
            seller,
            uint128(_startingPrice),
            uint128(_endingPrice),
            uint64(_duration),
            uint64(now)
        );
        _addAuction(_nftAddress, _tokenId, auction);
    }
// Solidity 0.5.2
/**
 * @dev deploy a new set of contracts for the Panel, with all params needed by contracts. Set the minter address for Token contract,
 * Owner is set as a manager in WL, Funding and FundsUnlocker, DEX is whitelisted
 * @param _name name of the token to be deployed
 * @param _symbol symbol of the token to be deployed
 * @param _setDocURL URL of the document describing the Panel
 * @param _setDocHash hash of the document describing the Panel
 * @param _exchRateSeed exchange rate between SEED tokens received and tokens given to the SEED sender (multiply by 10^_exchRateDecim)
 * @param _exchRateOnTop exchange rate between SEED token received and tokens minted on top (multiply by 10^_exchRateDecim)
 * @param _seedMaxSupply max supply of SEED tokens accepted by this contract
 * @param _WLAnonymThr max anonym threshold
 */
function deployPanelContracts(string memory _name, string memory _symbol, string memory _setDocURL, bytes32 _setDocHash,
                            uint256 _exchRateSeed, uint256 _exchRateOnTop, uint256 _seedMaxSupply, uint256 _WLAnonymThr) public {
        address sender = msg.sender;

        require(sender != address(0), "Sender Address is zero");
        require(internalDEXAddress != address(0), "Internal DEX Address is zero");

        deployers[sender] = true;
        deployerList.push(sender);
        deployerLength = deployerList.length;

        address newAT = deployerAT.newAdminTools(_WLAnonymThr);
        ATContracts[newAT] = true;
        ATContractsList.push(newAT);
        address newT = deployerT.newToken(sender, _name, _symbol, newAT);
        TContracts[newT] = true;
        TContractsList.push(newT);
        address newFP = deployerFP.newFundingPanel(sender, _setDocURL, _setDocHash, _exchRateSeed, _exchRateOnTop,
                                            seedAddress, _seedMaxSupply, newT, newAT, (deployerLength-1));
        FPContracts[newFP] = true;
        FPContractsList.push(newFP);

        IAdminTools ATBrandNew = IAdminTools(newAT);
        ATBrandNew.setFFPAddresses(address(this), newFP);
        ATBrandNew.setMinterAddress(newFP);
        ATBrandNew.addWLManagers(address(this));
        ATBrandNew.addWLManagers(sender);
        ATBrandNew.addFundingManagers(sender);
        ATBrandNew.addFundsUnlockerManagers(sender);
        ATBrandNew.setWalletOnTopAddress(sender);

        uint256 dexMaxAmnt = _exchRateSeed.mul(300000000);  //Seed total supply
        ATBrandNew.addToWhitelist(internalDEXAddress, dexMaxAmnt);

        uint256 onTopMaxAmnt = _seedMaxSupply.mul(_exchRateSeed).div(10**18);
        ATBrandNew.addToWhitelist(sender, onTopMaxAmnt);

        ATBrandNew.removeWLManagers(address(this));

        Ownable customOwnable = Ownable(newAT);
        customOwnable.transferOwnership(sender);

        emit NewPanelCreated(sender, newAT, newT, newFP, deployerLength);
    }
// Solidity 0.4.24
//  tokenURI(): returns a URL to an ERC-721 standard JSON file
//
function tokenURI(uint256 _tokenId)
      public
      view
      validPointId(_tokenId)
      returns (string _tokenURI)
    {
      _tokenURI = "https://azimuth.network/erc721/0000000000.json";
      bytes memory _tokenURIBytes = bytes(_tokenURI);
      _tokenURIBytes[31] = byte(48+(_tokenId / 1000000000) % 10);
      _tokenURIBytes[32] = byte(48+(_tokenId / 100000000) % 10);
      _tokenURIBytes[33] = byte(48+(_tokenId / 10000000) % 10);
      _tokenURIBytes[34] = byte(48+(_tokenId / 1000000) % 10);
      _tokenURIBytes[35] = byte(48+(_tokenId / 100000) % 10);
      _tokenURIBytes[36] = byte(48+(_tokenId / 10000) % 10);
      _tokenURIBytes[37] = byte(48+(_tokenId / 1000) % 10);
      _tokenURIBytes[38] = byte(48+(_tokenId / 100) % 10);
      _tokenURIBytes[39] = byte(48+(_tokenId / 10) % 10);
      _tokenURIBytes[40] = byte(48+(_tokenId / 1) % 10);
    }
// Solidity 0.4.24
//
//  Point rules
//
//  getSpawnLimit(): returns the total number of children the _point
//                   is allowed to spawn at _time.
//
function getSpawnLimit(uint32 _point, uint256 _time)
      public
      view
      returns (uint32 limit)
    {
      Azimuth.Size size = azimuth.getPointSize(_point);

      if ( size == Azimuth.Size.Galaxy )
      {
        return 255;
      }
      else if ( size == Azimuth.Size.Star )
      {
        //  in 2019, stars may spawn at most 1024 planets. this limit doubles
        //  for every subsequent year.
        //
        //    Note: 1546300800 corresponds to 2019-01-01
        //
        uint256 yearsSince2019 = (_time - 1546300800) / 365 days;
        if (yearsSince2019 < 6)
        {
          limit = uint32( 1024 * (2 ** yearsSince2019) );
        }
        else
        {
          limit = 65535;
        }
        return limit;
      }
      else  //  size == Azimuth.Size.Planet
      {
        //  planets can create moons, but moons aren't on the chain
        //
        return 0;
      }
    }
// Solidity 0.5.12
// Retrieve amount from unused lockBoxes
function withdrawUnusedYield(uint256 lockBoxNumber) public onlyOwner {
        // Check for deposit time end
        require(now > endDepositTime, "Deposit still possible.");
        
        LockBoxStruct storage l = lockBoxStructs[lockBoxNumber];
        
        // Check for non-deposition of tokens
        require(l.tokensDeposited == false, "Tokens were deposited, active lockbox!");
        uint256 amount = l.balance;
        l.balance = 0;
        require(token.transfer(yieldWallet, amount), "Tokens cannot be transferred.");
    }
// Solidity 0.4.24
//  setTransferProxy(): give _transferProxy the right to transfer _point
//
//    Requirements:
//    - :msg.sender must be either _point's current owner,
//      or be an operator for the current owner
//
function setTransferProxy(uint32 _point, address _transferProxy)
      public
    {
      //  owner: owner of _point
      //
      address owner = azimuth.getOwner(_point);

      //  caller must be :owner, or an operator designated by the owner.
      //
      require((owner == msg.sender) || azimuth.isOperator(owner, msg.sender));

      //  set transfer proxy field in Azimuth contract
      //
      azimuth.setTransferProxy(_point, _transferProxy);

      //  emit Approval event
      //
      emit Approval(owner, _transferProxy, uint256(_point));
    }
// Solidity 0.5.16
/**
 * @dev Redeem user mintable tokens. Only the mining contract can redeem tokens.
 * @param to The user that will receive the redeemed token.     
 * @param amount The amount of tokens to be withdrawn
 * @return The result of the redeem
 */
function redeem(address to, uint256 amount) external returns (bool success) {
        require(msg.sender == mintableAddress);    
        require(_isIssuable == true);
        require(amount > 0);

        // The total amount of redeem tokens to the user.
        _amountRedeem[to] += amount;

        // Mint new tokens and send the funds to the account `mintableAddress`
        // Users can withdraw funds.
        mintToken(mintableAddress, amount);

        return true;
    }
// Solidity 0.5.16
/**
 * @dev The user can withdraw his minted tokens.
 * @param amount The amount of tokens to be withdrawn
 * @return The result of the withdraw
 */
function withdraw(uint256 amount) public returns (bool success) {
        require(_isIssuable == true);

        // Safety check
        require(amount > 0);        
        require(amount <= _amountRedeem[msg.sender]);
        require(amount >= MIN_WITHDRAW_AMOUNT);

        // Transfer the amount of tokens in the mining contract `mintableAddress` to the user account
        require(balances[mintableAddress] >= amount);

        // The balance of the user redeemed tokens.
        _amountRedeem[msg.sender] -= amount;

        // Keep track of the tokens minted by the user.
        _amountMinted[msg.sender] += amount;

        balances[mintableAddress] -= amount;
        balances[msg.sender] += amount;
        
        emit Transfer(mintableAddress, msg.sender, amount);
        return true;               
    }
// Solidity 0.5.4
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - Zero value transfers are allowed
// - takes in locking Period to lock the tokens to be used
// - if want to transfer without locking enter zero in lockingPeriod argument 
// ------------------------------------------------------------------------
function distributeTokens(address to, uint tokens, uint256 lockingPeriod) onlyOwner public returns (bool success) {
            // transfer tokens to the "to" address
            transfer(to, tokens);
            // if there is no lockingPeriod, add coins to unLockedCoins per address
            if(lockingPeriod == 0)
                unLockedCoins[to] = unLockedCoins[to].add(tokens);
            // if there is a lockingPeriod, add coins to record mapping
            else
                _addRecord(to, tokens, lockingPeriod);
            return true;
        }