This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
functions.py
81 lines (68 loc) · 2.98 KB
/
functions.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import random
from questionary import select
from loguru import logger
from core import *
from settings import *
async def get_pair() -> str:
result = await select(
message="Выберите пару: ",
instruction='(используйте стрелочки для навигации)',
choices=['ZETA/BNB.BSC', 'ZETA/ETH.ETH', 'ZETA/BTC.BTC', 'Рандомная'],
qmark="\n❓ ",
pointer="👉 "
).ask_async()
if result == 'Рандомная':
return random.choice(['ZETA/BNB.BSC', 'ZETA/ETH.ETH', 'ZETA/BTC.BTC'])
else:
return result
async def work(zetachain: Zetachain) -> None:
if USE_OKX: okx = OKX(zetachain.acc.info); await okx_withdraw(zetachain)
await zetachain.check_tasks()
enroll_result = await zetachain.enroll()
if enroll_result: await sleep(20, 30)
await zetachain.transfer()
pairs = ['ZETA/BNB.BSC', 'ZETA/ETH.ETH', 'ZETA/BTC.BTC']
random.shuffle(pairs)
for pair in pairs: await zetachain.izumi_swap(pair)
await zetachain.izumi_liquidity(random.choice(pairs))
await zetachain.eddy_swap(random.choice(pairs))
await zetachain.mint_stzeta()
await zetachain.ultiverse_mint()
await sleep(30, 45)
await zetachain.claim()
tx_hash = await zetachain.withdraw()
if USE_OKX: await okx.wait_for_deposit('ZETA', 'ZetaChain', tx_hash)
async def custom_way(zetachain: Zetachain) -> None:
for action in CUSTOM_WAY:
if action == 'okx_withdraw':
await okx_withdraw(zetachain)
continue
pair = None
if 'swap' in action or 'liquidity' in action:
action, pair = action.split('-')
result = await run_solo_module(action, zetachain, pair)
if result: await sleep(20, 30)
async def run_solo_module(module: str, zetachain: Zetachain, pair: str | None = None) -> bool | None:
if zetachain.tasks == {}:await zetachain.check_tasks()
if 'swap' in module or 'liquidity' in module:
if not pair: pair = await get_pair()
return await getattr(zetachain, module)(pair)
await getattr(zetachain, module)()
async def okx_withdraw(zetachain: Zetachain) -> None:
if not USE_OKX:
logger.error(f'Вывод невозможен! ОКХ выключен в настройках')
return
okx = OKX(zetachain.acc.info)
if (await zetachain.acc.get_balance('ZETA'))['balance'] < MIN_WALLET_BALANCE:
amount = random.uniform(*AMOUNT_TO_WITHDRAW)
await okx.withdraw(zetachain.acc.address, amount, 'ZETA', 'ZetaChain')
else:
logger.info(f'{zetachain.acc.info} Аккаунт уже имеет более {MIN_WALLET_BALANCE} ZETA')
async def get_okx_balance():
if not USE_OKX:
logger.error(f'Не удалось получить баланс OKX! ОКХ выключен в настройках')
return
okx = OKX('')
balance = await okx.get_okx_ccy_balance('ZETA')
logger.info(f'Баланс OKX: {balance} $ZETA')
return balance