ERC20 - Tax Fees are not working

Hi,

Compiled ERC20 contract below on Remix and deployed on Ropsten test network.
Then created LP on Uniswap V2. Whenever I swap token on Uniswap it should take some fees and transfer between 4 wallets.

Contract: https://pastebin.com/bJAFLhXN

Problem:

  • It looks like it takes some fee but not distributing between 4 wallets.
  • Also not sure whether other logic described bellow applied. Like sell limits.

Logic description:

Anti-bot Protection:

  • 0,2% transaction limit prevents bots from buying large amounts on launch.

Anti-Dump Protection:

  • Sells are limited to 7% price impact. Forever.

Anti-Paperhands Protection:

  • Only 4 sells with increasing sell cooldowns and taxation rates are allowed within a 24 hours period. The tax is redistributed to holders.

Project fees distribution:

  • 70% charity (2 wallets)
  • 10% marketing
  • 20% burned

1st sell

  • 2% tax redistributed, 7% project fees, 1 hour cooldown

2nd sell

  • 4% tax redistributed, 14% project fees, 2 hours cooldown

3rd sell

  • 6% tax redistributed, 21% project fees, 6 hours cooldown

4th sell

  • 8% tax redistributed, 27% project fees, reset after 24 hours

Thank you in advance!

hey you should share the link of rospten.etherscan. Anyway it swaps to ETH only during sales or normal transfers, not during buys

1 Like

Thanks for reply.
Sorry I’m not a solidity pro and my questions could be strange.
Unfortunately, could not share etherscan link due to security reasons.
If it’s really required I can deploy new contract there.

  1. Is it sending fees in ETH or Token?
  2. Why fees are not reached 4 wallets? In a buy&sell transactions on etherscan there is no any fees involved.
  3. Buy swaps only works with 9% slip rate but again collected fees lost somewhere. Transaction on etherscan showing amount 9% less.
  4. Sell swaps works with almost any slip rate.

So I confused why so many strange things happening with this contract. Maybe I have to use different solidity version or something else?
Thanks

did you used the addLiquidity() function to add liqudity?

1 Like

No. manually added some tokens and eth to Uniswap V2 LP.
Is it required?

for this reason you don’t have swapENabled. You can’t turn it on manually so you must redeploy,. Please try to understand what your contract does. DOn’t do copy-paste without thinking

1 Like

Thanks. It’s not just copy and past. It’s combination of different ones with the fee logic we see.
addLiquidity() function is there but not used after deployment. I can use it right now and see what happens.

I trust you but I already saw a similar code in the past

1 Like

To use you have to send ETH + tokens to the cotract but I don’t know if it will work because rate is already set

1 Like

Yes, of course part of someone’s contract is there) I not so experienced with solidity to do everything from scratch.

1 Like

Ok I figured out almost everything. 1 Issue is that if I swap ETH from non-contract related address, like example buy 1,000 coins it deliver only 920 to wallet. Finally I noticed that 6% are went to balance of contract address and 2% distributed between holders.
Function used in this transaction: swapETHForExactTokens
So I have questions:

  1. I cant find the function swapETHForExactTokens in the code. If there is no function like that then why it charge 8% (6+2) fee.
  2. I could see that 6%&2% are related to the fees in section of function _transfer, but how I can reroute this _teamFee to wallets instead of the contract:
            require(!bots[from] && !bots[to]);
            if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) {
                require(tradingOpen);
                require(amount <= _maxTxAmount);
                require(buycooldown[to] < block.timestamp);
                buycooldown[to] = block.timestamp + (30 seconds);
                _teamFee = 6;
                _taxFee = 2;

I see it probably coming to this section but not sure what to adjust:

    function _transferStandard(address sender, address recipient, uint256 tAmount) private {
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
        _takeTeam(tTeam);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }

I need to do it same way as for the sale but not in ETH:

    function sendETHToFee(uint256 amount) private {
        _charityFirst.transfer(amount.mul(40).div(100));
        _charitySecond.transfer(amount.mul(40).div(100));
        _marketing.transfer(amount.mul(20).div(100));
    }

Thank you in advance!

This is your action (purchase).

I didn't udnerstand what you need

1 Like

Sorry, let me try to explain in simple way.
Now when someone swap ETH to Token it takes 8% fees.
Fees are distributed this way:

  • 2% tax between all holders
  • 6% team somehow added to contract address

I need to send 6% to 4 wallets instead of adding to contract address.
Thanks

As I told you, without using the addLiquidity funciton, the auto-swap is disabled. For this reason, the team fee which is stored in contract as tokens can’t be swapped to ETH and sent to the wallets:
image

To test the swap and send to wallets use manualSwap and then manualSend
image

1 Like

Akh sorry, I already used addLiquidity() and openTrading() functions and everything is working fine. I just asking how to change the code to send this 6% team fee (in token, not eth) to wallets like it’s done in section below:

   function sendETHToFee(uint256 amount) private {
        _charityFirst.transfer(amount.mul(40).div(100));
        _charitySecond.transfer(amount.mul(40).div(100));
        _marketing.transfer(amount.mul(20).div(100));
    }

Again thanks for your help for solving initial problem!

you have to change some code. Not something really fast.
You should add somehting like this in _tokenTransfer()

uint256 charityFirstAmt = amount.mul(charityFirstFee).div(100);
...same for the others...

and then subtract from the amount trasnfered these amounts:
amount.sub(charityFirstAmt).sub(charitySecondAmt)...;

remove all fees excepted the ones of current transfer and do
_trasnferStandard(sender, charityFirstwallet, charityFirstAmt);

and so on, At the ned re-enable all fees.

The other way is to copy takeLiquidity and do it for each addresses

1 Like

So I done this:

    function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
        if (!takeFee) removeAllFee();
        uint256 rFee;
        uint256 tFee;
        uint256 tTeam;
        _reflectFee(rFee, tFee);
        uint256 feeAmount = amount.mul(tTeam).div(100);
        uint256 charityFirstAmt = feeAmount.mul(40).div(100);
        uint256 charitySecondAmt = feeAmount.mul(40).div(100);
        uint256 charityBurnAmt = feeAmount.mul(20).div(100);
        amount.sub(charityFirstAmt).sub(charitySecondAmt).sub(charityBurnAmt);
        _transferStandard(sender, _charityFirst, charityFirstAmt);
        _transferStandard(sender, _charitySecond, charitySecondAmt);
        _transferStandard(sender, _burnWallet, charityBurnAmt);
        _transferStandard(sender, recipient, amount);
        if (!takeFee) restoreAllFee();
    }

Do I need to remove _takeTeam and keep _reflectFee (2% distribution) from this? Or better to remove _takeTeam and _reflectFee and add _reflectFee to _tokenTransfer?

    function _transferStandard(address sender, address recipient, uint256 tAmount) private {
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
        _takeTeam(tTeam);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }

Hey!

I am having the same issue with my contract right now... taxes are being sent back to the contract address rather than the marketing wallet... There is no addLiquidity() function in mine though.. any ideas?

This is the ropsten https://ropsten.etherscan.io/address/0x55628035280b1d4019703360b4c37622e34b3792

Hey @evcoins , you've found a solution to that? If you want to take it off-topic to now spam this thread, you can dm me on discord giehlman#7914 for further investigation.