venko.tech

How Do You Match a DEX Swap to Its Two Sides in a Ledger?

A decentralized exchange (DEX) swap is a single on-chain transaction that exchanges one token for another, but your ledger needs to record the swap as two separate legs: the disposal of the token you sold and the acquisition of the token you bought. This article explains how to identify and record both sides correctly so your portfolio tracker and tax reports remain accurate.

Why a single transaction needs two entries

When you swap Token A for Token B on a DEX like Uniswap or PancakeSwap, the blockchain records one transaction. Your portfolio tracker, however, must treat that transaction as a trade: you disposed of Token A (a sale) and acquired Token B (a purchase). Without splitting the transaction, your tracker will show only one side - usually the incoming token - and miss the cost basis of what you gave up. This mismatch inflates your balance and creates errors in realized gains calculations.

Step 1: Locate the Transaction in Your Wallet or Explorer

Open your wallet (MetaMask, Trust Wallet, or similar) or a block explorer like Etherscan or BscScan. Find the swap transaction by its hash. The transaction details will show:

The token transfers tab is your key. It lists every token that moved in or out of your wallet during that transaction. You will see two entries: one token leaving your wallet (the sold token) and one arriving (the bought token).

Step 2: Record the Disposal (Sell Side)

Create one entry in your ledger for the token you sent away. Include:

Step 3: Record the Acquisition (Buy Side)

Create a second entry for the token you received. Include:

Step 4: Verify the Two Sides Balance

Check that the net value of the two entries makes sense. The amount you disposed (in USD) should approximately equal the amount you acquired, minus any spread or slippage the DEX applied. If your software supports it, confirm the transaction’s total value matches the explorer’s token amounts.

A common mistake: recording the acquisition side only and forgetting the disposal. This leaves a phantom balance of the token you sold, as if you still hold it. Another mistake: duplicating the fee across both sides. The gas fee is a single cost; record it once, attached to the transaction as a whole, not split.

Handling partial fills and multi-token swaps

Some DEXs allow swaps that involve more than two tokens (e.g., a trade through a liquidity pool that routes through an intermediate token). In that case, the transaction will show three or more token transfers. Still, treat each pair of token movements as a separate swap leg. If the DEX splits your trade across multiple routes, you may see several incoming and outgoing tokens from the same transaction hash. Record each pair in sequence: dispose of Token A, acquire intermediate Token C, then dispose of Token C, acquire final Token B.

For partial fills (where a limit order on a DEX executes over time), each fill is a separate transaction with its own hash. Treat each fill as its own two-sided swap.

Tools that automate this

Most crypto portfolio trackers (such as those that support API auto sync or CSV import) already split DEX swaps into two entries. If yours does not, you will need to split them manually in your ledger. Check whether your tracker has a "split transaction" feature or a "manual trade" entry mode. If it imports the raw transaction as one line, edit that line to create two entries using the same hash.

What if the explorer shows no token transfers?

Some DEXs use internal transactions or complex contract interactions that do not appear in the simple "Token Transfer" tab. In that case, look under the "Internal Txns" tab or use a specialized DEX tracker like DexScreener or the DEX’s own history page. If your wallet’s activity log shows the swap, it likely includes the token amounts. When all else fails, manually reconstruct the swap from the DEX interface (check the swap history on the DEX website) and record it as two entries with the same timestamp.

Record keeping for tax purposes

Tax authorities in most jurisdictions require you to report both sides of a trade. The disposal triggers a taxable event (realized gain or loss), and the acquisition establishes the cost basis for a future sale. Matching both sides accurately is not optional for compliant reporting. Keep the transaction hash and a screenshot of the explorer page as backup documentation.

By splitting every DEX swap into its two sides, you maintain a ledger that reflects your true holdings and cost basis. Missing either side will eventually cause a discrepancy when you try to reconcile your portfolio or file taxes.

Not financial advice. venko.tech publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.

Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.

Back to portfolio