-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmallConfig.py
More file actions
executable file
·231 lines (214 loc) · 8.62 KB
/
smallConfig.py
File metadata and controls
executable file
·231 lines (214 loc) · 8.62 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/usr/bin/python3
import csv
import json
import pandas
import shutil
import os
from git import Repo
from pycoingecko import CoinGeckoAPI
TOKEN_MAP = 'penultimate.csv'
LOGOS_IN_DIR = 'Logos'
LOGOS_OUT_DIR = 'avalanche-tokens'
ETH_CONFIG_100 = 'ethereum100.config'
AVA_CONFIG_100 = 'avalanche100.config'
ETH_CONFIG_150 = 'ethereum150.config'
AVA_CONFIG_150 = 'avalanche150.config'
HOSTED_URL = 'https://raw.githubusercontent.com/ava-labs/bridge-tokens/main/'
def read_tokens():
token_map = pandas.read_csv(TOKEN_MAP)
#token_map['Avalanche Token Symbol'] = token_map['Avalanche Token Symbol'].astype('|S')
#breakpoint()
#print(token_map.loc[2:5, ["Avalanche Token Address", "Ethereum Token Address"]])
return token_map
def generateEthConfig(token_map):
out_file = {}
data_lst = list()
for _, row in token_map.iterrows():
data = {}
data['address'] = row['Ethereum Token Address']
data['name'] = row['Ethereum Token Name']
data['symbol'] = row['Ethereum Token Symbol']
data['imageUri'] = HOSTED_URL + LOGOS_OUT_DIR + '/' + row['Avalanche Token Address'] + '/logo.png'
data['resourceId'] = row['Resource ID']
data_lst.append(data)
out_file['data'] = data_lst
with open(ETH_CONFIG_150, 'w') as json_file:
json.dump(out_file, json_file, indent=4)
def generateAvaConfig(token_map):
out_file = {}
data_lst = list()
for _, row in token_map.iterrows():
data = {}
data['address'] = row['Avalanche Token Address']
data['name'] = row['Avalanche Token Name']
data['symbol'] = row['Avalanche Token Symbol']
data['imageUri'] = HOSTED_URL + LOGOS_OUT_DIR + '/' + row['Avalanche Token Address'] + '/logo.png'
data['resourceId'] = row['Resource ID']
data_lst.append(data)
out_file['data'] = data_lst
with open(AVA_CONFIG_150, 'w') as json_file:
json.dump(out_file, json_file, indent=4)
def avaTop100(token_map):
cg = CoinGeckoAPI()
out_file = {}
data_lst = list()
notFound = 0
#token_map["Ethereum Token Name"] = token_map["Ethereum Token Name"].lower()
token_map['symbol_lower'] = token_map.apply(lambda row : row['Avalanche Token Symbol'].lower(), axis = 1)
found = 0
page = 1
while found < 100:
result = cg.get_coins_markets('usd', per_page=250, page=page, order='market_cap_desc')
#breakpoint()
for i in range(len(result)):
#print(result[i])
#breakpoint()
row = token_map[token_map["symbol_lower"] == result[i]['symbol'].lower()]
#if result[i]['symbol'].lower() == 'mkr':
# breakpoint()
if len(row.index) == 0:
notFound += 1
elif len(row.index) > 1:
print("Collision for symbol", result[i]['symbol'])
else:
found += 1
data = {}
data['address'] = row.iloc[0]['Avalanche Token Address']
data['name'] = row.iloc[0]['Avalanche Token Name']
data['symbol'] = row.iloc[0]['Avalanche Token Symbol']
data['imageUri'] = HOSTED_URL + LOGOS_OUT_DIR + '/' + row.iloc[0]['Avalanche Token Address'] + '/logo.png'
data['resourceId'] = '0x' + row.iloc[0]['Resource ID']
data_lst.append(data)
if found == 100:
break
page += 1
out_file['data'] = data_lst
#breakpoint()
with open(AVA_CONFIG_100, 'w') as json_file:
json.dump(out_file, json_file, indent=4)
print("Not found:", notFound)
def avaTop150(token_map):
cg = CoinGeckoAPI()
out_file = {}
data_lst = list()
notFound = 0
#token_map["Ethereum Token Name"] = token_map["Ethereum Token Name"].lower()
token_map['symbol_lower'] = token_map.apply(lambda row : row['Avalanche Token Symbol'].lower(), axis = 1)
found = 0
page = 1
while found < 150:
result = cg.get_coins_markets('usd', per_page=250, page=page, order='market_cap_desc')
for i in range(len(result)):
#print(result[i])
#breakpoint()
row = token_map[token_map["symbol_lower"] == result[i]['symbol'].lower()]
#if result[i]['symbol'].lower() == 'mkr':
# breakpoint()
if len(row.index) == 0:
notFound += 1
elif len(row.index) > 1:
print("Collision for symbol", result[i]['symbol'])
else:
found += 1
data = {}
data['address'] = row.iloc[0]['Avalanche Token Address']
data['name'] = row.iloc[0]['Avalanche Token Name']
data['symbol'] = row.iloc[0]['Avalanche Token Symbol']
data['imageUri'] = HOSTED_URL + LOGOS_OUT_DIR + '/' + row.iloc[0]['Avalanche Token Address'] + '/logo.png'
data['resourceId'] = '0x' + row.iloc[0]['Resource ID']
data_lst.append(data)
if found == 150:
break
page += 1
out_file['data'] = data_lst
#breakpoint()
with open(AVA_CONFIG_150, 'w') as json_file:
json.dump(out_file, json_file, indent=4)
print("Not found:", notFound)
def ethTop100(token_map):
cg = CoinGeckoAPI()
out_file = {}
data_lst = list()
notFound = 0
#token_map["Ethereum Token Name"] = token_map["Ethereum Token Name"].lower()
token_map['symbol_lower'] = token_map.apply(lambda row : row['Avalanche Token Symbol'].lower(), axis = 1)
found = 0
page = 1
while found < 100:
result = cg.get_coins_markets('usd', per_page=250, page=page, order='market_cap_desc')
for i in range(len(result)):
#print(result[i])
#breakpoint()
row = token_map[token_map["symbol_lower"] == result[i]['symbol'].lower()]
#if result[i]['symbol'].lower() == 'mkr':
# breakpoint()
if len(row.index) == 0:
notFound += 1
elif len(row.index) > 1:
print("Collision for symbol", result[i]['symbol'])
else:
found += 1
data = {}
data['address'] = row.iloc[0]['Ethereum Token Address']
data['name'] = row.iloc[0]['Ethereum Token Name']
data['symbol'] = row.iloc[0]['Ethereum Token Symbol']
data['imageUri'] = HOSTED_URL + LOGOS_OUT_DIR + '/' + row.iloc[0]['Avalanche Token Address'] + '/logo.png'
data['resourceId'] = '0x' + row.iloc[0]['Resource ID']
data_lst.append(data)
if found == 100:
break
page += 1
out_file['data'] = data_lst
#breakpoint()
with open(ETH_CONFIG_100, 'w') as json_file:
json.dump(out_file, json_file, indent=4)
print("Not found:", notFound)
def ethTop150(token_map):
cg = CoinGeckoAPI()
out_file = {}
data_lst = list()
notFound = 0
#token_map["Ethereum Token Name"] = token_map["Ethereum Token Name"].lower()
token_map['symbol_lower'] = token_map.apply(lambda row : row['Avalanche Token Symbol'].lower(), axis = 1)
found = 0
page = 1
while found < 150:
result = cg.get_coins_markets('usd', per_page=250, page=page, order='market_cap_desc')
for i in range(len(result)):
#print(result[i])
#breakpoint()
row = token_map[token_map["symbol_lower"] == result[i]['symbol'].lower()]
#if result[i]['symbol'].lower() == 'mkr':
# breakpoint()
if len(row.index) == 0:
notFound += 1
elif len(row.index) > 1:
print("Collision for symbol", result[i]['symbol'])
else:
found += 1
data = {}
data['address'] = row.iloc[0]['Ethereum Token Address']
data['name'] = row.iloc[0]['Ethereum Token Name']
data['symbol'] = row.iloc[0]['Ethereum Token Symbol']
data['imageUri'] = HOSTED_URL + LOGOS_OUT_DIR + '/' + row.iloc[0]['Avalanche Token Address'] + '/logo.png'
data['resourceId'] = '0x' + row.iloc[0]['Resource ID']
data_lst.append(data)
if found == 150:
break
page += 1
out_file['data'] = data_lst
#breakpoint()
with open(ETH_CONFIG_150, 'w') as json_file:
json.dump(out_file, json_file, indent=4)
print("Not found:", notFound)
def main():
token_map = read_tokens()
#copy_logos(token_map)
#generateEthConfig(token_map)
#generateAvaConfig(token_map)
avaTop100(token_map)
ethTop100(token_map)
avaTop150(token_map)
ethTop150(token_map)
if __name__ == '__main__':
main()