Legs for asset exchanges out of operating currency

24 views
Skip to first unread message

Eric Altendorf

unread,
Jul 18, 2023, 8:50:50 PM7/18/23
to bean...@googlegroups.com
I'm trying to understand how to construct legs for a transaction where no legs are in the operating currency.  For example, one might exchange USDT (Tether) for BTC.  USDT is sorta like USD but actually not, and its exchange rate does fluctuate.  Such a transaction isn't technically just a purchase from the standpoint of US taxation; it rather is considered:

1) a virtual sale of the USDT for USD, for which capital gains may be owed
2) a virtual purchase of BTC with those USD proceeds, which establishes the cost basis for the BTC

I don't yet have a deep enough intuition on Beancount "cost" and "price" to understand whether this can be accomplished simply with two legs (a USDT leg and a BTC leg) with some "price" magic, or whether I need four legs (two additional USD legs).

How would one record such a transaction?

(For bonus points, some exchanges charge transaction fees in other assets, e.g. USDT.  In that case, the transaction fees are then also an implicit sale for USD, so I need to figure out how to enter that as well.)

thanks,
eric

Martin Blais

unread,
Jul 30, 2023, 12:09:25 PM7/30/23
to bean...@googlegroups.com
On Wed, Jul 19, 2023 at 8:50 AM Eric Altendorf <erical...@gmail.com> wrote:
I'm trying to understand how to construct legs for a transaction where no legs are in the operating currency.  For example, one might exchange USDT (Tether) for BTC.  USDT is sorta like USD but actually not, and its exchange rate does fluctuate.  Such a transaction isn't technically just a purchase from the standpoint of US taxation; it rather is considered:

1) a virtual sale of the USDT for USD, for which capital gains may be owed
2) a virtual purchase of BTC with those USD proceeds, which establishes the cost basis for the BTC

FYI, I don't think we do crypto well in Beancount (yet). I mean, if it works it's incidental, other than participation in threads and some design notes for the future, its author never really sat down to solve those issues.


I don't yet have a deep enough intuition on Beancount "cost" and "price" to understand whether this can be accomplished simply with two legs (a USDT leg and a BTC leg) with some "price" magic, or whether I need four legs (two additional USD legs).

How would one record such a transaction?

Does this work well enough?

plugin "beancount.plugins.sellgains"


2022-01-01 open Equity:Opening-Balances

2022-01-01 open Assets:Coinbase:USDT     USDT

2022-01-01 open Assets:Coinbase:BTC      BTC

2022-01-01 open Income:Coinbase:Pnl      USD



2022-06-01 * "Initial balances"

  Assets:Coinbase:USDT      20000 USDT {1.0000 USD}

  Assets:Coinbase:BTC       10 BTC {10000.00 USD}

  Equity:Opening-Balances


2022-06-01 * "Your transaction"

  Assets:Coinbase:USDT      -10209.18 USDT {} @ 1.023 USD

  Assets:Coinbase:BTC       1 BTC {10444 USD}

  Income:Coinbase:Pnl


The thing is, the capital gains between the USDT and the BTC are mixed together, maybe that's not great.




(For bonus points, some exchanges charge transaction fees in other assets, e.g. USDT.  In that case, the transaction fees are then also an implicit sale for USD, so I need to figure out how to enter that as well.)

thanks,
eric

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAFXPr0tqjUwuu6FPkN5wc9M0v5PrYnXoMDyzao%3DNY2zyiL69pg%40mail.gmail.com.

Eric Altendorf

unread,
Aug 1, 2023, 3:26:50 PM8/1/23
to bean...@googlegroups.com
On Sun, Jul 30, 2023 at 9:09 AM Martin Blais <bl...@furius.ca> wrote:
On Wed, Jul 19, 2023 at 8:50 AM Eric Altendorf <erical...@gmail.com> wrote:
I'm trying to understand how to construct legs for a transaction where no legs are in the operating currency.  For example, one might exchange USDT (Tether) for BTC.  USDT is sorta like USD but actually not, and its exchange rate does fluctuate.  Such a transaction isn't technically just a purchase from the standpoint of US taxation; it rather is considered:

1) a virtual sale of the USDT for USD, for which capital gains may be owed
2) a virtual purchase of BTC with those USD proceeds, which establishes the cost basis for the BTC

FYI, I don't think we do crypto well in Beancount (yet). I mean, if it works it's incidental, other than participation in threads and some design notes for the future, its author never really sat down to solve those issues.


I don't yet have a deep enough intuition on Beancount "cost" and "price" to understand whether this can be accomplished simply with two legs (a USDT leg and a BTC leg) with some "price" magic, or whether I need four legs (two additional USD legs).

How would one record such a transaction?

Does this work well enough?

plugin "beancount.plugins.sellgains"


2022-01-01 open Equity:Opening-Balances

2022-01-01 open Assets:Coinbase:USDT     USDT

2022-01-01 open Assets:Coinbase:BTC      BTC

2022-01-01 open Income:Coinbase:Pnl      USD



2022-06-01 * "Initial balances"

  Assets:Coinbase:USDT      20000 USDT {1.0000 USD}

  Assets:Coinbase:BTC       10 BTC {10000.00 USD}

  Equity:Opening-Balances


2022-06-01 * "Your transaction"

  Assets:Coinbase:USDT      -10209.18 USDT {} @ 1.023 USD

  Assets:Coinbase:BTC       1 BTC {10444 USD}

  Income:Coinbase:Pnl


The thing is, the capital gains between the USDT and the BTC are mixed together, maybe that's not great.

This is basically what I ended up with.  I think it should be good enough.  Thanks!
 




(For bonus points, some exchanges charge transaction fees in other assets, e.g. USDT.  In that case, the transaction fees are then also an implicit sale for USD, so I need to figure out how to enter that as well.)

thanks,
eric

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAFXPr0tqjUwuu6FPkN5wc9M0v5PrYnXoMDyzao%3DNY2zyiL69pg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages