-
Notifications
You must be signed in to change notification settings - Fork 0
/
pool_parser.py
46 lines (36 loc) · 1.45 KB
/
pool_parser.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
from supply_calls import pools
class PoolParser:
all_pools = pools
def parse(self):
parsed_supply_by_pool = {}
for pool in self.all_pools:
pool_id = ""
gamm_liquidity = {}
pool_liquidity = {}
if pool['@type'] == "/osmosis.gamm.poolmodels.stableswap.v1beta1.Pool":
pool_id = pool['id']
gamm_liquidity = pool['total_shares']
pool_liquidity = pool['pool_liquidity']
parsed_supply_by_pool[pool_id] = {
'pool_id': pool_id,
'gamm_liquidity': gamm_liquidity,
'pool_liquidity': pool_liquidity
}
return parsed_supply_by_pool
elif pool['@type'] == "/osmosis.gamm.v1beta1.Pool":
pool_id = pool['id']
gamm_liquidity = pool['total_shares']
pool_liquidity = []
for asset in pool['pool_liquidity']:
tokens = [asset['token']]
return tokens
pool_liquidity = tokens
parsed_supply_by_pool[pool_id] = {
'pool_id': pool_id,
'gamm_liquidity': gamm_liquidity,
'pool_liquidity': pool_liquidity
}
return parsed_supply_by_pool
@property
def parsed_supply(self):
return parsed_supply_by_pool