First of all, a newbie in Solana development speaking.
I’m trying to parse Solana transactions to display them in a friendly way as for example:
Transfer XXX token_name to YYY
Swap XX token_name for YY token_name_2
Buy XX NFT_collection_name
I am getting JSON information using http RPC calls to getTransaction() method from Solana nodes (using jsonParsed format), and processing response in C#.
So far managed to understand and parse transfers (no matter if SOL or a SPL token), but I’m totally stuck with token swaps.
Easyest way seems to compare pre and post balances from JSON, but I’m struggling with intermediate accounts. Take for example this transaction. Tokens are transferred through account 2MFoS3…CPCj3. How can it be identified as an intermediate account and not considered for balance update? If intermediate account not discarded, seems got double amount of tokens. And this is a simple swap, most of them have several intermediate accounts.
Maybe pre and post balances are not the best option. Is there any other information in the JSON useful to identify balance updates in a given tx? Any other RPC method or format?
I’ve also considered using 3rd party API proividing human readable information for a tx, but they offer a very limited number of requests and would end up with a huge bill.
Any information or clue appreciated.