lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.16
/**
 * @notice Mint new tokens
 * @param dst The address of the destination account
 * @param rawAmount The number of tokens to be minted
 */
function mint(address dst, uint rawAmount) external {
        require(msg.sender == minter, "Pool::mint: only the minter can mint");
        require(block.timestamp >= mintingAllowedAfter, "Pool::mint: minting not allowed yet");
        require(dst != address(0), "Pool::mint: cannot transfer to the zero address");

        // record the mint
        mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints);

        // mint the amount
        uint96 amount = safe96(rawAmount, "Pool::mint: amount exceeds 96 bits");
        require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), "Pool::mint: exceeded mint cap");
        totalSupply = safe96(SafeMath.add(totalSupply, amount), "Pool::mint: totalSupply exceeds 96 bits");

        // transfer the amount to the recipient
        balances[dst] = add96(balances[dst], amount, "Pool::mint: transfer amount overflows");
        emit Transfer(address(0), dst, amount);

        // move delegates
        _moveDelegates(address(0), delegates[dst], amount);
    }
// Solidity 0.4.13
// return dynamic pricing
function getRate() constant returns (uint256) {
    uint256 bonus = 0;
    if (now < (startTime + 1 weeks)) {
      bonus = 300;
    } else if (now < (startTime + 2 weeks)) {
      bonus = 200;
    } else if (now < (startTime + 3 weeks)) {
      bonus = 100;
    }
    return BASE_RATE.add(bonus);
  }
// Solidity 0.4.13
// do final token distribution
function finalize() onlyOwner() {
    if (isFinalized) revert();

    //if we are under the cap and not hit the duration then throw
    if (weiRaised < WEI_RAISED_CAP && now <= startTime + DURATION) revert();

    uint256 finalSupply = getFinalSupply();

    grantTokensByShare(ANGELS_ADDRESS, ANGELS_SHARE, finalSupply);
    grantTokensByShare(CORE_1_ADDRESS, CORE_1_SHARE, finalSupply);
    grantTokensByShare(CORE_2_ADDRESS, CORE_2_SHARE, finalSupply);

    grantTokensByShare(PARTNERSHIP_ADDRESS, PARTNERSHIP_SHARE, finalSupply);
    grantTokensByShare(REWARDS_ADDRESS, REWARDS_SHARE, finalSupply);
    grantTokensByShare(AFFILIATE_ADDRESS, AFFILIATE_SHARE, finalSupply);
    
    isFinalized = true;
  }
// Solidity 0.8.6
/**
 * @notice Retrieve the value of the amount at the latest oracle price.
 */
function _peek(bytes6 base, bytes6 quote, uint256 amountBase)
        private view
        returns (uint256 amountQuote, uint256 updateTime)
    {
        Source memory source = sources[base][quote];
        require(source.pool != address(0), "Source not found");
        int24 twapTick = OracleLibrary.consult(source.pool, source.twapInterval);
        amountQuote = OracleLibrary.getQuoteAtTick(
            twapTick,
            amountBase.u128(),
            source.baseToken,
            source.quoteToken
        );
        updateTime = block.timestamp - source.twapInterval;
    }
// Solidity 0.8.6
/**
 * @notice Set or reset an oracle source, its inverse and twapInterval
 */
function _setSource(bytes6 base, bytes6 quote, address pool, uint32 twapInterval) internal {
        sources[base][quote] = Source(
            pool,
            IUniswapV3PoolImmutables(pool).token0(),
            IUniswapV3PoolImmutables(pool).token1(),
            twapInterval        
        );
        sources[quote][base] = Source(
            pool,
            IUniswapV3PoolImmutables(pool).token1(),
            IUniswapV3PoolImmutables(pool).token0(),
            twapInterval        
        );
        emit SourceSet(base, quote, pool, twapInterval);
        emit SourceSet(quote, base, pool, twapInterval);
    }
// Solidity 0.4.25
// NOTE: Some common logic with _distributeTax
function _distributeAuctionTax(uint256 tax, address referrer) private {
        _distributeLandholderTax(_totalLandholderTax(tax));

        // NOTE: Because no notion of 'current jackpot', everything added to next pot
        uint256 totalJackpotTax = _jackpotTax(tax).add(_nextPotTax(tax));
        nextJackpot = nextJackpot.add(totalJackpotTax);

        // NOTE: referrer tax comes out of dev team tax
        bool hasReferrer = referrer != address(0);
        _sendToTeam(_teamTax(tax, hasReferrer));
        asyncSend(referrer, _referrerTax(tax, hasReferrer));
    }
