forked from lukyboi123/Stargate-bridge-accounts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuse_usdc_bridge.py
44 lines (34 loc) · 1.87 KB
/
use_usdc_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
41
42
43
44
import time
from web3 import Account
from bridge.usdc_bridge import swap_usdc_fantom_to_polygon, swap_usdc_polygon_to_fantom, get_balance_usdc_fantom, get_balance_usdc_polygon
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:
try:
fantom_balance = get_balance_usdc_fantom(account.address)
polygon_balance = get_balance_usdc_polygon(account.address)
if fantom_balance + polygon_balance < 10 * (10 ** 6):
continue
if fantom_balance > polygon_balance:
print("Swapping USDC from Fantom to Polygon...")
fantom_to_polygon_txn_hash = swap_usdc_fantom_to_polygon(account=account, amount=fantom_balance)
print("Waiting for the swap to complete...")
time.sleep(20)
print(f"Transaction: https://ftmscan.com/tx/{fantom_to_polygon_txn_hash.hex()}")
else:
print("Swapping USDC from Polygon to Fantom...")
polygon_to_fantom_txn_hash = swap_usdc_polygon_to_fantom(account=account, amount=polygon_balance)
print("Waiting for the swap to complete...")
time.sleep(20)
print(f"Transaction: https://polygonscan.com/tx/{polygon_to_fantom_txn_hash.hex()}")
print("Sleeping 60 seconds for the next account")
time.sleep(60)
except:
pass
print("Sleeping 1200 seconds for the next cycle")
time.sleep(1200)
if __name__ == '__main__':
total_rounds = 10
main(total_rounds)