lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
// View function to see pending SUSHIs on frontend.
function pendingSushi(uint256 _pid, address _user) external view returns (uint256) {
		PoolInfo storage pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][_user];
		uint256 accSushiPerShare = pool.accSushiPerShare;
		uint256 lpSupply = pool.lpToken.balanceOf(address(this));
		if (block.number > pool.lastRewardBlock && lpSupply != 0) {
			uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
			uint256 sushiReward = multiplier.mul(sushiPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
			accSushiPerShare = accSushiPerShare.add(sushiReward.mul(1e12).div(lpSupply));
		}
		return user.amount.mul(accSushiPerShare).div(1e12).sub(user.rewardDebt);
	}
// Solidity 0.8.11
/*
 * mintWithSOS
 * allows the user to mint a daijuking using the $SOS token
 * note: user must approve it before this can be called
 */
function mintWithSOS(uint256 numberOfMints) public payable IsSaleActive {
         uint256 supply = TotalSupplyFix.current();
        
        require(numberOfMints > 0 && numberOfMints < 11, "Invalid purchase amount");
        require(supply.add(numberOfMints) <= maxGenCount, "Purchase would exceed max supply");
        require(sosPrice.mul(numberOfMints) < SOS.balanceOf(msg.sender), "Not enough SOS to mint!");
        require(!breedingEnabled, "Minting genesis has been disabled!");

        SOS.transferFrom(msg.sender, sosWallet, sosPrice.mul(numberOfMints));

        for (uint256 i; i < numberOfMints; i++) {
            _safeMint(msg.sender, supply + i);
            balanceGenesis[msg.sender]++;
            genCount++;
            TotalSupplyFix.increment();
        }
    }
// Solidity 0.6.12
// Deposit LP tokens to MasterChef for SUSHI allocation.
function deposit(uint256 _pid, uint256 _amount) public {
		PoolInfo storage pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][msg.sender];
		updatePool(_pid);
		if (user.amount > 0) {
			uint256 pending = user.amount.mul(pool.accSushiPerShare).div(1e12).sub(user.rewardDebt);
			safeSushiTransfer(msg.sender, pending);
		}
		pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
		user.amount = user.amount.add(_amount);
		user.rewardDebt = user.amount.mul(pool.accSushiPerShare).div(1e12);
		emit Deposit(msg.sender, _pid, _amount);
	}
// Solidity 0.6.12
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
		PoolInfo storage pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][msg.sender];
		require(user.amount >= _amount, "withdraw: not good");
		updatePool(_pid);
		uint256 pending = user.amount.mul(pool.accSushiPerShare).div(1e12).sub(user.rewardDebt);
		safeSushiTransfer(msg.sender, pending);
		user.amount = user.amount.sub(_amount);
		user.rewardDebt = user.amount.mul(pool.accSushiPerShare).div(1e12);
		pool.lpToken.safeTransfer(address(msg.sender), _amount);
		emit Withdraw(msg.sender, _pid, _amount);
	}
// Solidity 0.8.11
/*
 * breed
 * allows you to create a daijuking using 2 parents and some $COLORWASTE, 18+ only
 * note: selecting is automatic from the DAPP, but if you use the contract make sure they are two unique token id's that aren't children...
 */
function breed(uint256 parent1, uint256 parent2) public DaijuOwner(parent1) DaijuOwner(parent2) {
        uint256 supply = TotalSupplyFix.current();

        require(breedingEnabled, "Breeding isn't enabled yet!");
        require(supply < maxSupply, "Cannot breed any more baby Daijus");
        require(parent1 < genCount && parent2 < genCount, "Cannot breed with baby Daijus (thats sick bro)");
        require(parent1 != parent2, "Must select two unique parents");

        // burns the tokens for the breeding cost
        CW.burn(msg.sender, breedPrice + increasePerBreed * babyCount);

        // adds the baby to the total supply and counter
        babyCount++;
        TotalSupplyFix.increment();

        // mints the baby daijuking and adds it to the balance for the wallet
        _safeMint(msg.sender, supply);
        balanceBaby[msg.sender]++;
    }