// Solidity 0.4.18
/*
 * @dev Function used by currency contracts to create a request in the Core
 *
 * @dev _payees and _expectedAmounts must have the same size
 *
 * @param _creator Request creator. The creator is the one who initiated the request (create or sign) and not necessarily the one who broadcasted it
 * @param _payees array of payees address (the index 0 will be the payee the others are subPayees). Size must be smaller than 256.
 * @param _expectedAmounts array of Expected amount to be received by each payees. Must be in same order than the payees. Size must be smaller than 256.
 * @param _payer Entity expected to pay
 * @param _data data of the request
 * @return Returns the id of the request
 */
function createRequest(
        address     _creator,
        address[]   _payees,
        int256[]    _expectedAmounts,
        address     _payer,
        string      _data)
        external
        whenNotPaused 
        returns (bytes32 requestId) 
    {
        // creator must not be null
        require(_creator!=0); // not as modifier to lighten the stack
        // call must come from a trusted contract
        require(isTrustedContract(msg.sender)); // not as modifier to lighten the stack

        // Generate the requestId
        requestId = generateRequestId();

        address mainPayee;
        int256 mainExpectedAmount;
        // extract the main payee if filled
        if(_payees.length!=0) {
            mainPayee = _payees[0];
            mainExpectedAmount = _expectedAmounts[0];
        }

        // Store the new request
        requests[requestId] = Request(_payer, msg.sender, State.Created, Payee(mainPayee, mainExpectedAmount, 0));

        // Declare the new request
        Created(requestId, mainPayee, _payer, _creator, _data);
        
        // Store and declare the sub payees (needed in internal function to avoid "stack too deep")
        initSubPayees(requestId, _payees, _expectedAmounts);

        return requestId;
    }
// Solidity 0.4.18
/*
 * @dev Function used to update the balance
 * @dev callable only by the currency contract of the request
 * @param _requestId Request id
 * @param _payeeIndex index of the payee (0 = main payee)
 * @param _deltaAmount modifier amount
 */
function updateBalance(bytes32 _requestId, uint8 _payeeIndex, int256 _deltaAmount)
        external
    {   
        Request storage r = requests[_requestId];
        require(r.currencyContract==msg.sender);

        if( _payeeIndex == 0 ) {
            // modify the main payee
            r.payee.balance = r.payee.balance.add(_deltaAmount);
        } else {
            // modify the sub payee
            Payee storage sp = subPayees[_requestId][_payeeIndex-1];
            sp.balance = sp.balance.add(_deltaAmount);
        }
        UpdateBalance(_requestId, _payeeIndex, _deltaAmount);
    }
// Solidity 0.4.18
/*
 * @dev Function update the expectedAmount adding additional or subtract
 * @dev callable only by the currency contract of the request
 * @param _requestId Request id
 * @param _payeeIndex index of the payee (0 = main payee)
 * @param _deltaAmount modifier amount
 */
function updateExpectedAmount(bytes32 _requestId, uint8 _payeeIndex, int256 _deltaAmount)
        external
    {   
        Request storage r = requests[_requestId];
        require(r.currencyContract==msg.sender); 

        if( _payeeIndex == 0 ) {
            // modify the main payee
            r.payee.expectedAmount = r.payee.expectedAmount.add(_deltaAmount);    
        } else {
            // modify the sub payee
            Payee storage sp = subPayees[_requestId][_payeeIndex-1];
            sp.expectedAmount = sp.expectedAmount.add(_deltaAmount);
        }
        UpdateExpectedAmount(_requestId, _payeeIndex, _deltaAmount);
    }
// Solidity 0.4.18
/*
 * @dev Internal: Init payees for a request (needed to avoid 'stack too deep' in createRequest())
 * @param _requestId Request id
 * @param _payees array of payees address
 * @param _expectedAmounts array of payees initial expected amounts
 */
function initSubPayees(bytes32 _requestId, address[] _payees, int256[] _expectedAmounts)
        internal
    {
        require(_payees.length == _expectedAmounts.length);
     
        for (uint8 i = 1; i < _payees.length; i = i.add(1))
        {
            // payees address cannot be 0x0
            require(_payees[i] != 0);
            subPayees[_requestId][i-1] = Payee(_payees[i], _expectedAmounts[i], 0);
            NewSubPayee(_requestId, _payees[i]);
        }
    }
