Skip to content

Commit

Permalink
изменил структуру, добавил bitget и tx_checker
Browse files Browse the repository at this point in the history
  • Loading branch information
zaivanza committed Jun 28, 2023
1 parent 790b4ef commit b1f54c0
Show file tree
Hide file tree
Showing 22 changed files with 2,003 additions and 1,594 deletions.
51 changes: 43 additions & 8 deletions MAIN.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,88 @@
from config import *
from utils import *
from web3_checker import *
from debank import *
from config import RUN_TEXT, RUN_COLOR, WALLETS
from setting import RANDOM_WALLETS, CHECK_GWEI, TG_BOT_SEND , IS_SLEEP, SLEEP_FROM, SLEEP_TO

from modules.helpers import evm_wallet, list_send, wait_gas, send_msg, sleeping
from modules import *

from loguru import logger
from termcolor import cprint
import random


def start_module(module, key=''):

if module == 1:
cprint(f'\nstart : web3_checker\n', 'white')
web3_check()

if module == 2:
cprint(f'\nstart : debank_checker\n', 'white')
start_debank()

if module == 3:
cprint(f'\nstart : exchange_withdraw\n', 'white')
exchange_withdraw(key)

if module == 4:
cprint(f'\nstart : okx_withdraw\n', 'white')
okx_withdraw(key)

if module == 5:
cprint(f'\nstart : transfer\n', 'white')
transfer(key)

if module == 6:
cprint(f'\nstart : 0x_swap\n', 'white')
zeroX_swap(key)

if module == 7:
cprint(f'\nstart : orbiter_bridge\n', 'white')
orbiter_bridge(key)

if module == 8:
cprint(f'\nstart : woofi_bridge\n', 'white')
woofi_bridge(key)

if module == 9:
cprint(f'\nstart : woofi_swap\n', 'white')
woofi_swap(key)

if module == 10:
cprint(f'\nstart : sushiswap\n', 'white')
sushiswap(key)

if module == 11:
cprint(f'\nstart : bungee_refuel\n', 'white')
bungee_refuel(key)

if module == 12:
cprint(f'\nstart : tx_checker\n', 'white')
start_tx_check()


if __name__ == "__main__":

cprint(RUN_TEXT, RUN_COLOR)
cprint(f'\nsubscribe to us : https://t.me/hodlmodeth\n', RUN_COLOR)

MODULE = int(MODULE)

if MODULE in [1, 2]:
MODULE = int(input('''
MODULE:
1. web3_checker
2. debank checker
3. exchange withdraw : вывод с биржи
4. okx withdraw
5. transfer
6. 0x_swap
7. orbiter finance
8. woofi_bridge
9. woofi_swap
10. sushiswap
11. bungee_refuel
12. tx_checker
Выберите модуль (1 - 12) : '''))

if MODULE in [1, 2, 12]:
start_module(MODULE)

else:
Expand Down Expand Up @@ -78,4 +114,3 @@ def start_module(module, key=''):
except Exception as error:
logger.error()


39 changes: 10 additions & 29 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
import requests, json, time, ccxt
from ccxt import ExchangeError
import json, time
import random, requests
from loguru import logger
from web3 import Web3, AsyncHTTPProvider
from web3.eth import AsyncEth
import asyncio, aiohttp
from termcolor import cprint
import random
import telebot
from tqdm import tqdm
import hmac, base64
import csv
from pyuseragents import random as random_useragent
from tabulate import tabulate
import math
import decimal

from setting import *
from data.abi.abi import *
from data.data import *

max_time_check_tx_status = 100 # в секундах. если транза не выдаст статус за это время, она будет считаться исполненной

Expand All @@ -40,6 +24,7 @@
with open(f"{outfile}data/proxies.txt", "r") as f:
PROXIES = [row.strip() for row in f]


STR_DONE = '✅ '
STR_CANCEL = '❌ '

Expand Down Expand Up @@ -305,6 +290,7 @@ def sleeping(from_sleep, to_sleep):
'arbitrum' : '0x9aed3a8896a85fe9a8cac52c9b402d092b629a30',
'optimism' : '0xEAf1Ac8E89EA0aE13E0f03634A4FF23502527024',
'fantom' : '0x382A9b0bC5D29e96c3a0b81cE9c64d6C8F150Efb',
'zksync' : '0xfd505702b37Ae9b626952Eb2DD736d9045876417',
}