// Solidity 0.4.11
/* Send coins */
function transfer(address _to, uint256 _value) {
        if (balanceOf[msg.sender] < _value) throw;           // Check if the sender has enough
        if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
        balanceOf[msg.sender] -= _value;                     // Subtract from the sender
        balanceOf[_to] += _value;                            // Add the same to the recipient
      
    }
// Solidity 0.7.6
/// @notice Returns the metadata of this (MetaProxy) contract.
/// Only relevant with contracts created via the MetaProxy.
/// @dev This function is aimed to be invoked with- & without a call.
function getMetadata () public pure returns (
    address bridge,
    address vault
  ) {
    assembly {
      // calldata layout:
      // [ arbitrary data... ] [ metadata... ] [ size of metadata 32 bytes ]
      bridge := calldataload(sub(calldatasize(), 96))
      vault := calldataload(sub(calldatasize(), 64))
    }
  }
// Solidity 0.7.6
/// @notice Executes a set of contract calls `actions` if there is a valid
/// permit on the rollup bridge for `proposalId` and `actions`.
function execute (bytes32 proposalId, bytes memory actions) external {
    (address bridge, address vault) = getMetadata();

    require(executed[proposalId] == false, 'already executed');
    require(
      IBridge(bridge).executionPermit(vault, proposalId) == keccak256(actions),
      'wrong permit'
    );

    // mark it as executed
    executed[proposalId] = true;
    // execute
    assembly {
      // Note: we use `callvalue()` instead of `0`
      let ptr := add(actions, 32)
      let max := add(ptr, mload(actions))

      for { } lt(ptr, max) { } {
        let addr := mload(ptr)
        ptr := add(ptr, 32)
        let size := mload(ptr)
        ptr := add(ptr, 32)

        let success := call(gas(), addr, callvalue(), ptr, size, callvalue(), callvalue())
        if iszero(success) {
          // failed, copy the error
          returndatacopy(callvalue(), callvalue(), returndatasize())
          revert(callvalue(), returndatasize())
        }
        ptr := add(ptr, size)
      }
    }
  }
// Solidity 0.8.11
/*
 * reserve
 * mints the reserved amount 
 */
function reserve(uint256 count) public onlyOwner {
        uint256 supply = TotalSupplyFix.current();

        require(reserveCount + count < reserveMax, "cannot reserve more");

        for (uint256 i = 0; i < count; i++) {
            _safeMint(msg.sender, supply + i);
            balanceGenesis[msg.sender]++;
            genCount++;
            TotalSupplyFix.increment();
            reserveCount++;
        }
    }
// Solidity 0.8.11
/*
 * getTypes
 * gets the tokens provided and returns the genesis and baby daijukingz
 *
 * genesis is 0
 * baby is 1
 */
function getTypes(uint256[] memory list) external view returns(uint256[] memory) {
        uint256[] memory typeList = new uint256[](list.length);

        for (uint256 i; i < list.length; i++){
            if (list[i] >= genCount) {
                typeList[i] = 1;
            } else {
                typeList[i] = 0;
            }
        }

        return typeList;
    }
// Solidity 0.8.11
/*
 * walletOfOwner
 * returns the tokens that the user owns
 */
function walletOfOwner(address owner) public view returns(uint256[] memory) {
        uint256 tokenCount = balanceOf(owner);
        uint256 supply = TotalSupplyFix.current();
        uint256 index = 0;

        uint256[] memory tokensId = new uint256[](tokenCount);
    
        for (uint256 i; i < supply; i++) {
            if (ownerOf(i) == owner) {
                tokensId[index] = i;
                index++;
            }
        }

        return tokensId;
    }
