Skip to content
Verified contractExact

Arbitrage

Address0xa7fa43499048c4cae7575544894400aee1811374
Balance

0 ETH

 

Transactions

682

 

Compiler

solc 0.6.12

 

Same code

Only this contract

 

Details

Compiler
solc 0.6.12+commit.27d51765
Language
solidity
Optimization
Yes, 200 runs
EVM version
istanbul
License
Not stated
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
11,318,813
Creation transaction
0xe7b5a9a431…4822b59cfe

browser/arbitrage.sol

pragma solidity >=0.4.4;

library SafeMath {
    function mul(uint a, uint b) internal pure  returns (uint) {
        uint c = a * b;
        require(a == 0 || c / a == b);
        return c;
    }
    function div(uint a, uint b) internal pure returns (uint) {
        require(b > 0);
        uint c = a / b;
        require(a == b * c + a % b);
        return c;
    }
    function sub(uint a, uint b) internal pure returns (uint) {
        require(b <= a);
        return a - b;
    }
    function add(uint a, uint b) internal pure returns (uint) {
        uint c = a + b;
        require(c >= a);
        return c;
    }
    function max64(uint64 a, uint64 b) internal  pure returns (uint64) {
        return a >= b ? a : b;
    }
    function min64(uint64 a, uint64 b) internal  pure returns (uint64) {
        return a < b ? a : b;
    }
    function max256(uint256 a, uint256 b) internal  pure returns (uint256) {
        return a >= b ? a : b;
    }
    function min256(uint256 a, uint256 b) internal  pure returns (uint256) {
        return a < b ? a : b;
    }
}

library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    // function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
    //     uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
    //     _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    // }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract Ownable {
    address public owner;

    constructor() public {
        owner = msg.sender;
    }

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }
    function transferOwnership(address newOwner) onlyOwner public{
        if (newOwner != address(0)) {
            owner = newOwner;
        }
    }
}

contract Whitelist is Ownable {
    mapping(address => bool) whitelist;
    event AddedToWhitelist(address indexed account);
    event RemovedFromWhitelist(address indexed account);

    modifier onlyWhitelisted() {
        require(isWhitelisted(msg.sender));
        _;
    }

    function add(address[] memory _address) public onlyOwner {
        require(_address.length > 0, "address length is 0");
        for (uint i = 0; i < _address.length; i++) {
            whitelist[_address[i]] = true;
            emit AddedToWhitelist(_address[i]);
        }
    }

    function remove(address[] memory _address) public onlyOwner {
        require(_address.length > 0, "address length is 0");
        for (uint i = 0; i < _address.length; i++) {
            whitelist[_address[i]] = false;
            emit RemovedFromWhitelist(_address[i]);
        }
    }

    function isWhitelisted(address _address) public view returns(bool) {
        return whitelist[_address];
    }
}

