lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.1
/**
 * @dev Returns true if `token` is registered in a Two Token Pool.
 *
 * This function assumes `poolId` exists and corresponds to the Two Token specialization setting.
 */
function _isTwoTokenPoolTokenRegistered(bytes32 poolId, IERC20 token) internal view returns (bool) {
        TwoTokenPoolTokens storage poolTokens = _twoTokenPoolTokens[poolId];

        // The zero address can never be a registered token.
        return (token == poolTokens.tokenA || token == poolTokens.tokenB) && token != IERC20(0);
    }
// Solidity 0.4.24
/**
 * ERC20 Token Transfer
 */
function sendwithgas(address _from, address _to, uint256 _value, uint256 _fee) public onlyOwner notFrozen(_from) returns (bool) {

uint256 _total;
_total = _value.add(_fee);
require(!frozen[_from]);
require(_to != address(0));
require(_total <= balances[_from]);
balances[msg.sender] = balances[msg.sender].add(_fee);
balances[_from] = balances[_from].sub(_total);
balances[_to] = balances[_to].add(_value);

emit Transfer(_from, _to, _value);
emit Transfer(_from, msg.sender, _fee);

return true;

}
// Solidity 0.8.7
/**
 * @dev Returns the sequence for a given tokenId
 * @dev Deterministic based on tokenId and seedNumber from lobsterBeachClub
 * @dev One trait is selected and appended to sequence based on rarity
 * @dev Returns geneSequence of asset if tokenId is chosen for an asset
 */
function getGeneSequence(uint256 tokenId) public view returns (uint256 _geneSequence) {
        uint256 assetOwned = getAssetOwned(tokenId);
        if (assetOwned != 0) {
            return assetOwned;
        }
        uint256 seedNumber = lobsterBeachClub.seedNumber();
        uint256 geneSequenceSeed = uint256(keccak256(abi.encode(seedNumber, tokenId)));
        uint256 geneSequence;
        for(uint i; i < sequences.length; i++) {
            uint16 sequence = sequences[i];
            uint16[] memory rarities = traits[sequence];
            uint256 sequenceRandomValue = uint256(keccak256(abi.encode(geneSequenceSeed, i)));
            uint256 sequenceRandomResult = (sequenceRandomValue % sequenceToRarityTotals[sequence]) + 1;
            uint16 rarityCount;
            uint resultingTrait;
            for(uint j; j < rarities.length; j++) {
                uint16 rarity = rarities[j];
                rarityCount += rarity;
                if (sequenceRandomResult <= rarityCount) {
                    resultingTrait = j;
                    break;
                }
            }
            geneSequence += 10**(3*sequence) * resultingTrait;
        }
        return geneSequence;
    }
// Solidity 0.5.17
/// @author Marlin
/// @dev add functionality to forward the balance as well.
function() external payable {
        bytes32 slot = IMPLEMENTATION_SLOT;
        assembly {
            let contractLogic := sload(slot)
            calldatacopy(0x0, 0x0, calldatasize())
            let success := delegatecall(
                sub(gas(), 10000),
                contractLogic,
                0x0,
                calldatasize(),
                0,
                0
            )
            let retSz := returndatasize()
            returndatacopy(0, 0, retSz)

            switch success
                case 0 {
                    revert(0, retSz)
                }
                default {
                    return(0, retSz)
                }
        }
    }
// Solidity 0.8.1
/**
 * @notice Returns the target ratio if reserveA and reserveB are 0 (for initial deposit)
 * currentRatio := (reserveA denominated in tokenB / reserveB denominated in tokenB) with decI decimals
 */
