DeFi Accounting Nightmares: How I Track LP Tokens and Yield Farming in Beancount

I dove into DeFi yield farming about a year ago, chasing those juicy APYs. What I wasn’t prepared for was the accounting nightmare that came with it. After months of figuring this out, I want to share how I’m tracking LP tokens and yield farming in Beancount—and why it’s genuinely complex.

The Core Problem: Every Swap May Be Taxable

Here’s what makes DeFi accounting brutal: the IRS treats every crypto-to-crypto exchange as a potentially taxable event. When you deposit ETH and USDC into a Uniswap pool and receive LP tokens, that might be a taxable swap. When you receive reward tokens from yield farming, that’s definitely taxable income. When you withdraw and the ratio has changed due to impermanent loss… well, that’s where it gets really messy.

The IRS hasn’t issued specific guidance for DeFi liquidity pools, so taxpayers are left choosing between two approaches:

  1. Conservative approach: Treat LP token creation as a crypto-to-crypto exchange (taxable)
  2. Aggressive approach: Treat it as a deposit (non-taxable until withdrawal)

I’ve chosen the conservative approach because I’d rather overpay than explain myself to an auditor.

My Account Structure

Here’s how I set up my Beancount accounts for DeFi:

; DeFi-specific accounts
2024-01-01 open Assets:Crypto:DeFi:Uniswap:ETH-USDC-LP     UNI-V2-ETH-USDC
2024-01-01 open Assets:Crypto:DeFi:Curve:3CRV-LP          3CRV
2024-01-01 open Income:Crypto:DeFi:YieldFarming           USD
2024-01-01 open Income:Crypto:DeFi:LPFees                 USD
2024-01-01 open Expenses:Crypto:DeFi:ImpermanentLoss      USD

; Underlying assets still tracked separately
2024-01-01 open Assets:Crypto:Wallet:ETH                  ETH
2024-01-01 open Assets:Crypto:Wallet:USDC                 USDC

Recording a Liquidity Pool Deposit (Conservative Approach)

When I deposit into a pool, I record it as disposing of the underlying assets and acquiring LP tokens:

2025-06-15 * "Add liquidity to Uniswap ETH-USDC pool"
    ; Dispose of underlying assets (capital gains event)
    Assets:Crypto:Wallet:ETH           -1.0 ETH {2500.00 USD, 2024-03-15}
    Assets:Crypto:Wallet:USDC          -2500 USDC {1.00 USD}
    ; Receive LP tokens with combined cost basis
    Assets:Crypto:DeFi:Uniswap:ETH-USDC-LP  0.5 UNI-V2-ETH-USDC {5000.00 USD, 2025-06-15}
    Income:Crypto:CapitalGains

The key insight: the cost basis of my LP tokens equals the fair market value of what I deposited. Any gain or loss on the deposited assets is realized at this point.

Recording Yield Farming Rewards

Rewards are simpler—they’re ordinary income at fair market value when received:

2025-06-20 * "Yield farming rewards - UNI airdrop"
    Assets:Crypto:Wallet:UNI            10.0 UNI {8.50 USD, 2025-06-20}
    Income:Crypto:DeFi:YieldFarming     -85.00 USD

I record rewards when I claim them, not when they accrue. This matches the “dominion and control” standard from IRS guidance on staking.

The Impermanent Loss Problem

Here’s where things get genuinely ugly. When I withdraw from a pool, the ratio of assets has usually changed due to impermanent loss. How do you record that?

2025-12-01 * "Withdraw from Uniswap ETH-USDC pool"
    ; Dispose of LP tokens
    Assets:Crypto:DeFi:Uniswap:ETH-USDC-LP  -0.5 UNI-V2-ETH-USDC {5000.00 USD, 2025-06-15}
    ; Receive different ratio of assets
    Assets:Crypto:Wallet:ETH            0.8 ETH {3200.00 USD, 2025-12-01}
    Assets:Crypto:Wallet:USDC           2960 USDC {1.00 USD}
    ; Impermanent loss realized
    Expenses:Crypto:DeFi:ImpermanentLoss  280.00 USD
    Income:Crypto:CapitalGains           720.00 USD

The math: I put in $5,000, I’m getting out $5,520 worth of assets (0.8 ETH × $4,000 + 2960 USDC). But if I had just held the original 1 ETH + 2500 USDC, I’d have $6,500 now. That $980 difference is impermanent loss—but only $280 of it is “realized” in my accounting because the rest is unrealized gain on the ETH I received back.

