Leverage Trading On DEX

I do a lot of trading on GMX which is a leverage trading DEX. Coinpanda doesn’t seem to be able to handle that very well. Are there any fixes in the works or can someone recommend a method to keep to keep up with gains, losses, liquidations, margin changes etc?

1 Like

Hi Jojo,
What kind of issue are you having? I would be able to tell you more re: fixes if I knew what you are referring to
For tax purposes, you basically only need to import:

  • PnL transactions, which is simply a Send(loss) or Receive(gain) transaction.
  • Transaction fees
  • Funding fees

You can check out the help article for the Coinpanda generic CSV template

We can calculate the PnL for supported exchanges, in case the CSV doesn’t contain it outright. If you open a ticket in Discord or message the live chat, you can send your CSV file and we can look into supporting it.

Hi Ruben - you understand this stuff a lot better than I do. Let me try to explain using an example:

For a DEX trading platform (SNX, GMX, DXDY etc) I’m trading directly from wallet (Meta Mask).

Let’s say I want to open an ETH long position or 1 ETH with 10X leverage.

I send 1 ETH from my wallet to the contract and it opens a 10 ETH position. There is a fee to open the position and ongoing funding fees. Now several scenarios can take place:

  1. I get liquidated. In this case, the contract will close the position and send me whatever small remaining amount of ETH is left.

  2. I can see the trade is going against me before being liquidated and choose to add collateral so that I don’t get liquidated.

  3. I can close position for a loss.

  4. I can add to the position to make it larger.

  5. I can close position for a gain.

My issue is that Coinpanda (and other’s like Koinly) does not seem to be capturing any of this. For example, it will show me sending 1 ETH and later receiving .02 ETH but doesn’t correlate that with a liquidation or even a loss. Same is true for all scenarios listed above. Am I wrong and just not understanding something?

Thank you! All the support has been really excellent.

I think I see what you mean. If you import the transaction data via API, the transactions will not necessarily be recognized in relation to each other as belonging to a leverage trading operation.

That is indeed a limitation of API data, where the transactions may or may not contain enough metadata for us to be able to interpret everything exactly.

It is probably doable, but it requires that we write code to support the specific protocol you are interacting with.

To simplify the issue, all we really need to determine is how much value/money is sent and/or received, as I mentioned before. This is easier said than done, even if you have the all the transaction data, you would still need to calculate the actual PnL.

GMX is complicated since you are trading on multiple different blockchains as well.

I think your best bet is to prepare a CSV for all of this. You could initially do an API sync and then export that transaction data. Import that into a spreadsheet and copy the necessary transactions to a generic CSV.

PnL would be calculated at the time of closing a position. So you would have a Send or Receive transaction for each closed position.
Funding fees are also counted per position, and they can be merged into 1 transaction per day. Same for fees

In Coinpanda you would end up with a series of Send/Receive transactions, labeled as “Realized P&L”, “Margin Trading Fee”, or “Margin Funding Cost”

1 Like

Thank you for the info.

In my case the data was imported via API when I synched Meta Mask. I didn’t realize that you can then export the transactions to CSV. I will take a look at that.

Also, I came across this GMX site which is already doing the P&L for my trades. Is there anyway to pull this data?

https://www.gmx.house/arbitrum/account/0xe0E75A9b83AC7e0b7D78aD10551Bf8a1FbCA733C

On the right side you can click each trade and it shows you the history.

1 Like

I haven’t seen that website before, but it looks promising. We might be able to call their API, but I would have to check with the dev team how that might work. It would mean we’d have to create a dedicated GMX leverage trade wallet. It’s not something that would happen quickly.

But it would be worth reaching out to the gmx.house team to see if they can provide you with a CSV printout of that data. It shouldn’t be hard for them to do. Even if you can get in in json format, we could easily convert that to CSV

Maybe possible to obtain json file using the graph

All of this is new to me, so not certain…