pragma solidity >=0.4.4;
// import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
// import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";
// import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/utils/Address.sol";
// import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/access/Ownable.sol";
// import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol";
import "./whitelist.sol";
import "./token_manager.sol";
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 Arbitrage is Ownable {
// address internal constant UNISWAP_ROUTER_ADDRESS = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// rinkeby
// address internal constant WHITE_LIST_ADDRESS = address(0xAED2808F8c058342bac2902250922E383630CBD1);
// address internal constant TOKEN_MANAGER_ADDRESS = address(0xF7d1bB748261c90bA0d5Ef9E8136B5633F683f2a);
// mainnet
// address internal constant WHITE_LIST_ADDRESS = address(0x95Cc0c3F46Ae97b959d5Ffa02f0881C1994Ee39D);
// address internal constant TOKEN_MANAGER_ADDRESS = address(0x1c14052e535F47E041091D8de61F352cfd0d37c7);
IUniswapV2Router02 internal uniswapRouter;
Whitelist internal whitelist;
TokenManager internal tokenManager;
using SafeMath for uint;
using SafeERC20 for IERC20;
// address[] internal tokenList;
event LogTokenMultiSent(address token,uint256 total);
event LogGetToken(address token, address receiver, uint256 balance);
// address public receiverAddress;
// bool locked = false;
constructor (address routerAddress, address wlAddress, address tmAddress) public {
uniswapRouter = IUniswapV2Router02(routerAddress);
whitelist = Whitelist(wlAddress);
tokenManager = TokenManager(tmAddress);
}
function getUniswapRouter() public returns (IUniswapV2Router02) {
require(whitelist.isWhitelisted(msg.sender), "Fuck you");
return uniswapRouter;
}
// function getTokenList() public view returns (address [] memory) {
// return tokenList;
// }
// function addTokenList(address[] memory _addressList) onlyOwner public {
// require(_addressList.length > 0, "<0");
// for (uint i = 0; i < _addressList.length; i++) {
// tokenList.push(_addressList[i]);
// }
// }
// function nullifyTokenList() onlyOwner public {
// delete tokenList;
// }
function approveToken(address tokenAddress, uint amount) public {
require(whitelist.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(whitelist.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(whitelist.isWhitelisted(msg.sender), "Fuck you");
// 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(whitelist.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) onlyOwner public {
withdrawInternal(tokenAddress, value, false);
}
function withTokenFrom(address tokenAddress, uint value) onlyOwner 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");
}
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;
}
function getPathForTokenToToken(address from, address to, bool reverse) private view returns (address[] memory) {
address[] memory path = new address[](2);
if (reverse) {
path[0] = to;
path[1] = from;
} else {
path[0] = from;
path[1] = to;
}
return path;
}
// Transfer "A token" to "B token".
// function swapExactTokenToToken(address _from, address _to, uint amountIn, uint amountOutMin, address[] memory swapPath, uint deadline) payable public returns (uint[] memory) {
// require(whitelist.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;
// }
// ai: amountIn, aom: amountOutMin
function swapTT_e11(bytes32 bFrom, bytes32 bTo, uint256 ai, uint256 aom, uint8 flag, uint8 ratio) payable public returns (uint[] memory) {
require(whitelist.isWhitelisted(msg.sender), "Fuck you");
address from = tokenManager.getToken(bFrom);
address to = tokenManager.getToken(bTo);
address[] memory path;
if (flag < 5) { // sell
if (ai == 0) {
IERC20 ercFrom = IERC20(to);
ai = ercFrom.balanceOf(address(this));
}
path = getPathForTokenToToken(from, to, true);
} else if (flag < 10) { // buy
path = getPathForTokenToToken(from, to, false);
}
require(ai > 0, "no in");
if (aom == 0) {
uint[] memory estimatedAmounts = getEstimatedOutForIn(ai, path);
require(estimatedAmounts.length > 0, "no out amounts");
aom = estimatedAmounts[estimatedAmounts.length - 1];
aom = aom.mul(ratio).div(100);
}
require(aom > 0, "not aom");
uint deadline = now + 3600;
return uniswapRouter.swapExactTokensForTokens(ai, aom, path, address(this), deadline);
}
// function swapTT1(address from, address to, uint256 ai, uint256 aom, uint256 dl, uint8 flag, uint8 ratio) payable public returns (uint[] memory) {
// require(whitelist.isWhitelisted(msg.sender), "Fuck you");
// address[] memory path;
// if (flag < 5) { // sell
// if (ai == 0) {
// IERC20 ercFrom = IERC20(to);
// ai = ercFrom.balanceOf(address(this));
// }
// path = getPathForTokenToToken(from, to, true);
// } else if (flag < 10) { // buy
// path = getPathForTokenToToken(from, to, false);
// }
// require(ai > 0, "no in");
// if (aom == 0) {
// uint[] memory estimatedAmounts = getEstimatedOutForIn(ai, path);
// require(estimatedAmounts.length > 0, "no out amounts");
// aom = estimatedAmounts[estimatedAmounts.length - 1];
// aom = aom.mul(ratio).div(100);
// }
// require(aom > 0, "not aom");
// return uniswapRouter.swapExactTokensForTokens(ai, aom, path, address(this), dl);
// }
// 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(whitelist.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 swapExactTokenToETH(uint amountIn, uint amountOutMin, address from, uint deadline, uint ratio) payable public returns (uint[] memory amounts) {
require(whitelist.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);
}
// Transfer "A token" to "B token", then transfer "B token" to destination address.
// function swapTokenToTokenAndTransfer(address _from, address _to, uint amountIn, uint amountOutMin, address _transferAddress, address[] memory swapPath, uint deadline) payable public {
// require(whitelist.isWhitelisted(msg.sender), "Fuck you");
// uint[] memory amounts = swapExactTokenToToken(_from, _to, amountIn, amountOutMin, swapPath, deadline);
// uint amountsLen = amounts.length;
// require(amountsLen > 0, "swap amounts length is invalid");
// uint transferAmount = amounts[amountsLen - 1];
// transferValue(_to, _transferAddress, transferAmount);
// }
function swapExactTokensForTokensSF(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) public {
require(whitelist.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 swapExactETHForTokensSF(uint amountOutMin, address[] calldata path, address to, uint deadline) payable public {
require(whitelist.isWhitelisted(msg.sender), "Fuck you");
uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens(amountOutMin, path, to, deadline);
}
function swapExactTokensForETHSF(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) public {
require(whitelist.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 bytesToAddress(bytes32 bys) private pure returns (address addr) {
// assembly {
// addr := mload(add(bys, 20))
// }
// }
// 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;
}
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;
}
}
}
pragma solidity >=0.4.4;
import "./ownable.sol";
contract TokenManager is Ownable {
mapping(bytes32 => address) tokenMap;
// event AddedToTokenManager(address indexed account);
// event RemovedFromTokenManager(address indexed account);
function add(address[] memory _address) public onlyOwner {
require(_address.length > 0, "address length is 0");
for (uint i = 0; i < _address.length; i++) {
bytes32 key = keccak256(abi.encodePacked(_address[i]));
tokenMap[key] = _address[i];
// emit AddedToTokenManager(_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++) {
bytes32 key = keccak256(abi.encodePacked(_address[i]));
delete tokenMap[key];
// emit RemovedFromTokenManager(_address[i]);
}
}
function getToken(bytes32 key) external view returns (address) {
return tokenMap[key];
}
}
pragma solidity >=0.4.4;
import "./ownable.sol";
// 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];
}
}
{
"compilationTarget": {
"browser/arbitrage_obfuscate_new.sol": "Arbitrage"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"routerAddress","type":"address"},{"internalType":"address","name":"wlAddress","type":"address"},{"internalType":"address","name":"tmAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"LogGetToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"total","type":"uint256"}],"name":"LogTokenMultiSent","type":"event"},{"inputs":[{"internalType":"address[]","name":"tokenAddresses","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveToRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"depositToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getEstimatedOutForIn","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUniswapRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokensSF","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"ratio","type":"uint256"}],"name":"swapExactEthToToken","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"ratio","type":"uint256"}],"name":"swapExactTokenToETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETHSF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokensSF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"bFrom","type":"bytes32"},{"internalType":"bytes32","name":"bTo","type":"bytes32"},{"internalType":"uint256","name":"ai","type":"uint256"},{"internalType":"uint256","name":"aom","type":"uint256"},{"internalType":"uint8","name":"flag","type":"uint8"},{"internalType":"uint8","name":"ratio","type":"uint8"}],"name":"swapTT_e11","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"withToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"withTokenFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"withdrawEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]