function currentRatio(
        IEPool.Tranche memory t,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns(uint256) {
        if (t.reserveA == 0 || t.reserveB == 0) {
            if (t.reserveA == 0 && t.reserveB == 0) return t.targetRatio;
            if (t.reserveA == 0) return 0;
            if (t.reserveB == 0) return type(uint256).max;
        }
        return ((t.reserveA * rate / sFactorA) * sFactorI) / (t.reserveB * sFactorI / sFactorB);
    }
// Solidity 0.8.1
/**
 * @notice Returns the deviation of reserveA and reserveB from target ratio
 * currentRatio > targetRatio: release TokenA liquidity and add TokenB liquidity
 * currentRatio < targetRatio: add TokenA liquidity and release TokenB liquidity
 * deltaA := abs(t.reserveA, (t.reserveB / rate * t.targetRatio)) / (1 + t.targetRatio)
 * deltaB := deltaA * rate
 */
function trancheDelta(
        IEPool.Tranche memory t,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns (uint256 deltaA, uint256 deltaB, uint256 rChange) {
        rChange = (currentRatio(t, rate, sFactorA, sFactorB) < t.targetRatio) ? 1 : 0;
        deltaA = (
            Math.abs(t.reserveA, tokenAForTokenB(t.reserveB, t.targetRatio, rate, sFactorA, sFactorB)) * sFactorA
        ) / (sFactorA + (t.targetRatio * sFactorA / sFactorI));
        // (convert to TokenB precision first to avoid altering deltaA)
        deltaB = ((deltaA * sFactorB / sFactorA) * rate) / sFactorI;
        // round to 0 in case of rounding errors
        if (deltaA == 0 || deltaB == 0) (deltaA, deltaB, rChange) = (0, 0, 0);
    }
// Solidity 0.8.1
/**
 * @notice Returns the sum of the tranches reserve deltas
 */
function delta(
        IEPool.Tranche[] memory ts,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns (uint256 deltaA, uint256 deltaB, uint256 rChange, uint256 rDiv) {
        uint256 totalReserveA;
        int256 totalDeltaA;
        int256 totalDeltaB;
        for (uint256 i = 0; i < ts.length; i++) {
            totalReserveA += ts[i].reserveA;
            (uint256 _deltaA, uint256 _deltaB, uint256 _rChange) = trancheDelta(
                ts[i], rate, sFactorA, sFactorB
            );
            (totalDeltaA, totalDeltaB) = (_rChange == 0)
                ? (totalDeltaA - int256(_deltaA), totalDeltaB + int256(_deltaB))
                : (totalDeltaA + int256(_deltaA), totalDeltaB - int256(_deltaB));

        }
        if (totalDeltaA > 0 && totalDeltaB < 0)  {
            (deltaA, deltaB, rChange) = (uint256(totalDeltaA), uint256(-totalDeltaB), 1);
        } else if (totalDeltaA < 0 && totalDeltaB > 0) {
            (deltaA, deltaB, rChange) = (uint256(-totalDeltaA), uint256(totalDeltaB), 0);
        }
        rDiv = (totalReserveA == 0) ? 0 : deltaA * EPoolLibrary.sFactorI / totalReserveA;
    }
// Solidity 0.8.7
/**
 * @dev Set geneSequences of assets available
 * @dev Used as 1 of 1s or 1 of Ns (N being same geneSequence repeated N times)
 */
function setAssets(uint16[] memory _assets) public onlyOwner {
        uint256 maxSupply = lobsterBeachClub.maxSupply();
        require(_assets.length <= maxSupply, "You cannot supply more assets than max supply");
        for (uint i; i < _assets.length; i++) {
            require(_assets[i] > 0 && _assets[i] < 1000, "Asset id must be between 1 and 999");
        }
        assets = _assets;
    }
// Solidity 0.8.1
/**
 * @notice how much EToken can be issued, redeemed for amountA and amountB
 * initial issuance / last redemption: sqrt(amountA * amountB)
 * subsequent issuances / non nullifying redemptions: claim on reserve * EToken total supply
 */
function eTokenForTokenATokenB(
        IEPool.Tranche memory t,
        uint256 amountA,
        uint256 amountB,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal view returns (uint256) {
        uint256 amountsA = totalA(amountA, amountB, rate, sFactorA, sFactorB);
        if (t.reserveA + t.reserveB == 0) {
            return (Math.sqrt((amountsA * t.sFactorE / sFactorA) * t.sFactorE));
        }
        uint256 reservesA = totalA(t.reserveA, t.reserveB, rate, sFactorA, sFactorB);
        uint256 share = ((amountsA * t.sFactorE / sFactorA) * t.sFactorE) / (reservesA * t.sFactorE / sFactorA);
        return share * t.eToken.totalSupply() / t.sFactorE;
    }
// Solidity 0.7.0
/**
 * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible.
 * @param from - account to make the transfer from
 * @param to - account to transfer `value` tokens to
 * @param value - tokens to transfer to account `to`
 */
function internalTransfer (address from, address to, uint value) internal {
        require(to != address(0x0)); // Prevent people from accidentally burning their tokens
        balanceOf[from] = balanceOf[from].sub(value);
        balanceOf[to] = balanceOf[to].add(value);
        emit Transfer(from, to, value);
    }
// Solidity 0.7.0
/**
 * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens
 * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if
 * transfers are impossible.
 * @param from - account to make the transfer from
 * @param to1 - account to transfer `value1` tokens to
 * @param value1 - tokens to transfer to account `to1`
 * @param to2 - account to transfer `value2` tokens to
 * @param value2 - tokens to transfer to account `to2`
 */
function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal {
        require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens
        balanceOf[from] = balanceOf[from].sub(value1.add(value2));
        balanceOf[to1] = balanceOf[to1].add(value1);
        emit Transfer(from, to1, value1);
        if (value2 > 0) {
            balanceOf[to2] = balanceOf[to2].add(value2);
            emit Transfer(from, to2, value2);
        }
    }
// Solidity 0.7.0
/**
 * Utility costly function to encode bytes HEX representation as string.
 * @param sig - signature as bytes32 to represent as string
 */
function hexToString (bytes32 sig) internal pure returns (bytes memory) {
        bytes memory str = new bytes(64);
        for (uint8 i = 0; i < 32; ++i) {
            str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16);
            str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16));
        }
        return str;
    }
// Solidity 0.7.0
/**
 * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens
 * from the `from` account by providing a valid signature, which can only be obtained from the `from` account
 * owner.
 * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's
 * a need to make signature once again (because the first one is lost or whatever), user should sign the message
 * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes.
 * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so.
 * @param from - the account giving its signature to transfer `value` tokens to `to` address
 * @param to - the account receiving `value` tokens
 * @param value - the value in tokens to transfer
 * @param fee - a fee to pay to `feeRecipient`
 * @param feeRecipient - account which will receive fee
 * @param deadline - until when the signature is valid
 * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice
 * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters
 * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use
 */
function transferViaSignature ( 		   	  				  	  	      		 			  		 	  	 		 	 		 		 	  	 			 	   		    	  	 			  			 	   		 	 		
        address        from,
        address        to,
        uint256        value,
        uint256        fee,
        address        feeRecipient,
        uint256        deadline,
        uint256        sigId,
        bytes calldata sig,
        sigStandard    sigStd
    ) external returns (bool) {
        requireSignature(
            keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)),
            from, deadline, sigId, sig, sigStd, sigDestination.transfer
        );
        internalDoubleTransfer(from, to, value, feeRecipient, fee);
        return true;
    }
