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:
- Conservative approach: Treat LP token creation as a crypto-to-crypto exchange (taxable)
- 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
-
Auto-compounding vaults (like Yearn): How do you track when rewards are automatically reinvested? Is each auto-compound a new taxable event?
-
Multi-hop swaps: When a swap routes through multiple pools, do you need to record each intermediate step?
-
Failed/reverted transactions: Still cost gas. Is that a deductible loss?
-
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.