lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.16
// ------ FUNCTION -------
// 
//   SET REWARDS INTERVAL () ONLY OWNER
// 
//      #require() that reward interval sullpied as argument is greater than 1 and less than 365 inclusive
//   
//      MODIFY : rewardInterval to supplied _rewardInterval
// 
//      EMIT : update reward interval
//   
//   EXIT
//  
function setRewardsInterval(uint256 _rewardInterval) external onlyOwner {
        require(
            _rewardInterval >= 1 && _rewardInterval <= 365,
            "Staking reward interval must be between 1 and 365 inclusive"
        );
        rewardInterval = _rewardInterval * 1 days;
        emit RewardsDurationUpdated(rewardInterval);
    }
// Solidity 0.5.16
// ------ FUNCTION -------#
// 
//   SET REWARDS DIVIDER () ONLY OWNER
// 
//      #require() that reward divider sullpied as argument is greater than original divider
//   
//      MODIFY : rewardIntervalDivider to supplied _rewardInterval
//   
//   EXIT
//  
function updateChunkUsersRewards(uint256 startIndex, uint256 endIndex) external onlyOwner {

        uint256 length = allAddress.length;
        require(endIndex <= length, "Cant end on index greater than length of addresses");
        require(endIndex > startIndex, "Nothing to iterate over");
        

        for (uint i = startIndex; i < endIndex; i++) {
            lockInRewardOnBehalf(allAddress[i]);
        }
    }