# через что бриджим на woofi (usdc / usdt)
Expand Down Expand Up @@ -388,19 +374,14 @@ def sleeping(from_sleep, to_sleep):
texts = [text1, text2]
colors = ['green', 'yellow', 'blue', 'magenta', 'cyan']

RUN_TEXT = random.choice(texts)
RUN_COLOR = random.choice(colors)

# разбивка массива на части по кол-ву элементов
def func_chunks_generators(lst, n):
for i in range(0, len(lst), n):
yield lst[i: i + n]
RUN_TEXT = random.choice(texts)
RUN_COLOR = random.choice(colors)

def get_wallet_proxies():
def get_wallet_proxies(wallets, proxies):
try:
result = {}
for i in range(len(WALLETS)):
result[WALLETS[i]] = PROXIES[i % len(PROXIES)]
for i in range(len(wallets)):
result[wallets[i]] = proxies[i % len(proxies)]
return result
except: None

Expand Down Expand Up @@ -457,7 +438,7 @@ def get_bungee_data():
return data

PRICES_NATIVE = get_prices()
WALLET_PROXIES = get_wallet_proxies()
WALLET_PROXIES = get_wallet_proxies(WALLETS, PROXIES)
BUNGEE_LIMITS = get_bungee_data()


3 changes: 2 additions & 1 deletion data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'kucoin' : {'api_key': 'your_api_key', 'api_secret': 'your_api_secret', 'password': 'your_api_password'},
'huobi' : {'api_key': 'your_api_key', 'api_secret': 'your_api_secret'},
'bybit' : {'api_key': 'your_api_key', 'api_secret': 'your_api_secret'},
'bitget' : {'api_key': 'your_api_key', 'api_secret': 'your_api_secret', 'password': 'your_api_password'},
}

# можешь записать любое кол-во аккаунтов, сделал таким образом чтобы постоянно данные от новых акков не вводить, а просто вызывать по имени аккаунта
Expand All @@ -53,4 +54,4 @@
'api_secret': 'your_api_secret',
'password' : 'your_api_password',
},
}
}
1 change: 0 additions & 1 deletion data/proxies.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
http://login:password@ip:port (формат, удали эту строку)
1 change: 0 additions & 1 deletion data/recipients.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

1 change: 0 additions & 1 deletion data/starknet_address.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

10 changes: 10 additions & 0 deletions modules/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .zerox_swap import zeroX_swap
from .bungee_refuel import bungee_refuel
from .exchange_withdraw import exchange_withdraw, okx_withdraw
from .orbiter import orbiter_bridge
from .sushiswap import sushiswap
from .transfer import transfer
from .woofi import woofi_bridge, woofi_swap
from .web3_checker import web3_check
from .debank import start_debank
from .tx_checker import start_tx_check
132 changes: 132 additions & 0 deletions modules/bungee_refuel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from data.data import DATA
from data.abi.abi import ABI_BUNGEE_REFUEL
from config import BUNGEE_LIMITS, STR_DONE, STR_CANCEL, BUNGEE_REFUEL_CONTRACTS
from setting import value_bungee, RETRY
from .helpers import add_gas_limit, add_gas_price, sign_tx, check_balance, check_status_tx, checker_total_fee, round_to, list_send, decimalToInt, intToDecimal, sleeping

from loguru import logger
from web3 import Web3
import random

def get_bungee_limits(from_chain, to_chain):

from_chain_id = DATA[from_chain]['chain_id']
to_chain_id = DATA[to_chain]['chain_id']

data = BUNGEE_LIMITS

for i in range(len(data['result'])):
if data['result'][i]['chainId'] == from_chain_id:
infos = data['result'][i]['limits']

try:

if [x for x in infos if x['chainId'] == to_chain_id][0] \
and [x for x in infos if x['chainId'] == to_chain_id][0]['isEnabled'] == True:

info = [x for x in infos if x['chainId'] == to_chain_id][0]
return int(info['minAmount']), int(info['maxAmount'])
else:
logger.error(f'рефуел из {from_chain} в {to_chain} невозможен')
return 0, 0

except Exception as error:
logger.error(error)

def bungee_refuel(privatekey, retry=0):

try:

from_chain, to_chain, bridge_all_balance, amount_from, amount_to, min_amount_bridge, keep_value_from, keep_value_to = value_bungee()

module_str = f'bungee_refuel : {from_chain} => {to_chain}'
logger.info(module_str)

keep_value = round(random.uniform(keep_value_from, keep_value_to), 8)
if bridge_all_balance == True: amount = check_balance(privatekey, from_chain, '') - keep_value
else: amount = round(random.uniform(amount_from, amount_to), 8)

