Skip to content

Commit

Permalink
Merge 83d16e3 into d647350
Browse files Browse the repository at this point in the history
  • Loading branch information
SmokinCaterpillar committed Sep 2, 2018
2 parents d647350 + 83d16e3 commit 1e00b46
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
- 0.6.8a - 2018-09-02

* Now paying STEEM to investors alongside SBD
* Updated the texts

- 0.6.6a - 2018-08-12

* Removed the hacky NoApiSteem connection
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/bchain/getaccountdata_test.py
Expand Up @@ -20,13 +20,15 @@ def test_shares_query(steem):

def test_payouts(steem):
now_24 = pd.datetime.utcnow() + pd.Timedelta(days=1)
result = tpac.get_delegate_payouts('trufflepig', steem,
result, result_steem = tpac.get_delegate_payouts('trufflepig', steem,
now_24,
1,
0.5)

assert 'smcaterpillar' in result
assert 'trufflepig' not in result
assert 'smcaterpillar' in result_steem
assert 'trufflepig' not in result_steem


def test_bidbot_test(steem):
Expand Down
2 changes: 1 addition & 1 deletion trufflepig/__init__.py
@@ -1 +1 @@
__version__ = '0.6.6a'
__version__ = '0.6.7a'
12 changes: 9 additions & 3 deletions trufflepig/bchain/getaccountdata.py
Expand Up @@ -188,6 +188,8 @@ def get_delegate_payouts(account, steem, current_datetime,
-------
dict of float:
SBD to pay to each investor
dict of float:
STEEM to pay to each investor
"""
assert 0 < investor_share <= 1
Expand All @@ -203,15 +205,19 @@ def get_delegate_payouts(account, steem, current_datetime,
acc = none_error_retry(Account,
errors=(Exception,))(account, steem)

pending = acc.balances['rewards']['SBD']
pending_sbd = acc.balances['rewards']['SBD']
pending_steem = acc.balances['rewards']['STEEM']
vests = acc.balances['total']['VESTS']
filtered_vests_by[account] = vests

total_vests = sum(filtered_vests_by.values())
payouts = {delegator: np.round(vests / total_vests * investor_share * pending, decimals=3)
sbd_payouts = {delegator: np.round(vests / total_vests * investor_share * pending_sbd, decimals=3)
for delegator, vests in filtered_vests_by.items() if delegator != account}

steem_payouts = {delegator: np.round(vests / total_vests * investor_share * pending_steem, decimals=3)
for delegator, vests in filtered_vests_by.items() if delegator != account}

return payouts
return sbd_payouts, steem_payouts


def get_upvote_payments(account, steem, min_datetime, max_datetime,
Expand Down
32 changes: 26 additions & 6 deletions trufflepig/bchain/paydelegates.py
Expand Up @@ -37,13 +37,17 @@ def pay_delegates(account, steem,
"""
logger.info('Computing payouts for delegates!')
payouts = error_retry(tpga.get_delegate_payouts)(account, steem,
current_datetime=current_datetime,
min_days=min_days,
investor_share=investor_share)
logger.info('Found the following payouts:\n{}'.format(payouts))
sbd_payouts, steem_payouts = error_retry(tpga.get_delegate_payouts)(
account, steem,
current_datetime=current_datetime,
min_days=min_days,
investor_share=investor_share
)

claim_all_reward_balance(steem, account)
for delegator, payout in payouts.items():

logger.info('Found the following SBD payouts:\n{}'.format(sbd_payouts))
for delegator, payout in sbd_payouts.items():
try:
if payout:
logger.info('Paying {} SBD to {}'.format(delegator, payout))
Expand All @@ -58,6 +62,22 @@ def pay_delegates(account, steem,
'Reconnecting...'.format(payout, delegator))
steem.reconnect()

logger.info('Found the following STEEM payouts:\n{}'.format(steem_payouts))
for delegator, payout in steem_payouts.items():
try:
if payout:
logger.info('Paying {} STEEM to {}'.format(delegator, payout))
error_retry(steem.commit.transfer,
errors=(RPCError, TypeError))(to=delegator,
amount=payout,
asset='STEEM',
memo=memo,
account=account)
except Exception as e:
logger.exception('Could not pay {} STEEM to {}! '
'Reconnecting...'.format(payout, delegator))
steem.reconnect()


def claim_all_reward_balance(steem, account):
"""Helper funtion to claim rewards because of bug in Steem"""
Expand Down
6 changes: 3 additions & 3 deletions trufflepig/bchain/posts.py
Expand Up @@ -128,7 +128,7 @@ def topN_post(topN_authors, topN_permalinks, topN_titles, topN_filtered_bodies,
## Delegate and Invest in the Bot
If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation.
If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD and STEEM income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation.
Click on one of the following links to delegate **[2]({sp2}), [5]({sp5}), [10]({sp10}), [20]({sp20}), [50]({sp50}), [100]({sp100}), [200]({sp200}), [500]({sp500}), [1000]({sp1000}), [2000]({sp2000}),** or even **[5000 Steem Power]({sp5000})**. Thank You!
Expand Down Expand Up @@ -389,7 +389,7 @@ def weekly_update(current_datetime,
## Delegate and Invest in the Bot
If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation.
If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD and STEEM income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation.
Big thank you to the people who already delegated Power to me: {delegator_list}!
Expand Down Expand Up @@ -528,7 +528,7 @@ def top_trending_post(topN_authors, topN_permalinks, topN_titles, topN_filtered_
## Delegate and Invest in the Bot
If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts in my other top list. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation.
If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts in my other top list. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD and STEEM income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation.
Click on one of the following links to delegate **[2]({sp2}), [5]({sp5}), [10]({sp10}), [20]({sp20}), [50]({sp50}), [100]({sp100}), [200]({sp200}), [500]({sp500}), [1000]({sp1000}), [2000]({sp2000}),** or even **[5000 Steem Power]({sp5000})**. Thank You!
Expand Down

0 comments on commit 1e00b46

Please sign in to comment.