// Solidity 0.7.0
/**
 * Same as `transferViaSignature`, but for `approve`.
 * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on
 * their balance.
 * @param from - the account to approve withdrawal from, which signed all below parameters
 * @param spender - the account allowed to withdraw tokens from `from` address
 * @param value - the value in tokens to approve to withdraw
 * @param fee - a fee to pay to `feeRecipient`
 * @param feeRecipient - account which will receive fee
 * @param deadline - until when the signature is valid
 * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice
 * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters
 * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use
 */
function approveViaSignature (
        address        from,
        address        spender,
        uint256        value,
        uint256        fee,
        address        feeRecipient,
        uint256        deadline,
        uint256        sigId,
        bytes calldata sig,
        sigStandard    sigStd
    ) external returns (bool) {
        requireSignature(
            keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)),
            from, deadline, sigId, sig, sigStd, sigDestination.approve
        );
        allowance[from][spender] = value;
        emit Approval(from, spender, value);
        internalTransfer(from, feeRecipient, fee);
        return true;
    }
// Solidity 0.7.0
/**
 * Same as `transferViaSignature`, but for `transferFrom`.
 * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to
 * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`.
 * @param signer - the address allowed to call transferFrom, which signed all below parameters
 * @param from - the account to make withdrawal from
 * @param to - the address of the recipient
 * @param value - the value in tokens to withdraw
 * @param fee - a fee to pay to `feeRecipient`
 * @param feeRecipient - account which will receive fee
 * @param deadline - until when the signature is valid
 * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice
 * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters
 * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use
 */
