lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.17
/**
 * @dev Internal function to deposit all accrued fees on interest back into the fund on behalf of the master beneficiary.
 * @return Integer indicating success (0), no fees to claim (1), or no RFT to mint (2).
 */
function _depositFees() internal fundEnabled cacheRawFundBalance returns (uint8) {
        // Input validation
        require(_interestFeeMasterBeneficiary != address(0), "Master beneficiary cannot be the zero address.");

        // Get and validate unclaimed interest fees
        uint256 amountUsd = getInterestFeesUnclaimed();
        if (amountUsd <= 0) return 1;

        // Calculate RFT amount to mint and validate
        uint256 rftTotalSupply = rariFundToken.totalSupply();
        uint256 rftAmount = 0;

        if (rftTotalSupply > 0) {
            uint256 fundBalanceUsd = getFundBalance();
            if (fundBalanceUsd > 0) rftAmount = amountUsd.mul(rftTotalSupply).div(fundBalanceUsd);
            else rftAmount = amountUsd;
        } else rftAmount = amountUsd;

        if (rftAmount <= 0) return 2;

        // Update claimed interest fees and net deposits, mint RFT, emit events, and return no error
        _interestFeesClaimed = _interestFeesClaimed.add(amountUsd);
        _netDeposits = _netDeposits.add(int256(amountUsd));
        require(rariFundToken.mint(_interestFeeMasterBeneficiary, rftAmount), "Failed to mint output tokens.");
        emit Deposit("USD", _interestFeeMasterBeneficiary, _interestFeeMasterBeneficiary, amountUsd, amountUsd, rftAmount);
        emit InterestFeeDeposit(_interestFeeMasterBeneficiary, amountUsd);

        // Update RGT distribution speeds
        updateRgtDistributionSpeeds();

        // Return no error
        return 0;
    }
// Solidity 0.5.17
/**
 * @notice Deposits all accrued fees on interest back into the fund on behalf of the master beneficiary.
 * @return Boolean indicating success.
 */
function depositFees() external onlyRebalancer {
        uint8 result = _depositFees();
        require(result == 0, result == 2 ? "Deposit amount is so small that no RFT would be minted." : "No new fees are available to claim.");
    }
// Solidity 0.5.17
/**
 * @dev Sets the withdrawal fee rate.
 * @param rate The proportion of every withdrawal taken as a service fee (scaled by 1e18).
 */
function setWithdrawalFeeRate(uint256 rate) external fundEnabled onlyOwner {
        require(rate != _withdrawalFeeRate, "This is already the current withdrawal fee rate.");
        require(rate <= 1e18, "The withdrawal fee rate cannot be greater than 100%.");
        _withdrawalFeeRate = rate;
    }
// Solidity 0.8.12
//===============================================================================================================
//===============================================================================================================
//===============================================================================================================
// Ownable removed as a lib and added here to allow for custom transfers and renouncements.
// This allows for removal of ownership privileges from the owner once renounced or transferred.
function transferOwner(address newOwner) external onlyOwner {
        require(newOwner != address(0), "Call renounceOwnership to transfer owner to the zero address.");
        require(newOwner != DEAD, "Call renounceOwnership to transfer owner to the zero address.");
        setExcludedFromFees(_owner, false);
        setExcludedFromFees(newOwner, true);
        
        if(balanceOf(_owner) > 0) {
            _transfer(_owner, newOwner, balanceOf(_owner));
        }
        
        _owner = newOwner;
        emit OwnershipTransferred(_owner, newOwner);
        
    }
// Solidity 0.6.12
/// @notice Initializes the Prize Pool and Yield Service with the required contract connections
/// @param _controlledTokens Array of addresses for the Ticket and Sponsorship Tokens controlled by the Prize Pool
/// @param _maxExitFeeMantissa The maximum exit fee size, relative to the withdrawal amount
/// @param _yieldSource Address of the yield source
function initializeYieldSourcePrizePool (
    RegistryInterface _reserveRegistry,
    ControlledTokenInterface[] memory _controlledTokens,
    uint256 _maxExitFeeMantissa,
    IYieldSource _yieldSource
  )
    public
    initializer
  {
    require(address(_yieldSource).isContract(), "YieldSourcePrizePool/yield-source-not-contract-address");
    PrizePool.initialize(
      _reserveRegistry,
      _controlledTokens,
      _maxExitFeeMantissa
    );
    yieldSource = _yieldSource;

    // A hack to determine whether it's an actual yield source
    (bool succeeded,) = address(_yieldSource).staticcall(abi.encode(_yieldSource.depositToken.selector));
    require(succeeded, "YieldSourcePrizePool/invalid-yield-source");

    emit YieldSourcePrizePoolInitialized(address(_yieldSource));
  }