The controversial question: Can you deduct impermanent loss? The IRS hasn’t said. I record it separately so I can discuss it with my accountant.

Questions for the Community

  1. Auto-compounding vaults (like Yearn): How do you track when rewards are automatically reinvested? Is each auto-compound a new taxable event?

  2. Multi-hop swaps: When a swap routes through multiple pools, do you need to record each intermediate step?

  3. Failed/reverted transactions: Still cost gas. Is that a deductible loss?

  4. Has anyone built importers for pulling DeFi positions into Beancount automatically?

This is genuinely the most complex accounting I’ve ever done. Would love to hear how others are handling it.

@finance_fred, excellent breakdown. As someone who helps clients navigate crypto taxes professionally, I want to add some important context about the regulatory landscape and why your conservative approach is wise.

The Current Regulatory Uncertainty

You’re right that the IRS hasn’t issued specific guidance for DeFi liquidity pools. What’s notable is that Congress actually repealed the Treasury’s broker reporting requirements for DeFi protocols in early 2025 (H.J. Res.25). This leaves us in regulatory limbo—the IRS clearly wants oversight but hasn’t figured out how to implement it for decentralized protocols.

IRS Notice 2024-57 provides some relief: liquidity and staking pool providers are not currently subject to reporting requirements under Section 6045. However, this doesn’t mean the transactions aren’t taxable—it just means the IRS isn’t requiring third-party reporting yet.

Why Conservative Is Smart

Your choice to treat LP token creation as a taxable exchange aligns with how the IRS has historically viewed property exchanges. Under Cottage Savings Ass’n v. Commissioner (1991), exchanging “legally distinct property” triggers realization. LP tokens are certainly legally distinct from the underlying assets you deposited.

The key requirement: whatever approach you choose, apply it consistently. The worst thing you can do is take the aggressive position for profitable deposits and the conservative position for losses. That’s the kind of inconsistency that draws auditor attention.

On Impermanent Loss Deductibility

This is the million-dollar question. My professional view:

  • Impermanent loss isn’t truly “realized” until you withdraw from the pool
  • When you withdraw, the loss is embedded in the capital gain/loss calculation
  • Recording it separately (as you do) is smart for visibility, but I wouldn’t recommend claiming it as a separate deduction without professional guidance

The IRS could reasonably argue that impermanent loss is simply part of your cost basis adjustment, not a separate deductible expense. Tread carefully here.

What’s Coming in 2026

By 2026, centralized exchanges will be required to report cost basis. While this doesn’t directly affect DeFi, it signals the IRS is building infrastructure for crypto enforcement. Smart taxpayers are documenting everything now so they can demonstrate good faith if audited later.

Your Beancount approach—with clear transaction records and consistent methodology—is exactly what I recommend to clients.

Thanks for this detailed writeup, @finance_fred! As a developer just getting into DeFi tracking, I have a few questions about the practical implementation.

Auto-Compounding Vaults Confusion

I deposited into a Yearn vault last month and I’m already confused. The vault automatically harvests rewards and reinvests them—I don’t touch anything. But based on what you’re saying, each auto-compound might be a taxable event?

So if the vault compounds daily, I would have 365 taxable events per year just from one position? And I need the USD value of the rewards at each compounding moment?

This feels impossible to track manually. Is there any tooling that helps with this, or do people just… not report it accurately?

Income Recognition Timing

You mentioned recording rewards when you claim them. But what about protocols where rewards just accrue to your balance automatically? On some platforms, my balance visibly increases every block—there’s nothing to “claim.”

Do I pick an arbitrary snapshot time (monthly? quarterly?) or do I somehow need to track it at the moment of actual accrual?

Missing Transactions Anxiety

Here’s what keeps me up at night: how do I know I’ve captured everything? With on-chain transactions, there’s at least a blockchain record. But DeFi has:

  • Auto-compounding
  • MEV rebates
  • Governance airdrops I didn’t know I was eligible for
  • LP fees that accrue without transactions

Is there a reconciliation strategy where I can verify my Beancount records against actual on-chain state?

Automation Dreams

Has anyone built importers that work with DeFi? I’m comfortable writing Python, but I’d rather not reinvent the wheel. Something that pulls from Zapper, DeBank, or directly from blockchain would be amazing.

