Skip to content

Commit

Permalink
add token_power_to_token_backed_dollar
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed Jun 29, 2020
1 parent f6ec4a5 commit cd7ea6f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Changelog
* Add BLURT chain
* Remove not used STEEM chains (STEEMZERO and STEEMAPPBASE)
* add Blurt class
* rshares_to_token_backed_dollar, get_token_per_mvest, token_power_to_vests and vests_to_token_power have been added for chain independent usage
* rshares_to_token_backed_dollar, get_token_per_mvest, token_power_to_vests, token_power_to_token_backed_dollar
and vests_to_token_power have been added for chain independent usage
* New beempy command followlist, which can be used on HIVE to receive info about follow lists
* Fix beempy info on Hive
* Use Hive() on beempy when setting default_chain to "hive"
Expand Down
2 changes: 1 addition & 1 deletion beem/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def get_voting_value(self, post_rshares=0, voting_weight=100, voting_power=None,
tp = self.get_token_power()
else:
tp = token_power
voteValue = self.blockchain.rshares_to_token_backed_dollar(tp, post_rshares=post_rshares, voting_power=voting_power * 100, vote_pct=voting_weight * 100, not_broadcasted_vote=not_broadcasted_vote)
voteValue = self.blockchain.token_power_to_token_backed_dollar(tp, post_rshares=post_rshares, voting_power=voting_power * 100, vote_pct=voting_weight * 100, not_broadcasted_vote=not_broadcasted_vote)
return voteValue

def get_voting_value_SBD(self, post_rshares=0, voting_weight=100, voting_power=None, steem_power=None, not_broadcasted_vote=True):
Expand Down
14 changes: 14 additions & 0 deletions beem/blockchaininstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ def rshares_to_token_backed_dollar(self, rshares, not_broadcasted_vote=False, us
"""
raise Exception("not implemented")

def token_power_to_token_backed_dollar(self, token_power, post_rshares=0, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
""" Obtain the resulting Token backed dollar vote value from Token power
:param number hive_power: Token Power
:param int post_rshares: rshares of post which is voted
:param int voting_power: voting power (100% = 10000)
:param int vote_pct: voting percentage (100% = 10000)
:param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
Only impactful for very big votes. Slight modification to the value calculation, as the not_broadcasted
vote rshares decreases the reward pool.
"""
raise Exception("not implemented")

def get_chain_properties(self, use_stored_data=True):
""" Return witness elected chain properties
Expand Down
3 changes: 3 additions & 0 deletions beem/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def hp_to_vests(self, hp, timestamp=None, use_stored_data=True):
def token_power_to_vests(self, token_power, timestamp=None, use_stored_data=True):
return self.hp_to_vests(token_power, timestamp=timestamp, use_stored_data=use_stored_data)

def token_power_to_token_backed_dollar(self, token_power, post_rshares=0, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
return self.hp_to_hbd(token_power, post_rshares=post_rshares, voting_power=voting_power, vote_pct=vote_pct, not_broadcasted_vote=not_broadcasted_vote, use_stored_data=use_stored_data)

def hp_to_hbd(self, hp, post_rshares=0, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
""" Obtain the resulting HBD vote value from Hive power
Expand Down
3 changes: 3 additions & 0 deletions beem/steem.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def token_power_to_vests(self, token_power, timestamp=None, use_stored_data=True
def get_token_per_mvest(self, time_stamp=None, use_stored_data=True):
return self.get_steem_per_mvest(time_stamp=time_stamp, use_stored_data=use_stored_data)

def token_power_to_token_backed_dollar(self, token_power, post_rshares=0, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
return self.sp_to_sbd(token_power, post_rshares=post_rshares, voting_power=voting_power, vote_pct=vote_pct, not_broadcasted_vote=not_broadcasted_vote, use_stored_data=use_stored_data)

def sp_to_sbd(self, sp, post_rshares=0, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
""" Obtain the resulting SBD vote value from Steem power
Expand Down

0 comments on commit cd7ea6f

Please sign in to comment.