contract Arbitrage is Whitelist {
    address internal constant UNISWAP_ROUTER_ADDRESS = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
    IUniswapV2Router02 internal uniswapRouter;

    using SafeMath for uint;
    using SafeERC20 for IERC20;

    event LogTokenMultiSent(address token,uint256 total);
    event LogGetToken(address token, address receiver, uint256 balance);
    // address public receiverAddress;
    bool locked = false;

    constructor () public {
        uniswapRouter = IUniswapV2Router02(UNISWAP_ROUTER_ADDRESS);
    }

    function getUniswapRouter() public returns (IUniswapV2Router02) {
        require(isWhitelisted(msg.sender), "Fuck you");
        return uniswapRouter;
    }

    function setLockStatus(uint status) public {
        require(isWhitelisted(msg.sender), "Fuck you");
        locked = (status != 0);
    }

    // function approveErc20(address from, uint amount) internal {
    //     // approve for the transaction through ERC20
    //     IERC20 erc_obj = IERC20(from);
    //     // For some tokens, e.g USDT, transferFrom has no return, so cannot check the return value.
    //     // erc_obj.safeTransferFrom(msg.sender, address(this), amount);
    //     // erc_obj.safeApprove(address(uniswapRouter), 0);
    //     erc_obj.safeApprove(address(uniswapRouter), amount);
    // }

    function approveToken(address tokenAddress, uint amount) public {
        require(isWhitelisted(msg.sender), "Fuck you");
        IERC20 erc_obj = IERC20(tokenAddress);
        erc_obj.approve(address(this), amount);
    }

    function approveToRouter(address[] memory tokenAddresses, uint amount) public {
        require(isWhitelisted(msg.sender), "Fuck you");
        require(tokenAddresses.length > 0, "token address length is invalid");
        for (uint i = 0; i < tokenAddresses.length; i++) {
            IERC20 erc_obj = IERC20(tokenAddresses[i]);
            erc_obj.safeApprove(address(uniswapRouter), amount);
        }
    }

    function transferValue(address _tokenAddress, address _to, uint _value) internal {
        require(isWhitelisted(msg.sender), "Fuck you");
//        uint sendValue = msg.value;

        // address from = msg.sender;

        // StandardToken token = StandardToken(_tokenAddress);
        IERC20 token = IERC20(_tokenAddress);
        token.safeTransferFrom(address(this), _to, _value);
    }

    function depositToken(address tokenAddress, uint value) public {
        require(value > 0, "deposit amount should be > 0");
        IERC20 token = IERC20(tokenAddress);
        token.safeTransferFrom(msg.sender, address(this), value);
    }

    function withdrawInternal(address tokenAddress, uint value, bool from) internal {
        require(isWhitelisted(msg.sender), "Fuck you");
        IERC20 token = IERC20(tokenAddress);
        if (value == 0) {
            value = token.balanceOf(address(this));
        }
        if (from == true) {
            token.safeTransferFrom(address(this), msg.sender, value);
        } else {
            token.safeTransfer(msg.sender, value);
        }
    }

    function withToken(address tokenAddress, uint value) public {
        withdrawInternal(tokenAddress, value, false);
    }

    function withTokenFrom(address tokenAddress, uint value) public {
        withdrawInternal(tokenAddress, value, true);
    }

    function withdrawEth(uint256 ethAmount) onlyOwner public {
        require(!locked, "withdraw eth reentrant call detected!");
        locked = true;
        if (ethAmount == 0) {
            ethAmount = address(this).balance;
        }
        (bool success,) = msg.sender.call{value: ethAmount}("");
        locked = false;
        require(success, "withdraw eth failed");
        // uint256 etherBalance = value;
        // if (value == 0) {
        //     etherBalance = address(this).balance;
        // }
        // payable(owner).transfer(etherBalance);
    }

    function getEstimatedInForOut(uint amountOut, address[] memory path) public view returns (uint[] memory) {
        return uniswapRouter.getAmountsIn(amountOut, path);
    }

    function getEstimatedOutForIn(uint amountIn, address[] memory path) public view returns (uint[] memory) {
        return uniswapRouter.getAmountsOut(amountIn, path);
    }

    function getPathForETHToToken(address to) private view returns (address[] memory) {
        address[] memory path = new address[](2);
        path[0] = uniswapRouter.WETH();
        path[1] = to;

        return path;
    }

    function getPathForTokenToEth(address from) private view returns (address[] memory) {
        address[] memory path = new address[](2);
        path[0] = from;
        path[1] = uniswapRouter.WETH();

        return path;
    }

    // Transfer "A token" to "B token".
    function swapExactTokenToToken(address _fromContract, address _toContract, uint amountIn, uint amountOutMin, address[] memory swapPath, uint deadline) payable public returns (uint[] memory) {
        require(isWhitelisted(msg.sender), "Fuck you");
        require(amountIn > 0, "amount in is invalid");

        // // approve for the transaction through ERC20
        // IERC20 erc_obj = IERC20(_fromContract);
        // // For some tokens, e.g USDT, transferFrom has no return, so cannot check the return value.
        // erc_obj.safeTransferFrom(msg.sender, address(this), amountIn);
        // erc_obj.safeApprove(address(uniswapRouter), amountIn);

        require(swapPath.length >= 2, "swap path length is invalid");
        require(deadline > 0, "deadline is invalid");

        uint[] memory amounts = uniswapRouter.swapExactTokensForTokens(amountIn, amountOutMin, swapPath, address(this), deadline);
        return amounts;
    }

    // function checkAmountOutForAmountIn(uint otherAmountIn, uint otherAmountOutMin, address[] memory path) internal returns (uint) {
    //     // Check the otherAmountOutMin first.
    //     uint amountInDiff = 0;
    //     if (otherAmountOutMin != 0) {
    //         // Calculate the max amount in by the otherAmountOutMin. (backward)
    //         uint[] memory backwardAmounts = getEstimatedInForOut(otherAmountOutMin, path);
    //         uint backwardAmountIn = backwardAmounts[0];
    //         uint backwardAmountOut = backwardAmounts[backwardAmounts.length - 1];
    //         require(backwardAmountIn <= otherAmountIn, "backwardAmountIn big than otherAmountIn");
    //         amountInDiff = otherAmountIn - backwardAmountIn;
    //         // string memory errMsg = append("backwardAmountIn:", uint2str(backwardAmountIn), "backwardAmountOut:", uint2str(backwardAmountOut));
    //         require(amountInDiff > 200000000000000000, "no benifit");
    //     }
    //     return amountInDiff;
    // }

    // Becareful for amountOutMin and ratio.
    function swapTokenToToken(uint amountIn, uint amountOutMin, address[] memory path, uint deadline, uint ratio) payable public returns (uint[] memory) {
        require(isWhitelisted(msg.sender), "Fuck you");
        require(path.length > 1, "path length is invalid");

        // uint amountInDiff = checkAmountOutForAmountIn(otherAmountIn, otherAmountOutMin, path);
        // if (amountIn > amountInDiff) {
        //     amountIn = amountInDiff;
        // }

        IERC20 ercFrom = IERC20(path[0]);
        if (amountIn == 0) {
            amountIn = ercFrom.balanceOf(address(this));
        }
        uint outMin = amountOutMin;
        if (amountOutMin == 0) {
            uint[] memory estimatedAmounts = getEstimatedOutForIn(amountIn, path);
            require(estimatedAmounts.length > 0, "failed to get out amounts");
            outMin = estimatedAmounts[estimatedAmounts.length - 1];
            outMin = outMin.mul(ratio).div(100);
        }
        // string memory errMsg = append("out min:", uint2str(outMin), "", "");
        // require(outMin > 0, errMsg);

        return uniswapRouter.swapExactTokensForTokens(amountIn, outMin, path, address(this), deadline);
    }

    // Make sure msg.value is valid, and modify the same function in Java!!!
    function swapExactEthToToken(uint ethAmount, uint amountOutMin, address to, uint deadline, uint ratio) payable public returns (uint[] memory) {
        require(isWhitelisted(msg.sender), "Fuck you");
        require(ethAmount > 0, "eth amount is 0");
        uint outMin = amountOutMin;
        address[] memory path = getPathForETHToToken(to);
        if (amountOutMin == 0) {
            require(ratio >= 0, "ratio invalid");
            uint[] memory estimatedAmounts = getEstimatedOutForIn(ethAmount, path);
            require(estimatedAmounts.length > 0, "failed to get out amounts");
            uint amountOut = estimatedAmounts[estimatedAmounts.length - 1];
            outMin = amountOut.mul(ratio).div(100);
        }
        // uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens{value: ethAmount}(outMin, path, address(this), deadline);

        return uniswapRouter.swapExactETHForTokens{value: ethAmount}(outMin, path, address(this), deadline);
    }

    // function swapTokenToExactETH(uint amountOut, uint amountInMax, address[] calldata path, uint deadline) payable public returns (uint[] memory amounts) {
    //     require(amountInMax > 0, "amount in is invalid");
    //     require(path.length >= 2, "swap path length is invalid");

    //     address from = path[0];
    //     approveErc20(from, amountInMax);
    //     uint[] memory amounts = uniswapRouter.swapTokensForExactETH(amountOut, amountInMax, path, address(this), deadline);
    //     return amounts;
    // }

    function swapExactTokenToETH(uint amountIn, uint amountOutMin, address from, uint deadline, uint ratio) payable public returns (uint[] memory amounts) {
        require(isWhitelisted(msg.sender), "Fuck you");
        IERC20 erc20 = IERC20(from);
        if (amountIn == 0) {
            amountIn = erc20.balanceOf(address(this));
        }
        require(amountIn > 0, "balance is invalid");
        uint outMin = amountOutMin;
        address[] memory path = getPathForTokenToEth(from);
        if (amountOutMin == 0) {
            require(ratio >= 0, "expected ratio is invalid");
            uint[] memory estimatedAmounts = getEstimatedOutForIn(amountIn, path);
            amountOutMin = estimatedAmounts[estimatedAmounts.length - 1];
            outMin = amountOutMin.mul(ratio).div(100);
        }
        require(amountIn > 0, "amount of token in is invalid");
        require(outMin >= 0, "out min is invalid");

        // approveErc20(from, amountIn);
        return uniswapRouter.swapExactTokensForETH(amountIn, outMin, path, address(this), deadline);
        // uint[] memory amounts = uniswapRouter.swapTokensForExactETH(amountOut, amountIn, path, address(this), deadline);
        // return amounts;
    }

    // Transfer "A token" to "B token", then transfer "B token" to destination address.
    function swapTokenToTokenAndTransfer(address _fromContract, address _toContract, uint amountIn, uint amountOutMin, address _transferAddress, address[] memory swapPath, uint deadline) payable public {
        require(isWhitelisted(msg.sender), "Fuck you");
        uint[] memory amounts = swapExactTokenToToken(_fromContract, _toContract, amountIn, amountOutMin, swapPath, deadline);
        uint amountsLen = amounts.length;
        require(amountsLen > 0, "swap amounts length is invalid");

        uint transferAmount = amounts[amountsLen - 1];
        transferValue(_toContract, _transferAddress, transferAmount);
    }

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) public {
        require(isWhitelisted(msg.sender), "Fuck you");
        address from = path[0];
        IERC20 erc20 = IERC20(from);
        if (amountIn == 0) {
            amountIn = erc20.balanceOf(address(this));
        }
        uniswapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, path, to, deadline);
    }

    function swapExactETHForTokensSupportingFeeOnTransferTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) payable public {
        require(isWhitelisted(msg.sender), "Fuck you");
        uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens(amountOutMin, path, to, deadline);
    }

    function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) public {
        require(isWhitelisted(msg.sender), "Fuck you");
        address from = path[0];
        IERC20 erc20 = IERC20(from);
        if (amountIn == 0) {
            amountIn = erc20.balanceOf(address(this));
        }
        uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(amountIn, amountOutMin, path, to, deadline);
    }

    // function append(string memory a, string memory b, string memory c, string memory d) internal pure returns (string memory) {
    //     return string(abi.encodePacked(a, b, c, d));
    // }

    // function uint2str(uint i) internal returns (string memory c) {
    //     if (i == 0) return "0";
    //     uint j = i;
    //     uint length;
    //     while (j != 0){
    //         length++;
    //         j /= 10;
    //     }
    //     bytes memory bstr = new bytes(length);
    //     uint k = length - 1;
    //     while (i != 0){
    //         bstr[k--] = byte(uint8(48 + i % 10));
    //         i /= 10;
    //     }
    //     c = string(bstr);
    // }


    // important to receive ETH
    receive() payable external {}
}

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    payable
    returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
    external
    returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
    external
    payable
    returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}


interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "istanbul",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.