Code Monkey home page Code Monkey logo

Comments (9)

eprbell avatar eprbell commented on May 30, 2024 1

The issue seems fully resolved: closing. If DaLI and RP2 are useful to you, please consider adding a star to their Github page. Thanks!

from dali-rp2.

eprbell avatar eprbell commented on May 30, 2024

No apology needed, you have helped a lot with all the bug reports and the log data! I'll take a look at this.

from dali-rp2.

eprbell avatar eprbell commented on May 30, 2024

Implemented in the latest version: could you please test?

from dali-rp2.

jameskupke avatar jameskupke commented on May 30, 2024

Tested on 0.4.0 see the Staking Reward transactions, no errors when I run now!

When looking at the spot prices for XTZ, this one stood out:

2021-10-06 15:38:49 +0000
$16.58

Is that right?

from dali-rp2.

eprbell avatar eprbell commented on May 30, 2024

Looks too high, but it could be an artifact of Coinbase returning low-precision values. The spot price is calculated by native_amount/amount: if native_amount is around 1-2c, then the calculation of spot_price can be off by quite a bit. The problem is that Coinbase is returning 2 decimal digit precision for fiat values. However this should have no impact on your taxes, because they are computed based on the reported fiat value. Can you paste here the transaction from the log files: that would help us verify the above explanation.

from dali-rp2.

jameskupke avatar jameskupke commented on May 30, 2024

Sorry, should have clarified, this is using the -s flag on DaLI, as the staking rewards don't have a Spot Price from Coinbase by default.

from dali-rp2.

jameskupke avatar jameskupke commented on May 30, 2024

Here's the log for it:

2022-03-30 21:06:18,490/dali/DEBUG: Self-contained transaction: InTransaction:
  plugin=Coinbase
  unique_id=AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA
  raw_data={"id": "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA", "type": "staking_reward", "status": "completed", "amount": {"amount": "0.000603", "currency": "XTZ"}, "native_amount": {"amount": "0.01", "currency": "USD"}, "description": null, "created_at": "2021-10-06T15:38:49Z", "updated_at": "2021-10-06T15:38:49Z", "resource": "transaction", "resource_path": "/v2/accounts/CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC/transactions/AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA", "instant_exchange": false, "from": {"id": "BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB", "resource": "user", "resource_path": "/v2/users/BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB", "currency": "XTZ"}, "details": {"title": "Tezos reward", "subtitle": "From Coinbase", "header": "Received 0.000603 XTZ ($0.01)", "health": "positive"}, "hide_native_amount": false}
  timestamp=2021-10-06 15:38:49 +0000
  asset=XTZ
  exchange=Coinbase
  holder=((name))
  transaction_type=Staking
  spot_price=16.58374792703150912106135987
  crypto_in=0.000603
  fiat_fee=0
  fiat_in_no_fee=0.01
  fiat_in_with_fee=0.01
  notes=Tezos reward

from dali-rp2.

eprbell avatar eprbell commented on May 30, 2024

The -s option has no effect here because the native amount is > 0, so the spot price is computed as native_amount / amount (0.01/0.000603=16.58). The -s option would take effect when Coinbase incorrectly returns the native_amount as zero. The problem in this case is that Coinbase returns 2-decimal-digit precision fiat numbers, which is very low precision: when the fiat amount is very low (in this case it's $0.01) the low precision can cause the calculation of spot price to be off. E.g. imagine the real fiat amount was $0.0051 and Coinbase rounds it to $0.01: if they had returned a higher precision number ($0.0051), then we would have computed the spot price to be 0.0051/0.000603=8.45. The -s option only takes effect when we don't have a way to get the spot number. For higher fiat values (e.g. $5.07, the problem is lessened, because you have more precision). However since the taxes are calculated using fiat amounts (as they are given by the exchange) the spot price in this case should not affect the final result. For additional context, Coinbase Pro doesn't have this problem: they return high precision fiat numbers and so the issue doesn't present itself there.

Bottom line: i think this is correct, given the (bad) numbers returned by Coinbase when fiat amounts are very low.

from dali-rp2.

eprbell avatar eprbell commented on May 30, 2024

I also should mention that the other option would be to use -s whenever Coinbase doesn't report the price, but this comes with other problems, because in this case the calculation would seem off (amount * spot price != native price). I think the solution we have in place now (described in my previous post) is preferable. But again neither solution is perfect and the cause is Coinbase sending out low-precision numbers.

from dali-rp2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.