lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * @dev endIco closes down the ICO 
 **/
function endIco() internal {
        currentStage = Stages.icoEnd;
        // Transfer any remaining tokens
        if(remainingTokens > 0)
            balances[owner] = balances[owner].add(remainingTokens);
        // transfer any remaining ETH balance in the contract to the owner
        owner.transfer(address(this).balance); 
    }
// Solidity 0.6.12
// Query the second referred user.
function getReferreds2(address addr, uint256 startPos)
        external
        view
        returns (uint256 length, address[] memory data)
    {
        address[] memory referreds = referreds2[addr];
        length = referreds.length;
        data = new address[](length);
        for (uint256 i = 0; i < 5 && i + startPos < length; i++) {
            data[i] = referreds[startPos + i];
        }
    }
// Solidity 0.6.12
// Query user all rewards
function allPendingRose(address _user)
        external
        view
        returns (uint256 pending)
    {
        for (uint256 i = 0; i < poolInfo1.length; i++) {
            pending = pending.add(pendingRose1(i, _user));
        }
        for (uint256 i = 0; i < poolInfo2.length; i++) {
            pending = pending.add(pendingRose2(i, _user));
        }
    }
// Solidity 0.6.12
// Mint for referrers.
function mintReferralReward(uint256 _amount) internal {
        address referrer = referrers[msg.sender];
        // no referrer.
        if (address(0) == referrer) {
            return;
        }
        // mint for user and the first level referrer.
        rose.mint(msg.sender, _amount.div(100));
        rose.mint(referrer, _amount.mul(2).div(100));

        // only the referrer of the top person is himself.
        if (referrers[referrer] == referrer) {
            return;
        }
        // mint for the second level referrer.
        rose.mint(referrers[referrer], _amount.mul(2).div(100));
    }
// Solidity 0.6.12
// Update the locked amount that meet the conditions
function updateLockedAmount(PoolInfo2 storage pool) internal {
        uint256 passedBlock = block.number - pool.lastUnlockedBlock;
        if (passedBlock >= pool.unlockIntervalBlock) {
            // case 2 and more than 2 period have passed.
            pool.lastUnlockedBlock = pool.lastUnlockedBlock.add(
                pool.unlockIntervalBlock.mul(
                    passedBlock.div(pool.unlockIntervalBlock)
                )
            );
            uint256 lockedAmount = pool.lockedAmount;
            pool.lockedAmount = 0;
            pool.freeAmount = pool.freeAmount.add(lockedAmount);
        } else if (pool.lockedAmount >= pool.maxLockAmount) {
            // Free 75% to freeAmont from lockedAmount.
            uint256 freeAmount = pool.lockedAmount.mul(75).div(100);
            pool.lockedAmount = pool.lockedAmount.sub(freeAmount);
            pool.freeAmount = pool.freeAmount.add(freeAmount);
        }
    }
// Solidity 0.4.24
// Allocate tokens to the users
// @param _owners The owners list of the token
// @param _values The value list of the token
function allocateTokens(address[] _owners, uint256[] _values) public onlyOwner {

        require(_owners.length == _values.length, "data length mismatch");
        address from = msg.sender;

        for(uint256 i = 0; i < _owners.length ; i++){
            address to = _owners[i];
            uint256 value = _values[i];
            require(value <= balances[from]);

            balances[to] = balances[to].add(value);
            balances[from] = balances[from].sub(value);
            emit Transfer(from, to, value);
        }
    }
// Solidity 0.8.7
/**
 * @dev Returns the ceiling of the division of two numbers.
 *
 * This differs from standard division with `/` in that it rounds up instead
 * of rounding down.
 */
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
// Solidity 0.8.7
/**
 * @notice retrieve price for multiple NFTs
 *
 * @param amount the amount of NFTs to get price for
 */
function getPrice(uint256 amount) public  view returns (uint256){
        uint256 supply = totalSupply(ARTWORK) - _reserved;
        uint totalCost = 0;
        for (uint i = 0; i < amount; i++) {
            totalCost += getCurrentPriceAtPosition(supply + i);
        }
        return totalCost;
    }
// Solidity 0.8.7
/**
 * @notice global mint function used in early access and public sale
 *
 * @param amount the amount of tokens to mint
 */
function mint(uint256 amount) private {
        require(amount > 0, "Need to request at least 1 NFT");
        require(totalSupply(ARTWORK) + amount <= _maxSupply, "Exceeds maximum supply");
        require(msg.value >= getPrice(amount), "Not enough ETH sent, check price");

        purchaseTxs[msg.sender] += amount;
        _mint(msg.sender, ARTWORK, amount, "");
    }