// Solidity 0.5.16
/**
 * @dev Transfer underlying token interest earned to recipient
 * @return uint256 Amount dispensed
 */
function dispenseEarning() public returns (uint256) {
        if (earningRecipient == address(0)) {
           return 0;
        }

        uint256 earnings = calcUndispensedEarningInUnderlying();
        // total dispense amount = earning + withdraw fee
        uint256 totalDispenseAmount =  earnings.add(balanceInUnderlying());
        if (totalDispenseAmount < earningDispenseThreshold) {
           return 0;
        }

        // Withdraw earning from provider
        _withdrawFromProvider(earnings);

        // Transfer earning + withdraw fee to recipient
        IERC20(underlyingToken).safeTransfer(earningRecipient, totalDispenseAmount);

        emit Dispensed(underlyingToken, totalDispenseAmount);

        return totalDispenseAmount;
    }
// Solidity 0.5.16
/**
 * @dev Transfer reward token earned to recipient
 * @return uint256 Amount dispensed
 */
function dispenseReward() public returns (uint256) {
        if (rewardRecipient == address(0)) {
           return 0;
        }

        uint256 rewards = calcUndispensedProviderReward();
        if (rewards < rewardDispenseThreshold) {
           return 0;
        }

        // Transfer COMP rewards to recipient
        IERC20(rewardToken).safeTransfer(rewardRecipient, rewards);

        emit Dispensed(rewardToken, rewards);

        return rewards;
    }
// Solidity 0.4.19
// add new team percentage of tokens
function addTeamAddressInternal(address addr, uint release_time, uint token_percentage) internal {
	if((team_token_percentage_total.add(token_percentage)) > team_token_percentage_max) revert();
	if((team_token_percentage_total.add(token_percentage)) > 100) revert();
	if(team_addresses_token_percentage[addr] != 0) revert();
	
	team_addresses_token_percentage[addr]= token_percentage;
	team_addresses_idx[team_address_count]= addr;
	team_address_count++;
	
	team_token_percentage_total = team_token_percentage_total.add(token_percentage);

	AddTeamAddress(addr, release_time, token_percentage);
  }
// Solidity 0.4.19
/* Crowdfund state machine management. */
function getState() public constant returns (State) {
    if(finalized) return State.Finalized;
    else if (now < startsAt) return State.PreFunding;
    else if (now <= endsAt && !isMinimumGoalReached()) return State.Funding;
    else if (isMinimumGoalReached()) return State.Success;
    else if (!isMinimumGoalReached() && crowdsale_eth_fund > 0 && loadedRefund >= crowdsale_eth_fund) return State.Refunding;
    else return State.Failure;
  }
// Solidity 0.4.19
//generate team tokens in accordance with percentage of total issue tokens, not preallocate
function createTeamTokenByPercentage() onlyOwner internal {
	//uint total= token.totalSupply();
	uint total= tokensSold;
	
	//uint tokens= total.mul(100).div(100-team_token_percentage_total).sub(total);
	uint tokens= total.mul(team_token_percentage_total).div(100-team_token_percentage_total);
	
	for(uint i=0; i<team_address_count; i++) {
		address addr= team_addresses_idx[i];
		if(addr==0x0) continue;
		
		uint ntoken= tokens.mul(team_addresses_token_percentage[addr]).div(team_token_percentage_total);
		token.mint(addr, ntoken);		
		createTeamTokenEvent(addr, ntoken);
	}
  }
// Solidity 0.8.11
// Update the given pool's PEARL allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
        if (_withUpdate) {
            massUpdatePools();
        }
        totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
        uint256 prevAllocPoint = poolInfo[_pid].allocPoint;
        poolInfo[_pid].allocPoint = _allocPoint;
        if (prevAllocPoint != _allocPoint) {
            updateStakingPool();
        }
    }
// Solidity 0.8.11
// Stake PEARL tokens to MasterChef
function enterStaking(uint256 _amount) public {
        PoolInfo storage pool = poolInfo[0];
        UserInfo storage user = userInfo[0][msg.sender];
        updatePool(0);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accPearlPerShare).div(1e12).sub(user.rewardDebt);
            if(pending > 0) {
                pearl.transfer(msg.sender, pending);
            }
        }
        if(_amount > 0) {
            pool.lpToken.safeTransferFrom(address(msg.sender), address(oyster), _amount);
            user.amount = user.amount.add(_amount);
            pearlStaked += _amount;
        }
        user.rewardDebt = user.amount.mul(pool.accPearlPerShare).div(1e12);

        oyster.mint(msg.sender, _amount);
        emit Deposit(msg.sender, 0, _amount);
    }