// Solidity 0.4.18
/*
 * @dev check if all the payees balances are null
 * @param _requestId Request id
 * @return true if all the payees balances are equals to 0
 */
function areAllBalanceNull(bytes32 _requestId)
        public
        constant
        returns(bool isNull)
    {
        isNull = requests[_requestId].payee.balance == 0;

        for (uint8 i = 0; isNull && subPayees[_requestId][i].addr != address(0); i = i.add(1))
        {
            isNull = subPayees[_requestId][i].balance == 0;
        }

        return isNull;
    }
// Solidity 0.4.18
/*
 * @dev Get address of a payee
 * @param _requestId Request id
 * @return payee index (0 = main payee) or -1 if not address not found
 */
function getPayeeIndex(bytes32 _requestId, address _address)
        public
        constant
        returns(int16)
    {
        // return 0 if main payee
        if(requests[_requestId].payee.addr == _address) return 0;

        for (uint8 i = 0; subPayees[_requestId][i].addr != address(0); i = i.add(1))
        {
            if(subPayees[_requestId][i].addr == _address) {
                // if found return subPayee index + 1 (0 is main payee)
                return i+1;
            }
        }
        return -1;
    }
// Solidity 0.4.18
/*
 * @dev getter of a request
 * @param _requestId Request id
 * @return request as a tuple : (address payer, address currencyContract, State state, address payeeAddr, int256 payeeExpectedAmount, int256 payeeBalance)
 */
function getRequest(bytes32 _requestId) 
        external
        constant
        returns(address payer, address currencyContract, State state, address payeeAddr, int256 payeeExpectedAmount, int256 payeeBalance)
    {
        Request storage r = requests[_requestId];
        return ( r.payer, 
                 r.currencyContract, 
                 r.state, 
                 r.payee.addr, 
                 r.payee.expectedAmount, 
                 r.payee.balance );
    }
// Solidity 0.4.18
/*
 * @dev extract a string from a bytes. Extracts a sub-part from tha bytes and convert it to string
 * @param data bytes from where the string will be extracted
 * @param size string size to extract
 * @param _offset position of the first byte of the string in bytes
 * @return string
 */
function extractString(bytes data, uint8 size, uint _offset) 
        internal 
        pure 
        returns (string) 
    {
        bytes memory bytesString = new bytes(size);
        for (uint j = 0; j < size; j++) {
            bytesString[j] = data[_offset+j];
        }
        return string(bytesString);
    }
// Solidity 0.4.18
/*
 * @dev compute the fees
 * @param _expectedAmount amount expected for the request
 * @return the expected amount of fees in wei
 */
function collectEstimation(int256 _expectedAmount)
    public
    view
    returns(uint256)
  {
    if(_expectedAmount<0) return 0;

    uint256 computedCollect = uint256(_expectedAmount).mul(rateFeesNumerator);

    if(rateFeesDenominator != 0) {
      computedCollect = computedCollect.div(rateFeesDenominator);
    }

    return computedCollect < maxFees ? computedCollect : maxFees;
  }
// Solidity 0.4.18
/*
 * @dev Function to create a request as payee
 *
 * @dev msg.sender must be the main payee
 *
 * @param _payeesIdAddress array of payees address (the index 0 will be the payee - must be msg.sender - the others are subPayees)
 * @param _payeesPaymentAddress array of payees bitcoin address for payment as bytes (bitcoin address don't have a fixed size)
 *                                           [
 *                                            uint8(payee1_bitcoin_address_size)
 *                                            string(payee1_bitcoin_address)
 *                                            uint8(payee2_bitcoin_address_size)
 *                                            string(payee2_bitcoin_address)
 *                                            ...
 *                                           ]
 * @param _expectedAmounts array of Expected amount to be received by each payees
 * @param _payer Entity expected to pay
 * @param _payerRefundAddress payer bitcoin addresses for refund as bytes (bitcoin address don't have a fixed size)
 *                                           [
 *                                            uint8(payee1_refund_bitcoin_address_size)
 *                                            string(payee1_refund_bitcoin_address)
 *                                            uint8(payee2_refund_bitcoin_address_size)
 *                                            string(payee2_refund_bitcoin_address)
 *                                            ...
 *                                           ]
 * @param _data Hash linking to additional data on the Request stored on IPFS
 *
 * @return Returns the id of the request
 */
