You are viewing a single comment's thread from:

RE: HiveFest 7, It's Over - My Take

in #hivefest2 years ago (edited)

to avoid a comment going under the dust level and paying ZERO, what is the minimum amount of vests it requires?

oh... maybe I can help with that!

from beem import Steem
from beem.nodelist import NodeList
from beem.amount import Amount

nodelist = NodeList()
nodelist.update_nodes()
hivenodes = nodelist.get_nodes(hive=True)
hiveaccess = Steem(node=hivenodes, no_broadcast=True)

def getRsharesForRewardValue(hiveaccess, targetreward):
    try:
        rewardsfund = hiveaccess.get_reward_funds()
        rewards = float(Amount(rewardsfund["reward_balance"]).amount)/float(rewardsfund["recent_claims"])
        medianhistory = hiveaccess.get_current_median_history()
        price = float(Amount(medianhistory["base"]).amount)/float(Amount(medianhistory["quote"]).amount)
        tclaims = int(targetreward/(rewards*price))
        rshares = int(tclaims)
    except Exception as inst:
        print("hiveaccess OP ERROR on calculating rshares for target reward value")
        print(type(inst))
        print(inst.args)
        return False
    else:
        return rshares

def getVestsRequiredForReward(hiveaccess, reward):
    try:
        power = 100
        weight = 100
        rshares = getRsharesForRewardValue(hiveaccess, reward)
        vests = (rshares+50000000)/(2*(49+(power*weight)))
    except Exception as inst:
        print("hiveaccess OP ERROR on calculating vests required for target reward")
        print(type(inst))
        print(inst.args)
        return False
    else:
        return vests

def vestsToHP(hiveaccess, vests):
    try:
        HP = hiveaccess.vests_to_sp(vests)
    except Exception as inst:
        print("hiveaccess OP ERROR on converting vests")
        print(type(inst))
        print(inst.args)
        return False
    else:
        return HP

vests = getVestsRequiredForReward(hiveaccess, 0.02)
HP = vestsToHP(hiveaccess, vests)

print("To generate a dust-save reward of $0.02 with a 100% upvote you will need:")
print(str(int(vests))+" Vests ("+str(round(HP, 3))+" HP)")

cheers

Sort:  

Thanks @fraenk, can I go a little farther and ask for a sample call line to these? I am not an experienced Python coder and can get by with prodding. I can see getVestsRequiredForReward calls getRsharesForRewardValue so the call would be something like:

vests = getVestsRequiredForReward(whatgoeshere, andhere)

hehehe... here I am just wanting to make a smart-ass-comment on your lingering question by copy pasting some snippets from @dustbunny's library... but sure, let's go farther ;)

I'll edit the code above so you can just copy paste it into a dustsavevest.py file and run it... still assuming you have beem already installed!

It will output something like this:

To generate a dust-save reward of $0.02 with a 100% upvote you will need:
1388977 Vests (766.581 HP)

If you just want to calculate the %-power a specific account needs to make to be voting dustsave... I do have some more handy code snippets up my sleve

I am using BEEM, it was quite hard going at first but have got to grips with it now.

Incidentally the reason I need this is to combat a certain blockchain parasite who keeps negating my @dustbunny votes hehe..., that's perfect edited above. I can work with that!

Loading...