Is there a way to check which direction is transfer() of erc-20 token if someone is selling or buying our tokens for eth (i mean uniswap for example)?
Asked
Active
Viewed 1,300 times
3 Answers
3
I did some analysis, the ony issue I had was sell and addLiquidity gave the same paramenters:
add liquidity
uniswapRouter ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
uniswapPair ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
msgSender ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
sender ====>> 0xbde658ba6aaf6c9f7938820b69d47f099bc5ea23
recipient ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
for adding liquidity
1. router is the msgSender
2. tx sender is the owner of the tokens
2. Pair is the recipient
Token Sell
uniswapRouter ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
uniswapPair ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
msgSender ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
sender ====>> 0xbde658ba6aaf6c9f7938820b69d47f099bc5ea23
recipient ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
For Token Sell
1. router is msgSender
2. sender is asset owner
3. recipient is uniswap pair
Buy Tokens
uniswapRouter ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
uniswapPair ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
msgSender ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
sender ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
recipient ====>> 0xbde658ba6aaf6c9f7938820b69d47f099bc5ea23
For Token Buy
1. pair is msgSender
2. transfer sender is the pair
3. recipient is the actual owner of final tokens
remove liquidity
uniswapRouter ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
uniswapPair ====>> 0x4f58b3a4c69f1ee8a9bf11cb5defadc89751c32a
msgSender ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
sender ====>> 0x7a250d5630b4cf539739df2c5dacb4c659f2488d
recipient ====>> 0xbde658ba6aaf6c9f7938820b69d47f099bc5ea23
For Remove liquidity
1. router is msgSender
2. sender is router
3. recipient asset owner

Big Zak
- 1,040
- 12
- 17
1
Uniswap transactions are swaps, not buys or sells. It can have two input token and two output token at the same time.
One way define Uniswap token transaction as a buy or sell is to define one of token0 and token1 as quote token (USD, ETH) and then if the amount of quote token was less after the swap, it was buy.

Mikko Ohtamaa
- 82,057
- 50
- 264
- 435
0
You can differentiate it by checking whether your account received or transfered the tokens.
Eg:
transactionType: address === obj.from ? 'Sold' : 'Bought'
From is your account address.
Obj - Is the transaction details.

BlackMirror
- 17
- 1
- 9