I am trying to list the history of a token in my wallet. So, I am dealing with different scenarios right now, and I am stucked with a swap transaction and I am wondering the best way to identify a transaction as a swap (right now I am trying to detect some amount out and some in into the user wallet).

I see solscan.io and wallets can decode the instructions properly, the library gives me information about it and I have everything I need, however, in one inner instruction an account is opened and closed and the authority is not the user itself and I am wondering how solscan (and others) identify that.

This is what solscan.io shows:

enter image description here

and the instruction is this one:

enter image description here

And I have this same information but I am not able to determine how that is related to the user:

enter image description here

In ATLAS to USDC exchange I can identify the user because the authority is the wallet user but on this one I don't know what to do, any help is appreciated.

To be clear, what I am trying to figuring out is how to identify a transaction (like the one I show on the pictures) as a type “swap”. Using ts sdk, what is the best approach to identify a transaction of swap from Prism or Jupiter as a swap transaction? Since there are a lot of inner instructions, what would be the best way to classify transactions (specifically for this case, a swap transaction)


1 Answer 1


You would first check for those transfer instructions that you posted in your question. Then you would also dig through your ParsedTransactionMeta, and look at the preTokenBalances and postTokenBalances to determine the amounts.


  • 2
    Your comment gave me the idea of just comparing pre/post token balances which already worked, with that comparison digging into meta is not needed unless I am missing something. Thanks for the help. Commented Aug 1, 2022 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.