cexplorer / cexplorer.io

website features, implementations, docs
23 stars 15 forks source link

Conversion rates ($ per Ada) are performed using exchange rate that is out by 1 full epoch #24

Closed rickmccabe2 closed 1 year ago

rickmccabe2 commented 1 year ago

Describe the bug On the Stake Address > Rewards page, the exchange rate to convert from Ada rewards to Dollars is performed using the Ada value at the end of the previous epoch (or start of current epoch if you wish to look at it that way)

To Reproduce Steps to reproduce the behavior:

  1. Go to 'this random stake address record' (Not my stake address for Privacy - picked a random one)
  2. Look at record for epoch 370
  3. Reward is 2.19Ada
  4. Conversion to Dollars is $0.77 (rounded to $0.8)
  5. This equates to a conversion rate of $0.35 per Ada
  6. At the end of epoch 370 the conversion rate was approx $0.39 per Ada (CoinMarketCap data)
  7. At the end of epoch 369 the conversion rate was approx $0.35 per Ada (CoinMarketCap data)
  8. Also click on the tax screen and you can see the Epoch End Time is out by a factor of 1 epoch. Epoch 370 End Time = 2022-10-22 21:43:10

Expected behavior Exchange rate ($ per Ada) for any epoch should be the rate at the end of the epoch, i.e. the date the rewards are paid.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

cexplorer commented 1 year ago

Hey, I mean, it is okay, look with me:

Epoch 370 2022-10-17 21:48:28 - 2022-10-22 21:43:10

When I open cmc ( https://coinmarketcap.com/currencies/cardano/historical-data/ ) and take a look on

close 22-10, it says $0.3514

we have for epoch 370 in DB 0.35336693588606 (we are using coinpaprika)

So, 2,19 * 0,3533 = 0,773727 (rounded to $0,8)

So its look okay, or?

==

UPDATE: I probably know reason from this confusion. DB-sync is saving into db rewards "earlier", before they are really earned - ie actually rewards from 371 are not available, they will be available in 372 (epoch+2).

What we can do there, we are actually in tax page working with earned epochs, not with spent epoch and we can have option, which one user want use - would that help?

rickmccabe2 commented 1 year ago

Ah yes you're right - it is more of a problem of what the consuming user wants to see rather than a bug.

From my point of view I would need to see the the value of the rewards at the time of "payment" rather than at the value at the end of the epoch. I think your suggestion of allowing the user to have the option is perfect. I must admin, that I've only just realised, from your answer, that the end of epoch date is not the same as the reward date - I assumed they were the same until now!

So currently the tax page shows ADAUSD value and USD value for the end of the epoch - I guess you're suggesting the user could select to use end of epoch date or reward date for these values - that would work well.

Thanks

cexplorer commented 1 year ago

Okay thanks. Give us some time and we will improve this :)

cexplorer commented 1 year ago

@rickmccabe2 both options are available now :)