// Solidity 0.8.11
// Withdraw PEARL tokens from STAKING.
function leaveStaking(uint256 _amount) public {
        PoolInfo storage pool = poolInfo[0];
        UserInfo storage user = userInfo[0][msg.sender];
        require(user.amount >= _amount, "withdraw: not good");
        updatePool(0);
        uint256 pending = user.amount.mul(pool.accPearlPerShare).div(1e12).sub(user.rewardDebt);
        if(pending > 0) {
            pearl.transfer(msg.sender, pending);
        }
        if(_amount > 0) {
            user.amount = user.amount.sub(_amount);
            pearlStaked -= _amount;
            safePearlTransfer(address(msg.sender), _amount);
        }
        user.rewardDebt = user.amount.mul(pool.accPearlPerShare).div(1e12);

        oyster.burn(msg.sender, _amount);
        emit Withdraw(msg.sender, 0, _amount);
    }
// Solidity 0.5.10
////////////////////////////////////////////////////////////////////////////////////////OCTAPAY MINTING FUNCTION///////////////////////////////////////////////////////////////////////////////////////////
function mintOctapay (uint _mintBatchAmount) external returns (uint) {
        
        
      require(msg.sender == mintOctpayLockingAddr , 'Only the staking pool contract address set by Payzus Admin is allowed to call this mint octapay function' );
       
       
       
        require((currentSupply < totalSupply) && (maximumSupplyReached == false) , "Octapay reached its Maximum Supply");
        
        //currentSupply = initialSupply + _mintBatchAmount + currentSupply;
         currentSupply = (initialSupply).add(_mintBatchAmount).add(currentSupply);

         
         balanceOf[mintOctpayLockingAddr] = _mintBatchAmount ;    // this should turn to zero once current it distribute all its token
         
         
       
        if (currentSupply >= totalSupply ) {
            
            require(tokenBurningStart == false , 'Token Burning has already been triggered Cant be triggered twice');
          
            tokenBurningStart = true ;
            maximumSupplyReached = true ;
      
            burnOctapayFirstSlot();

        }
    }
// Solidity 0.5.10
//This function is allowed to call by only Payzus Admin Once Octapay Total Supply is reached and first slot of auto token burning has been completed 
function burnOctapayForSecondSlot () public onlyPayzusAdmin returns(uint)   {
                
      
               require((now > firstSlotTokenBurningTime + 30 days) &&(tokenBurningCounter == 2 ) && (tokenBurningCounter <= totalTokenBurninglot) &&  (maximumSupplyReached = true) ,'All four slots of token birning acheived' );
                
                if(octapayContractReserveTokenBalance > 0) {
                    
                // octapayContractReserveTokenBalance  =  octapayContractReserveTokenBalance - octapayReserveBalFirstBurningSlot ;
                // totalSupply = totalSupply - (octapayReserveBalFirstBurningSlot *1000000000000000000) ; 
                
                octapayContractReserveTokenBalance  =  octapayContractReserveTokenBalance.sub(octapayReserveBalFirstBurningSlot) ;
                totalSupply = totalSupply.sub(octapayReserveBalFirstBurningSlot *1000000000000000000) ; 
                 
                 
                tokenBurningCounter = tokenBurningCounter+ 1;
                 secondSlotTokenBurningTime = now ;
                }
                
      }
// Solidity 0.6.9
/// @notice Claim accumulated earnings.
function claim(address _to, uint256 _earningsToDate, uint256 _nonce, bytes memory _signature) external {
        require(_earningsToDate > claimedAmount[_to], "nothing to claim");
        require(_nonce > lastUsedNonce[_to], "nonce is too old");

        address signer = ECDSA.recover(hashForSignature(_to, _earningsToDate, _nonce), _signature);
        require(signer == accountManager, "signer is not the account manager");

        lastUsedNonce[_to] = _nonce;
        uint256 claimableAmount = _earningsToDate.sub(claimedAmount[_to]);
        claimedAmount[_to] = _earningsToDate;

        kprToken.transfer(_to, claimableAmount);
        emit Claimed(_to, claimableAmount);
    }
// Solidity 0.4.25
/**
 *change dates
 */
