You are viewing a single comment's thread from:

RE: HiveStats: Developer's Insight

in LeoFinance3 years ago (edited)

I have gotten the majority of the values below. I have not found what the 'weight' is .. it is not actually found on this page, however is used in the formula.

This one is estimated upvote/vote value calculation. Weight is voting mana ratio (out of 10000, not percentage), so it calculates user's vote value rather than post's. Hope it is clear! Don't hesitate to ask further if not.

i have not found reverse_auction_% yet.

It is probably an old way of calculating it, I don't know about it.

my understanding is, I need to total the value of all the votes on the post.. as the post total value affects how much you get depending upon when you voted.

so estimating it implies guessing how much the post value would be

Exactly!

Rest about curation is not correct, I'll provide the details.

it says oldest item in history. it is actually the newest item in history.

I did also struggle with several wording there, one of was that. What it means is, data it returns is sorted oldest to newest. So, imagine getting last 50 history of an account. The array it returns is sorted from the oldest, so if the latest operation was with index 24424, that would be the last index of the array. So, it is reverse than what you expect. This isn't true for HiveEngine for example, if you ever go into that route!


Now, about curation rewards. I'll provide examples as pseudocode:

You'll need these methods and fields:

  • get_current_median_history_price -> base // median price of Hive/HBD
  • get_reward_fund-> percent_curation_reward // curation reward ratio (50/50 as of now)
  • get_content -> pending_payout_value, max_accepted_payout, total_vote_weight, active_votes

You do need to calculate post rewards first:

function post_reward(median_price, pending_payout_value, max_accepted_payout) {
  // We do only use max allowed value (read about min function if this looks nonsense)
  // I don't know where max_accepted_payout is used, it could be declined rewards.
  let payout = min(pending_payout_value, max_accepted_payout);

  // We do convert Hive to HBD as pending_payout_value is Hive.
  return payout / median_price;
}

Next, you need to calculate how much of this is curation reward:

function curation_reward(post_reward, percent_curation_rewards) {
  // percent_curation_rewards is a ratio. I'm not native and don't know
  // how I can describe it, but it is like 24/100, but scaled up to 10000
  // so like 2400/10000. percent_curation_rewards is the 2400 part of it
  // They do use 10k instead of normalized value, probably for precision reasons.
  if (post_reward == 0) {
    // If we don't this, it could return NaN in rare cases.
    return 0;
  }

  // 1000 is denominator here, used for precision calc.
  let hive = post_reward * 1000;
  // we do multiply high precision high value by percent, later floor it to cut out
  // possible unnecessary precision bits. later divide it by 10000. I described
  // reason at top.
  let curation_reward = floor(hive * percent_curation_rewards) / 10000;

  // As we don't need to make calculations over this, we can divide it back.
  return curation_reward / 1000;  
}

Now, we can calculate the vote reward:

function vote_reward(curation_reward, total_vote_weight, weight) {
  // Self explanatory I believe
  let ratio = curation_reward * 1000 * weight / total_vote_weight;
  // Making sure negative values result in 0 (due to downvotes). Then floor and denom
  // as like above.
  return floor(max(0, ratio) / 1000);
}

Ta da, now you have curation reward as Hive/HP. You can combine these into one function and reduce the amount of denom operations you do. So it could be like this:

function curation_reward(
  median_price,
  pending_payout_value,
  max_accepted_payout
  percent_curation_rewards,
  total_vote_weight
  weight
) {
  let payout = min(pending_payout_value, max_accepted_payout);
  let post_reward = payout / median_price;

  if (post_reward == 0) {
    return 0;
  }

  let hive = post_reward * 1000;
  let curation_reward = floor(hive * percent_curation_rewards) / 10000;

  let ratio = curation_reward * weight / total_vote_weight;
  return floor(max(0, ratio) / 1000);
}

I didn't show how weight is calculated, about that: Well, you can find it by filtering active_votes. It has a limitation though, active_votes don't show more than 1000 votes. I didn't solve it in HiveStats as it is quite rare. But I do believe that a workaround should be possible, like calculating weight by yourself using shares or using another method like: https://developers.hive.io/apidefinitions/#database_api.list_votes

