You are viewing a single comment's thread from:

RE: Calculating the USD Vote Value for a Hive account

in HiveDevs2 years ago (edited)

By the way, I couldn't mention it yesterday but I made an adaptation to your code and got a different result despite using the formula? It's strange. I'll share with you:

I'm not really sure why but it's much more far off than yours. Maybe I did something wrong?

image.png


I edited my code to divide by / 10000 because why not... And it's much more similar lmao. It actually matches PeakD right now but it didn't yesterday. Strange!

image.png

image.png

image.png


FIXED

Lmao I hadn't noticed I had a * 10000 instead of a * weight / 10000. I double and triple checked last night but it was too late hahah, guess I was half asleep.

I checked again today and saw the * 10000 first time around. I added the weight parameter and divided by 10k instead and it seems to work well :)

It's already updated on the gist

Sort:  

Glad you have it solved! By the way how did you come up with the idea to get the hbd_median_price by dividing the base by quote (especially that they have different units to them—one is HBD and the other HIVE)? This is not specified in the formula in the documentation?

It's actually a very dumb reason hahahahah

image.png

As you can see, base is the price, and the other one, for some reason, is always 1. So in my head, x/1 = x, and I needed x, but didn't want to just leave the other one without using it when it might be important? So I justified it as "ahhh that's probably what you divide it by!". But I now realize that doesn't make much sense hahah.

I don't honestly know what base and quote mean. :) I just know it works, whether by coincidence or intention. Maybe one day it will not be 1 anymore and the script won't work anymore!

Lol that's too convoluted as for my taste XD I'll just leave it as base, let's hope nothing breaks :D

BTW what kind of an app are you building there?! I am interested! Given you can share some details, of course!

just a react frontend for hive :) but very slowly cuz I have work and this is unpaid labor!

I wanna make a static, simple, open source frontend, cuz we don't have one yet on hive

Hey, I think I got it XD If you multiply by base you will get the vote value in USD, and if you multiply by quote you'll get the vote value in HIVE. So:

rshares / recent_claims * reward_balance * base

gives the USD value. However, the one below gives you the HIVE values:

rshares / recent_claims * reward_balance * quote

The quote is always 1.000 so in theory you could just omit that, but who knows if it will or will not change in the future...

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment !STOP below