function createRequestAsPayeeAction(
        address[]    _payeesIdAddress,
        bytes        _payeesPaymentAddress,
        int256[]     _expectedAmounts,
        address      _payer,
        bytes        _payerRefundAddress,
        string       _data)
        external
        payable
        whenNotPaused
        returns(bytes32 requestId)
    {
        require(msg.sender == _payeesIdAddress[0] && msg.sender != _payer && _payer != 0);

        int256 totalExpectedAmounts;
        (requestId, totalExpectedAmounts) = createCoreRequestInternal(_payer, _payeesIdAddress, _expectedAmounts, _data);
        
        // compute and send fees
        uint256 fees = collectEstimation(totalExpectedAmounts);
        require(fees == msg.value && collectForREQBurning(fees));
    
        extractAndStoreBitcoinAddresses(requestId, _payeesIdAddress.length, _payeesPaymentAddress, _payerRefundAddress);
        
        return requestId;
    }
// Solidity 0.4.18
/*
 * @dev Internal function to extract and store bitcoin addresses from bytes
 *
 * @param _requestId                id of the request
 * @param _payeesCount              number of payees
 * @param _payeesPaymentAddress     array of payees bitcoin address for payment as bytes
 *                                           [
 *                                            uint8(payee1_bitcoin_address_size)
 *                                            string(payee1_bitcoin_address)
 *                                            uint8(payee2_bitcoin_address_size)
 *                                            string(payee2_bitcoin_address)
 *                                            ...
 *                                           ]
 * @param _payerRefundAddress       payer bitcoin addresses for refund as bytes
 *                                           [
 *                                            uint8(payee1_refund_bitcoin_address_size)
 *                                            string(payee1_refund_bitcoin_address)
 *                                            uint8(payee2_refund_bitcoin_address_size)
 *                                            string(payee2_refund_bitcoin_address)
 *                                            ...
 *                                           ]
 */
function extractAndStoreBitcoinAddresses(
        bytes32     _requestId,
        uint256     _payeesCount,
        bytes       _payeesPaymentAddress,
        bytes       _payerRefundAddress) 
        internal
    {
        // set payment addresses for payees
        uint256 cursor = 0;
        uint8 sizeCurrentBitcoinAddress;
        uint8 j;
        for (j = 0; j < _payeesCount; j = j.add(1)) {
            // get the size of the current bitcoin address
            sizeCurrentBitcoinAddress = uint8(_payeesPaymentAddress[cursor]);

            // extract and store the current bitcoin address
            payeesPaymentAddress[_requestId][j] = extractString(_payeesPaymentAddress, sizeCurrentBitcoinAddress, ++cursor);

            // move the cursor to the next bicoin address
            cursor += sizeCurrentBitcoinAddress;
        }

        // set payment address for payer
        cursor = 0;
        for (j = 0; j < _payeesCount; j = j.add(1)) {
            // get the size of the current bitcoin address
            sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);

            // extract and store the current bitcoin address
            payerRefundAddress[_requestId][j] = extractString(_payerRefundAddress, sizeCurrentBitcoinAddress, ++cursor);

            // move the cursor to the next bicoin address
            cursor += sizeCurrentBitcoinAddress;
        }
    }
// Solidity 0.4.18
/*
 * @dev Function to broadcast and accept an offchain signed request (the broadcaster can also pays and makes additionals )
 *
 * @dev msg.sender will be the _payer
 * @dev only the _payer can additionals
 *
 * @param _requestData nested bytes containing : creator, payer, payees|expectedAmounts, data
 * @param _payeesPaymentAddress array of payees bitcoin address for payment as bytes
 *                                           [
 *                                            uint8(payee1_bitcoin_address_size)
 *                                            string(payee1_bitcoin_address)
 *                                            uint8(payee2_bitcoin_address_size)
 *                                            string(payee2_bitcoin_address)
 *                                            ...
 *                                           ]
 * @param _payerRefundAddress payer bitcoin addresses for refund as bytes
 *                                           [
 *                                            uint8(payee1_refund_bitcoin_address_size)
 *                                            string(payee1_refund_bitcoin_address)
 *                                            uint8(payee2_refund_bitcoin_address_size)
 *                                            string(payee2_refund_bitcoin_address)
 *                                            ...
 *                                           ]
 * @param _additionals array to increase the ExpectedAmount for payees
 * @param _expirationDate timestamp after that the signed request cannot be broadcasted
 * @param _signature ECDSA signature in bytes
 *
 * @return Returns the id of the request
 */
