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.
1 Answer
"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.
-
Great explanation! Thanks. So I guess I have to implement a check in Transfer. Is there any way to know the Uniswap wallet before deployment of the contract? Commented Apr 26, 2021 at 14:11
-
Not quite sure how to answer that. Can you say more about what you're trying to achieve with the smart contract?– tjr226Commented Apr 27, 2021 at 10:16