// Solidity 0.6.12
// Using feeAmount to buy back ROSE and share every holder.
function convert(uint256 _pid) external {
        PoolInfo2 storage pool = poolInfo2[_pid];
        uint256 lpSupply = pool.freeAmount.add(pool.lockedAmount);
        if (address(sfr2rose) != address(0) && pool.feeAmount > 0) {
            uint256 amountOut = swapSFRForROSE(pool.feeAmount);
            if (amountOut > 0) {
                pool.feeAmount = 0;
                pool.sharedFeeAmount = pool.sharedFeeAmount.add(amountOut);
                pool.accRosePerShare = pool.accRosePerShare.add(
                    amountOut.mul(1e12).div(lpSupply)
                );
            }
        }
    }
// Solidity 0.6.12
/// @param _reserve underlying token address
function getReserveData(address _reserve)
        external virtual
        view
        returns (
            uint256 totalLiquidity,               // reserve total liquidity
            uint256 availableLiquidity,           // reserve available liquidity for borrowing
            uint256 totalBorrowsStable,           // total amount of outstanding borrows at Stable rate
            uint256 totalBorrowsVariable,         // total amount of outstanding borrows at Variable rate
            uint256 liquidityRate,                // current deposit APY of the reserve for depositors, in Ray units.
            uint256 variableBorrowRate,           // current variable rate APY of the reserve pool, in Ray units.
            uint256 stableBorrowRate,             // current stable rate APY of the reserve pool, in Ray units.
            uint256 averageStableBorrowRate,      // current average stable borrow rate
            uint256 utilizationRate,              // expressed as total borrows/total liquidity.
            uint256 liquidityIndex,               // cumulative liquidity index
            uint256 variableBorrowIndex,          // cumulative variable borrow index
            address aTokenAddress,                // aTokens contract address for the specific _reserve
            uint40 lastUpdateTimestamp            // timestamp of the last update of reserve data
        );
// Solidity 0.6.12
/// @param _user users address
function getUserAccountData(address _user)
        external virtual
        view
        returns (
            uint256 totalLiquidityETH,            // user aggregated deposits across all the reserves. In Wei
            uint256 totalCollateralETH,           // user aggregated collateral across all the reserves. In Wei
            uint256 totalBorrowsETH,              // user aggregated outstanding borrows across all the reserves. In Wei
            uint256 totalFeesETH,                 // user aggregated current outstanding fees in ETH. In Wei
            uint256 availableBorrowsETH,          // user available amount to borrow in ETH
            uint256 currentLiquidationThreshold,  // user current average liquidation threshold across all the collaterals deposited
            uint256 ltv,                          // user average Loan-to-Value between all the collaterals
            uint256 healthFactor                  // user current Health Factor
    );
// Solidity 0.6.12
/// @param _reserve underlying token address
/// @param _user users address
function getUserReserveData(address _reserve, address _user)
        external virtual
        view
        returns (
            uint256 currentATokenBalance,         // user current reserve aToken balance
            uint256 currentBorrowBalance,         // user current reserve outstanding borrow balance
            uint256 principalBorrowBalance,       // user balance of borrowed asset
            uint256 borrowRateMode,               // user borrow rate mode either Stable or Variable
            uint256 borrowRate,                   // user current borrow rate APY
            uint256 liquidityRate,                // user current earn rate on _reserve
            uint256 originationFee,               // user outstanding loan origination fee
            uint256 variableBorrowIndex,          // user variable cumulative index
            uint256 lastUpdateTimestamp,          // Timestamp of the last data update
            bool usageAsCollateralEnabled         // Whether the user's current reserve is enabled as a collateral
    );
// Solidity 0.8.7
/// @dev mint up to `punks` tokens
function mint(uint256 punks) public payable {
        _enforceNotPaused();
        _enforceSale();
        uint256 ts = totalSupply();
        uint256 sl = MAX_WP_SUPPLY;
        require(ts < MAX_WP_SUPPLY, "WantedPunksSoldOut");
        require(punks > 0, "ZeroWantedPunksRequested");
        require(punks <= WP_PACK_LIMIT, "BuyLimitExceeded");
        require(PRICE * punks == msg.value, "InvalidETHAmount");
        require(ts + punks <= sl, "MintingExceedsMaxSupply");

        for (uint256 i = 0; i < punks; i++) {
            _safeMint(msg.sender, ts + i);
        }

        uint256 tip = (msg.value * SPLIT) / 100;
        tipAccumulator += tip;
        earningsAccumulator += (msg.value - tip);

        if (totalSupply() == sl) {
            _reveal();
        }
    }
// Solidity 0.4.24
//
//  Point writing
//
//  activatePoint(): activate a point, register it as spawned by its prefix
//
function activatePoint(uint32 _point)
      onlyOwner
      external
    {
      //  make a point active, setting its sponsor to its prefix
      //
      Point storage point = points[_point];
      require(!point.active);
      point.active = true;
      registerSponsor(_point, true, getPrefix(_point));
      emit Activated(_point);
    }
