// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; /// @title MRTaxToken — PinkSale-style tax token (buy/sell fee to treasury wallet). contract MRTaxToken is ERC20, Ownable { uint256 public buyTaxBps; uint256 public sellTaxBps; address public taxWallet; mapping(address => bool) public isExcludedFromTax; mapping(address => bool) public automatedMarketMakerPairs; uint8 private immutable _customDecimals; event TaxUpdated(uint256 buyTaxBps, uint256 sellTaxBps); event TaxWalletUpdated(address indexed wallet); event PairUpdated(address indexed pair, bool value); constructor( string memory name_, string memory symbol_, uint256 totalSupply_, uint8 decimals_, address owner_, uint256 buyTaxBps_, uint256 sellTaxBps_, address taxWallet_ ) ERC20(name_, symbol_) Ownable(owner_) { require(owner_ != address(0), "owner=0"); require(buyTaxBps_ <= 2500 && sellTaxBps_ <= 2500, "tax>25%"); _customDecimals = decimals_; buyTaxBps = buyTaxBps_; sellTaxBps = sellTaxBps_; taxWallet = taxWallet_ == address(0) ? address(this) : taxWallet_; isExcludedFromTax[owner_] = true; isExcludedFromTax[address(this)] = true; isExcludedFromTax[taxWallet_] = true; _mint(owner_, totalSupply_); } function decimals() public view override returns (uint8) { return _customDecimals; } function setAutomatedMarketMakerPair(address pair, bool value) external onlyOwner { require(pair != address(0), "pair=0"); automatedMarketMakerPairs[pair] = value; emit PairUpdated(pair, value); } function setTaxWallet(address wallet) external onlyOwner { require(wallet != address(0), "tax=0"); isExcludedFromTax[taxWallet] = false; taxWallet = wallet; isExcludedFromTax[wallet] = true; emit TaxWalletUpdated(wallet); } function setTax(uint256 buyBps, uint256 sellBps) external onlyOwner { require(buyBps <= 2500 && sellBps <= 2500, "tax>25%"); buyTaxBps = buyBps; sellTaxBps = sellBps; emit TaxUpdated(buyBps, sellBps); } function setExcludedFromTax(address account, bool excluded) external onlyOwner { isExcludedFromTax[account] = excluded; } function _update(address from, address to, uint256 amount) internal override { if (amount == 0 || isExcludedFromTax[from] || isExcludedFromTax[to]) { super._update(from, to, amount); return; } uint256 taxBps; if (automatedMarketMakerPairs[from]) { taxBps = buyTaxBps; } else if (automatedMarketMakerPairs[to]) { taxBps = sellTaxBps; } if (taxBps == 0) { super._update(from, to, amount); return; } uint256 tax = (amount * taxBps) / 10_000; uint256 send = amount - tax; super._update(from, taxWallet, tax); super._update(from, to, send); } }