I keep thinking this is like the early days of git—we’re all manually managing something that will eventually have better tooling. But I need to track this now.

@finance_fred, I appreciate the thoroughness of your approach. From a CPA perspective, I want to add some professional context about documentation and audit readiness.

Documentation Is Non-Negotiable

In traditional accounting, we can often get away with reasonable estimates and rounding. With crypto—and DeFi especially—“close enough” isn’t good enough. Here’s why:

  1. Every transaction is on-chain and verifiable. An auditor can see exactly what happened and when.
  2. The amounts matter. A rounding error that costs you $50 in tax on one transaction multiplied by hundreds of transactions becomes material.
  3. Positions are complex. Without clear documentation of your methodology, no one (including future-you) can verify your calculations.

For each DeFi position, I recommend documenting:

  • Your chosen tax treatment approach (conservative vs. aggressive)
  • The rationale for that choice
  • Screenshots or exports from the protocol showing your position
  • Links to etherscan/blockchain explorer for each transaction

Track Both Approaches

Here’s a practice I recommend to clients with significant DeFi holdings: maintain calculations under both the conservative and aggressive approaches.

Why? Because:

  • You can see which approach benefits you (and by how much)
  • If you’re audited, you can demonstrate you considered the options
  • If IRS guidance eventually clarifies the rules, you can easily adjust

In Beancount, you could do this with separate ledger files or tagged transactions that let you query both interpretations.

Form 8949 Will Be Painful

One thing that hasn’t been mentioned: Form 8949 requires you to list each disposition separately. If you’re taking the conservative approach and treating every LP token creation as a taxable event, you could have dozens or hundreds of line items.

The IRS does allow “summary” reporting if you attach a statement, but you need to be prepared to produce the detail if asked. Make sure your Beancount queries can generate the required output.

Gas Fees Are Deductible

To answer one of your questions: yes, gas fees on failed transactions are generally deductible as an expense. Document them separately—they add up.

@newbie_accountant, let me address your questions directly. I’ve been through the DeFi tracking journey and made most of the mistakes, so hopefully I can save you some time.

Auto-Compounding Vaults: My Pragmatic Approach

You’re right that technically each auto-compound could be a taxable event. But here’s my practical approach for Yearn-style vaults:

Treat the vault share as a single asset. You deposit tokens, receive yVault shares. Track the vault shares as the asset, not the underlying.

2025-01-15 * "Deposit to Yearn ETH vault"
    Assets:Crypto:Wallet:ETH        -5.0 ETH {3000.00 USD, 2024-06-01}
    Assets:Crypto:DeFi:Yearn:yETH   5.0 yETH {15000.00 USD, 2025-01-15}
    Income:Crypto:CapitalGains

When you withdraw, your yETH shares are worth more (because of compounding). You’ll have a capital gain at that point:

2025-12-15 * "Withdraw from Yearn ETH vault"
    Assets:Crypto:DeFi:Yearn:yETH  -5.0 yETH {15000.00 USD, 2025-01-15}
    Assets:Crypto:Wallet:ETH        5.8 ETH {4000.00 USD, 2025-12-15}
    Income:Crypto:CapitalGains

This approach treats the compounding as unrealized gains until withdrawal. It’s simpler and arguably defensible since you never had “dominion and control” over the intermediate compounds.

Important caveat: This is my personal approach, not tax advice. Discuss with a professional.

Income Recognition: Be Practical

For rewards that accrue without claiming, I take monthly snapshots. On the 1st of each month, I record any accrued rewards as income at that day’s FMV. Quarterly could work too.

The key is consistency. Pick an interval, document it, apply it everywhere.

Reconciliation Strategy

Here’s what I do monthly:

  1. Export wallet balances from Zapper or DeBank
  2. Compare to my Beancount balance assertions
  3. Investigate any discrepancies

In Beancount:

2025-06-01 balance Assets:Crypto:DeFi:Yearn:yETH    5.0 yETH
2025-06-01 balance Assets:Crypto:Wallet:ETH         2.5 ETH

If the balance assertion fails, you know you’re missing something.

On Tooling

I haven’t found great DeFi importers for Beancount specifically. What I’ve done is:

  • Use Koinly or CoinTracker for initial transaction parsing
  • Export to CSV
  • Write a simple Python script to convert to Beancount format

It’s not elegant, but it works. Start with one protocol, get it right, then expand.

Don’t over-engineer this on day one. You’ll learn what you need as you go.