Like we do for flipstarter and voter.cash transactions, we can identify AnyHedge transactions.
Let me put it in pseudocode.
From the parsed tx, you have:
hedge payout satoshis
long payout satoshis
settlement price
funding transaction (outpoint)
From that you get:
total contract satoshis = hedge payout satoshis + long payout satoshis
hedge USD payout = (hedge payout satoshis / 1e8) * settlement price
long USD payout = (long payout satoshis / 1e8) * settlement price
By definition:
hedge USD payin = hedge USD payout
Then you look up the funding transaction's block timestamp (1 rpc call).
Then you look up the approximate BCH price at the time of funding (e.g. coingecko API). Note that this is an approximation, because we cannot know the exact price used in the contract funding.
From there you calculate:
approx hedge payin satoshis = (hedge USD payin / approx funding price) * 1e8
approx long payin satoshis = total contract satoshis - approx hedge payin satoshis
approx long USD payin = (approx long payin satoshis / 1e8) * approx funding price
From there you can calculate the long's approx profit/loss in terms of sats, $ or %.
Does that make sense? So it should be 1 rpc call + 1 price api call
We don't need to provide all that info, but that is what is possible.