// Solidity 0.4.24
//  setKeys(): set network public keys of _point to _encryptionKey and
//            _authenticationKey, with the specified _cryptoSuiteVersion
//
function setKeys(uint32 _point,
                     bytes32 _encryptionKey,
                     bytes32 _authenticationKey,
                     uint32 _cryptoSuiteVersion)
      onlyOwner
      external
    {
      Point storage point = points[_point];
      if ( point.encryptionKey == _encryptionKey &&
           point.authenticationKey == _authenticationKey &&
           point.cryptoSuiteVersion == _cryptoSuiteVersion )
      {
        return;
      }

      point.encryptionKey = _encryptionKey;
      point.authenticationKey = _authenticationKey;
      point.cryptoSuiteVersion = _cryptoSuiteVersion;
      point.keyRevisionNumber++;

      emit ChangedKeys(_point,
                       _encryptionKey,
                       _authenticationKey,
                       _cryptoSuiteVersion,
                       point.keyRevisionNumber);
    }
// Solidity 0.4.24
//  registerSpawn(): add a point to its prefix's list of spawned points
//
function registerSpawned(uint32 _point)
      onlyOwner
      external
    {
      //  if a point is its own prefix (a galaxy) then don't register it
      //
      uint32 prefix = getPrefix(_point);
      if (prefix == _point)
      {
        return;
      }

      //  register a new spawned point for the prefix
      //
      points[prefix].spawned.push(_point);
      emit Spawned(prefix, _point);
    }
// Solidity 0.4.24
//  canManage(): true if _who is the owner or manager of _point
//
function canManage(uint32 _point, address _who)
      view
      external
      returns (bool result)
    {
      Deed storage deed = rights[_point];
      return ( (0x0 != _who) &&
               ( (_who == deed.owner) ||
                 (_who == deed.managementProxy) ) );
    }
// Solidity 0.4.24
//  canSpawnAs(): true if _who is the owner or spawn proxy of _point
//
function canSpawnAs(uint32 _point, address _who)
      view
      external
      returns (bool result)
    {
      Deed storage deed = rights[_point];
      return ( (0x0 != _who) &&
               ( (_who == deed.owner) ||
                 (_who == deed.spawnProxy) ) );
    }
// Solidity 0.4.18
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
        public
        payable
        onSale
        validValue
        validInvestor {
        uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
        require(balances[owner] >= requestedUnits);
        // prepare transfer data
        balances[owner] -= requestedUnits;
        balances[msg.sender] += requestedUnits;
        
        // increase total deposit amount
        deposit[msg.sender] += msg.value;
        
        // check total and auto turnOffSale
        totalTokenSold += requestedUnits;
        if (totalTokenSold >= _icoSupply){
            _selling = false;
        }
        
        // submit transfer
        Transfer(owner, msg.sender, requestedUnits);
        owner.transfer(msg.value);
    }
// Solidity 0.4.18
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice) 
        onlyOwner 
        public {
        require(newBuyPrice>0);
        _originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
        // control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
        // maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
        // 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
        // 100,000,00000/3000 0000 ~ 33ETH => change to wei
        _maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
    }
