Loading...
Loading...
Export trade history and tax calculations in formats compatible with Koinly, CoinTracker, CoinLedger, TokenTax, and IRS Form 8949
npx skill4agent add agiprolabs/claude-trading-skills crypto-tax-exportDisclaimer: This skill provides data formatting and calculation tools only. It does not constitute tax advice. Consult a qualified tax professional for guidance on reporting cryptocurrency transactions. Tax laws vary by jurisdiction and change frequently.
helius-apibirdeye-apicoingecko-api| Capability | Description |
|---|---|
| Multi-format CSV export | Koinly, CoinTracker, CoinLedger, TokenTax, TurboTax, TaxAct |
| IRS Form 8949 generation | Part I (short-term) and Part II (long-term), columns a through h |
| Solana tx classification | Jupiter swaps, multi-hop routes, LP deposits/withdrawals, staking, airdrops |
| Cost basis methods | FIFO, LIFO, HIFO, Specific Identification |
| Reconciliation | Match on-chain history against internal trade journal |
| Failed tx handling | Identify and exclude failed transactions (no taxable event) |
Date,Sent Amount,Sent Currency,Received Amount,Received Currency,Fee Amount,Fee Currency,Net Worth Amount,Net Worth Currency,Label,Description,TxHashswapstakingairdropliquidity_inliquidity_outcostgiftlostDate,Received Quantity,Received Currency,Sent Quantity,Sent Currency,Fee Amount,Fee Currency,Tagtradestaking_rewardairdroplp_depositlp_withdrawalDate (UTC),Type,Received Currency,Received Amount,Sent Currency,Sent Amount,Fee Currency,Fee Amount,Exchange/WalletTradeIncomeGift ReceivedMiningStaking RewardAirdropType,BuyAmount,BuyCurrency,SellAmount,SellCurrency,FeeAmount,FeeCurrency,Exchange,Group,Comment,DateTradeIncomeStakingAirdropSpendingDescription of Property,Date Acquired,Date Sold,Proceeds,Cost Basis,Gain or Losstx = {
"type": "swap",
"sent": {"amount": 1.5, "currency": "SOL", "usd_value": 225.00},
"received": {"amount": 50000, "currency": "BONK", "usd_value": 224.50},
"fee": {"amount": 0.000005, "currency": "SOL", "usd_value": 0.00075},
"timestamp": "2025-03-15T14:30:00Z",
"tx_hash": "5abc...def",
}from enum import Enum
class CostBasisMethod(Enum):
FIFO = "fifo" # First In, First Out (IRS default)
LIFO = "lifo" # Last In, First Out
HIFO = "hifo" # Highest In, First Out (minimizes gains)
SPEC_ID = "spec_id" # Specific Identification (requires lot tracking)
def compute_gain(
proceeds: float,
cost_basis: float,
adjustments: float = 0.0,
) -> float:
"""Compute gain or loss for Form 8949 column (h)."""
return proceeds - cost_basis + adjustmentsdef reconcile(
journal_trades: list[dict],
onchain_txs: list[dict],
tolerance: float = 0.001,
) -> dict:
"""Match journal entries to on-chain transactions.
Args:
journal_trades: Internal trade records with tx_hash field.
onchain_txs: Parsed on-chain transactions.
tolerance: Relative tolerance for amount matching.
Returns:
Dict with matched, missing_onchain, missing_journal,
mismatched lists.
"""
onchain_by_hash = {tx["tx_hash"]: tx for tx in onchain_txs}
matched, missing_onchain, missing_journal, mismatched = [], [], [], []
for trade in journal_trades:
tx = onchain_by_hash.pop(trade.get("tx_hash", ""), None)
if tx is None:
missing_onchain.append(trade)
elif abs(trade["amount"] - tx["amount"]) / max(tx["amount"], 1e-9) > tolerance:
mismatched.append({"journal": trade, "onchain": tx})
else:
matched.append({"journal": trade, "onchain": tx})
missing_journal = list(onchain_by_hash.values())
return {
"matched": matched,
"missing_onchain": missing_onchain,
"missing_journal": missing_journal,
"mismatched": mismatched,
"summary": {
"total_journal": len(journal_trades),
"total_onchain": len(onchain_txs),
"matched": len(matched),
"missing_onchain": len(missing_onchain),
"missing_journal": len(missing_journal),
"mismatched": len(mismatched),
},
}from scripts.tax_exporter import (
generate_demo_trades,
export_koinly_csv,
export_form_8949_csv,
)
# Generate sample trades
trades = generate_demo_trades()
# Export to Koinly format
export_koinly_csv(trades, "koinly_import.csv")
# Export to Form 8949 format
export_form_8949_csv(trades, "form_8949.csv")python scripts/tax_exporter.py --demo| File | Description |
|---|---|
| Export format specs, Form 8949 mapping, Solana tx classification, reconciliation methodology |
| Demo script: generate trades, export to Koinly CSV and Form 8949 CSV, show format differences |
helius-apibirdeye-apicoingecko-apisolana-onchaintrade-journal