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

avatar
(Edited)

You are viewing a single comment's thread:

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



0
0
0.000
5 comments
avatar

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)

0
0
0.000
avatar
(Edited)

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

0
0
0.000
avatar

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!

0
0
0.000
avatar

I see I see... well, this might come in handy:

def getActiveVests(hiveaccess, accountname):
    try:
        account = Account(accountname, steem_instance=hiveaccess)
        allVests = float(account.get("vesting_shares"))
        delegatedVests = float(account.get("delegated_vesting_shares"))
        receivedVests = float(account.get("received_vesting_shares"))
        activeVests = allVests - delegatedVests + receivedVests
    except Exception as inst:
        print("hiveaccess OP ERROR on fetching account active VESTS")
        print(type(inst))
        print(inst.args)
        return False
    else:
        return activeVests

def getVotingPower(hiveaccess, accountname):
    try:
        account = Account(accountname, steem_instance=hiveaccess)
    except Exception as inst:
        print("hiveaccessOP ERROR on get_account")
        print(type(inst))
        print(inst.args)
        return False    
    else:
        votingpower = (account.vp)*100
        if votingpower > 10000:
            votingpower = 10000
        return votingpower

def getVoteWeightForRshares(hiveaccess, username, rshares):
    try:
        vests = getActiveVests(hiveaccess, username)
        power = getVotingPower(hiveaccess, username)
        weight = (rshares+50000000-98*vests)/(2*vests*power)
    except Exception as inst:
        print("hiveaccess OP ERROR on calculating vote-weight for target rshares")
        print(type(inst))
        print(inst.args)
        return False
    else:
        return weight*100

those will require to also from beem.account import Account first

0
0
0.000
avatar

Thank you sir @fraenk, I inadvertently changed my HF7 post into a Python one heh.., I am going to completely re-write the code from the remnants of my old one that got deleted by mistake (very clumsy I know). It keeps my brain whirring around..

0
0
0.000