Skip to content

Potential bug with cost basis during crypto-style transfers #2575

@ag-eitilt

Description

@ag-eitilt

I don't know if this is me just not understanding the syntax/bookkeeping, or if there's an actual bug here, so I figured I'd submit a report as a means of asking for either a fix, or for a clarification in the documentation.

I'm trying to mark gas fees as (small) capital gains events; this may or may not be necessary for direct transfers like I have in the example (the IRS has conflicting FAQ entries), but either way it would be proper for payments or swaps. The cost basis is indeed calculated correctly, and although I stripped the lots off of the minimum reproducer below, those are also being tracked correctly. However, breaking off a part of the lot to pay for the gas fees doesn't seem to be working:

$ cat tfer.journal
03-06 buy
    assets:custodial                            1.000000 ETH
    assets:custodial                      -$1,980.78

03-09 transfer
    assets:custodial                           -1.000000 ETH
    assets:cold wallet                          0.999601 ETH
    expenses:fees:trading                       0.000399 ETH @ $1,992.36
    income:gains
$ hledger --version
hledger 1.99.1, freebsd-x86_64
$ hledger reg -f tfer.journal
2026-03-06 buy                  assets:custodial      1.000000 ETH  1.000000 ETH
                                assets:custodial        $-1,980.78    $-1,980.78
                                                                    1.000000 ETH
2026-03-09 transfer             assets:custodial     -1.000000 ETH    $-1,980.78
                                assets:cold wallet    0.999601 ETH    $-1,980.78
                                                                    0.999601 ETH
                                ex:fees:trading       0.000399 ETH    $-1,980.78
                                                                    1.000000 ETH
                                income:gains                $-0.79    $-1,981.57
                                                      0.000399 ETH  1.000399 ETH

The $0.79 difference in basis is showing up right where I'd expect it to, but a second copy of the fee is also being added to the same inferred posting. I know the gain is effectively appearing "magically" so far as the register goes, and that for proper double-entry bookkeeping there'd probably be an equity posting for the basis itself that would balance it, but (A) I've not put a lot of time into figuring out how to represent that when hledger seems like it'll do that for me via the cost syntax, and (B) even if I did I wouldn't expect that to require additional entries of the non-USD commodity. Am I doing something completely wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.investingRelated to investments, lots, capital gains, etc.journalThe journal file format, and its features.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions