Filter swaps in response body

I created a stream to listen to a list of non-smart-contract addresses on all the EVM chains. I want somehow in the code determine what event happened. Is it a swap or just a transfer. I am struggling with swaps so much, becaause I dont know how to filter them out from just transfers. I need to know that wallet I am listening events from swapped tokens or transferred them or received them. Can someone help with it?

Hi @cryptone3d

Can you please share more details on which endpoint you are currelty using to get the transfer and swap data?

Hey @johnversus
I am not using an endpoint, I just exposed a webhook where response data posted from moralis it is basically this

Ahh I see. In that case you can use the topic0 hash from the streams body to identify the transfer, swap event. Each event will have a unique topic0 hash which you can hard code in your code for comparison.

Hm, I saw the logs, but it looks like there is always transfer, maybe I am warong have to check that, I made a swap on polygon network and I see several logs and it seems like it it a Trasnfer, because I see in the logs this hash 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

I believe every swap transaction will include the token transfer event as well as one will be followed by other.

I found one, in the logs I see transfer and swap, I think I have to go through all of the logs and if see a Swap signature I may assume that swap happened, am I correct on this? And one more question, would swap signature differ from chain to chain or swap router?

By swap signature if you mean swap token0 hash then yes you can use it.
It will be same on all chains but they can be be different with swap contracts / router.

what do you mean by token0? I’ve seen this one when I made swap on polygon network Swap(string,address) 0xbeee1e6e7fe307ddcf84b0a16137a4430ad5e2480fc4f4a8e250ab56ccd7630d

sry I meant to say topic0 hash.
Example for topic0 hash of transfer event:

I see, I found this one in the logs Swap(string,address) is it gonna be different if I swap on metamask router or uniswap, or it always be the same? Or should I somehow find a database with all possible swap signatures?

I believe it would be different if the underlying swap contract used for the swap is different. You will have to verify it by checking the popular swap contracts.

I hope this would work :slight_smile: Thank you!