forked from lukyboi123/Stargate-bridge-accounts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuse_eth_bridge.py
40 lines (31 loc) · 1.87 KB
/
use_eth_bridge.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
import time
from web3 import Account, Web3
from bridge.eth_bridge import swap_eth_arbitrum_optimism, swap_eth_optimism_arbitrum, get_balance_eth_arbitrum, get_balance_eth_optimism
def main(tr):
with open('keys.txt', 'r') as keys_file:
accounts = [Account.from_key(line.replace("\n", "")) for line in keys_file.readlines()]
for _ in range(0, tr):
for account in accounts:
arbitrum_balance = get_balance_eth_arbitrum(account.address)
optimism_balance = get_balance_eth_optimism(account.address)
if arbitrum_balance + optimism_balance < Web3.to_wei(0.02, 'ether'):
continue
if arbitrum_balance > optimism_balance:
print("Swapping ETH from Arbitrum to Optimism...")
arbitrum_to_optimism_txs_hash = swap_eth_arbitrum_optimism(account=account, amount=arbitrum_balance - Web3.to_wei(0.01, 'ether'))
print("Waiting for the swap to complete...")
time.sleep(20)
print(f"Transaction: https://arbiscan.io/tx/{arbitrum_to_optimism_txs_hash.hex()}")
else:
print("Swapping ETH from Optimism to Arbitrum...")
optimism_to_arbitrum_txs_hash = swap_eth_optimism_arbitrum(account=account, amount=optimism_balance - Web3.to_wei(0.01, 'ether'))
print("Waiting for the swap to complete...")
time.sleep(20)
print(f"Transaction: https://optimistic.etherscan.io/tx{optimism_to_arbitrum_txs_hash.hex()}")
print("Sleeping 60 seconds for the next account")
time.sleep(60)
print("Sleeping 1200 seconds for the next cycle")
time.sleep(1200)
if __name__ == '__main__':
total_rounds = 10
main(total_rounds)