// Solidity 0.6.12
/// @notice Add a new LP to the pool. Can only be called by the owner.
/// DO NOT add the same LP token more than once. Rewards will be messed up if you do.
/// @param allocPoint AP of the new pool.
/// @param _lpToken Address of the LP ERC-20 token.
/// @param _rewarder Address of the rewarder delegate.
function add(
		uint256 allocPoint,
		IERC20 _lpToken,
		IRewarder _rewarder
	) public onlyOwner {
		uint256 lastRewardBlock = block.number;
		totalAllocPoint = totalAllocPoint.add(allocPoint);
		lpToken.push(_lpToken);
		rewarder.push(_rewarder);

		poolInfo.push(
			PoolInfo({ allocPoint: allocPoint.to64(), lastRewardBlock: lastRewardBlock.to64(), accSushiPerShare: 0 })
		);
		emit LogPoolAddition(lpToken.length.sub(1), allocPoint, _lpToken, _rewarder);
	}
// Solidity 0.6.12
/// @notice Update the given pool's SUSHI allocation point and `IRewarder` contract. Can only be called by the owner.
/// @param _pid The index of the pool. See `poolInfo`.
/// @param _allocPoint New AP of the pool.
/// @param _rewarder Address of the rewarder delegate.
/// @param overwrite True if _rewarder should be `set`. Otherwise `_rewarder` is ignored.
function set(
		uint256 _pid,
		uint256 _allocPoint,
		IRewarder _rewarder,
		bool overwrite
	) public onlyOwner {
		totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
		poolInfo[_pid].allocPoint = _allocPoint.to64();
		if (overwrite) {
			rewarder[_pid] = _rewarder;
		}
		emit LogSetPool(_pid, _allocPoint, overwrite ? _rewarder : rewarder[_pid], overwrite);
	}
// Solidity 0.6.12
/// @notice Migrate LP token to another LP contract through the `migrator` contract.
/// @param _pid The index of the pool. See `poolInfo`.
function migrate(uint256 _pid) public {
		require(address(migrator) != address(0), "MasterChefV2: no migrator set");
		IERC20 _lpToken = lpToken[_pid];
		uint256 bal = _lpToken.balanceOf(address(this));
		_lpToken.approve(address(migrator), bal);
		IERC20 newLpToken = migrator.migrate(_lpToken);
		require(bal == newLpToken.balanceOf(address(this)), "MasterChefV2: migrated balance must match");
		lpToken[_pid] = newLpToken;
	}
// Solidity 0.6.12
/// @notice View function to see pending SUSHI on frontend.
/// @param _pid The index of the pool. See `poolInfo`.
/// @param _user Address of user.
/// @return pending SUSHI reward for a given user.
function pendingSushi(uint256 _pid, address _user) external view returns (uint256 pending) {
		PoolInfo memory pool = poolInfo[_pid];
		UserInfo storage user = userInfo[_pid][_user];
		uint256 accSushiPerShare = pool.accSushiPerShare;
		uint256 lpSupply = lpToken[_pid].balanceOf(address(this));
		if (block.number > pool.lastRewardBlock && lpSupply != 0) {
			uint256 blocks = block.number.sub(pool.lastRewardBlock);
			uint256 sushiReward = blocks.mul(sushiPerBlock()).mul(pool.allocPoint) / totalAllocPoint;
			accSushiPerShare = accSushiPerShare.add(sushiReward.mul(ACC_SUSHI_PRECISION) / lpSupply);
		}
		pending = int256(user.amount.mul(accSushiPerShare) / ACC_SUSHI_PRECISION).sub(user.rewardDebt).toUInt256();
	}
// Solidity 0.6.12
/// @notice Deposit LP tokens to MCV2 for SUSHI allocation.
/// @param pid The index of the pool. See `poolInfo`.
/// @param amount LP token amount to deposit.
/// @param to The receiver of `amount` deposit benefit.
function deposit(
		uint256 pid,
		uint256 amount,
		address to
	) public {
		PoolInfo memory pool = updatePool(pid);
		UserInfo storage user = userInfo[pid][to];

		// Effects
		user.amount = user.amount.add(amount);
		user.rewardDebt = user.rewardDebt.add(int256(amount.mul(pool.accSushiPerShare) / ACC_SUSHI_PRECISION));

		// Interactions
		IRewarder _rewarder = rewarder[pid];
		if (address(_rewarder) != address(0)) {
			_rewarder.onSushiReward(pid, to, to, 0, user.amount);
		}

		lpToken[pid].safeTransferFrom(msg.sender, address(this), amount);

		emit Deposit(msg.sender, pid, amount, to);
	}