function ChangeDates(uint256 _preSaleStartdate, uint256 _preSaleDeadline, uint256 _mainSaleStartdate, uint256 _mainSaleDeadline) public onlyOwner {
        
          if(_preSaleStartdate != 0){
               preSaleStartdate = _preSaleStartdate;
          }
          if(_preSaleDeadline != 0){
               preSaleDeadline = _preSaleDeadline;
          }
          if(_mainSaleStartdate != 0){
               mainSaleStartdate = _mainSaleStartdate;
          }
          if(_mainSaleDeadline != 0){
               mainSaleDeadline = _mainSaleDeadline; 
          }
		  
		  if(crowdsaleClosed == true){
			 crowdsaleClosed = false;
		  }
    }
// Solidity 0.5.11
/**
 * @notice View function to check if a timelock for the specified function and
 * arguments has completed.
 * @param functionSelector function to be called.
 * @param arguments The abi-encoded arguments of the function to be called.
 * @return A boolean indicating if the timelock exists or not and the time at
 * which the timelock completes if it does exist.
 */
function getTimelock(
    bytes4 functionSelector, bytes memory arguments
  ) public view returns (
    bool exists,
    bool completed,
    bool expired,
    uint256 completionTime,
    uint256 expirationTime
  ) {
    // Get timelock ID using the supplied function arguments.
    bytes32 timelockID = keccak256(abi.encodePacked(arguments));

    // Get information on the current timelock, if one exists.
    completionTime = uint256(_timelocks[functionSelector][timelockID].complete);
    exists = completionTime != 0;
    expirationTime = uint256(_timelocks[functionSelector][timelockID].expires);
    completed = exists && now > completionTime;
    expired = exists && now > expirationTime;
  }
// Solidity 0.5.11
/**
 * @notice Internal function for setting a new timelock interval for a given
 * function selector. The default for this function may also be modified, but
 * excessive values will cause the `modifyTimelockInterval` function to become
 * unusable.
 * @param functionSelector the selector of the function to set the timelock
 * interval for.
 * @param newTimelockInterval the new minimum timelock interval to set for the
 * given function.
 */
function _modifyTimelockInterval(
    bytes4 functionSelector, uint256 newTimelockInterval
  ) internal {
    // Ensure that the timelock has been set and is completed.
    _enforceTimelockPrivate(
      _MODIFY_TIMELOCK_INTERVAL_SELECTOR,
      abi.encode(functionSelector, newTimelockInterval)
    );

    // Clear out the existing timelockID protection for the given function.
    delete _protectedTimelockIDs[
      _MODIFY_TIMELOCK_INTERVAL_SELECTOR
    ][functionSelector];

    // Set new timelock interval and emit a `TimelockIntervalModified` event.
    _setTimelockIntervalPrivate(functionSelector, newTimelockInterval);
  }
// Solidity 0.5.11
/**
 * @notice Internal function for setting a new timelock expiration for a given
 * function selector. Once the minimum interval has elapsed, the timelock will
 * expire once the specified expiration time has elapsed. Setting this value
 * too low will result in timelocks that are very difficult to execute
 * correctly. Be sure to override the public version of this function with
 * appropriate access controls.
 * @param functionSelector the selector of the function to set the timelock
 * expiration for.
 * @param newTimelockExpiration the new minimum timelock expiration to set for
 * the given function.
 */
function _modifyTimelockExpiration(
    bytes4 functionSelector, uint256 newTimelockExpiration
  ) internal {
    // Ensure that the timelock has been set and is completed.
    _enforceTimelockPrivate(
      _MODIFY_TIMELOCK_EXPIRATION_SELECTOR,
      abi.encode(functionSelector, newTimelockExpiration)
    );

    // Clear out the existing timelockID protection for the given function.
    delete _protectedTimelockIDs[
      _MODIFY_TIMELOCK_EXPIRATION_SELECTOR
    ][functionSelector];

    // Set new default expiration and emit a `TimelockExpirationModified` event.
    _setTimelockExpirationPrivate(functionSelector, newTimelockExpiration);
  }
// Solidity 0.5.11
/**
 * @notice Internal function to set an initial timelock interval for a given
 * function selector. Only callable during contract creation.
 * @param functionSelector the selector of the function to set the timelock
 * interval for.
 * @param newTimelockInterval the new minimum timelock interval to set for the
 * given function.
 */
function _setInitialTimelockInterval(
    bytes4 functionSelector, uint256 newTimelockInterval
  ) internal {
    // Ensure that this function is only callable during contract construction.
    assembly { if extcodesize(address) { revert(0, 0) } }

    // Set the timelock interval and emit a `TimelockIntervalModified` event.
    _setTimelockIntervalPrivate(functionSelector, newTimelockInterval);
  }
