-
Notifications
You must be signed in to change notification settings - Fork 3
/
withdraw_vesting.py
executable file
·48 lines (37 loc) · 1.21 KB
/
withdraw_vesting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import click
from golos.account import Account
from golosscripts.decorators import common_options, helper
@click.command()
@common_options
@helper
@click.option(
'-m',
'--min-balance',
default=5,
type=float,
help='minimal Golos Power balance to keep on withdrawing account (default: 5)',
)
@click.option('-t', '--to', type=str, help='destination account (optional)')
@click.argument('account')
@click.pass_context
def main(ctx, min_balance, to, account):
"""Withdraw from vesting balance of one account to specified account."""
cv = ctx.helper.converter
min_balance = cv.sp_to_vests(min_balance)
acc = Account(account)
balance = acc.get_balances()
vests = balance['available']['GESTS']
withdraw_amount = vests - min_balance
if to:
ctx.helper.set_withdraw_vesting_route(to, percentage=100, account=account, auto_vest=False)
else:
to = account
ctx.log.info(
'withdrawing {:.4f} MGESTS ({:.3f} GOLOS): {} -> {}'.format(
withdraw_amount / 1000000, cv.vests_to_sp(withdraw_amount), account, to
)
)
ctx.helper.withdraw_vesting(withdraw_amount, account=account)
if __name__ == '__main__':
main()