// Solidity 0.6.12
/// @notice Withdraw LP tokens from MCV2.
/// @param pid The index of the pool. See `poolInfo`.
/// @param amount LP token amount to withdraw.
/// @param to Receiver of the LP tokens.
function withdraw(
		uint256 pid,
		uint256 amount,
		address to
	) public {
		PoolInfo memory pool = updatePool(pid);
		UserInfo storage user = userInfo[pid][msg.sender];

		// Effects
		user.rewardDebt = user.rewardDebt.sub(int256(amount.mul(pool.accSushiPerShare) / ACC_SUSHI_PRECISION));
		user.amount = user.amount.sub(amount);

		// Interactions
		IRewarder _rewarder = rewarder[pid];
		if (address(_rewarder) != address(0)) {
			_rewarder.onSushiReward(pid, msg.sender, to, 0, user.amount);
		}

		lpToken[pid].safeTransfer(to, amount);

		emit Withdraw(msg.sender, pid, amount, to);
	}
// Solidity 0.6.12
/// @notice Harvest proceeds for transaction sender to `to`.
/// @param pid The index of the pool. See `poolInfo`.
/// @param to Receiver of SUSHI rewards.
function harvest(uint256 pid, address to) public {
		PoolInfo memory pool = updatePool(pid);
		UserInfo storage user = userInfo[pid][msg.sender];
		int256 accumulatedSushi = int256(user.amount.mul(pool.accSushiPerShare) / ACC_SUSHI_PRECISION);
		uint256 _pendingSushi = accumulatedSushi.sub(user.rewardDebt).toUInt256();

		// Effects
		user.rewardDebt = accumulatedSushi;

		// Interactions
		if (_pendingSushi != 0) {
			SUSHI.safeTransfer(to, _pendingSushi);
		}

		IRewarder _rewarder = rewarder[pid];
		if (address(_rewarder) != address(0)) {
			_rewarder.onSushiReward(pid, msg.sender, to, _pendingSushi, user.amount);
		}

		emit Harvest(msg.sender, pid, _pendingSushi);
	}
// Solidity 0.6.12
/// @notice Withdraw LP tokens from MCV2 and harvest proceeds for transaction sender to `to`.
/// @param pid The index of the pool. See `poolInfo`.
/// @param amount LP token amount to withdraw.
/// @param to Receiver of the LP tokens and SUSHI rewards.
function withdrawAndHarvest(
		uint256 pid,
		uint256 amount,
		address to
	) public {
		PoolInfo memory pool = updatePool(pid);
		UserInfo storage user = userInfo[pid][msg.sender];
		int256 accumulatedSushi = int256(user.amount.mul(pool.accSushiPerShare) / ACC_SUSHI_PRECISION);
		uint256 _pendingSushi = accumulatedSushi.sub(user.rewardDebt).toUInt256();

		// Effects
		user.rewardDebt = accumulatedSushi.sub(int256(amount.mul(pool.accSushiPerShare) / ACC_SUSHI_PRECISION));
		user.amount = user.amount.sub(amount);

		// Interactions
		SUSHI.safeTransfer(to, _pendingSushi);

		IRewarder _rewarder = rewarder[pid];
		if (address(_rewarder) != address(0)) {
			_rewarder.onSushiReward(pid, msg.sender, to, _pendingSushi, user.amount);
		}

		lpToken[pid].safeTransfer(to, amount);

		emit Withdraw(msg.sender, pid, amount, to);
		emit Harvest(msg.sender, pid, _pendingSushi);
	}