limits = get_bungee_limits(from_chain, to_chain)
min_limit = round_to(decimalToInt(limits[0], 18))
max_limit = round_to(decimalToInt(limits[1], 18))

value = intToDecimal(amount, 18)
web3 = Web3(Web3.HTTPProvider(DATA[from_chain]['rpc']))
account = web3.eth.account.from_key(privatekey)
wallet = account.address

if amount > min_limit and amount < max_limit: None
else:
logger.error(f'amount {amount} but bungee_limits : {min_limit} - {max_limit}')
list_send.append(f'{STR_CANCEL}{module_str} : amount {amount} but bungee_limits : {min_limit} - {max_limit}')
return False

if amount >= min_amount_bridge:

contract = web3.eth.contract(address=Web3.to_checksum_address(BUNGEE_REFUEL_CONTRACTS[from_chain]), abi=ABI_BUNGEE_REFUEL)

contract_txn = contract.functions.depositNativeToken(
DATA[to_chain]['chain_id'], # destinationChainId
wallet # _to
).build_transaction(
{
# "chainId": web3.eth.chain_id,
"from": wallet,
"nonce": web3.eth.get_transaction_count(wallet),
'gasPrice': 0,
'gas': 0,
"value": value
}
)

contract_txn = add_gas_price(web3, contract_txn)
contract_txn = add_gas_limit(web3, contract_txn)

# смотрим газ, если выше выставленного значения : спим
total_fee = int(contract_txn['gas'] * contract_txn['gasPrice'])
is_fee = checker_total_fee(from_chain, total_fee)

if is_fee == True:

if bridge_all_balance == True:
gas_gas = int(contract_txn['gas'] * contract_txn['gasPrice'])
contract_txn['value'] = contract_txn['value'] - gas_gas

tx_hash = sign_tx(web3, contract_txn, privatekey)
tx_link = f'{DATA[from_chain]["scan"]}/{tx_hash}'

status = check_status_tx(from_chain, tx_hash)
if status == 1:
logger.success(f'{module_str} | {tx_link}')
list_send.append(f'{STR_DONE}{module_str}')
return True

else:
if retry < RETRY:
logger.info(f'{module_str} | tx is failed, try again in 10 sec | {tx_link}')
sleeping(10, 10)
bungee_refuel(privatekey, retry+1)
else:
logger.error(f'{module_str} | tx is failed | {tx_link}')
list_send.append(f'{STR_CANCEL}{module_str} | tx is failed | {tx_link}')

else:
bungee_refuel(privatekey, retry)

else:
logger.error(f"{module_str} : can't bridge : {amount} (amount) < {min_amount_bridge} (min_amount_bridge)")
list_send.append(f'{STR_CANCEL}{module_str} : {amount} less {min_amount_bridge}')


except Exception as error:

logger.error(f'{module_str} | {error}')
if retry < RETRY:
logger.info(f'try again | {wallet}')
sleeping(10, 10)
bungee_refuel(privatekey, retry+1)
else:
list_send.append(f'{STR_CANCEL}{module_str}')



24 changes: 13 additions & 11 deletions debank.py → modules/debank.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from .helpers import func_chunks_generators, evm_wallet, call_json
from config import outfile, PROXIES, WALLETS, DEBANK_ACTIVATE_CHAINS
from setting import value_debank

import time
from loguru import logger
import asyncio, aiohttp
from termcolor import cprint
import random
import csv
from tabulate import tabulate
import math

from config import *

get_result = {
'token' : {},
Expand All @@ -13,15 +24,6 @@
'protocol' : {}
}

def evm_wallet(key):

try:
web3 = Web3(Web3.HTTPProvider(DATA['ethereum']['rpc']))
wallet = web3.eth.account.from_key(key).address
return wallet
except:
return key

async def get_debank(session, address, type_, chain=''):

while True:
Expand Down Expand Up @@ -321,7 +323,7 @@ def send_result(get_json, file_name, check_chain, check_coin):

file.close()

cprint(f'результаты записаны в файлы : {outfile}{file_name}.csv и {outfile}{file_name}.txt\n', 'blue')
cprint(f'Результаты записаны в файлы : {outfile}{file_name}.csv и {outfile}{file_name}.txt\n', 'blue')

async def get_activate_debank(session, wallet, chain):

Expand Down
Loading

0 comments on commit b1f54c0

Please sign in to comment.