I'm developing an ERC20 Token Contract in Solidity.
I would like to know if there is a way to determine when transfers are called for Swap transactions via Exchanges that implement Uniswap v2 (Such as PancakeSwap for the BSC network). This is in order to apply a certain logic when the transfer is part of a swap.
Already, I have researched that I could use msg.sender to determine when the call is coming from specific exchange routers (I would need manage these addresses on a mapping within the smart contract). Also, I could use the sender and receiver addresses to determine if a certain pair / pool is involved (The pool of my token with another token or currency, this would require another mapping). However, by this method, I would not identify swaps, but also liquidity transactions (operations that add and remove liquidity), and I'm am interested in excluding them.
Is there a better method of accomplishing this? Which allows me to single out only token and eth swaps.
I'm planning on deploying my contract to BSC (PancakeSwap is the exchange with the highest volume there).
I really appreciate any help you can provide.