/*
🌎 Website: https://doctormonkey.org/
📃 Docs: https://docs.doctormonkey.org/
🔊 Channel TG: https://t.me/DoctorMonkeyChannel
👥 Main TG: https://t.me/DoctorMonkeyOfficial
💪 TG Army Group: https://t.me/DoctorMonkeyArmy
🐦 Twitter: https://twitter.com/DoctorMonkey22
▶️ Youtube: https://www.youtube.com/channel/UCJGXWLRePw3HTZAXjb5uNLA
👥 Discord: https://discord.gg/GYTYVvvnHT
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.3;
// Interfaces
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
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
);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
// Contracts
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
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);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function getTime() public view returns (uint256) {
return block.timestamp;
}
}
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 9;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account)
public
view
virtual
override
returns (uint256)
{
return _balances[account];
}
function transfer(address recipient, uint256 amount)
public
virtual
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
virtual
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
virtual
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(
currentAllowance >= amount,
"ERC20: transfer amount exceeds allowance"
);
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender] addedValue
);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(
currentAllowance >= subtractedValue,
"ERC20: decreased allowance below zero"
);
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(
senderBalance >= amount,
"ERC20: transfer amount exceeds balance"
);
_balances[sender] = senderBalance - amount;
_balances[recipient] = amount;
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = amount;
_balances[account] = amount;
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
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 _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
contract DMONKEY is ERC20, Ownable {
// Custom
IUniswapV2Router02 public uniswapV2Router;
// Bool
bool public swapAndLiquifyEnabled = true;
bool public sendToMarketing = true;
bool public sendToTeam = true;
bool public sendToBuyback = true;
bool public marketActive = false;
bool public maxWalletActive = true;
bool public blockMultiBuys = true;
bool public limitSells = true;
bool public limitBuys = true;
bool public feeStatus = true;
bool public buyFeeStatus = true;
bool public sellFeeStatus = true;
bool private isInternalTransaction = false;
// Address
address public uniswapV2Pair;
address public marketingAddress;
address public teamAddress;
address public buybackAddress;
// Uint
uint256 private total_supply;
uint256 public minimumWeiForTokenomics = 1 * 10**7;
uint256 public buyMarketingFee;
uint256 public sellMarketingFee;
uint256 public buyTeamFee;
uint256 public sellTeamFee;
uint256 public buyBuybackFee;
uint256 public sellBuybackFee;
uint256 public totalBuyFee = buyMarketingFee buyTeamFee buyBuybackFee;
uint256 public totalSellFee =
sellMarketingFee sellTeamFee sellBuybackFee;
uint256 public maxBuyTxAmount;
uint256 public maxSellTxAmount;
uint256 public maxWallet;
uint256 public minimumTokensBeforeSwap;
uint256 public tokensToSwap;
uint256 public intervalSecondsForSwap;
uint256 private startTimeForSwap;
uint256 private marketActiveAt;
// Struct
struct userData {
uint256 lastBuyTime;
}
// Mapping
mapping(address => bool) public premarketUser;
mapping(address => bool) public excludedFromFees;
mapping(address => bool) public automatedMarketMakerPairs;
mapping(address => userData) public userLastTradeData;
// Event
event MarketingCollected(uint256 amount);
event TeamCollected(uint256 amount);
event BuybackCollected(uint256 amount);
// Constructor
constructor() ERC20("Doctor Monkey", "DMONKEY") {
total_supply = 100_000_000 * 10**decimals();
// Set gvars
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x10ED43C718714eb63d5aA57B78B54704E256024E
);
uniswapV2Router = _uniswapV2Router;
// Spawn pair
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// Mappings
excludedFromFees[address(this)] = true;
excludedFromFees[owner()] = true;
premarketUser[owner()] = true;
automatedMarketMakerPairs[uniswapV2Pair] = true;
_mint(msg.sender, total_supply); // Mint is used only here
}
// Accept bnb for autoswap
receive() external payable {}
// Utility functions
function MultipleTransfer(
address[] memory _address,
uint256[] memory _amount
) external onlyOwner {
for (uint256 i = 0; i < _amount.length; i ) {
address adr = _address[i];
uint256 amnt = _amount[i] * 10**decimals();
super._transfer(owner(), adr, amnt);
}
}
function updateUniswapV2Router(
address newAddress,
bool create,
address pair
) external onlyOwner {
require(
newAddress != address(uniswapV2Router),
"The router already has that address"
);
uniswapV2Router = IUniswapV2Router02(newAddress);
if (create) {
address _uniswapV2Pair = IUniswapV2Factory(
uniswapV2Router.factory()
).createPair(address(this), uniswapV2Router.WETH());
uniswapV2Pair = _uniswapV2Pair;
} else {
uniswapV2Pair = pair;
}
}
function transferForeignToken(
address _token,
address _to,
uint256 _value
) external onlyOwner returns (bool _sent) {
if (_value == 0) {
_value = IERC20(_token).balanceOf(address(this));
}
_sent = IERC20(_token).transfer(_to, _value);
}
function sweep() external onlyOwner {
uint256 balance = address(this).balance;
payable(owner()).transfer(balance);
}
// Switch functions
function switchMarketActive(bool _state) external onlyOwner {
marketActive = _state;
if (_state) {
marketActiveAt = block.timestamp;
}
}
function switchBlockMultiBuys(bool _state) external onlyOwner {
blockMultiBuys = _state;
}
function switchLimitSells(bool _state) external onlyOwner {
limitSells = _state;
}
function switchLimitBuys(bool _state) external onlyOwner {
limitBuys = _state;
}
// Set functions
function setsendFee(
bool marketing,
bool team,
bool buyback
) external onlyOwner {
sendToMarketing = marketing;
sendToBuyback = buyback;
sendToTeam = team;
}
function setminimumWeiForTokenomics(uint256 _value) external onlyOwner {
minimumWeiForTokenomics = _value;
}
function setFeesAddress(
address marketing,
address team,
address buyback
) public onlyOwner {
marketingAddress = marketing;
teamAddress = team;
buybackAddress = buyback;
excludedFromFees[teamAddress] = true;
excludedFromFees[buybackAddress] = true;
excludedFromFees[marketingAddress] = true;
}
function setMaxSellTxAmount(uint256 _value) external onlyOwner {
require(
_value >= ((total_supply * 1) / 1000) / (10**decimals()),
"MaxSell Tx too low"
);
maxSellTxAmount = _value * 10**decimals();
}
function setMaxBuyTxAmount(uint256 _value) external onlyOwner {
require(
_value >= ((total_supply * 1) / 1000) / (10**decimals()),
"MaxBuy Tx too low"
);
maxBuyTxAmount = _value * 10**decimals();
}
function setMaxWallet(bool status, uint256 max) external onlyOwner {
require(
max >= ((total_supply * 5) / 1000) / (10**decimals()),
"MaxWallet too low"
);
maxWalletActive = status;
maxWallet = max * 10**decimals();
}
function setFee(
bool is_buy,
uint256 marketing,
uint256 team,
uint256 buyback
) public onlyOwner {
if (is_buy) {
buyTeamFee = team;
buyMarketingFee = marketing;
buyBuybackFee = buyback;
totalBuyFee = buyMarketingFee buyTeamFee buyBuybackFee;
} else {
sellTeamFee = team;
sellMarketingFee = marketing;
sellBuybackFee = buyback;
totalSellFee = sellMarketingFee sellTeamFee sellBuybackFee;
}
}
function setFeeStatus(
bool buy,
bool sell,
bool _state
) external onlyOwner {
feeStatus = _state;
buyFeeStatus = buy;
sellFeeStatus = sell;
}
function setSwapAndLiquify(
bool _state,
uint256 _intervalSecondsForSwap,
uint256 _minimumTokensBeforeSwap,
uint256 _tokensToSwap
) public onlyOwner {
swapAndLiquifyEnabled = _state;
intervalSecondsForSwap = _intervalSecondsForSwap;
minimumTokensBeforeSwap = _minimumTokensBeforeSwap * 10**decimals();
tokensToSwap = _tokensToSwap * 10**decimals();
}
function set_baseContractSettings(
uint256 bMarketing,
uint256 sMarketing,
uint256 bTeam,
uint256 sTeam,
uint256 bBback,
uint256 sBback,
uint256 tkSwap,
uint256 minTkBswap,
uint256 intSec,
address marketA,
address teamA,
address bBackA
) public onlyOwner {
uint256 totSFee = sMarketing sTeam sBback;
uint256 totBFee = bMarketing bTeam bBback;
require(totBFee totSFee <= 45, "Fee too high!");
setFee(true, bMarketing, bTeam, bBback);
setFee(false, sMarketing, sTeam, sBback);
setSwapAndLiquify(true, intSec, minTkBswap, tkSwap);
setFeesAddress(marketA, teamA, bBackA);
}
function setLimitz(
uint256 maxbuy,
uint256 maxsell,
uint256 maxWall
) public onlyOwner {
require(
maxbuy >= ((total_supply * 1) / 1000) / (10**decimals()) &&
maxsell >= ((total_supply * 1) / 1000) / (10**decimals()),
"MaxTx buy and/or sell too low!"
);
require(
maxWall >= ((total_supply * 5) / 1000) / (10**decimals()),
"MaxWallet too low!"
);
maxBuyTxAmount = maxbuy * 10**decimals();
maxSellTxAmount = maxsell * 10**decimals();
maxWallet = maxWall * 10**decimals();
}
// Mappings functions
function editPremarketUser(address _target, bool _status)
external
onlyOwner
{
premarketUser[_target] = _status;
}
function editExcludedFromFees(address _target, bool _status)
external
onlyOwner
{
excludedFromFees[_target] = _status;
}
function editAutomatedMarketMakerPairs(address _target, bool _status)
external
onlyOwner
{
automatedMarketMakerPairs[_target] = _status;
}
// Operational functions
function swapTokensForEth(uint256 tokenAmount) private {
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 swapTokens(uint256 contractTokenBalance) private {
isInternalTransaction = true;
swapTokensForEth(contractTokenBalance);
isInternalTransaction = false;
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
uint256 trade_type = 0;
bool overMinimumTokenBalance = balanceOf(address(this)) >=
minimumTokensBeforeSwap;
// Market status flag
if (!marketActive) {
require(
premarketUser[from],
"Can not trade before the market opening"
);
}
// Normal transaction
if (!isInternalTransaction) {
// Tx limits
// Buy
if (automatedMarketMakerPairs[from]) {
trade_type = 1;
// Limits
if (!excludedFromFees[to]) {
// Tx limit
if (limitBuys) {
require(
amount <= maxBuyTxAmount,
"maxBuyTxAmount Limit Exceeded"
);
}
// Multi-buy limit
if (blockMultiBuys) {
require(
marketActiveAt 3 < block.timestamp,
"Launch delay protection revert."
);
require(
userLastTradeData[to].lastBuyTime 3 <=
block.timestamp,
"Multi-buy orders disabled."
);
userLastTradeData[to].lastBuyTime = block.timestamp;
}
}
}
// Sell
else if (automatedMarketMakerPairs[to]) {
trade_type = 2;
// Marketing auto-bnb
if (swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0) {
if (
overMinimumTokenBalance &&
startTimeForSwap intervalSecondsForSwap <=
block.timestamp
) {
startTimeForSwap = block.timestamp;
// Sell to bnb
swapTokens(tokensToSwap);
}
}
// Limits
if (!excludedFromFees[from]) {
// Tx limit
if (limitSells) {
require(
amount <= maxSellTxAmount,
"maxSellTxAmount Limit Exceeded"
);
}
}
}
// Fees redistribution
if (address(this).balance > minimumWeiForTokenomics) {
uint256 caBalance = address(this).balance;
// Marketing
if (sendToMarketing) {
uint256 marketingTokens = (caBalance * sellMarketingFee) /
totalSellFee;
(bool success, ) = address(marketingAddress).call{
value: marketingTokens
}("");
if (success) {
emit MarketingCollected(marketingTokens);
}
}
// Team
if (sendToTeam) {
uint256 teamTokens = (caBalance * sellTeamFee) /
totalSellFee;
(bool success, ) = address(teamAddress).call{
value: teamTokens
}("");
if (success) {
emit TeamCollected(teamTokens);
}
}
// Buyback
if (sendToBuyback) {
uint256 buybackTokens = (caBalance * sellBuybackFee) /
totalSellFee;
(bool success, ) = address(buybackAddress).call{
value: buybackTokens
}("");
if (success) {
emit BuybackCollected(buybackTokens);
}
}
}
// MaxWallet
if (maxWalletActive) {
if (
!excludedFromFees[from] &&
!excludedFromFees[to] &&
(trade_type == 1 || trade_type == 0)
) {
require(
amount balanceOf(to) <= maxWallet,
"maxWallet Limit Exceeded"
);
}
}
// Fees management
if (feeStatus) {
// Buy
if (trade_type == 1 && buyFeeStatus && !excludedFromFees[to]) {
uint256 txFees = (amount * totalBuyFee) / 100;
amount -= txFees;
super._transfer(from, address(this), txFees);
}
// Sell
if (
trade_type == 2 && sellFeeStatus && !excludedFromFees[from]
) {
uint256 txFees = (amount * totalSellFee) / 100;
amount -= txFees;
super._transfer(from, address(this), txFees);
}
// No wallet to wallet tax
}
}
// Transfer tokens
super._transfer(from, to, amount);
}
}