hello guys. Anyone has knowledge on the best way to differenciate a Buy from a Sell if I use uniswap? trying to call two different functions, one on sell and one on buy

Feb 13, 2021, 10:58 PM
You have to be more specific. A buy is always also a sell, it just depends on the point of view. Also, are you looking from inside the token or how are you observing this? If inside the token, then I don't think you can differentiate as the token has no idea what is it being bought/sold against
Feb 14, 2021, 6:09 AM
Hey thanks for your answer. A buy/Sell to the point of view of the person using Uniswap. And I think it'd be easier to look from inside the token contract, if that's something I can do
Feb 14, 2021, 3:38 PM
As I said, you can't see it from inside the token contract since the token contract only sees that the token is being transferred - it doesn't even know that some other asset is transferred at the same time.
So you probably need to monitor Uniswap emitted events and consider for example that if there is a swap of asset A to asset B, you have to decide whether to consider that as a buy or a sell.
Feb 14, 2021, 3:42 PM
I see awesome. How do I monitor Uniswap emitted events? Do I need to import the Router Interface and then the router functions to modify them from inside my own contract?
Feb 14, 2021, 3:47 PM
no, this has nothing to do with Solidity. you can't do this on-chain. here's some random article which was the first google hit: https://www.pauric.blog/How-to-Query-and-Monitor-Ethereum-Contract-Events-with-Web3/
Feb 14, 2021, 3:55 PM
Thanks i'll read
Feb 14, 2021, 4:05 PM
It's often best to have as small contracts as possible, to avoid bugs
Feb 14, 2021, 5:58 PM

© 2024 Draquery.com All rights reserved.