lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.25
// This famous algorithm is called "exponentiation by squaring"
// and calculates x^n with x as fixed-point and n as regular unsigned.
//
// It's O(log n), instead of O(n) for naive repeated multiplication.
//
// These facts are why it works:
//
//  If n is even, then x^n = (x^2)^(n/2).
//  If n is odd,  then x^n = x * x^(n-1),
//   and applying the equation for even x gives
//    x^n = x * (x^2)^((n-1) / 2).
//
//  Also, EVM division is flooring and
//    floor[(n-1) / 2] = floor[n / 2].
//
function rpow(uint x, uint n) internal pure returns (uint z) {

        z = n % 2 != 0 ? x : RAY;



        for (n /= 2; n != 0; n /= 2) {

            x = rmul(x, x);



            if (n % 2 != 0) {

                z = rmul(z, x);

            }

        }

    }
// Solidity 0.4.25
/**
 
 * @dev Transfer tokens from one address to another
 
 * @param src address The address which you want to send tokens from
 
 * @param dst address The address which you want to transfer to
 
 * @param wad uint256 the amount of tokens to be transferred
 
 */
function transferFrom(address src, address dst, uint wad)

        public

        returns (bool)

    {

        if (src != msg.sender) {

            _approvals[src][msg.sender] = sub(_approvals[src][msg.sender], wad);

        }



        _balances[src] = sub(_balances[src], wad);

        _balances[dst] = add(_balances[dst], wad);



        emit Transfer(src, dst, wad);



        return true;

    }
// Solidity 0.6.12
/* ========== USER MUTATIVE FUNCTIONS ========== */
function deposit(uint _amount) external nonReentrant {
      _updateReward(msg.sender);

      uint _pool = balance();
      token.safeTransferFrom(msg.sender, address(this), _amount);

      uint shares = 0;
      if (totalSupply() == 0) {
        shares = _amount;
      } else {
        shares = (_amount.mul(totalSupply())).div(_pool);
      }
      _mint(msg.sender, shares);
      emit Deposit(msg.sender, _amount);
  }
// Solidity 0.6.12
// No rebalance implementation for lower fees and faster swaps
function withdraw(uint _shares) public nonReentrant {
      _updateReward(msg.sender);

      uint r = (balance().mul(_shares)).div(totalSupply());
      _burn(msg.sender, _shares);

      // Check balance
      uint b = token.balanceOf(address(this));
      if (b < r) {
          uint _withdraw = r.sub(b);
          IController(controller).withdraw(address(this), _withdraw);
          uint _after = token.balanceOf(address(this));
          uint _diff = _after.sub(b);
          if (_diff < _withdraw) {
              r = b.add(_diff);
          }
      }

      token.safeTransfer(msg.sender, r);
      emit Withdraw(msg.sender, r);
  }
// Solidity 0.6.12
// Keepers call farm() to send funds to strategy
function farm() external onlyKeeper {
      uint _bal = available();

      uint keeperFee = _bal.mul(farmKeeperFeeMin).div(MAX);
      if (keeperFee > 0) {
          token.safeTransfer(msg.sender, keeperFee);
      }

      uint amountLessFee = _bal.sub(keeperFee);
      token.safeTransfer(controller, amountLessFee);
      IController(controller).farm(address(this), amountLessFee);

      emit Farm(msg.sender, keeperFee, amountLessFee);
  }
// Solidity 0.6.12
// Keepers call harvest() to claim rewards from strategy
// harvest() is marked as onlyEOA to prevent sandwich/MEV attack to collect most rewards through a flash-deposit() follow by a claim
function harvest() external onlyKeeper {
      uint _rewardBefore = rewardToken.balanceOf(address(this));
      IController(controller).harvest(address(this));
      uint _rewardAfter = rewardToken.balanceOf(address(this));

      uint harvested = _rewardAfter.sub(_rewardBefore);
      uint keeperFee = harvested.mul(harvestKeeperFeeMin).div(MAX);
      if (keeperFee > 0) {
          rewardToken.safeTransfer(msg.sender, keeperFee);
      }

      uint newRewardAmount = harvested.sub(keeperFee);
      // distribute new rewards to current shares evenly
      rewardsPerShareStored = rewardsPerShareStored.add(newRewardAmount.mul(1e18).div(totalSupply()));

      emit Harvest(msg.sender, keeperFee, newRewardAmount);
  }
