I have the following code that it is working on wallet to wallet but when I buy and sell on Pancakeswap only on buys the fees are burned and send to dev wallet, but if anybody sell the tokens the fees are not take.
What should I add/change so it will work on sells on Pancakeswap, not only when somebody buy tokens?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, ERC20Burnable, Pausable, Ownable {
uint public BURN_FEE = 5;
uint DEV_FEE = 5;
address public founder;
mapping(address => bool) public excludeFromTax;
constructor() ERC20("MyToken07", "MTK07") {
_mint(msg.sender, 1000000 * 10 ** decimals());
founder = msg.sender;
excludeFromTax[msg.sender] = true;
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
if(excludeFromTax[msg.sender] == true) {
_transfer(_msgSender(), recipient, amount);
}else{
uint burnAmount = amount * BURN_FEE/100;
uint adminAmount = amount * DEV_FEE/100;
_burn(_msgSender(), burnAmount);
_transfer(_msgSender(), founder, adminAmount);
_transfer(_msgSender(), recipient, amount - (burnAmount + adminAmount));
}
return true;
}
}