Skip to main content

2 posts tagged with "DeFi"

View All Tags

The Complete Guide to Cryptocurrency Accounting with Beancount.io

· 11 min read
Mike Thrift
Mike Thrift
Marketing Manager

Are you drowning in crypto transactions across multiple exchanges, struggling with DeFi complexity, or panicking about tax season? You're not alone. The cryptocurrency landscape has exploded from simple Bitcoin purchases to a sophisticated ecosystem of DeFi protocols, staking rewards, yield farming, and cross-chain activities that challenge traditional accounting methods.

Here's the harsh reality: every crypto transaction is potentially taxable, and the IRS is watching. Whether you're a casual Bitcoin holder or a DeFi power user managing positions across dozens of protocols, maintaining accurate financial records isn't optional—it's essential for compliance and financial clarity.

The problem? Traditional accounting software has limited native support for crypto's complexity. While tools like QuickBooks can handle crypto with additional plugins, and Excel can import blockchain data with scripts, most solutions require significant customization for comprehensive crypto accounting.

The solution? Beancount.io's plain-text accounting system built on the powerful open-source Beancount language. Important note: Beancount is an open-source double-entry accounting language created by Martin Blais, while Beancount.io is a commercial hosting service that provides a user-friendly interface and cloud infrastructure for Beancount. This guide covers both the underlying Beancount principles and how to use them effectively through the Beancount.io platform.

Complete Guide to Cryptocurrency Accounting

