serenita-org / ethstaker.tax

The easiest way to determine your Ethereum staking income!
https://ethstaker.tax
MIT License
22 stars 7 forks source link

Decimal precision #22

Open aliask opened 1 year ago

aliask commented 1 year ago

Recently it seems like the decimal precision has dropped from 9 places to 6. Is it possible to revert this behaviour back to the increased precision?

eth2353 commented 1 year ago

I did reduce the precision because the rewards table on the website was getting a bit full and there were some issues caused by the floats, where sometimes you'd see a number like 0.0032141000000001 . I figured 6 decimal places would be more than enough.

Would it be sufficient for your usecase if the exported CSV contained the full precision (and the website still only showed the 6 decimal places)?

aliask commented 1 year ago

I had been using the info in an attempt to accurately track the actual ETH reward, but I guess even 9 decimal places doesn't cut it for that purpose.

Ideally accounting software like this would use the Decimal class so that the values do not suffer from any float rounding problems on the backend, and you can choose however many decimal places to display on the web UI.

eth2353 commented 1 year ago

If you want to be completely accurate you'd need to track it in Wei, since validators can receive as little as 1 Wei as execution layer rewards (consensus layer is limited to units of Gwei).

The numbers are stored in the database with sufficient precision at the moment:

So the indexing currently tracks every single Wei correctly.

Presenting the data on the website however is not that precise currently and would require some slightly bigger changes:

I'm not sure if it is worth making those changes to gain that tiny bit of extra precision. For one validator I think the difference would add up to something you'd probably round off on a tax form anyway.

EvilJordan commented 1 year ago

You should convert the floats to a hexidecimal representation of a BigNumber, then you won't have any storage issues at all.

What you will have is some function to convert to/from on the view/import/export layer.