// Solidity 0.5.8
// Writes are allowed only if the accessManager approves
function setAttribute(address _who, bytes32 _attribute, uint256 _value, bytes32 _notes) public {
        require(confirmWrite(_attribute, msg.sender));
        attributes[_who][_attribute] = AttributeData(_value, _notes, msg.sender, block.timestamp);
        emit SetAttribute(_who, _attribute, _value, _notes, msg.sender);

        RegistryClone[] storage targets = subscribers[_attribute];
        uint256 index = targets.length;
        while (index --> 0) {
            targets[index].syncAttributeValue(_who, _attribute, _value);
        }
    }
// Solidity 0.5.1
/**
 * @notice Deposit funds into contract.
 * @dev the amount of deposit is determined by allowance of this contract
 */
function depositToken(address _user) public {


        uint256 allowance = StakeToken(token).allowance(_user, address(this));
        uint256 oldBalance = userTokenBalance[_user];
        uint256 newBalance = oldBalance.add(allowance);
        require(StakeToken(token).transferFrom(_user, address(this), allowance), "transfer failed");

        /// Update user balance
        userTokenBalance[_user] = newBalance;

        /// update the total balance for the token
        totalTokenBalance = totalTokenBalance.add(allowance);

        // assert(StakeToken(token).balanceOf(address(this)) == totalTokenBalance);

        /// Fire event and return some goodies
        emit UserBalanceChange(_user, oldBalance, newBalance);
    }
// Solidity 0.4.24
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
///  is approved by `_from`
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transferFrom(address _from, address _to, uint256 _amount
    ) public returns (bool success) {

        // The controller of this contract can move tokens around at will,
        //  this is important to recognize! Confirm that you trust the
        //  controller of this contract, which in most situations should be
        //  another open source smart contract or 0x0
        if (msg.sender != controller) {
            require(transfersEnabled);

            // The standard ERC 20 transferFrom functionality
            require(allowed[_from][msg.sender] >= _amount);
            allowed[_from][msg.sender] -= _amount;
        }
        doTransfer(_from, _to, _amount);
        return true;
    }
// Solidity 0.4.24
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
///  its behalf. This is a modified version of the ERC20 approve function
///  to be a little bit safer
/// @param _spender The address of the account able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the approval was successful
function approve(address _spender, uint256 _amount) public returns (bool success) {
        require(transfersEnabled);

        // To change the approve amount you first have to reduce the addresses`
        //  allowance to zero by calling `approve(_spender,0)` if it is not
        //  already 0 to mitigate the race condition described here:
        //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
        require((_amount == 0) || (allowed[msg.sender][_spender] == 0));

        // Alerts the token controller of the approve function call
        if (isContract(controller)) {
            require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
        }

        allowed[msg.sender][_spender] = _amount;
        emit Approval(msg.sender, _spender, _amount);
        return true;
    }
// Solidity 0.4.24
////////////////
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
/// @param _owner The address from which the balance will be retrieved
/// @param _blockNumber The block number when the balance is queried
/// @return The balance at `_blockNumber`
function balanceOfAt(address _owner, uint256 _blockNumber) public view
        returns (uint256) {

        // These next few lines are used when the balance of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.balanceOfAt` be queried at the
        //  genesis block for that token as this contains initial balance of
        //  this token
        if ((balances[_owner].length == 0)
            || (balances[_owner][0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
            } else {
                // Has no parent
                return 0;
            }

        // This will return the expected balance during normal situations
        } else {
            return getValueAt(balances[_owner], _blockNumber);
        }
    }
// Solidity 0.4.24
/// @notice Total amount of tokens at a specific `_blockNumber`.
/// @param _blockNumber The block number when the totalSupply is queried
/// @return The total amount of tokens at `_blockNumber`
function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {

        // These next few lines are used when the totalSupply of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.totalSupplyAt` be queried at the
        //  genesis block for this token as that contains totalSupply of this
        //  token at this block number.
        if ((totalSupplyHistory.length == 0)
            || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
            } else {
                return 0;
            }

        // This will return the expected totalSupply during normal situations
        } else {
            return getValueAt(totalSupplyHistory, _blockNumber);
        }
    }
