def main(): parser = argparse.ArgumentParser( description='show user balances', epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues' ) parser.add_argument('account', help='account name') parser.add_argument('-c', '--config', default='./common.yml', help='specify custom path for config file') args = parser.parse_args() # parse config with open(args.config, 'r') as ymlfile: conf = yaml.load(ymlfile) golos = Steem(nodes=conf['nodes_old'], no_broadcast=True) a = Account(args.account, steemd_instance=golos) b = a.get_balances() cv = Converter(golos) gp = cv.vests_to_sp(b['total']['GESTS']) for asset in b['savings']: print('{:<15}{:>18.3f}'.format('SAVINGS_{}'.format(asset), b['savings'][asset])) for asset in b['total']: print('{:<15}{:>18.3f}'.format('{}:'.format(asset), b['available'][asset])) print('{:<15}{:>18.3f}'.format('GP:', gp)) print('{:<15}{:>18.3f}'.format('MGESTS:', b['total']['GESTS'] / 1000000))
def calc_rshares(steemd_instance, account, vote_percent): """ Calc current rshares for an account :param Steem steemd_instance: Steem() instance to use when accesing a RPC :param str account: :param float vote_percent: up percent, 0-100 """ a = Account(account, steemd_instance=steemd_instance) cv = Converter(steemd_instance) try: voting_power = get_voting_power(steemd_instance, account) b = a.get_balances() log.info('current voting_power: {}, {:.2f}'.format( account, voting_power)) except Exception as e: log.error('error in calc_rshares(): %s', e) return False # look for detailed code in libraries/chain/steem_evaluator.cpp, search used_power vesting_shares = b['available']['GESTS'] sp = cv.vests_to_sp(vesting_shares) rshares = cv.sp_to_rshares(sp, voting_power=voting_power * 100, vote_pct=vote_percent * 100) return rshares
def main(ctx, no_header, no_sum): """Show multiple users balances.""" if not no_header: print('{:<20} {:>10} {:>11} {:>11}'.format('Account', 'GBG', 'GOLOS', 'GP')) print('--------------------') sum_gbg = float() sum_golos = float() sum_gp = float() for acc in ctx.config['accs']: account = Account(acc) balance = account.get_balances() cv = ctx.helper.converter gp = cv.vests_to_sp(balance['total']['GESTS']) print('{:<20} {:>10} {:>10} {:>10.0f}'.format( acc, balance['total']['GBG'], balance['total']['GOLOS'], gp)) sum_gbg += balance['total']['GBG'] sum_golos += balance['total']['GOLOS'] sum_gp += gp if not no_sum: print('--------------------') print('{:<20} {:>10.3f} {:>10.3f} {:>10.0f}'.format( 'Totals:', sum_gbg, sum_golos, sum_gp))
def main(ctx, to, amount, to_vesting, account): """Claim funds from accumulative balance to tip balance or to vesting.""" if not amount: acc = Account(account) balance = acc.get_balances() amount = balance['accumulative']['GOLOS'] if not to: to = account ctx.helper.claim(to, amount, to_vesting=to_vesting, account=account)
def main(ctx, account): """Calculate profit from vesting holdings.""" props = ctx.helper.get_dynamic_global_properties() acc = Account(account) balance = acc.get_balances() account_vesting = balance['total']['GESTS'] vesting_fund = Amount(props['total_vesting_shares']) daily_emission = ctx.helper.calc_inflation() vesting_share = account_vesting / vesting_fund.amount ctx.log.info(f'{account} vesting share: {vesting_share:.4%}') daily_account_vesting = vesting_share * daily_emission.vesting ctx.log.info(f'{account} daily vesting: {daily_account_vesting:.0f}')
def main(ctx, min_balance, to): """Withdraw from vesting balance of multiple accounts to specified account.""" cv = ctx.helper.converter min_balance = cv.sp_to_vests(min_balance) for account in ctx.config['accs']: acc = Account(account) balance = acc.get_balances() vests = balance['available']['GESTS'] withdraw_amount = vests - min_balance ctx.log.info( 'withdrawing {:.4f} MGESTS ({:.3f} GOLOS): {} -> {}'.format( withdraw_amount / 1000000, cv.vests_to_sp(withdraw_amount), account, to ) ) ctx.helper.set_withdraw_vesting_route(to, percentage=100, account=account, auto_vest=False) ctx.helper.withdraw_vesting(withdraw_amount, account=account)
def main(ctx, account): """Show account balances.""" account = Account(account) balance = account.get_balances() print('{:<15}{:>18.3f}'.format('Claim GOLOS:', balance['accumulative']['GOLOS'])) print('{:<15}{:>18.3f}'.format('Tip GOLOS:', balance['tip']['GOLOS'])) for asset in balance['savings']: print('{:<15}{:>18.3f}'.format('SAVINGS_{}'.format(asset), balance['savings'][asset])) for asset in balance['available']: print('{:<15}{:>18.3f}'.format('{}:'.format(asset), balance['available'][asset])) gp = ctx.helper.converter.vests_to_sp(balance['total']['GESTS']) print('{:<15}{:>18.3f}'.format('GP:', gp)) print('{:<15}{:>18.3f}'.format('MGESTS:', balance['total']['GESTS'] / 1000000))
def main(): parser = argparse.ArgumentParser( description='show multiple users balances', epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues' ) parser.add_argument('-c', '--config', default='./common.yml', help='specify custom path for config file') parser.add_argument('--no-header', action='store_true', help='supress header') parser.add_argument('--no-sum', action='store_true', help='supress summary output') parser.add_argument('-d', '--debug', action='store_true', help='enable debug output'), args = parser.parse_args() # create logger if args.debug == True: log.setLevel(logging.DEBUG) else: log.setLevel(logging.INFO) handler = logging.StreamHandler() formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s") handler.setFormatter(formatter) log.addHandler(handler) # parse config with open(args.config, 'r') as ymlfile: conf = yaml.load(ymlfile) golos = Steem(nodes=conf['nodes_old'], no_broadcast=True) if not args.no_header: print('{:<20} {:>10} {:>11} {:>11}'.format('Account', 'GBG', 'GOLOS', 'GP')) print('--------------------') sum_gbg = float() sum_golos = float() sum_gp = float() for acc in conf['accs']: a = Account(acc, steemd_instance=golos) b = a.get_balances() cv = Converter(golos) gp = cv.vests_to_sp(b['total']['GESTS']) print('{:<20} {:>10} {:>10} {:>10.0f}'.format( acc, b['total']['GBG'], b['total']['GOLOS'], gp)) sum_gbg += b['total']['GBG'] sum_golos += b['total']['GOLOS'] sum_gp += gp if not args.no_sum: print('--------------------') print('{:<20} {:>10.3f} {:>10.3f} {:>10.0f}'.format( 'Totals:', sum_gbg, sum_golos, sum_gp))