forked from Vikapobeda2020/Solana-Sniping-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (45 loc) · 1.75 KB
/
main.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
import json
import time
from PhantomBot import PhantomBot
from Scraper import Scraper
CONFIG = json.load(open('config.json'))
BOT = PhantomBot(CONFIG)
SCRAPER = Scraper(CONFIG)
COOLDOWN = 60 * CONFIG['cooldown']
if __name__ == "__main__":
driver = BOT.setupDriver()
driver.get("https://www.magiceden.io/")
BOT.initWallet(driver)
BOT.selectWallet(driver)
collections = SCRAPER.getCollections()
while True:
listings = list()
for collection in collections:
if CONFIG['collectionName'] == collection['name']:
listings = SCRAPER.getListing(collection['symbol'])
print(f"Found: {collection['symbol']}")
eligibleListings, listingPrices = SCRAPER.getEligibleListings(listings)
if len(listingPrices) > 0:
lowestPrice = min(listingPrices)
bestOffer = str()
for listing in eligibleListings:
if lowestPrice == listing['price']:
bestOffer = f'https://www.magiceden.io/item-details/{listing["tokenMint"]}'
if len(bestOffer) > 0:
print(f'Found the best offer - {bestOffer}')
try:
pass
BOT.makePurchase(driver, bestOffer)
except Exception as err:
print(f'Unable to purchase: {err}')
finally:
break
else:
print("Couldn't find a suitable offer")
else:
print("Couldn't find a suitable offer")
print(f"Next try in {COOLDOWN / 60} minutes")
time.sleep(COOLDOWN)
if CONFIG['closeBrowser']:
print("Stop working...")
driver.quit()