Contract Name:
theprotocol
Contract Source Code:
File 1 of 1 : theprotocol
// SPDX-License-Identifier: Unlicensed
/**
We’ll be sending 2% out of our 4% tax to THE deployer for their LP.
Love,
the baby
Twitter: https://twitter.com/babytheprotocol
Additional 2% tax goes to our project for:
1% to marketing
1% to LP & instantly burned
btw... don't try to bot this. first 6 blocks blacklisted & 99 sell tax first 5 min
*/
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;
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 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 IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract theprotocol is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1e10 * 10**9;
uint256 private _buyTHEFee = 2;
uint256 private _previousBuyTHEFee = _buyTHEFee;
uint256 private _buyLiquidityFee = 1;
uint256 private _previousBuyLiquidityFee = _buyLiquidityFee;
uint256 private _buytheMarketingFee = 1;
uint256 private _previousBuytheMarketingFee = _buytheMarketingFee;
uint256 private _sellTHEFee = 2;
uint256 private _previousSellTHEFee = _sellTHEFee;
uint256 private _sellLiquidityFee = 1;
uint256 private _previousSellLiquidityFee = _sellLiquidityFee;
uint256 private _selltheMarketingFee = 1;
uint256 private _previousSelltheMarketingFee = _selltheMarketingFee;
uint256 private tokensFortheMarketing;
uint256 private tokensForTHE;
uint256 private tokensForLiquidity;
address payable private _theMarketingWallet;
address payable private _THEWallet;
address payable private _liquidityWallet;
string private constant _name = "the";
string private constant _symbol = "the protocol";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private swapping;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private tradingActiveBlock = 0; // 0 means trading is not active
uint256 private blocksToBlacklist = 6;
uint256 private _maxBuyAmount = _tTotal;
uint256 private _maxSellAmount = _tTotal;
uint256 private _maxWalletAmount = _tTotal;
uint256 private swapTokensAtAmount = 0;
event MaxBuyAmountUpdated(uint _maxBuyAmount);
event MaxSellAmountUpdated(uint _maxSellAmount);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_THEWallet = payable(0x8D21b508091BD04cA9f05f50c931F2C19c5BC4e5);
_liquidityWallet = payable(address(0xdead));
_theMarketingWallet = payable(0x55960985F635F2a69b8B99BA2F02174f659F1f12);
_rOwned[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_THEWallet] = true;
_isExcludedFromFee[_liquidityWallet] = true;
_isExcludedFromFee[_theMarketingWallet] = true;
emit Transfer(address(0x6a9CAd5D8C50fcbfC17Bc4aADb10f9C0AB2AC321), _msgSender(), _tTotal);
}
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 _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _rOwned[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
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()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function setSwapEnabled(bool onoff) external onlyOwner(){
swapEnabled = onoff;
}
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);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0));
require(to != address(0));
require(amount > 0);
bool takeFee = false;
bool shouldSwap = false;
if (from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping) {
require(!bots[from] && !bots[to]);
takeFee = true;
if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) {
require(amount <= _maxBuyAmount);
require(balanceOf(to) + amount <= _maxWalletAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && !_isExcludedFromFee[from] && cooldownEnabled) {
require(amount <= _maxSellAmount);
shouldSwap = true;
}
}
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = (contractTokenBalance > swapTokensAtAmount) && shouldSwap;
if (canSwap && swapEnabled && !swapping && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapping = true;
swapBack();
swapping = false;
}
_tokenTransfer(from,to,amount,takeFee, shouldSwap);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensFortheMarketing + tokensForTHE;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 10) {
contractBalance = swapTokensAtAmount * 10;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethFortheMarketing = ethBalance.mul(tokensFortheMarketing).div(totalTokensToSwap);
uint256 ethForTHE = ethBalance.mul(tokensForTHE).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethFortheMarketing - ethForTHE;
tokensForLiquidity = 0;
tokensFortheMarketing = 0;
tokensForTHE = 0;
(success,) = address(_theMarketingWallet).call{value: ethFortheMarketing}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(_THEWallet).call{value: address(this).balance}("");
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
_liquidityWallet,
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_THEWallet.transfer(amount);
}
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = true;
_maxBuyAmount = 1e8 * 10**9;
_maxSellAmount = 1e8 * 10**9;
_maxWalletAmount = 1e8 * 10**9;
swapTokensAtAmount = 5e6 * 10**9;
tradingOpen = true;
tradingActiveBlock = block.number;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setMaxBuyAmount(uint256 maxBuy) public onlyOwner {
_maxBuyAmount = maxBuy;
}
function setMaxSellAmount(uint256 maxSell) public onlyOwner {
_maxSellAmount = maxSell;
}
function setMaxWalletAmount(uint256 maxToken) public onlyOwner {
_maxWalletAmount = maxToken;
}
function setSwapTokensAtAmount(uint256 newAmount) public onlyOwner {
require(newAmount >= 1e3 * 10**9);
require(newAmount <= 5e6 * 10**9);
swapTokensAtAmount = newAmount;
}
function setTHEWallet(address THEWallet) public onlyOwner() {
require(THEWallet != address(0));
_isExcludedFromFee[_THEWallet] = false;
_THEWallet = payable(THEWallet);
_isExcludedFromFee[_THEWallet] = true;
}
function settheMarketingWallet(address theMarketingWallet) public onlyOwner() {
require(theMarketingWallet != address(0));
_isExcludedFromFee[_theMarketingWallet] = false;
_theMarketingWallet = payable(theMarketingWallet);
_isExcludedFromFee[_theMarketingWallet] = true;
}
function setLiquidityWallet(address liquidityWallet) public onlyOwner() {
require(liquidityWallet != address(0), "liquidityWallet address cannot be 0");
_isExcludedFromFee[_liquidityWallet] = false;
_liquidityWallet = payable(liquidityWallet);
_isExcludedFromFee[_liquidityWallet] = true;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setBuyFee(uint256 buyTHEFee, uint256 buyLiquidityFee, uint256 buytheMarketingFee) external onlyOwner {
require(buyTHEFee + buyLiquidityFee + buytheMarketingFee <= 6);
_buyTHEFee = buyTHEFee;
_buyLiquidityFee = buyLiquidityFee;
_buytheMarketingFee = buytheMarketingFee;
}
function setSellFee(uint256 sellTHEFee, uint256 sellLiquidityFee, uint256 selltheMarketingFee) external onlyOwner {
require(sellTHEFee + sellLiquidityFee + selltheMarketingFee <= 99);
_sellTHEFee = sellTHEFee;
_sellLiquidityFee = sellLiquidityFee;
_selltheMarketingFee = selltheMarketingFee;
}
function setBlocksToBlacklist(uint256 blocks) public onlyOwner {
blocksToBlacklist = blocks;
}
function removeAllFee() private {
if(_buyTHEFee == 0 && _buyLiquidityFee == 0 && _buytheMarketingFee == 0 && _sellTHEFee == 0 && _sellLiquidityFee == 0 && _selltheMarketingFee == 0) return;
_previousBuyTHEFee = _buyTHEFee;
_previousBuyLiquidityFee = _buyLiquidityFee;
_previousBuytheMarketingFee = _buytheMarketingFee;
_previousSellTHEFee = _sellTHEFee;
_previousSellLiquidityFee = _sellLiquidityFee;
_previousSelltheMarketingFee = _selltheMarketingFee;
_buyTHEFee = 0;
_buyLiquidityFee = 0;
_buytheMarketingFee = 0;
_sellTHEFee = 0;
_sellLiquidityFee = 0;
_selltheMarketingFee = 0;
}
function restoreAllFee() private {
_buyTHEFee = _previousBuyTHEFee;
_buyLiquidityFee = _previousBuyLiquidityFee;
_buytheMarketingFee = _previousBuytheMarketingFee;
_sellTHEFee = _previousSellTHEFee;
_sellLiquidityFee = _previousSellLiquidityFee;
_selltheMarketingFee = _previousSelltheMarketingFee;
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee, bool isSell) private {
if(!takeFee) {
removeAllFee();
} else {
amount = _takeFees(sender, amount, isSell);
}
_transferStandard(sender, recipient, amount);
if(!takeFee) {
restoreAllFee();
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
_rOwned[sender] = _rOwned[sender].sub(tAmount);
_rOwned[recipient] = _rOwned[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
function _takeFees(address sender, uint256 amount, bool isSell) private returns (uint256) {
uint256 _totalFees;
uint256 THEFee;
uint256 liqFee;
uint256 mktFee;
if(tradingActiveBlock + blocksToBlacklist >= block.number){
_totalFees = 99;
liqFee = 99;
} else {
_totalFees = _getTotalFees(isSell);
if (isSell) {
THEFee = _sellTHEFee;
liqFee = _sellLiquidityFee;
mktFee = _selltheMarketingFee;
} else {
THEFee = _buyTHEFee;
liqFee = _buyLiquidityFee;
mktFee = _buytheMarketingFee;
}
}
uint256 fees = amount.mul(_totalFees).div(100);
tokensFortheMarketing += fees * mktFee / _totalFees;
tokensForTHE += fees * THEFee / _totalFees;
tokensForLiquidity += fees * liqFee / _totalFees;
if(fees > 0) {
_transferStandard(sender, address(this), fees);
}
return amount -= fees;
}
receive() external payable {}
function manualswap() public onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() public onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function withdrawStuckETH() external onlyOwner {
require(!tradingOpen, "Can only withdraw if trading hasn't started");
bool success;
(success,) = address(msg.sender).call{value: address(this).balance}("");
}
function _getTotalFees(bool isSell) private view returns(uint256) {
if (isSell) {
return _sellTHEFee + _sellLiquidityFee + _selltheMarketingFee;
}
return _buyTHEFee + _buyLiquidityFee + _buytheMarketingFee;
}
}