// Solidity 0.4.24
////////////////
/// @notice Generates `_amount` tokens that are assigned to `_owner`
/// @param _owner The address that will be assigned the new tokens
/// @param _amount The quantity of tokens generated
/// @return True if the tokens are generated correctly
function generateTokens(address _owner, uint256 _amount
    ) public onlyController returns (bool) {
        uint256 curTotalSupply = totalSupply();
        require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
        uint256 previousBalanceTo = balanceOf(_owner);
        require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
        updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
        updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
        emit Transfer(0, _owner, _amount);
        return true;
    }
// Solidity 0.4.24
/// @notice Burns `_amount` tokens from `_owner`
/// @param _owner The address that will lose the tokens
/// @param _amount The quantity of tokens to burn
/// @return True if the tokens are burned correctly
function destroyTokens(address _owner, uint256 _amount
    ) onlyController public returns (bool) {
        uint256 curTotalSupply = totalSupply();
        require(curTotalSupply >= _amount);
        uint256 previousBalanceFrom = balanceOf(_owner);
        require(previousBalanceFrom >= _amount);
        updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
        updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
        emit Transfer(_owner, 0, _amount);
        return true;
    }
// Solidity 0.4.24
////////////////
/// @dev `getValueAt` retrieves the number of tokens at a given block number
/// @param checkpoints The history of values being queried
/// @param _block The block number to retrieve the value at
/// @return The number of tokens being queried
function getValueAt(Checkpoint[] storage checkpoints, uint256 _block
    ) view internal returns (uint256) {
        if (checkpoints.length == 0) return 0;

        // Shortcut for the actual value
        if (_block >= checkpoints[checkpoints.length-1].fromBlock)
            return checkpoints[checkpoints.length-1].value;
        if (_block < checkpoints[0].fromBlock) return 0;

        // Binary search of the value in the array
        uint256 min = 0;
        uint256 max = checkpoints.length-1;
        while (max > min) {
            uint256 mid = (max + min + 1) / 2;
            if (checkpoints[mid].fromBlock <= _block) {
                min = mid;
            } else {
                max = mid - 1;
            }
        }
        return checkpoints[min].value;
    }
// Solidity 0.4.24
/// @dev `updateValueAtNow` used to update the `balances` map and the
///  `totalSupplyHistory`
/// @param checkpoints The history of data being updated
/// @param _value The new number of tokens
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value
    ) internal  {
        if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
            Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
            newCheckPoint.fromBlock = uint128(block.number);
            newCheckPoint.value = uint128(_value);
        } else {
            Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
            oldCheckPoint.value = uint128(_value);
        }
    }
// Solidity 0.4.24
/** 
 * @notice `msg.sender` transfers `_amount` to `_to` contract and then tokenFallback() function is triggered in the `_to` contract.
 * @param _to The address of the contract able to receive the tokens
 * @param _amount The amount of tokens to be transferred
 * @param _data The payload to be treated by `_to` contract in corresponding format
 * @return True if the function call was successful
 */
function transferAndCall(address _to, uint _amount, bytes _data) public returns (bool) {
        require(transfer(_to, _amount));

        emit Transfer(msg.sender, _to, _amount, _data);

        // call receiver
        if (isContract(_to)) {
            ERC677Receiver(_to).tokenFallback(msg.sender, _amount, _data);
        }

        return true;
    }
// Solidity 0.4.24
/**
 * @notice Sets the locks of an array of addresses.
 * @dev Must be called while minting (enableTransfers = false). Sizes of `_holder` and `_lockups` must be the same.
 * @param _holders The array of investor addresses
 * @param _lockups The array of timestamps until which corresponding address must be locked
 */