// Solidity 0.4.18
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
        public 
        isTradable
        returns (bool) {
        // if sender's balance has enough unit and amount >= 0, 
        //      and the sum is not overflow,
        // then do transfer 
        if ( (balances[msg.sender] >= _amount) &&
             (_amount >= 0) && 
             (balances[_to] + _amount > balances[_to]) ) {  

            balances[msg.sender] -= _amount;
            balances[_to] += _amount;
            Transfer(msg.sender, _to, _amount);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.18
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
        address _from,
        address _to,
        uint256 _amount
    )
    public
    isTradable
    returns (bool success) {
        if (balances[_from] >= _amount
            && allowed[_from][msg.sender] >= _amount
            && _amount > 0
            && balances[_to] + _amount > balances[_to]) {
            balances[_from] -= _amount;
            allowed[_from][msg.sender] -= _amount;
            balances[_to] += _amount;
            Transfer(_from, _to, _amount);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.18
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
        public
        validRequirement(_owners.length, _required)
    {
        for (uint i=0; i<_owners.length; i++) {
            if (isOwner[_owners[i]] || _owners[i] == 0)
                revert();
            isOwner[_owners[i]] = true;
        }
        owners = _owners;
        required = _required;
    }
// Solidity 0.4.18
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
        public
        onlyWallet
        ownerExists(owner)
    {
        isOwner[owner] = false;
        for (uint i=0; i<owners.length - 1; i++)
            if (owners[i] == owner) {
                owners[i] = owners[owners.length - 1];
                break;
            }
        owners.length -= 1;
        if (required > owners.length)
            changeRequirement(owners.length);
        OwnerRemoval(owner);
    }
// Solidity 0.4.18
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
        public
        onlyWallet
        ownerExists(owner)
        ownerDoesNotExist(newOwner)
    {
        for (uint i=0; i<owners.length; i++)
            if (owners[i] == owner) {
                owners[i] = newOwner;
                break;
            }
        isOwner[owner] = false;
        isOwner[newOwner] = true;
        OwnerRemoval(owner);
        OwnerAddition(newOwner);
    }
// Solidity 0.4.18
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
        public
        constant
        returns (bool)
    {
        uint count = 0;
        for (uint i=0; i<owners.length; i++) {
            if (confirmations[transactionId][owners[i]])
                count += 1;
            if (count == required)
                return true;
        }
    }
// Solidity 0.4.18
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
        internal
        notNull(destination)
        returns (uint transactionId)
    {
        transactionId = transactionCount;
        transactions[transactionId] = Transaction({
            destination: destination,
            value: value,
            data: data,
            executed: false
        });
        transactionCount += 1;
        Submission(transactionId);
    }
// Solidity 0.4.18
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
        public
        constant
        returns (address[] _confirmations)
    {
        address[] memory confirmationsTemp = new address[](owners.length);
        uint count = 0;
        uint i;
        for (i=0; i<owners.length; i++)
            if (confirmations[transactionId][owners[i]]) {
                confirmationsTemp[count] = owners[i];
                count += 1;
            }
        _confirmations = new address[](count);
        for (i=0; i<count; i++)
            _confirmations[i] = confirmationsTemp[i];
    }
// Solidity 0.4.18
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
        public
        constant
        returns (uint[] _transactionIds)
    {
        uint[] memory transactionIdsTemp = new uint[](transactionCount);
        uint count = 0;
        uint i;
        for (i=0; i<transactionCount; i++)
            if (   pending && !transactions[i].executed
                || executed && transactions[i].executed)
            {
                transactionIdsTemp[count] = i;
                count += 1;
            }
        _transactionIds = new uint[](to - from);
        for (i=from; i<to; i++)
            _transactionIds[i - from] = transactionIdsTemp[i];
    }
// Solidity 0.6.12
/// @notice Takes a feePercentage and sends it to wallet
/// @param _amount Dai amount of the whole trade
/// @param _user Address of the user
/// @param _token Address of the token
/// @param _dfsFeeDivider Dfs fee divider
/// @return feeAmount Amount in Dai owner earned on the fee
function getFee(uint256 _amount, address _user, address _token, uint256 _dfsFeeDivider) internal returns (uint256 feeAmount) {
        if (_dfsFeeDivider != 0 && Discount(DISCOUNT_ADDRESS).isCustomFeeSet(_user)) {
            _dfsFeeDivider = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(_user);
        }

        if (_dfsFeeDivider == 0) {
            feeAmount = 0;
        } else {
            feeAmount = _amount / _dfsFeeDivider;

            // fee can't go over 10% of the whole amount
            if (feeAmount > (_amount / 10)) {
                feeAmount = _amount / 10;
            }

            if (_token == KYBER_ETH_ADDRESS) {
                WALLET_ID.transfer(feeAmount);
            } else {
                ERC20(_token).safeTransfer(WALLET_ID, feeAmount);
            }
        }
    }
// Solidity 0.4.24
//  addClaim(): register a claim as _point
//
function addClaim(uint32 _point,
                    string _protocol,
                    string _claim,
                    bytes _dossier)
    external
    activePointManager(_point)
  {
    //  cur: index + 1 of the claim if it already exists, 0 otherwise
    //
    uint8 cur = findClaim(_point, _protocol, _claim);

    //  if the claim doesn't yet exist, store it in state
    //
    if (cur == 0)
    {
      //  if there are no empty slots left, this throws
      //
      uint8 empty = findEmptySlot(_point);
      claims[_point][empty] = Claim(_protocol, _claim, _dossier);
    }
    //
    //  if the claim has been made before, update the version in state
    //
    else
    {
      claims[_point][cur-1] = Claim(_protocol, _claim, _dossier);
    }
    emit ClaimAdded(_point, _protocol, _claim, _dossier);
  }
// Solidity 0.4.24
//  removeClaim(): unregister a claim as _point
//
function removeClaim(uint32 _point, string _protocol, string _claim)
    external
    activePointManager(_point)
  {
    //  i: current index + 1 in _point's list of claims
    //
    uint256 i = findClaim(_point, _protocol, _claim);

    //  we store index + 1, because 0 is the eth default value
    //  can only delete an existing claim
    //
    require(i > 0);
    i--;

    //  clear out the claim
    //
    delete claims[_point][i];

    emit ClaimRemoved(_point, _protocol, _claim);
  }