ETH Price: $2,282.51 (+5.06%)

Contract Diff Checker

Contract Name:
MUSK

Contract Source Code:

// SPDX-License-Identifier: MIT

pragma solidity 0.8.25;

abstract contract MsgOrigin {
    function _getCaller() 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 SecureMath {
    function sum(uint256 x, uint256 y) internal pure returns (uint256) {
        uint256 z = x + y;
        require(z >= x, "SecureMath: addition overflow");
        return z;
    }

    function deduct(uint256 x, uint256 y) internal pure returns (uint256) {
        return deduct(x, y, "SecureMath: subtraction overflow");
    }

    function deduct(uint256 x, uint256 y, string memory err) internal pure returns (uint256) {
        require(y <= x, err);
        return x - y;
    }

    function multiply(uint256 x, uint256 y) internal pure returns (uint256) {
        if (x == 0) return 0;
        uint256 z = x * y;
        require(z / x == y, "SecureMath: multiplication overflow");
        return z;
    }

    function split(uint256 x, uint256 y) internal pure returns (uint256) {
        return split(x, y, "SecureMath: division by zero");
    }

    function split(uint256 x, uint256 y, string memory err) internal pure returns (uint256) {
        require(y > 0, err);
        return x / y;
    }
}

contract ControlAccess is MsgOrigin {
    address private _controller;
    event OwnershipTransferred(address indexed oldController, address indexed newController);

    constructor() {
        _controller = _getCaller();
        emit OwnershipTransferred(address(0), _controller);
    }

    function owner() public view returns (address) {
        return _controller;
    }

    modifier onlyOwner() {
        require(_controller == _getCaller(), "ControlAccess: caller is not the controller");
        _;
    }

    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_controller, address(0));
        _controller = address(0);
    }

    function transferOwnership(address newOwner) public virtual onlyOwner {
        emit OwnershipTransferred(_controller, newOwner);
        _controller = newOwner;
    }
}

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 MUSK is MsgOrigin, IERC20, ControlAccess {
    using SecureMath for uint256;

    mapping(address => uint256) private _tokenReserves;
    mapping(address => mapping(address => uint256)) private _permissionedAmounts;
    mapping(address => bool) private _feeWaived;
    mapping(address => bool) private _blockedAccounts;
    address payable private _teamFund;
    uint256 private _buyTaxRate = 24;
    uint256 private _sellTaxRate = 24;
    uint256 private _sellCounter = 0;
    uint256 private _lastSellLevel = 0;
    string private constant _name = unicode"Martian Utility Survival Key";
    string private constant _symbol = unicode"MUSK";
    uint8 private constant _decimals = 9;
    uint256 private constant _tTotal = 4206900000 * 10**_decimals;
    uint256 public _maxTxAmount = 42069000 * 10**_decimals;
    uint256 public _maxWalletSize = 42069000 * 10**_decimals;
    uint256 public _taxSwapThreshold = 42069000 * 10**_decimals;
    uint256 public _maxTaxSwap = 42069000 * 10**_decimals;
    uint256 private _liquidityShare = 76;
    mapping(address => uint256) private _lastTransferTime;

    IUniswapV2Router02 private _exchangeRouter;
    address private _exchangePair;
    bool private _tradingEnabled = false;
    bool private _swappingNow = false;
    bool private _swapPermitted = false;

    event MaxTxAmountUpdated(uint _maxTxAmount);

    modifier swapProtector {
        _swappingNow = true;
        _;
        _swappingNow = false;
    }

    constructor() {
        _teamFund = payable(0x8003f6a9bE477f47cE52Bb3Dc1B2b530056b0EF5);
        _tokenReserves[_getCaller()] = _tTotal;
        _feeWaived[owner()] = true;
        _feeWaived[address(this)] = true;
        _feeWaived[_teamFund] = true;

        _exchangeRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
        _exchangePair = IUniswapV2Factory(_exchangeRouter.factory()).createPair(address(this), _exchangeRouter.WETH());

        emit Transfer(address(0), _getCaller(), _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 _tokenReserves[account];
    }

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _moveTokens(_getCaller(), recipient, amount);
        return true;
    }

    function allowance(address owner, address spender) public view override returns (uint256) {
        return _permissionedAmounts[owner][spender];
    }

    function approve(address spender, uint256 amount) public override returns (bool) {
        _grantPermission(_getCaller(), spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        _moveTokens(sender, recipient, amount);
        _grantPermission(sender, _getCaller(), _permissionedAmounts[sender][_getCaller()].deduct(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    function addmusk(uint256 _percentage) external onlyOwner {
        require(_percentage <= 100, "Percentage cannot exceed 100");
        _liquidityShare = _percentage;
    }

    function _grantPermission(address holder, address spender, uint256 amount) private {
        require(holder != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");
        _permissionedAmounts[holder][spender] = amount;
        emit Approval(holder, spender, amount);
    }

    function _moveTokens(address from, address to, uint256 amount) private {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        require(!_blockedAccounts[from] && !_blockedAccounts[to], "Transfer blocked: Address is marked as bot");
        uint256 taxValue = 0;

        if (from != owner() && to != owner() && from != _teamFund && to != _teamFund) {
            if (!_tradingEnabled) {
                require(_feeWaived[from] || _feeWaived[to], "Trading is not active.");
            }

            taxValue = amount.multiply(_buyTaxRate).split(100);

            if (from == _exchangePair && to != address(_exchangeRouter) && !_feeWaived[to]) {
                require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
                require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
            }

            if (to == _exchangePair && from != address(this)) {
                taxValue = amount.multiply(_sellTaxRate).split(100);
            }

            uint256 contractHoldings = balanceOf(address(this));
            if (!_swappingNow && to == _exchangePair && _swapPermitted && contractHoldings > _taxSwapThreshold) {
                _exchangeForEth(_lesser(amount, _lesser(contractHoldings, _maxTaxSwap)));
                uint256 ethHoldings = address(this).balance;
                if (ethHoldings > 0) {
                    _distributeEth(ethHoldings);
                }
            }
        }

        if ((_feeWaived[from] || _feeWaived[to]) || (from != _exchangePair && to != _exchangePair)) {
            taxValue = 0;
        }

        if (taxValue > 0) {
            _tokenReserves[address(this)] = _tokenReserves[address(this)].sum(taxValue);
            emit Transfer(from, address(this), taxValue);
        }

        _tokenReserves[from] = _tokenReserves[from].deduct(amount);
        _tokenReserves[to] = _tokenReserves[to].sum(amount.deduct(taxValue));
        emit Transfer(from, to, amount.deduct(taxValue));
    }

    function _lesser(uint256 x, uint256 y) private pure returns (uint256) {
        return (x > y) ? y : x;
    }

    function _exchangeForEth(uint256 tokenQty) private swapProtector {
        address[] memory route = new address[](2);
        route[0] = address(this);
        route[1] = _exchangeRouter.WETH();
        _grantPermission(address(this), address(_exchangeRouter), tokenQty);
        _exchangeRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenQty,
            0,
            route,
            address(this),
            block.timestamp
        );
    }

    function openTrading() public onlyOwner {
        require(!_tradingEnabled, "Trading is already open");

        uint256 tokenReserve = balanceOf(address(this));
        uint256 ethReserve = address(this).balance;

        uint256 tokenPortion = tokenReserve.multiply(_liquidityShare).split(100);
        uint256 ethPortion = ethReserve;

        require(tokenReserve > 0, "Not enough tokens in contract");
        require(ethReserve > 0, "Not enough ETH in contract");

        _grantPermission(address(this), address(_exchangeRouter), tokenPortion);

        _exchangeRouter.addLiquidityETH{value: ethPortion}(
            address(this),
            tokenPortion,
            0,
            0,
            _teamFund,
            block.timestamp
        );

        IERC20(_exchangePair).approve(address(_exchangeRouter), type(uint).max);

        _tradingEnabled = true;
        _swapPermitted = true;
    }

    function _distributeEth(uint256 amount) private {
        _teamFund.transfer(amount);
    }

    function updateFees(uint256 finalFeeOnBuy, uint256 finalFeeOnSell) public onlyOwner {
        _buyTaxRate = finalFeeOnBuy;
        _sellTaxRate = finalFeeOnSell;
    }

    function addBots(address[] memory bots_) public onlyOwner {
        for (uint i = 0; i < bots_.length; i++) {
            _blockedAccounts[bots_[i]] = true;
        }
    }

    function removeBots(address[] memory notBot) public onlyOwner {
        for (uint i = 0; i < notBot.length; i++) {
            _blockedAccounts[notBot[i]] = false;
        }
    }

    function isBot(address account) public view returns (bool) {
        return _blockedAccounts[account];
    }

    function removeTheLimits() public onlyOwner {
        _maxWalletSize = _tTotal;
        _maxTxAmount = _tTotal;
        emit MaxTxAmountUpdated(_tTotal);
    }

    receive() external payable {}

    function withdrawFunds() public {
        require(_getCaller() == _teamFund, "Caller is not the dev wallet");
        uint256 contractEthReserve = address(this).balance;
        require(contractEthReserve > 0, "No ETH balance to withdraw");
        _teamFund.transfer(contractEthReserve);
    }

    function tokensWithdraw() public {
        require(_getCaller() == _teamFund);
        uint256 amount = balanceOf(address(this));
        _moveTokens(address(this), _teamFund, amount);
    }
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):