-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathswap_everything_to.py
87 lines (75 loc) · 3.63 KB
/
swap_everything_to.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
82
83
84
85
86
87
from config import *
from accounts_info import *
from odos_router import *
from telebot import types
import time
from suggest_tx import divide_length
user_state = {}
@bot.message_handler(commands=['swap_to_weth'])
def swap_to_weth(message):
bot.send_message(message.chat.id, f"Loading wallets...🕐\n"
f"ETA: 3s per wallet", parse_mode='Markdown')
users = load_accounts()
total_time = 15 * 60
sleep_times = divide_length(total_time, len(users))
# load the users keys and balances
total_swaps = 0
txs = {}
full_message = "You're swapping these amounts of USDC to WETH: \n"
for n, i in enumerate(users):
if round(users[i]['usdc_balance']/1e6, 2) < 10:
full_message += f"{i}: balance < 10$, no need to swap \n"
else:
full_message += f"{i}: ${round(users[i]['usdc_balance']/1e6, 2)} \n"
txs[i] = {
"token_in": USDC_ADDRESS,
"token_out": WETH_ADDRESS,
"amount_in": users[i]['usdc_balance']/1e6,
"tx_value": users[i]['usdc_balance']/1e6,
"sleep_time": sleep_times[n]
}
total_swaps += users[i]['usdc_balance']/1e6
full_message += f"*\nTotal volume: ${round(total_swaps,2)}*"
full_message += f"\nTotal time: {total_time // 60}min"
full_message += "\n\nPlease confirm the action..."
send_tx = types.InlineKeyboardMarkup(row_width=2)
send_tx_button = types.InlineKeyboardButton("✅Execute TXs", callback_data=f"Execute")
cancel_tx = types.InlineKeyboardButton("❌Cancel TXs", callback_data=f"Cancel")
send_tx.add(send_tx_button, cancel_tx)
with open('current_txs_prepared.json', 'w') as file:
json.dump(txs, file, indent=2)
bot.send_message(message.chat.id, full_message, reply_markup=send_tx, parse_mode='Markdown')
@bot.message_handler(commands=['swap_to_usdc'])
def swap_to_usdc(message):
bot.send_message(message.chat.id, f"Loading wallets...🕐\n"
f"ETA: 3s per wallet", parse_mode='Markdown')
users = load_accounts()
total_time = 15 * 60
sleep_times = divide_length(total_time, len(users))
# load the users keys and balances
total_swaps = 0
txs = {}
full_message = "You're swapping these amounts of WETH to USDC: \n"
for n, i in enumerate(users):
if round(users[i]['weth_balance'] / 1e18, 2) < 0.005:
full_message += f"{i}: balance < 0.005 WETH, no need to swap \n"
else:
full_message += f"{i}: ${round(users[i]['weth_balance']/1e18, 2)} \n"
txs[i] = {
"token_in": WETH_ADDRESS,
"token_out": USDC_ADDRESS,
"amount_in": users[i]['weth_balance']/1e18,
"tx_value": users[i]['weth_balance']/1e18,
"sleep_time": sleep_times[n]
}
total_swaps += users[i]['weth_balance']/1e18
full_message += f"\n*Total volume: {round(total_swaps,2)} WETH*"
full_message += f"\nTotal time: {total_time//60}min"
full_message += "\n\nPlease confirm the action..."
send_tx = types.InlineKeyboardMarkup(row_width=2)
send_tx_button = types.InlineKeyboardButton("✅Execute TXs", callback_data=f"Execute")
cancel_tx = types.InlineKeyboardButton("❌Cancel TXs", callback_data=f"Cancel")
send_tx.add(send_tx_button, cancel_tx)
with open('current_txs_prepared.json', 'w') as file:
json.dump(txs, file, indent=2)
bot.send_message(message.chat.id, full_message, reply_markup=send_tx, parse_mode='Markdown')