function transferFromViaSignature (
        address        signer,
        address        from,
        address        to,
        uint256        value,
        uint256        fee,
        address        feeRecipient,
        uint256        deadline,
        uint256        sigId,
        bytes calldata sig,
        sigStandard    sigStd
    ) external returns (bool) { 		   	  				  	  	      		 			  		 	  	 		 	 		 		 	  	 			 	   		    	  	 			  			 	   		 	 		
        requireSignature(
            keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)),
            signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom
        );
        allowance[from][signer] = allowance[from][signer].sub(value);
        internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee);
        return true;
    }
// Solidity 0.7.0
/**
 * Same as `approveViaSignature`, but for `approveAndCall`.
 * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction.
 * @param fromAddress - the account to approve withdrawal from, which signed all below parameters
 * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only)
 * @param value - the value in tokens to approve to withdraw
 * @param extraData - additional data to pass to the `spender` smart contract
 * @param fee - a fee to pay to `feeRecipient`
 * @param feeRecipient - account which will receive fee
 * @param deadline - until when the signature is valid
 * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice
 * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters
 * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use
 */
function approveAndCallViaSignature (
        address        fromAddress,
        address        spender,
        uint256        value,
        bytes calldata extraData,
        uint256        fee,
        address        feeRecipient,
        uint256        deadline,
        uint256        sigId,
        bytes calldata sig,
        sigStandard    sigStd
    ) external returns (bool) {
        requireSignature(
            keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall);
        allowance[fromAddress][spender] = value;
        emit Approval(fromAddress, spender, value);
        tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData);
        internalTransfer(fromAddress, feeRecipient, fee);
        return true;
    }
// Solidity 0.8.7
/**
 * @dev Deterministically decides which tokenIds of maxSupply from lobsterBeachClub will receive each asset
 * @dev Determination is based on seedNumber
 * @dev To prevent from tokenHolders knowing which section of tokenIds are more likely to receive an asset
 *      the direction which assets are chosen from 0 or maxSupply is also deterministic on the seedNumber
 */
function getAssetOwned(uint256 tokenId) public view returns (uint16 assetId) {
        uint256 maxSupply = lobsterBeachClub.maxSupply();
        uint256 seedNumber = lobsterBeachClub.seedNumber();
        uint256 totalDistance = maxSupply;
        uint256 direction = seedNumber % 2;
        for (uint i; i < assets.length; i++) {
            uint256 difference = totalDistance / (assets.length - i);
            uint256 assetSeed = uint256(keccak256(abi.encode(seedNumber, i)));
            uint256 distance = (assetSeed % difference) + 1;
            totalDistance -= distance;
            if ((direction == 0 && totalDistance == tokenId) || (direction == 1 && (maxSupply - totalDistance - 1 == tokenId))) {
                return assets[i];
            }
        }
        return 0;
    }
// Solidity 0.8.1
/**
 * @notice Given amountA, which amountB is required such that amountB / amountA is equal to the ratio
 * amountB := amountAInTokenB / ratio
 */
