1

i've been lately trying to create an ERC20 Token with Some Fees implemented on the transfer functions and an AntiSnipe system which is supposed to block the addresses trying to make a transfer in a certain range of time. As per Uniswap documentation, IUniswapV2Router02 implements methods which accepts transfers with fees and in fact the system works in part.

Basically, after i deploy on Goerli, i am able to create a liquidity pool and with a 2nd wallet, i'm able to either buy or sell from the liquidity pool once.

After the first buy or sell, noone is able to either buy or sell anymore.

Considering that the first buy/sell works, and my 3rd wallet actually receives the fees, i suppose the way i've wrote TransferFrom function is right.

It feels like the liquidity pool Reserves dont gets updated after the first transfer and this brings the 2nd to fail (Just an idea, i have no message errors at all)

The transfer function has this logic inside aswell, but with msg.sender instead of from.

Thank you in advance

    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
    require(!AntiSnipeDenyList[from] && !AntiSnipeDenyList[to], "AntiSnipe: address is on denylist");
    address spender = _msgSender();
    _spendAllowance(from, spender, amount);

        uint256 lp_tax_amount = 0;
        uint256 dev_tax_amount = 0;
        uint256 marketing_tax_amount = 0;
        uint256 transfer_amount;

    if(
         msg.sender != _contractDeployer
        && msg.sender != owner()
        && msg.sender != _uniswapV2RouterAddress
        && to != address(this)
        && from != address(this)
    )
    {   
        
        // Calculate Taxes
        lp_tax_amount = (amount * _lpTax)/100;
        dev_tax_amount = (amount * _devTax)/100;
        marketing_tax_amount = (amount * _marketingTax)/100;

        // Calculate final transfer amount
        transfer_amount = amount - lp_tax_amount - dev_tax_amount - marketing_tax_amount;

        // Begin Max Wallet Check
        uint256 wallet_size = balanceOf(to);
        require((wallet_size + transfer_amount) <= _maxWallet, "IBIT: maximum wallet cannot be exceeded");

        // InfinityBit Token official contract address will be announced only after
        //   _ASB blocks have passed since contract deployment. Any transfers before
        //   such time are considered to be bot snipers, and will be locked.

        if(block.timestamp < deploy + 60){
           AntiSnipeDenyList[to] = true;
        }
       
    }
    else
    {
        transfer_amount = amount;
    }

    if(marketing_tax_amount > 0)
    {
        _transfer(from, _marketingWallet, marketing_tax_amount);
    }

    if(dev_tax_amount > 0)
    {
       _transfer(from, _devWallet, dev_tax_amount);
    }

    if(lp_tax_amount > 0)
    {
        _transfer(from, _lpWallet, lp_tax_amount);
    }

    _transfer(from, to, transfer_amount);
    return true;
}
  • Its unclear what you are even asking. There are issues with your math logic, you should be using mulDiv for percents, I don't see where you're calling approve so Idk if your taxes will even transfer – johnny 5 Feb 15 '23 at 21:15
  • The sniper bot logic is pretty pointless, that logic is only relavent to LP pairs once deployed not really your token. You also have vulnerability where they can block anyones address if they decide to modify the to column instead of sniping to themselves – johnny 5 Feb 15 '23 at 21:18

0 Answers0