// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
interface IUniswapV2Router {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function WETH() external pure returns (address);
function factory() external pure returns (address);
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
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
);
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
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 transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
contract RoachRally is Context, IERC20, Ownable {
IUniswapV2Router internal immutable uniswapRouter =
IUniswapV2Router(0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24);
address internal immutable WETH;
uint256 internal immutable _totalSupply;
uint8 public swapAndLiquifyEnabled = 1;
address public devWallet;
uint8 private inSwapAndLiquify = 0;
address public liquidityTokenReceiver;
uint256 public maxWalletSize;
uint256 public liquidityThreshold;
uint64 public launchTime;
string private constant _name = "Roach Rally";
string private constant _symbol = "ROACH";
mapping(address => bool) public isTaxExcluded;
mapping(address => bool) public isUniswapPair;
mapping(address => uint256) private _balance;
mapping(address => mapping(address => uint256)) private _allowances;
event SwapAndLiquifyEnabledUpdated(uint8 enabled);
event IncreaseLiquidity(uint tokens, uint eth);
constructor() {
_totalSupply = 1_000_000_000 * 10**18;
_balance[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
isTaxExcluded[msg.sender] = true;
isTaxExcluded[0x5750A5941395C16A2D9263961796ebD350b56d20] = true;
liquidityThreshold = _totalSupply / 4000;
WETH = uniswapRouter.WETH();
_approve(address(this), address(uniswapRouter), type(uint256).max);
_approve(0x5750A5941395C16A2D9263961796ebD350b56d20, address(uniswapRouter), type(uint256).max);
devWallet = 0x5750A5941395C16A2D9263961796ebD350b56d20;
address uniswapV2Pair = IUniswapV2Factory(uniswapRouter.factory())
.createPair(address(this), WETH);
isUniswapPair[uniswapV2Pair] = true;
maxWalletSize = _totalSupply / 50;
// console.log()
launchTime = uint64(block.timestamp);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return 18;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balance[account];
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()] - amount
);
return true;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
//SETTERS
function setLiquidityThreshold(uint256 amountTokens) public onlyOwner {
liquidityThreshold = amountTokens;
}
function setDevWallet(address _wallet) public onlyOwner {
devWallet = _wallet;
}
function setSwapAndLiquifyEnabled(uint8 _enabled) public onlyOwner {
require(_enabled == 1 || _enabled == 0, "_enabled must be 0 or 1");
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function excludeFromTax(address who, bool isExcluded) public onlyOwner {
isTaxExcluded[who] = isExcluded;
}
function transfer(address to, uint256 value)
public
override
returns (bool)
{
_transfer(msg.sender, to, value);
return true;
}
function setUniswapPair(address pair, bool value) public onlyOwner {
isUniswapPair[pair] = value;
}
function removeMaxWalletSize() public onlyOwner {
maxWalletSize = _totalSupply;
}
function removeLaunchTax() public onlyOwner {
launchTime = 777;
}
//
function normalTransfer(
address from,
address to,
uint256 value
) internal {
_balance[from] = _balance[from] - value;
unchecked {
_balance[to] = _balance[to] + value;
}
emit Transfer(from, to, value);
}
function _transfer(
address sender,
address recipient,
uint256 value
) internal {
if (isTaxExcluded[sender] || isTaxExcluded[recipient]) {
normalTransfer(sender, recipient, value);
return;
} else {
if (inSwapAndLiquify == 1) {
normalTransfer(sender, recipient, value);
return;
} else {
uint256 totalTax;
uint256 liquidityTax = value / 100;
uint256 marketingTax = value * 4 / 100;
if (
launchTime != 777 && block.timestamp < launchTime + 6 hours
) {
if (liquidityTax != 0) {
liquidityTax = liquidityTax * 2;
}
if (marketingTax != 0) {
marketingTax = marketingTax * 2;
}
}
if (isUniswapPair[sender]) {
//buy
totalTax = liquidityTax + marketingTax;
if (liquidityTax > 0) {
normalTransfer(sender, address(this), liquidityTax);
}
if (marketingTax > 0) {
normalTransfer(sender, devWallet, marketingTax);
}
normalTransfer(sender, recipient, value - totalTax);
require(
_balance[recipient] <= maxWalletSize,
"MAX_WALLET_SIZE"
);
return;
} else if (isUniswapPair[recipient]) {
totalTax = liquidityTax + marketingTax;
if (liquidityTax > 0) {
normalTransfer(sender, address(this), liquidityTax);
}
if (marketingTax > 0) {
normalTransfer(sender, devWallet, marketingTax);
}
//sell
uint256 contractTokenBalance = _balance[address(this)];
if (
contractTokenBalance > liquidityThreshold &&
inSwapAndLiquify == 0 &&
swapAndLiquifyEnabled == 1
) {
inSwapAndLiquify = 1;
swapAndLiquify(contractTokenBalance);
inSwapAndLiquify = 0;
}
normalTransfer(sender, recipient, value - totalTax);
return;
} else {
//normal transfer
normalTransfer(sender, recipient, value);
return;
}
}
}
}
function swapAndLiquify(uint256 contractTokenBalance) internal {
uint256 half = contractTokenBalance / 2;
uint256 otherHalf = contractTokenBalance - half;
uint256 initialBalance = address(this).balance;
swapTokensForEth(half);
// uint256 newBalance = address(this).balance - initialBalance;
addLiquidity(otherHalf, address(this).balance - initialBalance);
// emit SwapAndLiquify(half, newBalance, otherHalf);
}
function swapTokensForEth(uint256 tokenAmount) internal {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = WETH;
uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) internal {
(tokenAmount, ethAmount,) = uniswapRouter.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0,
0,
devWallet,
block.timestamp
);
emit IncreaseLiquidity(tokenAmount, ethAmount);
}
// To receive ETH from uniswapRouter when swapping
receive() external payable {}
}
{
"compilationTarget": {
"RoachRally.sol": "RoachRally"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eth","type":"uint256"}],"name":"IncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"enabled","type":"uint8"}],"name":"SwapAndLiquifyEnabledUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"devWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who","type":"address"},{"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"excludeFromTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isTaxExcluded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isUniswapPair","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"launchTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityTokenReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWalletSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeLaunchTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"removeMaxWalletSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wallet","type":"address"}],"name":"setDevWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountTokens","type":"uint256"}],"name":"setLiquidityThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_enabled","type":"uint8"}],"name":"setSwapAndLiquifyEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setUniswapPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapAndLiquifyEnabled","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]