Sell and Transfer work fine in my contract, but Buy fee includes burn and I need to remove it.
When a buy occurs via pancakeswap, it takes 2% and includes a 3% burn. I need to keep the burn on sell and transfer but lose the burn on buy.
100 token buy currently looks like this:
95 tokens to buyer
2 tokens to contract
3 tokens to 0xdead.
It should be as follows:
98 tokens to buyer
2 tokens to contract
bool takeFee = true;
// if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
uint256 burn = 0;
if (takeFee) {
// uint256 fees = 0;
if (automatedMarketMakerPairs[to]) {
fees = totalSellFee - sellFee.burnFee;
burn = sellFee.burnFee;
} else if (automatedMarketMakerPairs[from]) {
fees = totalBuyFee;
}
else fees = totalTransferFee - transferFee.burnFee;
burn = transferFee.burnFee;
}
if (!_isExcludedFromLimit[from] && !_isExcludedFromLimit[to]) {
if (automatedMarketMakerPairs[to]) {
require(amount <= maxBuyAmount, "Buy exceeds limit");
{
if(block.number < tradingStartBlock + BLOCKCOUNT){
_isBlackListed[from] = true; // check this condition
}
}
}
uint256 feeAmount = amount.mul(fees).div(1000);
uint256 burnAmount = amount.mul(burn).div(1000);
amount = amount.sub(feeAmount).sub(burnAmount);
super._transfer(from, address(this), feeAmount);
super._transfer(from, address(deadAddress), burnAmount);
}
super._transfer(from, to, amount);