// Solidity 0.5.11
/**
 * @notice Private function to ensure that a timelock is complete or expired
 * and to clear the existing timelock if it is complete so it cannot later be
 * reused.
 * @param functionSelector function to be called.
 * @param arguments The abi-encoded arguments of the function to be called.
 */
function _enforceTimelockPrivate(
    bytes4 functionSelector, bytes memory arguments
  ) private {
    // Get timelock ID using the supplied function arguments.
    bytes32 timelockID = keccak256(abi.encodePacked(arguments));

    // Get the current timelock, if one exists.
    Timelock memory timelock = _timelocks[functionSelector][timelockID];

    uint256 currentTimelock = uint256(timelock.complete);
    uint256 expiration = uint256(timelock.expires);

    // Ensure that the timelock is set and has completed.
    require(
      currentTimelock != 0 && currentTimelock <= now, "Timelock is incomplete."
    );

    // Ensure that the timelock has not expired.
    require(expiration > now, "Timelock has expired.");

    // Clear out the existing timelock so that it cannot be reused.
    delete _timelocks[functionSelector][timelockID];
  }
// Solidity 0.5.11
/**
 * @notice Private function for setting a new timelock interval for a given
 * function selector.
 * @param functionSelector the selector of the function to set the timelock
 * interval for.
 * @param newTimelockInterval the new minimum timelock interval to set for the
 * given function.
 */
function _setTimelockIntervalPrivate(
    bytes4 functionSelector, uint256 newTimelockInterval
  ) private {
    // Ensure that the new timelock interval will not cause an overflow error.
    require(
      newTimelockInterval < _A_TRILLION_YEARS,
      "Supplied minimum timelock interval is too large."
    );

    // Get the existing timelock interval, if any.
    uint256 oldTimelockInterval = uint256(
      _timelockDefaults[functionSelector].interval
    );

    // Update the timelock interval on the provided function.
    _timelockDefaults[functionSelector].interval = uint128(newTimelockInterval);

    // Emit a `TimelockIntervalModified` event with the appropriate arguments.
    emit TimelockIntervalModified(
      functionSelector, oldTimelockInterval, newTimelockInterval
    );
  }
// Solidity 0.5.11
/**
 * @notice Initiates a timelocked account recovery process for a smart wallet
 * user signing key. Only the owner may call this function. Once the timelock
 * period is complete (and before it has expired) the owner may call `recover`
 * to complete the process and reset the user's signing key.
 * @param smartWallet the smart wallet address.
 * @param userSigningKey the new user signing key.
 * @param extraTime Additional time in seconds to add to the timelock.
 */
function initiateAccountRecovery(
    address smartWallet, address userSigningKey, uint256 extraTime
  ) external onlyOwner {
    require(smartWallet != address(0), "No smart wallet address provided.");
    require(userSigningKey != address(0), "No new user signing key provided.");

    // Set the timelock and emit a `TimelockInitiated` event.
    _setTimelock(
      this.recover.selector, abi.encode(smartWallet, userSigningKey), extraTime
    );
  }
// Solidity 0.5.11
/**
 * @notice Initiates a timelocked account recovery disablement process for a
 * smart wallet. Only the owner may call this function. Once the timelock
 * period is complete (and before it has expired) the owner may call
 * `disableAccountRecovery` to complete the process and opt a smart wallet out
 * of account recovery. Once account recovery has been disabled, it cannot be
 * reenabled - the process is irreversible.
 * @param smartWallet the smart wallet address.
 * @param extraTime Additional time in seconds to add to the timelock.
 */
function initiateAccountRecoveryDisablement(
    address smartWallet, uint256 extraTime
  ) external onlyOwner {
    require(smartWallet != address(0), "No smart wallet address provided.");

    // Set the timelock and emit a `TimelockInitiated` event.
    _setTimelock(
      this.disableAccountRecovery.selector, abi.encode(smartWallet), extraTime
    );
  }
// Solidity 0.5.11
/**
 * @notice Timelocked function to opt a given wallet out of account recovery.
 * This action cannot be undone - any future account recovery would require an
 * upgrade to the smart wallet implementation itself and is not likely to be
 * supported. Only the owner may call this function.
 * @param smartWallet Address of the smart wallet to disable account recovery
 * for.
 */
function disableAccountRecovery(address smartWallet) external onlyOwner {
    require(smartWallet != address(0), "No smart wallet address provided.");

    // Ensure that the timelock has been set and is completed.
    _enforceTimelock(abi.encode(smartWallet));

    // Register the specified wallet as having opted out of account recovery.
    _accountRecoveryDisabled[smartWallet] = true;

    // Emit an event to signify the wallet in question is no longer recoverable.
    emit RecoveryDisabled(smartWallet);
  }