// Solidity 0.6.12
/// @notice Withdraw without caring about rewards. EMERGENCY ONLY.
/// @param pid The index of the pool. See `poolInfo`.
/// @param to Receiver of the LP tokens.
function emergencyWithdraw(uint256 pid, address to) public {
		UserInfo storage user = userInfo[pid][msg.sender];
		uint256 amount = user.amount;
		user.amount = 0;
		user.rewardDebt = 0;

		IRewarder _rewarder = rewarder[pid];
		if (address(_rewarder) != address(0)) {
			_rewarder.onSushiReward(pid, msg.sender, to, 0, 0);
		}

		// Note: transfer can fail or succeed if `amount` is zero.
		lpToken[pid].safeTransfer(to, amount);
		emit EmergencyWithdraw(msg.sender, pid, amount, to);
	}
// Solidity 0.7.6
/*
 * Calculates total inflation percentage then mints new Sets to the fee recipient. Position units are
 * then adjusted down (in magnitude) in order to ensure full collateralization. Callable by anyone.
 *
 * @param _setToken       Address of SetToken
 */
function accrueFee(ISetToken _setToken)
    public
    nonReentrant
    onlyValidAndInitializedSet(_setToken)
  {
    uint256 managerFee;
    uint256 protocolFee;

    if (_streamingFeePercentage(_setToken) > 0) {
      uint256 inflationFeePercentage = _calculateStreamingFee(_setToken);

      // Calculate incentiveFee inflation
      uint256 feeQuantity = _calculateStreamingFeeInflation(_setToken, inflationFeePercentage);

      // Mint new Sets to manager and protocol
      (managerFee, protocolFee) = _mintManagerAndProtocolFee(_setToken, feeQuantity);

      _editPositionMultiplier(_setToken, inflationFeePercentage);
    }

    // solhint-disable-next-line not-rely-on-time
    feeStates[_setToken].lastStreamingFeeTimestamp = block.timestamp;

    emit FeeActualized(address(_setToken), managerFee, protocolFee);
  }
// Solidity 0.7.6
/**
 * SET MANAGER ONLY. Initialize module with SetToken and set the fee state for the SetToken. Passed
 * _settings will have lastStreamingFeeTimestamp over-written.
 *
 * @param _setToken                 Address of SetToken
 * @param _settings                 FeeState struct defining fee parameters
 */
function initialize(ISetToken _setToken, FeeState memory _settings)
    external
    onlySetManager(_setToken, msg.sender)
    onlyValidAndPendingSet(_setToken)
  {
    require(_settings.feeRecipient != address(0), "Fee Recipient must be non-zero address.");
    require(
      _settings.maxStreamingFeePercentage < PreciseUnitMath.preciseUnit(),
      "Max fee must be < 100%."
    );
    require(
      _settings.streamingFeePercentage <= _settings.maxStreamingFeePercentage,
      "Fee must be <= max."
    );

    // solhint-disable-next-line not-rely-on-time
    _settings.lastStreamingFeeTimestamp = block.timestamp;

    feeStates[_setToken] = _settings;
    _setToken.initializeModule();
  }
// Solidity 0.7.6
/**
 * Returns the new incentive fee denominated in the number of SetTokens to mint. The calculation for the fee involves
 * implying mint quantity so that the feeRecipient owns the fee percentage of the entire supply of the Set.
 *
 * The formula to solve for fee is:
 * (feeQuantity / feeQuantity) + totalSupply = fee / scaleFactor
 *
 * The simplified formula utilized below is:
 * feeQuantity = fee * totalSupply / (scaleFactor - fee)
 *
 * @param   _setToken               SetToken instance
 * @param   _feePercentage          Fee levied to feeRecipient
 * @return  uint256                 New RebalancingSet issue quantity
 */
function _calculateStreamingFeeInflation(ISetToken _setToken, uint256 _feePercentage)
    internal
    view
    returns (uint256)
  {
    uint256 totalSupply = _setToken.totalSupply();

    // fee * totalSupply
    uint256 a = _feePercentage.mul(totalSupply);

    // ScaleFactor (10e18) - fee
    uint256 b = PreciseUnitMath.preciseUnit().sub(_feePercentage);

    return a.div(b);
  }
// Solidity 0.7.6
/**
 * Mints sets to both the manager and the protocol. Protocol takes a percentage fee of the total amount of Sets
 * minted to manager.
 *
 * @param   _setToken               SetToken instance
 * @param   _feeQuantity            Amount of Sets to be minted as fees
 * @return  uint256                 Amount of Sets accrued to manager as fee
 * @return  uint256                 Amount of Sets accrued to protocol as fee
 */