The Cryptocurrency Accounting Nightmare (And Why It's Getting Worse)

Your Crypto Portfolio is Scattered Everywhere

Let's be honest about your setup. You probably have:

  • 3-5 different exchanges (Coinbase for easy buys, Binance for altcoins, Kraken for that one token...)
  • Multiple wallets (MetaMask for DeFi, Ledger for long-term holds, that old wallet you forgot about...)
  • DeFi positions across 10+ protocols (Uniswap, Compound, Aave, and whatever new yield farm caught your attention)
  • Staking rewards trickling in from various validators
  • Random airdrops appearing in your wallet like crypto Christmas presents

Each platform speaks a different language. Coinbase gives you a CSV that looks nothing like Binance's export. Uniswap doesn't even have exports. And don't get me started on tracking your DeFi positions across Layer 2 networks.

Transaction Types That Challenge Traditional Accounting

Your crypto activities include transaction types that traditional accounting systems weren't originally designed to handle:

  • Impermanent loss from liquidity providing (try explaining that to QuickBooks)
  • Flash loans that borrow and repay millions in a single transaction
  • Yield farming where you earn 5 different tokens for providing liquidity
  • Cross-chain bridges that make assets disappear on one network and appear on another
  • Staking derivatives like stETH that accrue value differently than the underlying asset
  • DAO governance tokens that you received for using protocols

The Tax Compliance Minefield

Here's what keeps crypto investors awake at night:

  • Every single trade is taxable (yes, even that ETH-to-USDC swap)
  • Cost basis tracking becomes impossible with hundreds of micro-transactions
  • Staking rewards are income the moment you receive them (at fair market value)
  • DeFi rewards are income even if you can't sell them yet
  • The IRS wants Form 8949 with every single transaction listed
  • Penalties are severe for getting it wrong

Traditional accounting software requires significant customization for this complexity. While solutions exist, they often require additional plugins, scripts, or manual processes to handle the full scope of cryptocurrency activities.

Enter Beancount.io: The Crypto Accounting Solution You've Been Waiting For

What if I told you there's an accounting system designed for exactly this chaos? Beancount.io isn't just another accounting tool—it's a plain-text accounting revolution that handles cryptocurrency complexity like it was born for it.

Why Beancount.io Dominates Crypto Accounting

🔍 Complete Transparency: Every calculation is visible. No black boxes, no "trust us" algorithms. You see exactly how your cost basis is calculated, how gains are computed, and where every satoshi went.

📊 Unlimited Flexibility: Create any account structure you need. Track DeFi positions, staking derivatives, cross-chain assets, or that weird token you got from a DAO vote. If you can imagine it, you can track it.

🎯 Precise Cost Basis: Lot-based tracking with specific identification. Choose exactly which Bitcoin you're selling for optimal tax outcomes. FIFO, LIFO, or cherry-pick your lots—your choice.

🔗 Future-Proof: Plain-text format means your data is yours forever. No vendor lock-in, no proprietary formats, no "sorry, we're shutting down" emails.

⚡ Scriptable Power: Automate imports, generate custom reports, and integrate with any tool. Because your crypto portfolio is unique, your accounting should be too.

Setting Up Your Crypto Command Center

Building Your Account Architecture

Think of this as designing the blueprint for your crypto empire. We're creating a structure that can handle everything from your first Bitcoin purchase to complex multi-protocol DeFi strategies:

Note: The examples use 1970-01-01 as a placeholder opening date. For actual use, replace with your real account opening dates, especially if using automated import tools that filter transactions by date.

; Exchange Accounts
1970-01-01 open Assets:Crypto:Coinbase:USD
1970-01-01 open Assets:Crypto:Coinbase:BTC
1970-01-01 open Assets:Crypto:Coinbase:ETH
1970-01-01 open Assets:Crypto:Binance:USD
1970-01-01 open Assets:Crypto:Binance:BTC
1970-01-01 open Assets:Crypto:Binance:ETH
1970-01-01 open Assets:Crypto:Binance:ADA

; Wallet Accounts
1970-01-01 open Assets:Crypto:Wallet:MetaMask:ETH
1970-01-01 open Assets:Crypto:Wallet:MetaMask:USDC
1970-01-01 open Assets:Crypto:Wallet:MetaMask:UNI
1970-01-01 open Assets:Crypto:Wallet:Ledger:BTC
1970-01-01 open Assets:Crypto:Wallet:Ledger:ETH

; DeFi Protocol Accounts
1970-01-01 open Assets:DeFi:Compound:cUSDC
1970-01-01 open Assets:DeFi:Uniswap:ETH-USDC-LP
1970-01-01 open Assets:Staking:Ethereum:ETH
1970-01-01 open Assets:Crypto:Mining:BTC

; Income Accounts
1970-01-01 open Income:Crypto:Staking:ETH
1970-01-01 open Income:Crypto:Mining:BTC
1970-01-01 open Income:Crypto:Airdrops
1970-01-01 open Income:Crypto:DeFi:Yield
1970-01-01 open Income:CapitalGains:Crypto
1970-01-01 open Income:Crypto:Trading:Margin

; Expense Accounts
1970-01-01 open Expenses:Crypto:Fees:Trading
1970-01-01 open Expenses:Crypto:Fees:Network
1970-01-01 open Expenses:Crypto:Fees:Withdrawal

; Additional accounts for advanced scenarios
1970-01-01 open Assets:Crypto:Binance:BTC-Margin
1970-01-01 open Liabilities:Crypto:Binance:Borrowed
1970-01-01 open Liabilities:Crypto:Binance:BTC
1970-01-01 open Assets:Checking
1970-01-01 open Expenses:Crypto:Mining:Electricity

Commodity Definitions

Define your cryptocurrencies as commodities with proper metadata:

1970-01-01 commodity BTC
name: "Bitcoin"
asset-class: "cryptocurrency"
price-source: "coinbase"

1970-01-01 commodity ETH
name: "Ethereum"
asset-class: "cryptocurrency"
price-source: "coinbase"

1970-01-01 commodity ADA
name: "Cardano"
asset-class: "cryptocurrency"
price-source: "binance"

1970-01-01 commodity USDC
name: "USD Coin"
asset-class: "stablecoin"
price-source: "coinbase"

1970-01-01 commodity UNI
name: "Uniswap"
asset-class: "cryptocurrency"
price-source: "coinbase"

1970-01-01 commodity UNI-V2-ETH-USDC
name: "Uniswap V2 ETH-USDC LP Token"
asset-class: "liquidity-pool"

Mastering Crypto Transactions: From Simple to Sophisticated

Ready to see Beancount.io in action? Let's walk through real-world scenarios that would break other accounting systems but are handled elegantly here.

1. Your First Bitcoin Purchase (The Gateway Drug)

Every crypto journey starts somewhere. Here's how to record that life-changing moment when you bought your first Bitcoin:

2024-01-15 * "Buy 0.5 BTC on Coinbase"
Assets:Crypto:Coinbase:BTC 0.5 BTC {30000.00 USD}
Assets:Crypto:Coinbase:USD -15025.00 USD
Expenses:Crypto:Fees:Trading 25.00 USD

2. Taking Profits (Or Cutting Losses) Like a Pro

The moment of truth: selling your crypto. This is where most accounting systems fall apart, but Beancount.io shines with precise cost basis tracking:

2024-03-20 * "Sell 0.3 BTC on Coinbase"
Assets:Crypto:Coinbase:BTC -0.3 BTC {30000.00 USD}
Assets:Crypto:Coinbase:USD 10470.00 USD
Expenses:Crypto:Fees:Trading 30.00 USD
Income:CapitalGains:Crypto 1440.00 USD ; 10470 - (0.3 × 30000) - 30 = 1440

3. Staking Rewards: Earning While You Sleep

Passive income at its finest. But remember, the IRS requires staking rewards to be reported as taxable income when received, based on fair market value at the time of receipt (per IRS Digital Assets guidance, 2024). While there is ongoing litigation (Jarrett v. United States), the current official position requires immediate reporting. Here's how to track them properly:

2024-02-01 * "ETH Staking Rewards"
Assets:Staking:Ethereum:ETH 0.05 ETH {2500.00 USD}
Income:Crypto:Staking:ETH 125.00 USD

4. DeFi Yield Farming: Where Things Get Spicy 🌶️

Welcome to advanced DeFi accounting. DeFi yield farming involves complex multi-token transactions that require sophisticated tracking. Here's how to properly account for a Uniswap liquidity position:

; Initial liquidity provision
2024-01-10 * "Add liquidity to ETH-USDC pool"
Assets:Crypto:Wallet:MetaMask:ETH -10 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:USDC -25000 USDC {1.00 USD}
Assets:DeFi:Uniswap:ETH-USDC-LP 100 UNI-V2-ETH-USDC {500.00 USD}

; Claiming rewards
2024-02-10 * "Claim Uniswap LP rewards"
Assets:Crypto:Wallet:MetaMask:UNI 50 UNI {8.00 USD}
Income:Crypto:DeFi:Yield 400.00 USD

5. Cross-Exchange Transfers

Moving Bitcoin from Coinbase to Ledger wallet:

2024-01-20 * "Transfer BTC from Coinbase to Ledger"
Assets:Crypto:Coinbase:BTC -1.0 BTC {30000.00 USD}
Assets:Crypto:Wallet:Ledger:BTC 0.9995 BTC {30000.00 USD}
Expenses:Crypto:Fees:Withdrawal 0.0005 BTC {30000.00 USD}

Advanced Cryptocurrency Scenarios

Margin Trading

Recording leveraged positions:

; Opening a leveraged long position (borrowing BTC)
2024-02-15 * "Open 2x leveraged BTC position"
Assets:Crypto:Binance:BTC-Margin 1.0 BTC {35000.00 USD}
Liabilities:Crypto:Binance:BTC -1.0 BTC {35000.00 USD}
Expenses:Crypto:Fees:Trading 50.00 USD
Assets:Crypto:Binance:USD -50.00 USD

; Closing the position with profit
2024-02-20 * "Close leveraged BTC position"
Assets:Crypto:Binance:BTC-Margin -1.0 BTC {35000.00 USD}
Assets:Crypto:Binance:USD 37950.00 USD
Liabilities:Crypto:Binance:BTC 1.0 BTC {35000.00 USD}
Income:Crypto:Trading:Margin -2900.00 USD
Expenses:Crypto:Fees:Trading 50.00 USD

Airdrops and Forks

Recording free token distributions:

2024-03-01 * "Received UNI airdrop"
Assets:Crypto:Wallet:MetaMask:UNI 400 UNI {8.00 USD}
Income:Crypto:Airdrops 3200.00 USD

Mining Operations

For cryptocurrency miners:

2024-01-01 * "Bitcoin mining reward"
Assets:Crypto:Mining:BTC 0.1 BTC {45000.00 USD}
Income:Crypto:Mining:BTC 4500.00 USD

; Mining expenses
2024-01-31 * "Mining electricity costs"
Expenses:Crypto:Mining:Electricity 800.00 USD
Assets:Checking -800.00 USD

Tax Reporting and Compliance

Cost Basis Tracking

Beancount.io automatically tracks cost basis using the lot-based system:

; Multiple purchases at different prices
2024-01-01 * "Buy BTC batch 1"
Assets:Crypto:Coinbase:BTC 1.0 BTC {40000.00 USD}
Assets:Crypto:Coinbase:USD -40000.00 USD

2024-02-01 * "Buy BTC batch 2"
Assets:Crypto:Coinbase:BTC 1.0 BTC {45000.00 USD}
Assets:Crypto:Coinbase:USD -45000.00 USD

; Selling specific lots (FIFO, LIFO, or specific identification)
2024-03-01 * "Sell BTC using FIFO"
Assets:Crypto:Coinbase:BTC -0.5 BTC {40000.00 USD}
Assets:Crypto:Coinbase:USD 22470.00 USD
Expenses:Crypto:Fees:Trading 30.00 USD
Income:CapitalGains:Crypto 2440.00 USD ; 22470 - 20000 - 30 = 2440

Generating Tax Reports

Use Beancount's query system and plugins to generate tax reports:

  • Form 8949: Capital gains and losses (via bean-query or third-party plugins)
  • Schedule D: Summary of capital gains (requires additional scripting)
  • Form 1040: Income from staking, mining, airdrops (via custom reports)
  • Detailed transaction logs: For audit purposes

Note: Tax report generation requires additional plugins, scripts, or integration with specialized tax software. Beancount provides the data foundation, but specific tax forms typically require custom development or third-party tools.

Best Practices for Crypto Accounting

1. Regular Reconciliation

  • Import exchange data weekly
  • Verify wallet balances monthly
  • Cross-check with blockchain explorers

2. Proper Documentation

  • Save all transaction confirmations
  • Document the purpose of each transaction
  • Maintain records of market prices at transaction time

3. Separate Business and Personal

; Personal crypto investments
Assets:Personal:Crypto:Coinbase:BTC

; Business crypto operations
Assets:Business:Crypto:Treasury:BTC

4. Track All Income Sources

  • Staking rewards (taxable as income)
  • Mining rewards (taxable as income)
  • Airdrops (taxable at fair market value)
  • DeFi yield (taxable as income)

5. Fee Management

Track all fees separately for proper tax deduction:

Expenses:Crypto:Fees:Trading     ; Exchange trading fees
Expenses:Crypto:Fees:Network ; Blockchain network fees
Expenses:Crypto:Fees:Withdrawal ; Withdrawal fees

Exchange API Integration

Beancount.io can integrate with major exchanges:

  • Coinbase Pro API: Automatic transaction import
  • Binance API: Real-time balance updates
  • Kraken API: Historical data synchronization

Blockchain Analysis

Connect with blockchain explorers:

  • Etherscan: Ethereum transaction verification
  • Blockchain.info: Bitcoin transaction tracking
  • BscScan: Binance Smart Chain monitoring

Portfolio Tracking

Sync with portfolio management tools:

  • CoinTracker: Tax report generation
  • Koinly: Multi-exchange aggregation
  • Blockfolio: Mobile portfolio tracking

Important Disclaimers

Tax and Legal Notice: This guide provides general information about cryptocurrency accounting using Beancount and does not constitute professional tax, legal, or financial advice. Tax treatment of cryptocurrency transactions varies by jurisdiction and individual circumstances. Complex scenarios like cross-chain bridges, impermanent loss, and flash loans may have unclear tax implications under current regulations. For specific guidance on whether transactions constitute taxable dispositions, refer to IRS FAQ Q-15 through Q-18 (2024) or consult local tax regulations. Always consult with a qualified tax professional or CPA familiar with cryptocurrency taxation in your jurisdiction before making tax-related decisions.

Software Clarification: Examples in this guide use standard Beancount syntax. While Beancount.io provides a user-friendly interface for Beancount, the underlying accounting principles apply to any Beancount implementation.

Conclusion

Cryptocurrency accounting doesn't have to be overwhelming. With Beancount's powerful plain-text accounting system, accessible through Beancount.io's platform, you can:

  • Maintain Complete Transparency: Every transaction is visible and auditable
  • Ensure Tax Compliance: Proper cost basis tracking and income reporting
  • Scale with Your Portfolio: Handle simple trades to complex DeFi strategies
  • Integrate Seamlessly: Connect with exchanges, wallets, and tax tools
  • Future-Proof Your Records: Plain-text format ensures long-term accessibility

Whether you're a casual Bitcoin holder or a sophisticated DeFi yield farmer, Beancount provides the foundation and flexibility needed to master cryptocurrency accounting. Start with basic transactions and gradually incorporate more complex scenarios as your crypto journey evolves.

The examples in this guide provide a solid foundation, but remember that cryptocurrency accounting is an evolving field. Stay informed about regulatory changes, consult with tax professionals, and adapt your accounting practices as needed.

Ready to take control of your cryptocurrency finances? Sign up for Beancount.io and experience the power of transparent, scriptable crypto accounting built on the robust Beancount foundation.

DeFi Accounting Made Simple: Tracking Yield Farming, Liquidity Pools, and Staking Rewards with Plain-Text Accounting

· 7 min read
Mike Thrift
Mike Thrift
Marketing Manager

Decentralized Finance (DeFi) has revolutionized how we interact with financial services, offering unprecedented opportunities for yield generation, liquidity provision, and decentralized trading. However, with these opportunities comes the challenge of accurately tracking complex transactions for tax compliance and portfolio management.

Traditional accounting methods struggle with DeFi's unique characteristics: automated market makers, liquidity mining, impermanent loss, and multi-token rewards. This comprehensive guide shows you how to master DeFi accounting using Beancount.io's powerful plain-text accounting system.

DeFi Accounting Made Simple

Understanding DeFi Accounting Challenges

The Complexity of DeFi Transactions

DeFi protocols create accounting challenges that don't exist in traditional finance:

  • Multi-token transactions: Single operations involving multiple cryptocurrencies
  • Automated compounding: Rewards automatically reinvested
  • Impermanent loss: Value changes due to price divergence in liquidity pools
  • Gas fee optimization: Complex fee structures across different networks
  • Protocol governance: Voting rights and governance token distributions
  • Cross-protocol interactions: Transactions spanning multiple DeFi platforms

Tax Implications of DeFi Activities

The IRS treats DeFi activities as taxable events:

  • Liquidity provision: May trigger taxable events when depositing assets
  • Yield farming rewards: Taxable as ordinary income at fair market value
  • Impermanent loss: Potential tax implications when withdrawing from pools
  • Governance tokens: Airdrops and rewards taxable as income
  • Staking rewards: Taxable as income when received

Setting Up DeFi Accounts in Beancount.io

Comprehensive Account Structure

Create a detailed account hierarchy that captures all DeFi activities:

; Wallet Accounts
1970-01-01 open Assets:Crypto:Wallet:MetaMask:ETH
1970-01-01 open Assets:Crypto:Wallet:MetaMask:USDC
1970-01-01 open Assets:Crypto:Wallet:MetaMask:DAI
1970-01-01 open Assets:Crypto:Wallet:MetaMask:WBTC

; Uniswap V3 Liquidity Pools
1970-01-01 open Assets:DeFi:Uniswap:ETH-USDC-LP
1970-01-01 open Assets:DeFi:Uniswap:DAI-USDC-LP
1970-01-01 open Assets:DeFi:Uniswap:WBTC-ETH-LP

; Compound Protocol
1970-01-01 open Assets:DeFi:Compound:cUSDC
1970-01-01 open Assets:DeFi:Compound:cETH
1970-01-01 open Assets:DeFi:Compound:cDAI

; Aave Protocol
1970-01-01 open Assets:DeFi:Aave:aUSDC
1970-01-01 open Assets:DeFi:Aave:aETH
1970-01-01 open Assets:DeFi:Aave:DebtETH

; Staking Protocols
1970-01-01 open Assets:Staking:Ethereum:ETH
1970-01-01 open Assets:Staking:Lido:stETH
1970-01-01 open Assets:Staking:RocketPool:rETH

; Income Accounts
1970-01-01 open Income:DeFi:Yield:Uniswap
1970-01-01 open Income:DeFi:Yield:Compound
1970-01-01 open Income:DeFi:Yield:Aave
1970-01-01 open Income:DeFi:Staking:Ethereum
1970-01-01 open Income:DeFi:Governance:Tokens
1970-01-01 open Income:DeFi:Airdrops

; Expense Accounts
1970-01-01 open Expenses:DeFi:Gas:Ethereum
1970-01-01 open Expenses:DeFi:Gas:Polygon
1970-01-01 open Expenses:DeFi:Gas:Arbitrum
1970-01-01 open Expenses:DeFi:ImpermanentLoss

DeFi-Specific Commodities

Define tokens and LP tokens with proper metadata:

1970-01-01 commodity UNI-V3-ETH-USDC
name: "Uniswap V3 ETH-USDC LP Token"
asset-class: "liquidity-pool"
protocol: "uniswap-v3"

1970-01-01 commodity cUSDC
name: "Compound USDC"
asset-class: "lending-token"
protocol: "compound"

1970-01-01 commodity stETH
name: "Lido Staked Ethereum"
asset-class: "staking-derivative"
protocol: "lido"

Tracking Common DeFi Activities

1. Uniswap Liquidity Provision

Adding Liquidity to a Pool

2024-01-15 * "Add liquidity to ETH-USDC Uniswap V3 pool"
Assets:Crypto:Wallet:MetaMask:ETH -5.0 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:USDC -12500 USDC
Assets:DeFi:Uniswap:ETH-USDC-LP 100 UNI-V3-ETH-USDC {250.00 USD}
Expenses:DeFi:Gas:Ethereum 0.01 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.01 ETH {2500.00 USD}

Claiming LP Fees

2024-02-15 * "Claim Uniswap LP fees"
Assets:Crypto:Wallet:MetaMask:ETH 0.2 ETH {2600.00 USD}
Assets:Crypto:Wallet:MetaMask:USDC 300 USDC
Income:DeFi:Yield:Uniswap 820.00 USD
Expenses:DeFi:Gas:Ethereum 0.005 ETH {2600.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.005 ETH {2600.00 USD}

Removing Liquidity with Impermanent Loss

2024-03-15 * "Remove liquidity from ETH-USDC pool"
Assets:DeFi:Uniswap:ETH-USDC-LP -100 UNI-V3-ETH-USDC {250.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH 4.8 ETH {2800.00 USD}
Assets:Crypto:Wallet:MetaMask:USDC 12800 USDC
Expenses:DeFi:ImpermanentLoss 240.00 USD ; IL calculation
Expenses:DeFi:Gas:Ethereum 0.008 ETH {2800.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.008 ETH {2800.00 USD}

2. Compound Protocol Lending

Supplying Assets to Compound

2024-01-20 * "Supply USDC to Compound"
Assets:Crypto:Wallet:MetaMask:USDC -10000 USDC
Assets:DeFi:Compound:cUSDC 500 cUSDC {20.00 USD}
Expenses:DeFi:Gas:Ethereum 0.008 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.008 ETH {2500.00 USD}

Earning Compound Interest

2024-02-20 * "Compound interest accrual"
Assets:DeFi:Compound:cUSDC 5.2 cUSDC {20.50 USD}
Income:DeFi:Yield:Compound 106.60 USD

Claiming COMP Rewards

2024-02-20 * "Claim COMP governance tokens"
Assets:Crypto:Wallet:MetaMask:COMP 12 COMP {85.00 USD}
Income:DeFi:Governance:Tokens 1020.00 USD
Expenses:DeFi:Gas:Ethereum 0.006 ETH {2600.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.006 ETH {2600.00 USD}

3. Aave Protocol Operations

Depositing and Borrowing

; Deposit ETH as collateral
2024-01-25 * "Deposit ETH to Aave"
Assets:Crypto:Wallet:MetaMask:ETH -10 ETH {2500.00 USD}
Assets:DeFi:Aave:aETH 10 aETH {2500.00 USD}
Expenses:DeFi:Gas:Ethereum 0.01 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.01 ETH {2500.00 USD}

; Borrow USDC against ETH collateral
2024-01-25 * "Borrow USDC from Aave"
Assets:Crypto:Wallet:MetaMask:USDC 15000 USDC
Liabilities:DeFi:Aave:DebtUSDC -15000 USDC
Expenses:DeFi:Gas:Ethereum 0.008 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.008 ETH {2500.00 USD}

Repaying Loans with Interest

2024-03-25 * "Repay USDC loan to Aave"
Liabilities:DeFi:Aave:DebtUSDC 15000 USDC
Expenses:DeFi:Interest:Aave 450 USDC ; Interest accrued
Assets:Crypto:Wallet:MetaMask:USDC -15450 USDC
Expenses:DeFi:Gas:Ethereum 0.008 ETH {2700.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.008 ETH {2700.00 USD}

4. Ethereum Staking

Direct Ethereum Staking

2024-01-10 * "Stake ETH on Ethereum 2.0"
Assets:Crypto:Wallet:MetaMask:ETH -32 ETH {2500.00 USD}
Assets:Staking:Ethereum:ETH 32 ETH {2500.00 USD}
Expenses:DeFi:Gas:Ethereum 0.01 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.01 ETH {2500.00 USD}

Staking Rewards

2024-02-10 * "ETH staking rewards"
Assets:Staking:Ethereum:ETH 0.15 ETH {2600.00 USD}
Income:DeFi:Staking:Ethereum 390.00 USD

Liquid Staking with Lido

2024-01-12 * "Stake ETH with Lido"
Assets:Crypto:Wallet:MetaMask:ETH -10 ETH {2500.00 USD}
Assets:Staking:Lido:stETH 10 stETH {2500.00 USD}
Expenses:DeFi:Gas:Ethereum 0.008 ETH {2500.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.008 ETH {2500.00 USD}

Advanced DeFi Scenarios

Yield Farming Strategies

Multi-Protocol Yield Farming

; Step 1: Deposit USDC to Compound
2024-01-30 * "Deposit USDC to Compound for yield farming"
Assets:Crypto:Wallet:MetaMask:USDC -20000 USDC
Assets:DeFi:Compound:cUSDC 1000 cUSDC {20.00 USD}

; Step 2: Borrow DAI against cUSDC
2024-01-30 * "Borrow DAI from Compound"
Assets:Crypto:Wallet:MetaMask:DAI 15000 DAI
Liabilities:DeFi:Compound:DebtDAI -15000 DAI

; Step 3: Provide DAI-USDC liquidity to Uniswap
2024-01-30 * "Add DAI-USDC liquidity for farming"
Assets:Crypto:Wallet:MetaMask:DAI -15000 DAI
Assets:Crypto:Wallet:MetaMask:USDC -5000 USDC ; Additional USDC
Assets:DeFi:Uniswap:DAI-USDC-LP 200 UNI-V3-DAI-USDC {100.00 USD}

Cross-Chain DeFi Operations

Bridging Assets

2024-02-05 * "Bridge ETH to Polygon"
Assets:Crypto:Wallet:MetaMask:ETH -5 ETH {2600.00 USD}
Assets:Crypto:Wallet:Polygon:ETH 5 ETH {2600.00 USD}
Expenses:DeFi:Bridge:Fees 0.01 ETH {2600.00 USD}
Assets:Crypto:Wallet:MetaMask:ETH -0.01 ETH {2600.00 USD}

Flash Loans and Arbitrage

2024-02-10 * "Flash loan arbitrage opportunity"
; Flash loan
Assets:Crypto:Temp:FlashLoan 100000 USDC
Liabilities:DeFi:Aave:FlashLoan -100000 USDC

; Arbitrage trade
Assets:Crypto:Temp:FlashLoan -100000 USDC
Assets:Crypto:Temp:Arbitrage 101500 USDC

; Repay flash loan
Liabilities:DeFi:Aave:FlashLoan 100000 USDC
Assets:Crypto:Temp:Arbitrage -100090 USDC ; Including fees

; Profit
Assets:Crypto:Wallet:MetaMask:USDC 1410 USDC
Income:DeFi:Arbitrage:Profit 1410.00 USD

DeFi Tax Reporting Considerations

Income Recognition

All DeFi rewards are taxable as ordinary income:

; Track all income sources separately
Income:DeFi:Yield:Uniswap ; LP fees
Income:DeFi:Yield:Compound ; Interest earned
Income:DeFi:Staking:Ethereum ; Staking rewards
Income:DeFi:Governance:Tokens ; Governance token airdrops
Income:DeFi:Airdrops ; Protocol airdrops

Expense Deductions

Track deductible expenses:

Expenses:DeFi:Gas:Ethereum          ; Gas fees
Expenses:DeFi:Gas:Polygon ; Layer 2 fees
Expenses:DeFi:Interest:Aave ; Borrowing costs
Expenses:DeFi:ImpermanentLoss ; IL from LP positions

Capital Gains Tracking

Use lot-based accounting for accurate capital gains:

; Different cost basis for same token
Assets:DeFi:Compound:cUSDC 100 cUSDC {20.00 USD} ; Batch 1
Assets:DeFi:Compound:cUSDC 100 cUSDC {21.00 USD} ; Batch 2

Best Practices for DeFi Accounting

1. Real-Time Transaction Recording

  • Record transactions immediately after execution
  • Use transaction hashes for verification
  • Monitor mempool for pending transactions

2. Gas Fee Optimization Tracking

; Track gas optimization strategies
Expenses:DeFi:Gas:Ethereum:Standard ; Standard gas price
Expenses:DeFi:Gas:Ethereum:Fast ; Fast gas price
Expenses:DeFi:Gas:Ethereum:Instant ; Instant gas price

3. Protocol Risk Management

; Track protocol-specific risks
Expenses:DeFi:Risk:SmartContract ; Smart contract failures
Expenses:DeFi:Risk:Liquidation ; Liquidation events
Expenses:DeFi:Risk:Slippage ; Slippage costs

4. Automated Reconciliation

  • Set up automated price feeds
  • Use protocol APIs for balance verification
  • Implement automated transaction imports

5. Documentation Standards

  • Maintain detailed transaction notes
  • Document strategy rationale
  • Keep protocol interaction records

Integration with DeFi Tools

Portfolio Tracking

  • DeBank: DeFi portfolio overview
  • Zapper: Multi-protocol dashboard
  • Zerion: DeFi wallet and tracker

Tax Reporting

  • Koinly: DeFi tax calculations
  • CoinTracker: Multi-protocol support
  • TokenTax: Specialized DeFi reporting

Analytics Platforms

  • DeFi Pulse: Protocol analytics
  • DeFiLlama: TVL and yield tracking
  • APY.vision: Impermanent loss tracking

Conclusion

DeFi accounting complexity shouldn't prevent you from participating in the decentralized finance revolution. With Beancount.io's powerful plain-text accounting system, you can:

  • Track Complex Transactions: Handle multi-protocol interactions seamlessly
  • Ensure Tax Compliance: Proper income recognition and expense tracking
  • Monitor Portfolio Performance: Real-time insights into DeFi positions
  • Manage Risk: Track impermanent loss and protocol risks
  • Scale Operations: From simple staking to complex yield farming strategies

The key to successful DeFi accounting is consistency, accuracy, and proper categorization. Start with basic protocols and gradually expand to more complex strategies as you become comfortable with the accounting patterns.

Ready to master DeFi accounting? Start your Beancount.io journey and take control of your decentralized finance portfolio today.