RE: RE: HiveStats: Developer's Insight
You are viewing a single comment's thread from:

RE: HiveStats: Developer's Insight

RE: HiveStats: Developer's Insight

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

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now