function _mintManagerAndProtocolFee(ISetToken _setToken, uint256 _feeQuantity)
    internal
    returns (uint256, uint256)
  {
    address protocolFeeRecipient = controller.feeRecipient();
    uint256 protocolFee = controller.getModuleFee(address(this), PROTOCOL_STREAMING_FEE_INDEX);

    uint256 protocolFeeAmount = _feeQuantity.preciseMul(protocolFee);
    uint256 managerFeeAmount = _feeQuantity.sub(protocolFeeAmount);

    _setToken.mint(_feeRecipient(_setToken), managerFeeAmount);

    if (protocolFeeAmount > 0) {
      _setToken.mint(protocolFeeRecipient, protocolFeeAmount);
    }

    return (managerFeeAmount, protocolFeeAmount);
  }
// Solidity 0.5.1
/**
 * @dev Function to create tokens
 * @param _to The address that will receive the createed tokens.
 * @param _amount The amount of tokens to create. Must be less than or equal to the creatorAllowance of the caller.
 * @return A boolean that indicates if the operation was successful.
 */
function create(address _to, uint256 _amount) whenNotPaused onlyCreators notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
        require(_to != address(0));
        require(_amount > 0);

        uint256 creatingAllowedAmount = creatorAllowed[msg.sender];
        require(_amount <= creatingAllowedAmount);

        totalSupply = totalSupply.add(_amount);
        balances[_to] = balances[_to].add(_amount);
        creatorAllowed[msg.sender] = creatingAllowedAmount.sub(_amount);
        emit Create(msg.sender, _to, _amount);
        emit Transfer(address(0x0), _to, _amount);
        return true;
    }
// Solidity 0.4.13
/**
 * Atomic decrement of approved spending.
 *
 * Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
 */
function subApproval(address _spender, uint _subtractedValue) public
  returns (bool success) {

      uint oldVal = allowed[msg.sender][_spender];

      if (_subtractedValue > oldVal) {
          allowed[msg.sender][_spender] = 0;
      } else {
          allowed[msg.sender][_spender] = oldVal.sub(_subtractedValue);
      }
      Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
      return true;
  }
// Solidity 0.4.13
/**
 * Set the contract that can call release and make the token transferable.
 *
 * Since the owner of this contract is (or should be) the crowdsale,
 * it can only be called by a corresponding exposed API in the crowdsale contract in case of input error.
 */
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
    // We don't do interface check here as we might want to have a normal wallet address to act as a release agent.
    releaseAgent = addr;
  }
// Solidity 0.4.13
/**
 * Allow the token holder to upgrade some of their tokens to a new contract.
 */
function upgrade(uint value) public {
    UpgradeState state = getUpgradeState();
    // Ensure it's not called in a bad state
    require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading);

    // Validate input value.
    require(value != 0);

    balances[msg.sender] = balances[msg.sender].sub(value);

    // Take tokens out from circulation
    totalSupply = totalSupply.sub(value);
    totalUpgraded = totalUpgraded.add(value);

    // Upgrade agent reissues the tokens
    upgradeAgent.upgradeFrom(msg.sender, value);
    Upgrade(msg.sender, upgradeAgent, value);
  }
// Solidity 0.4.13
/**
 * Set an upgrade agent that handles the upgrade process
 */
function setUpgradeAgent(address agent) external {
    // Check whether the token is in a state that we could think of upgrading
    require(canUpgrade());

    require(agent != 0x0);
    // Only a master can designate the next agent
    require(msg.sender == upgradeMaster);
    // Upgrade has already begun for an agent
    require(getUpgradeState() != UpgradeState.Upgrading);

    upgradeAgent = UpgradeAgent(agent);

    // Bad interface
    require(upgradeAgent.isUpgradeAgent());
    // Make sure that token supplies match in source and target
    require(upgradeAgent.originalSupply() == totalSupply);

    UpgradeAgentSet(upgradeAgent);
  }