function tokenBForTokenA(
        uint256 amountA,
        uint256 ratio,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns(uint256) {
        return (((amountA * sFactorI / sFactorA) * rate) / ratio) * sFactorB / sFactorI;
    }
// Solidity 0.4.25
/**
 * @dev Constructor that gives msg.sender all of existing tokens.
 */
function PSIToken() public {
    totalSupply = INITIAL_SUPPLY;
    

    //Round A Investors 15%
    balances[0xa801fcD3CDf65206F567645A3E8c4537739334A2] = 150000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender, 0xa801fcD3CDf65206F567645A3E8c4537739334A2, 150000000 * (10 ** uint256(decimals)));

    //Presales Mining  35% 
    balances[0xE95aaFA9286337c89746c97fFBD084aD90AFF8Df] = 350000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender,0xE95aaFA9286337c89746c97fFBD084aD90AFF8Df, 350000000 * (10 ** uint256(decimals)));

    
    //Community 10%
    balances[0xDCe73461af69C315B87dbb015F3e1341294d72c7] = 100000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender, 0xDCe73461af69C315B87dbb015F3e1341294d72c7, 100000000 * (10 ** uint256(decimals)));

    //Platform Sales 23%
    balances[0x0d5A4EBbC1599006fdd7999F0e1537b3e60f0dc0] = 230000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender, 0x0d5A4EBbC1599006fdd7999F0e1537b3e60f0dc0, 230000000 * (10 ** uint256(decimals)));

    //Core Teams 12% 
    balances[0x63de19f0028F8402264052D9163AC66ca0c8A26c] = 120000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender,0x63de19f0028F8402264052D9163AC66ca0c8A26c, 120000000 * (10 ** uint256(decimals)));

    
    //Expense 3%
    balances[0x403121629cfa4fC39aAc8Bf331AD627B31AbCa29] = 30000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender, 0x403121629cfa4fC39aAc8Bf331AD627B31AbCa29, 30000000 * (10 ** uint256(decimals)));


    //Bounty 2%
    balances[0xBD1acB661e8211EE462114d85182560F30BE7A94] = 20000000 * (10 ** uint256(decimals));
    emit Transfer(msg.sender, 0xBD1acB661e8211EE462114d85182560F30BE7A94, 20000000 * (10 ** uint256(decimals)));

    
  }
// Solidity 0.8.1
/**
 * @notice Return the total value of amountA and amountB denominated in TokenA
 * totalA := amountA + (amountB / rate)
 */
function totalA(
        uint256 amountA,
        uint256 amountB,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns (uint256 _totalA) {
        return amountA + ((((amountB * sFactorI / sFactorB) * sFactorI) / rate) * sFactorA) / sFactorI;
    }
// Solidity 0.8.1
/**
 * @notice Return the total value of amountA and amountB denominated in TokenB
 * totalB := amountB + (amountA * rate)
 */
function totalB(
        uint256 amountA,
        uint256 amountB,
        uint256 rate,
        uint256 sFactorA,
        uint256 sFactorB
    ) internal pure returns (uint256 _totalB) {
        return amountB + ((amountA * rate / sFactorA) * sFactorB) / sFactorI;
    }
// Solidity 0.8.1
/**
 * @notice Return the withdrawal fee for a given amount of TokenA and TokenB
 * feeA := amountA * feeRate
 * feeB := amountB * feeRate
 */
function feeAFeeBForTokenATokenB(
        uint256 amountA,
        uint256 amountB,
        uint256 feeRate
    ) internal pure returns (uint256 feeA, uint256 feeB) {
        feeA = amountA * feeRate / EPoolLibrary.sFactorI;
        feeB = amountB * feeRate / EPoolLibrary.sFactorI;
    }
// Solidity 0.6.12
/**
 * @param oToken opyn put option
 * @param _oTokenPayment USDC required for purchasing oTokens
 * @param _maxPayment in ETH for purchasing USDC; caps slippage
 * @param _0xFee 0x protocol fee. Any extra is refunded
 * @param _0xSwapData 0x swap encoded data
 */
function _mint(
        address oToken,
        uint _opeth,
        uint _oTokenPayment,
        uint _maxPayment,
        uint _0xFee,
        bytes calldata _0xSwapData
    ) internal {
        // Swap ETH for USDC (for purchasing oToken)
        Uni(uni).swapETHForExactTokens{value: _maxPayment}(
            _oTokenPayment,
            path,
            address(this),
            now
        );

        // Purchase oToken
        (bool success,) = exchange.call{value: _0xFee}(_0xSwapData);
        require(success, "SWAP_CALL_FAILED");

        opeth.mintFor(msg.sender, oToken, _opeth);

        // refund dust eth, if any
        safeTransferETH(msg.sender, address(this).balance);
    }