// Solidity 0.4.25
/// @notice Transfers '_value' in aToken to the '_to' address
/// @param _to The recipient address
/// @param _value The amount of wei to transfer
function transfer(address _to, uint256 _value) public returns (bool success) {
        /* Check if sender has balance and for overflows */
        require(balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
        
        /* Check if amount is nonzero */
        require(_value > 0);

        /* Add and subtract new balances */
        balances[msg.sender] -= _value;
        balances[_to] += _value;
    
        /* Notify anyone listening that this transfer took place */
        emit Transfer(msg.sender, _to, _value);
        
        return true;
    }
// Solidity 0.4.25
/// @notice Sells aToken in exchnage for wei at the current bid 
/// price, reduces resreve
/// @return Proceeds of wei from sale of aToken
function sell(uint256 amount) public returns (uint256 revenue){
        uint256 a = 0;
        
        require(initialSaleComplete);
        require(balances[msg.sender] >= amount);        // checks if the sender has enough to sell
        
        a = _totalSupply - amount;

        uint256 p = 0;
        uint8 ps = 0;

        (p, ps) = power(1000008,1000000,(uint32)(1e5+1e5*_totalSupply/SU),1e5); // Calculate exponent
        p=(S*p)>>ps;

        uint256 p2 = 0;
        uint8 ps2 = 0;

        (p2, ps2) = power(1000008,1000000,(uint32)(1e5+1e5*a/SU),1e5); // Calculate exponent
        p2=(S*p2)>>ps2;

            

        revenue = (SU*p-SU*p2)*R/S;
        
       // debugVal2 = revenue;
        //debugVal3 = p;
        //debugVal4 = p2;
        
        _totalSupply -= amount;                 // burn the tokens
        require(balances[reserveAddress] >= revenue);
        balances[reserveAddress] -= revenue;             // adds the amount to owner's balance
        balances[msg.sender] -= amount;                 // subtracts the amount from seller's balance
        Contract reserve = Contract(reserveAddress);
        reserve.sendFunds(msg.sender, revenue);
        
        emit Transfer(msg.sender, reserveAddress, amount);               // executes an event reflecting on the change

        quoteAsk();
        quoteBid();  

        return revenue;                                 // ends function and returns
    }
// Solidity 0.4.25
/// @notice Compute '_k * (1+1/_q) ^ _n', with precision '_p'
/// @dev The higher the precision, the higher the gas cost. It should be
/// something around the log of 'n'. When 'p == n', the
/// precision is absolute (sans possible integer overflows).
/// Much smaller values are sufficient to get a great approximation.
/// @param _k input param k
/// @param _q input param q
/// @param _n input param n
/// @param _p input param p
/// @return '_k * (1+1/_q) ^ _n'   
function fracExp(uint256 _k, uint256 _q, uint256 _n, uint256 _p) internal pure returns (uint256) {
      uint256 s = 0;
      uint256 N = 1;
      uint256 B = 1;
      for (uint256 i = 0; i < _p; ++i){
        s += _k * N / B / (_q**i);
        N  = N * (_n-i);
        B  = B * (i+1);
      }
      return s;
    }
// Solidity 0.4.25
/// @notice Compute the natural logarithm
/// @notice outputs ln()*FIXED_3*lnr*1e18
/// @dev This functions assumes that the numerator is larger than or equal 
/// to the denominator, because the output would be negative otherwise.
/// @param _numerator is a value between 1 and 2 ^ (256 - MAX_PRECISION) - 1
/// @param _denominator is a value between 1 and 2 ^ (256 - MAX_PRECISION) - 1
/// @return is a value between 0 and floor(ln(2 ^ (256 - MAX_PRECISION) - 1) * 2 ^ MAX_PRECISION)
function ln_fixed3_lnr_18(uint256 _numerator, uint256 _denominator) internal pure returns (uint256) {
        assert(_numerator <= MAX_NUM);

        uint256 res = 0;
        uint256 x = _numerator * FIXED_1 / _denominator;

        // If x >= 2, then we compute the integer part of log2(x), which is larger than 0.
        if (x >= FIXED_2) {
            uint8 count = floorLog2(x / FIXED_1);
            x >>= count; // now x < 2
            res = count * FIXED_1;
        }

        // If x > 1, then we compute the fraction part of log2(x), which is larger than 0.
        if (x > FIXED_1) {
            for (uint8 i = MAX_PRECISION; i > 0; --i) {
                x = (x * x) / FIXED_1; // now 1 < x < 4
                if (x >= FIXED_2) {
                    x >>= 1; // now 1 < x < 2
                    res += ONE << (i - 1);
                }
            }
        }

        return (((res * LN2_MANTISSA) >> LN2_EXPONENT)*lnR*1e18);
    }
// Solidity 0.4.25
/// @notice Compute the largest integer smaller than or equal to 
/// the binary logarithm of the input
/// @param _n Operand of the function
/// @return Floor(Log2(_n))
function floorLog2(uint256 _n) internal pure returns (uint8) {
        uint8 res = 0;

        if (_n < 256) {
            // At most 8 iterations
            while (_n > 1) {
                _n >>= 1;
                res += 1;
            }
        }
        else {
            // Exactly 8 iterations
            for (uint8 s = 128; s > 0; s >>= 1) {
                if (_n >= (ONE << s)) {
                    _n >>= s;
                    res |= s;
                }
            }
        }

        return res;
    }
// Solidity 0.4.25
/// @notice Round the operand to one decimal place
/// @param _n Operand to be rounded
/// @param _m Divisor
/// @return ROUND(_n/_m)
function round(uint256 _n, uint256 _m) internal pure returns (uint256) {
        uint256 res = 0;
        
        uint256 p =_n/_m;
        res = _n-(_m*p);
        
        if(res >= 1)
        {
            res = p+1;
        }
        else
        {
            res = p;
        }

        return res;
    }
// Solidity 0.8.7
/**
 * @dev Claims airdropped tokens.
 * @param amount The amount of the claim being made.
 * @param delegate The address the tokenholder wants to delegate their votes to.
 * @param merkleProof A merkle proof proving the claim is valid.
 */
function claimTokens(uint256 amount, address delegate, bytes32[] calldata merkleProof) external {
        bytes32 leaf = keccak256(abi.encodePacked(msg.sender, amount));
        (bool valid, uint256 index) = MerkleProof.verify(merkleProof, merkleRoot, leaf);
        require(valid, "ENS: Valid proof required.");
        require(!isClaimed(index), "ENS: Tokens already claimed.");
        
        claimed.set(index);
        emit Claim(msg.sender, amount);

        _delegate(msg.sender, delegate);
        _transfer(address(this), msg.sender, amount);
    }
// Solidity 0.8.7
/**
 * @dev Mints new tokens. Can only be executed every `minimumMintInterval`, by the owner, and cannot
 *      exceed `mintCap / 10000` fraction of the current total supply.
 * @param dest The address to mint the new tokens to.
 * @param amount The quantity of tokens to mint.
 */
function mint(address dest, uint256 amount) external onlyOwner {
        require(amount <= (totalSupply() * mintCap) / 10000, "ENS: Mint exceeds maximum amount");
        require(block.timestamp >= nextMint, "ENS: Cannot mint yet");

        nextMint = block.timestamp + minimumMintInterval;
        _mint(dest, amount);
    }
// Solidity 0.8.6
/**
 * Set some Giraffes aside
 */
function reserveGiraffes(uint256 numberOfTokens) public onlyOwner {
        uint256 i;
        for (i = 0; i < numberOfTokens; i++) {
            uint256 index = totalSupply();
            if (index < maxGiraffes) {
                setGiraffePortionTimesHundredByIndex(index, 0);
                _safeMint(msg.sender, index);
            }
        }
    }
// Solidity 0.8.6
/**
 * Mints Giraffes
 */
function mintGiraffe(uint256 numberOfTokens) public payable {
        require(saleIsActive, "Sale must be active to mint a Giraffe");
        require(
            numberOfTokens <= maxGiraffesPurchase,
            "Can only mint 10 Giraffes at a time"
        );
        require(
            totalSupply().add(numberOfTokens) <= maxGiraffes,
            "Purchase would exceed max supply of Giraffes"
        );
        require(
            giraffePrice.mul(numberOfTokens) <= msg.value,
            "Ether value sent is not correct"
        );

        for (uint256 i = 0; i < numberOfTokens; i++) {
            uint256 index = totalSupply();
            if (index < maxGiraffes) {
                setGiraffePortionTimesHundredByIndex(index, 0);
                _safeMint(msg.sender, index);
            }
        }
    }
// Solidity 0.6.6
// Function to use for staking with an event where cardId and cardAmount are fixed
function stake(uint256 _eventId) public {
        StakingEvent storage _event = stakingEvents[_eventId];
        UserInfo storage _userInfo = userInfo[msg.sender][_eventId];

        require(block.number <= _event.blockEventClose, "Event is closed");
        require(_userInfo.isCompleted == false, "Address already completed event");
        require(_userInfo.blockEnd == 0, "Address already staked for this event");

        pepemonFactory.safeBatchTransferFrom(msg.sender, address(this), _event.cardIdList, _event.cardAmountList, "");

        // Save list cards staked in storage
        for (uint256 i = 0; i < _event.cardIdList.length; i++) {
            uint256 cardId = _event.cardIdList[i];
            uint256 amount = _event.cardAmountList[i];

            cardsStaked[msg.sender][_eventId][cardId] = amount;
        }

        _userInfo.blockEnd = block.number.add(_event.blockStakeLength);

        emit StakingEventEntered(msg.sender, _eventId);
    }
// Solidity 0.8.7
/*///////////////////////////////////////////////////////////////
 EIP-2612 LOGIC
 //////////////////////////////////////////////////////////////*/
function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            bytes32 digest = keccak256(
                abi.encodePacked(
                    "\x19\x01",
                    DOMAIN_SEPARATOR(),
                    keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
                )
            );

            address recoveredAddress = ecrecover(digest, v, r, s);

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }
// Solidity 0.6.6
// Claim staked cards + reward
function claim(uint256 _eventId) public {
        StakingEvent storage _event = stakingEvents[_eventId];
        UserInfo storage _userInfo = userInfo[msg.sender][_eventId];

        require(block.number >= _userInfo.blockEnd, "BlockEnd not reached");

        _userInfo.isCompleted = true;
        pepemonFactory.mint(msg.sender, _event.cardRewardId, 1, "");
        _withdrawCardsStaked(_eventId, true);

        emit StakingEventCompleted(msg.sender, _eventId);
    }