function setLocks(address[] _holders, uint256[] _lockups) public onlyController {
        require(_holders.length == _lockups.length);
        require(_holders.length < 256);
        require(transfersEnabled == false);

        for (uint8 i = 0; i < _holders.length; i++) {
            address holder = _holders[i];
            uint256 lockup = _lockups[i];

            // make sure lockup period can not be overwritten once set
            require(lockups[holder] == 0);

            lockups[holder] = lockup;

            emit LockedTokens(holder, lockup);
        }
    }
// Solidity 0.4.24
/**
 * @notice Finishes minting process and throws out the controller.
 * @dev Owner can not finish minting without setting up address for burning tokens.
 * @param _burnable The address to burn tokens from
 */
function finishMinting(address _burnable) public onlyController() {
        require(_burnable != address(0x0)); // burnable address must be set
        assert(totalSupply() <= maxSupply); // ensure hard cap
        enableTransfers(true); // turn-on transfers
        changeController(address(0x0)); // ensure no new tokens will be created
        burnable = _burnable; // set burnable address
    }
// Solidity 0.4.24
/**
 * @notice Burns `_amount` tokens from pre-defined "burnable" address.
 * @param _amount The amount of tokens to burn
 * @return True if the tokens are burned correctly
 */
function burn(uint256 _amount) public onlyOwner returns (bool) {
        require(burnable != address(0x0)); // burnable address must be set

        uint256 currTotalSupply = totalSupply();
        uint256 previousBalance = balanceOf(burnable);

        require(currTotalSupply >= _amount);
        require(previousBalance >= _amount);

        updateValueAtNow(totalSupplyHistory, currTotalSupply - _amount);
        updateValueAtNow(balances[burnable], previousBalance - _amount);

        emit Transfer(burnable, 0, _amount);
        
        return true;
    }
// Solidity 0.6.12
// View function to see pending CHKs on frontend.
function pendingChk(uint256 _pid, address _user) external view returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accChkPerShare = pool.accChkPerShare;
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        // console.log("lpSupply: ", lpSupply);
        // console.log("pool.lastRewardBlock: ", pool.lastRewardBlock);
        if (block.number > pool.lastRewardBlock && lpSupply != 0) {
            uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
            // console.log("multiplier: ", multiplier );
            // console.log("chkPerBlock: ", chkPerBlock);
            // console.log("pool.allocPoint: ", pool.allocPoint);
            // console.log("totalAlloc: ", totalAllocPoint);
            uint256 chkReward = multiplier.mul(chkPerBlock.mul(pool.allocPoint).div(totalAllocPoint));
            // console.log("accChkPerShare: ", accChkPerShare);
            // console.log("chkReward: ", chkReward);
            accChkPerShare = accChkPerShare.add(chkReward.mul(1e18).div(lpSupply));
            // console.log("accChkPerShare: ", accChkPerShare);
        }
        return user.amount.mul(accChkPerShare).div(1e18).sub(user.rewardDebt);
    }
// Solidity 0.4.19
// =================================== Constructor =============================================
function JubsICO ()public {                 
      //Address
      walletETH = 0x6eA3ec9339839924a520ff57a0B44211450A8910;
      icoWallet = 0x357ace6312BF8B519424cD3FfdBB9990634B8d3E;
      preIcoWallet = 0x7c54dC4F3328197AC89a53d4b8cDbE35a56656f7;
      teamWallet = 0x06BC5305016E9972F4cB3F6a3Ef2C734D417788a;
      bountyMktWallet = 0x6f67b977859deE77fE85cBCAD5b5bd5aD58bF068;
      arbitrationWallet = 0xdE9DE3267Cbd21cd64B40516fD2Aaeb5D77fb001;
      rewardsWallet = 0x232f7CaA500DCAd6598cAE4D90548a009dd49e6f;
      advisorsWallet = 0xA6B898B2Ab02C277Ae7242b244FB5FD55cAfB2B7;
      operationWallet = 0x96819778cC853488D3e37D630d94A337aBd527A8;

      //Distribution Token  
      balances[icoWallet] = totalSupply.mul(63).div(100);                 //totalSupply * 63%
      balances[preIcoWallet] = totalSupply.mul(7).div(100);               //totalSupply * 7%
      balances[teamWallet] = totalSupply.mul(10).div(100);                //totalSupply * 10%
      balances[bountyMktWallet] = totalSupply.mul(7).div(100);            //totalSupply * 7%
      balances[arbitrationWallet] = totalSupply.mul(5).div(100);          //totalSupply * 5%
      balances[rewardsWallet] = totalSupply.mul(5).div(100);              //totalSupply * 5%
      balances[advisorsWallet] = totalSupply.mul(2).div(100);             //totalSupply * 2%
      balances[operationWallet] = totalSupply.mul(1).div(100);            //totalSupply * 1%      

      //set pause
      pause();

      //set token to sale
      totalTokenToSale = balances[icoWallet].add(balances[preIcoWallet]);           
    }
// Solidity 0.4.15
// if supply provided is 0, then default assigned
function svb(uint supply) {
        if (supply > 0) {
            totalSupply = supply;
        } else {
            totalSupply = totalSupplyDefault;
        }
        owner = msg.sender;
        demurringFeeOwner = owner;
        transferFeeOwner = owner;
        balances[this] = totalSupply;
    }
// Solidity 0.4.15
// charge demurring fee for previuos period
// fee is not applied to owners
function chargeDemurringFee(address addr) internal {
        if (addr != owner && addr != transferFeeOwner && addr != demurringFeeOwner && balances[addr] > 0 && now > timestamps[addr] + 60) {
            var mins = (now - timestamps[addr]) / 60;
            var fee = balances[addr] * mins * demurringFeeNum / demurringFeeDenum;
            if (fee < minFee) {
                fee = minFee;
            } else if (fee > balances[addr]) {
                fee = balances[addr];
            }

            balances[addr] -= fee;
            balances[demurringFeeOwner] += fee;
            Transfer(addr, demurringFeeOwner, fee);
            DemurringFee(addr, fee);

            timestamps[addr] = uint64(now);
        }
    }
// Solidity 0.4.15
// fee is not applied to owners
function chargeTransferFee(address addr, uint amount) internal returns (uint) {
        if (addr != owner && addr != transferFeeOwner && addr != demurringFeeOwner && balances[addr] > 0) {
            var fee = amount * transferFeeNum / transferFeeDenum;
            if (fee < minFee) {
                fee = minFee;
            } else if (fee > balances[addr]) {
                fee = balances[addr];
            }
            amount = amount - fee;

            balances[addr] -= fee;
            balances[transferFeeOwner] += fee;
            Transfer(addr, transferFeeOwner, fee);
            TransferFee(addr, fee);
        }
        return amount;
    }
// Solidity 0.6.12
/**
 * @dev Notifies Fragments contract about a new rebase cycle.
 * @param supplyDelta The number of new fragment tokens to add into circulation via expansion.
 * @return The total number of fragments after the supply adjustment.
 */
function rebase(uint256 epoch_, int256 supplyDelta)
        external
        onlyOwner
        returns (uint256)
    {

        // console.log(symbol(), ": starting total supply ",  epoch, _totalSupply.div(10**18));
        // console.log("gonsPerFragment: ", epoch, _gonsPerFragment);

        epoch = epoch_;

        if (supplyDelta == 0) {
            emit LogRebase(epoch, _totalSupply);
            return _totalSupply;
        }

        if (supplyDelta < 0) {
            // console.log(symbol(), ": supply delta / _totalSupply -", uint256(supplyDelta.abs()), _totalSupply);
            _totalSupply = _totalSupply.sub(uint256(supplyDelta.abs()));
        } else {
            // console.log(symbol(), ": supply delta +", uint256(supplyDelta.abs()));
            _totalSupply = _totalSupply.add(uint256(supplyDelta));
        }

        if (_totalSupply > MAX_SUPPLY) {
            _totalSupply = MAX_SUPPLY;
        }

        if (_totalSupply > 0) {
            _gonsPerFragment = _totalGons.div(_totalSupply);

            if (_gonsPerFragment == 0) {
                _gonsPerFragment = 10**24; //TODO: is this right?
            }
        } else if (_totalGons > 0) {
            _currentBalances++;
            _gonsPerFragment = 10**24;
            _totalGons = 0;
        }

        emit LogRebase(epoch, _totalSupply);
        return _totalSupply;
    }