Crypto Swaps and balancing

46 views
Skip to first unread message

Brandon Anderson

unread,
May 7, 2022, 7:10:44 AM5/7/22
to Beancount
So I started playing around with beancount again and quickly ran into a `Transaction does not balance: (-0.0000000000000000000000001 USD)` when recording crypto swaps in the way I would have thought they should be recorded. I have attached a minimum example file showing the transaction that fails to balance. At its core, I purchase crypto A from an exchange in the base currency of USD and then attempt to swap crypto A for crypto B, paying the transaction fees in crypto A, and the transaction won't balance. What would be the proper way to do this? Note in this example that Crypto A and Crypto B have different decimal values (8 vs. 14).

```
2022-05-07 * "Dex Exchange" "Exchange Crypto A for Crypto B"
    Assets:Crypto:Ledger                      257.12987453124598 CRYPTO_B {}
    Expenses:Crypto:Transaction-Fees            0.00000895 CRYPTO_A { 216.43 USD }
    Expenses:Crypto:Exchange-Fees               0.015 CRYPTO_A { 216.43 USD }
    Assets:Crypto:Ledger                       -1.25000895 CRYPTO_A { 216.43 USD }
```
test.beancount

Martin Michlmayr

unread,
May 7, 2022, 7:20:22 AM5/7/22
to bean...@googlegroups.com
* Brandon Anderson <brando...@gmail.com> [2022-05-07 04:10]:
> So I started playing around with beancount again and quickly ran
> into a `Transaction does not balance: (-0.0000000000000000000000001
> USD)`

I use this:

option "inferred_tolerance_default" "EUR:0.004"
option "inferred_tolerance_default" "GBP:0.004"
option "inferred_tolerance_default" "USD:0.004"

--
Martin Michlmayr
https://www.cyrius.com/

Brandon Anderson

unread,
May 7, 2022, 8:57:02 PM5/7/22
to Beancount
Sorry thought I replied to this,
Thanks that was exactly what I needed!

Reply all
Reply to author
Forward
0 new messages