// Solidity 0.8.7
/*///////////////////////////////////////////////////////////////
 ETH OPERATIONS
 //////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
        bool callStatus;

        assembly {
            // Transfer the ETH and store if it succeeded or not.
            callStatus := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(callStatus, "ETH_TRANSFER_FAILED");
    }
// Solidity 0.8.7
/*///////////////////////////////////////////////////////////////
 ERC20 OPERATIONS
 //////////////////////////////////////////////////////////////*/
function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        bool callStatus;

        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata to memory piece by piece:
            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
            mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "from" argument.
            mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
            mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.

            // Call the token and store if it succeeded or not.
            // We use 100 because the calldata length is 4 + 32 * 3.
            callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)
        }

        require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FROM_FAILED");
    }
// Solidity 0.8.7
/*///////////////////////////////////////////////////////////////
 INTERNAL HELPER LOGIC
 //////////////////////////////////////////////////////////////*/
function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) {
        assembly {
            // Get how many bytes the call returned.
            let returnDataSize := returndatasize()

            // If the call reverted:
            if iszero(callStatus) {
                // Copy the revert message into memory.
                returndatacopy(0, 0, returnDataSize)

                // Revert with the same message.
                revert(0, returnDataSize)
            }

            switch returnDataSize
            case 32 {
                // Copy the return data into memory.
                returndatacopy(0, 0, returnDataSize)

                // Set success to whether it returned true.
                success := iszero(iszero(mload(0)))
            }
            case 0 {
                // There was no return data.
                success := 1
            }
            default {
                // It returned some malformed input.
                success := 0
            }
        }
    }
