I'm building a smart contract to learn solidity and I'm wondering how I can distinguish buy and sell functionalities. I want the contract to do different functionalities on a buy and other functionalities on a sell. I'm using uniswap/pancakeswap as the exchange. Right now I'm using the Transfer method, but it seems like this is triggerd on a buy and a sell.
"Buy" and "Sell" are imperfect explanations of what's happening on Uniswap. You're trading one token for another, so for every transaction you're both buying and selling.
It looks like the Sell transfer would be the one sent from a wallet to Uniswap, and the Buy transfer is the one from Uniswap to the wallet.
An analogy might be if there was a stock exchange where you couldn't use money. On this exchange, you can only get different stocks if you trade existing shares in one company for shares in another company.
That's what Uniswap is, except for crypto tokens.