Sort:  

Thank you! So wonderful!

The following, is one issue. and a question about that. and reason why I care about it.

I did also struggle with several wording there, one of was that. What it means is, data it returns is sorted oldest to newest. So, imagine getting last 50 history of an account. The array it returns is sorted from the oldest, so if the latest operation was with index 24424, that would be the last index of the array. So, it is reverse than what you expect. This isn't true for HiveEngine for example, if you ever go into that route!

I understand this, the array is reversed, what is not clear is there is no other way to get to the newest item.. there is no way to have it ordered newest first..

so as you read thru it .. very unclear how to achieve this .. and given your struggle as well.. is there someone who we can bring this up with? because I actually find it super annoying to have things so unclear.

I have just stepped away from linux because I found it 'less than' open source in its actual implementation. so here I am curious the level of feedback we could get on such an issue. on linux they care not what the users think and projects, like gnome, often corporate entities.. and have just become bad if you ask a search engine .. this bit made me laugh from a comment..

  • Gnome really looks like it has been designed for and tested against mentally challenged people. It's infuriating, most of its utilities lack menus and basic options/settings, to the point where having a GUI is more of an impediment rathen than being something useful.

I am very worried by the fact that Ubuntu is reverting back to Gnome.

source

this is what happens if we don't mind our source !

can we help make such improvements? are there ways to get in touch that you are aware of ? i feel like discord is the way.. but I haven't really seen any obvious 'avenue' inviting me there .. or i just missed it. (aside from you, of course)

it will take me a moment to digest the code . thanks for taking the time. wanted to push that out of my thoughts before I continued to think on this.

I understand this, the array is reversed, what is not clear is there is no other way to get to the newest item.. there is no way to have it ordered newest first..

It is only reverse in returned data, not whole history. So, it contains newest, it isn't the first, it is the last element. So, imagine getting limit = 1000, index = -1. The newest is result[result.length - 1]

I have just stepped away from linux

Haha, I don't like linux either. I don't use it unless I have to.

can we help make such improvements? are there ways to get in touch that you are aware of ?

You can open an issue if you think you found a bug:
https://gitlab.syncad.com/hive

As for discord, there are two community discords you can hang around!

HiveDevs discord server:
https://discord.gg/JAEDPH3HVs
Hive (more general) discord server:
https://discord.gg/GUB7BCrE3x

I do know there are other chatting applications people use but I don't use them so I don't know specific details.

thanks for the links to the devs. i think i will log in and see the conversations.

Haha, I don't like linux either. I don't use it unless I have to.

i use netBSD and freeBSD. what is your os of choice?

It is only reverse in returned data, not whole history. So, it contains newest, it isn't the first, it is the last element. So, imagine getting limit = 1000, index = -1. The newest is result[result.length - 1]

i get it, but i don't get why . just seems backwards somehow. not something i really want to pursue.

thanks for the links to the HiveDevs chat. I will enjoy listening in. and you said you found answers in the chat logs.

i use netBSD and freeBSD. what is your os of choice?

Haha, Wind👀ws, nothing special there

i get it, but i don't get why

Well I don't really know. Probably due to how it is filtered (it is rocksdb as far as I know). So, reversing it is twice the cost, so they don't I assume.

Hello again. I have been working on this again, and found it very useful. Thank you. I was able to take your pseudo code and basically copy-pasta with little translation necessary.

At least, I think I have it working, there is one key element I don't have an answer for..

database_api.list_votes is the best I can find to get my current votes.. but this api doesn't have an option to reverse the search and get the most recent votes by an account.

any thoughts or another way that can give me the answers I am after?

my other choice is to go entirely thru the list, until I get to recent times.. and record a link in the vicinity that I can use later to avoid redundantly recalling the entire history.

Hey, happy to hear that it works as you want it!

database_api.list_votes is the best I can find to get my current votes

I didn't use it much, just experimented with it. So, instead of getting account's upvotes, getting post's upvotes the way to go I believe. So, you have to call it for each post. get_content already has active_votes field, so you can use that instead. Only difference is, active_votes field is limited at 1000 votes while you can query more with list_votes method.

Loading...