// Solidity 0.6.6
// Withdraw staked cards, but reset event progress
function cancel(uint256 _eventId) public {
        UserInfo storage _userInfo = userInfo[msg.sender][_eventId];

        require(_userInfo.isCompleted == false, "Address already completed event");
        require(_userInfo.blockEnd != 0, "Address is not staked for this event");

        delete _userInfo.isCompleted;
        delete _userInfo.blockEnd;

        _withdrawCardsStaked(_eventId, false);

        emit StakingEventCancelled(msg.sender, _eventId);
    }
// Solidity 0.8.7
/// @notice             Update merkle root and rate
/// @param _merkleRoot  root of merkle tree
/// @param _rate        price of pCNV in DAI/FRAX
function setRound(
        bytes32 _merkleRoot,
        uint256 _rate
    ) external onlyConcave {
        // push new root to array of all roots - for viewing
        roots.push(_merkleRoot);
        // update merkle root
        merkleRoot = _merkleRoot;
        // update rate
        rate = _rate;

        emit NewRound(merkleRoot,rate);
    }
// Solidity 0.8.7
/// @notice               mint pCNV by providing merkle proof and depositing DAI; uses EIP-2612 permit to save a transaction
/// @param to             whitelisted address pCNV will be minted to
/// @param tokenIn        address of tokenIn user wishes to deposit (DAI)
/// @param maxAmount      max amount of DAI sender can deposit for pCNV, to verify merkle proof
/// @param amountIn       amount of DAI sender wishes to deposit for pCNV
/// @param proof          merkle proof to prove "to" and "maxAmount" are in merkle tree
/// @param permitDeadline EIP-2612 : time when permit is no longer valid
/// @param v              EIP-2612 : part of EIP-2612 signature
/// @param r              EIP-2612 : part of EIP-2612 signature
/// @param s              EIP-2612 : part of EIP-2612 signature
function mintWithPermit(
        address to,
        address tokenIn,
        uint256 maxAmount,
        uint256 amountIn,
        bytes32[] calldata proof,
        uint256 permitDeadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountOut) {
        // Make sure payment tokenIn is DAI
        require(tokenIn == address(DAI), TOKEN_IN_ERROR);
        // Approve tokens for spender - https://eips.ethereum.org/EIPS/eip-2612
        ERC20(tokenIn).permit(msg.sender, address(this), amountIn, permitDeadline, v, r, s);
        // allow sender to mint for "to"
        return _purchase(msg.sender, to, tokenIn, maxAmount, amountIn, proof);
    }
// Solidity 0.6.6
// Keeping some NFTs aside
function reserveNft(uint256 reserve) public onlyOwner {
        uint supply = totalSupply();
        uint counter;
        for (counter = 0; counter < reserve; counter++) {
            uint reserved_id = supply + counter;
            _safeMint(msg.sender, reserved_id);
            // string memory tokenURI = string(abi.encodePacked(tokenURI(reserved_id), ".json"));
        }
    }
