This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
reverse-engineer-ocr-db.py
74 lines (61 loc) · 2.41 KB
/
reverse-engineer-ocr-db.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
'''
This is the script where I add in features / constraints to try and
get closer to orc's 16% buy rate, getting as close to their algorithm as possible
Currently, it excludes:
- Creator purchased more than 4.0 SOL
- Creator previously made a coin
- Creator was funded by someone who previously made a coin
'''
from trades_db_utils import create_connection
def fetch_all_coins(connection):
"""Retrieve all coins from the database."""
cursor = connection.cursor()
query = "SELECT id, mint_address, creator_address, funder_address FROM coins"
cursor.execute(query)
coins = cursor.fetchall()
cursor.close()
return coins
def fetch_trades_for_coin(connection, coin_id):
"""Retrieve all trades for a given coin."""
cursor = connection.cursor()
query = "SELECT * FROM trades WHERE coin_id = %s"
cursor.execute(query, (coin_id,))
trades = cursor.fetchall()
cursor.close()
return trades
def iterate_coins_and_trades():
# bad coins, aka coins we will not attempt to buy
bad_coins = set()
creators = set()
creator_made_multiple_coins = 0
creator_over_sol_buy_limit = 0
connection = create_connection()
try:
coins = fetch_all_coins(connection)
for coin in coins:
coin_id, mint_address, creator_address, funder_address = coin
trades = fetch_trades_for_coin(connection, coin_id)
if not trades:
continue
if creator_address not in creators:
creators.add(creator_address)
else:
bad_coins.add(mint_address)
creator_made_multiple_coins += 1
if funder_address in creators:
bad_coins.add(mint_address)
trades = reversed(trades)
for index, trade in enumerate(trades):
_, _, _, sol_amount, _, is_buy, user, _ = trade
if index < 10 and is_buy and user == creator_address:
if sol_amount > 2:
creator_over_sol_buy_limit += 1
bad_coins.add(mint_address)
print("Total coins", len(coins))
print("Coins where creator made multiple", creator_made_multiple_coins)
print("Coins where creator bought over 4.0 sol", creator_over_sol_buy_limit)
print("Total bad coins:", len(bad_coins))
finally:
if connection:
connection.close()
iterate_coins_and_trades()