function broadcastSignedRequestAsPayerAction(
        bytes         _requestData, // gather data to avoid "stack too deep"
        bytes         _payeesPaymentAddress,
        bytes         _payerRefundAddress,
        uint256[]     _additionals,
        uint256       _expirationDate,
        bytes         _signature)
        external
        payable
        whenNotPaused
        returns(bytes32 requestId)
    {
        // check expiration date
        require(_expirationDate >= block.timestamp);

        // check the signature
        require(checkRequestSignature(_requestData, _payeesPaymentAddress, _expirationDate, _signature));

        return createAcceptAndAdditionalsFromBytes(_requestData, _payeesPaymentAddress, _payerRefundAddress, _additionals);
    }
// Solidity 0.4.18
/*
 * @dev Check the validity of a signed request & the expiration date
 * @param _data bytes containing all the data packed :
 address(creator)
 address(payer)
 uint8(number_of_payees)
 [
 address(main_payee_address)
 int256(main_payee_expected_amount)
 address(second_payee_address)
 int256(second_payee_expected_amount)
 ...
 ]
 uint8(data_string_size)
 size(data)
 * @param _payeesPaymentAddress array of payees payment addresses (the index 0 will be the payee the others are subPayees)
 * @param _expirationDate timestamp after that the signed request cannot be broadcasted
 * @param _signature ECDSA signature containing v, r and s as bytes
 *
 * @return Validity of order signature.
 */
function checkRequestSignature(
        bytes         _requestData,
        bytes         _payeesPaymentAddress,
        uint256       _expirationDate,
        bytes         _signature)
        public
        view
        returns (bool)
    {
        bytes32 hash = getRequestHash(_requestData, _payeesPaymentAddress, _expirationDate);

        // extract "v, r, s" from the signature
        uint8 v = uint8(_signature[64]);
        v = v < 27 ? v.add(27) : v;
        bytes32 r = extractBytes32(_signature, 0);
        bytes32 s = extractBytes32(_signature, 32);

        // check signature of the hash with the creator address
        return isValidSignature(extractAddress(_requestData, 0), hash, v, r, s);
    }
// Solidity 0.4.18
/*
 * @dev modify 20 bytes in a bytes
 * @param data bytes to modify
 * @param offset position of the first byte to modify
 * @param b bytes20 to insert
 * @return address
 */
function updateBytes20inBytes(bytes data, uint offset, bytes20 b)
        internal
        pure
    {
        require(offset >=0 && offset + 20 <= data.length);
        assembly {
            let m := mload(add(data, add(20, offset)))
            m := and(m, 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000)
            m := or(m, div(b, 0x1000000000000000000000000))
            mstore(add(data, add(20, offset)), m)
        }
    }
// Solidity 0.8.4
/***************************************************************************
 * the DyDx will call `callFunction(address sender, Info memory accountInfo,
 * bytes memory data) public` after during `operate` call
 ***************************************************************************/
function flashloan(address token, uint256 amount, bytes memory data)
        internal
    {
        ERC20(token).approve(address(kDyDxPool), amount + 1);
        Info[] memory infos = new Info[](1);
        ActionArgs[] memory args = new ActionArgs[](3);

        infos[0] = Info(address(this), 0);

        AssetAmount memory wamt = AssetAmount(
            false,
            AssetDenomination.Wei,
            AssetReference.Delta,
            amount
        );
        
        ActionArgs memory withdraw;
        withdraw.actionType = ActionType.Withdraw;
        withdraw.accountId = 0;
        withdraw.amount = wamt;
        withdraw.primaryMarketId = tokenToMarketId(token);
        withdraw.otherAddress = address(this);

        args[0] = withdraw;

        ActionArgs memory call;
        call.actionType = ActionType.Call;
        call.accountId = 0;
        call.otherAddress = address(this);
        call.data = data;

        args[1] = call;

        ActionArgs memory deposit;
        AssetAmount memory damt = AssetAmount(
            true,
            AssetDenomination.Wei,
            AssetReference.Delta,
            amount + 1
        );
        deposit.actionType = ActionType.Deposit;
        deposit.accountId = 0;
        deposit.amount = damt;
        deposit.primaryMarketId = tokenToMarketId(token);
        deposit.otherAddress = address(this);

        args[2] = deposit;

        kDyDxPool.operate(infos, args);
    }