// Solidity 0.6.6
// The main minting function
function mint(uint256 amount) public payable {
        require(isSaleActive, "Sale must be active to mint NFT");
        require(amount <= MAX_NFT, "Amount must be less than MAX_NFT");
        require(totalSupply().add(amount) <= MAX_NFT, "Total supply + amount must be less than MAX_NFT");
        require(nftPrice.mul(amount) == msg.value, "Ether value sent is not correct");
        require(amount <= maxNftPurchase, "Can't mint more than 50");

        for(uint counter = 0; counter < amount; counter++) {
            uint mintIndex = totalSupply();
            if(totalSupply() < MAX_NFT) {
                _safeMint(msg.sender, mintIndex);
            }
        }

        // If we haven't set the starting index and it is either
        // 1. the last saleable token or
        // 2. the first token to be sold after the end of pre-sale
        // set the starting index block
        if(startingIndexBlock == 0 && (totalSupply() == MAX_NFT || block.timestamp >= REVEAL_TIMESTAMP)) {
            startingIndexBlock = block.number;
        }
    }
// Solidity 0.4.21
/// Withdraw a bid that was overbid.
function withdraw() public {
        uint amount = pendingReturns[msg.sender];
        require (amount > 0);

        // It is important to set this to zero because the recipient
        // can call this function again as part of the receiving call
        // before `send` returns.

        totalReturns -= amount;
        pendingReturns[msg.sender] -= amount;

        msg.sender.transfer(amount);
        emit Withdraw(msg.sender, amount);
    }
// Solidity 0.8.0
//                          pair , 100
function _reflect(address account, uint256 amount) internal {
        require(account != address(0), "reflect from the zero address");

        //      from(pair)  , to(this)     , 100DHOld 
        _rawTransfer(account, address(this), amount);
        totalReflected += amount;
        emit Transfer(account, address(this), amount);
    }
// Solidity 0.8.0
// modified from OpenZeppelin ERC20
function _rawTransfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "transfer from the zero address");
        require(recipient != address(0), "transfer to the zero address");

        uint256 senderBalance = balanceOf(sender);
        require(senderBalance >= amount, "transfer amount exceeds balance");
        unchecked {
            _subtractBalance(sender, amount);
        }
        _addBalance(recipient, amount);

        emit Transfer(sender, recipient, amount);
    }
// Solidity 0.6.12
// function to claim all the tokens locked for a user, after the locking period
function claimAllForUser(uint256 r, address user) public {
        require(!emergencyFlag, "Emergency mode, cannot access this function");
        require(r>latestCounterByUser[user], "Increase right header, already claimed till this");
        require(r<=lockInfoByUser[user].length, "Decrease right header, it exceeds total length");
        LockInfo[] memory lockInfoArrayForUser = lockInfoByUser[user];
        uint256 totalTransferableAmount = 0;
        uint i;
        for (i=latestCounterByUser[user]; i<r; i++){
            uint256 lockingPeriodHere = lockingPeriod;
            if(lockInfoArrayForUser[i]._isDev){
                lockingPeriodHere = devLockingPeriod;
            }
            if(now >= (lockInfoArrayForUser[i]._timestamp.add(lockingPeriodHere))){
                totalTransferableAmount = totalTransferableAmount.add(lockInfoArrayForUser[i]._amount);
                unclaimedTokensByUser[user] = unclaimedTokensByUser[user].sub(lockInfoArrayForUser[i]._amount);
                latestCounterByUser[user] = i.add(1);
            } else {
                break;
            }
        }
        boneToken.transfer(user, totalTransferableAmount);
    }
// Solidity 0.6.12
/**
 * @dev Destroys `amount` tokens from `account`, reducing the
 * total supply.
 *
 * Emits a {Transfer} event with `to` set to the zero address.
 *
 */
function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address disallowed");
        _beforeTokenTransfer(account, address(0), amount);
        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }
// Solidity 0.7.6
/// @dev get expected return and conversion rate
function getExpectedReturn(GetExpectedReturnParams calldata params)
        external
        view
        override
        onlyProxyContract
        returns (uint256 destAmount)
    {
        require(params.tradePath.length == 2, "kyber_invalidTradepath");
        uint256 expectedRate = kyberProxy.getExpectedRateAfterFee(
            IERC20Ext(params.tradePath[0]),
            IERC20Ext(params.tradePath[1]),
            params.srcAmount,
            params.feeBps,
            params.extraArgs
        );
        destAmount = calcDestAmount(
            IERC20Ext(params.tradePath[0]),
            IERC20Ext(params.tradePath[1]),
            params.srcAmount,
            expectedRate
        );
    }