defi-state-querier 0.5.7__py3-none-any.whl → 0.5.9__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- defi_services/__init__.py +1 -1
- defi_services/jobs/processors/cosmos_state_processor.py +6 -5
- defi_services/services/cosmos_token_services.py +22 -20
- defi_services/services/dex/uniswap_v3_service.py +1 -1
- {defi_state_querier-0.5.7.dist-info → defi_state_querier-0.5.9.dist-info}/METADATA +6 -6
- {defi_state_querier-0.5.7.dist-info → defi_state_querier-0.5.9.dist-info}/RECORD +9 -9
- {defi_state_querier-0.5.7.dist-info → defi_state_querier-0.5.9.dist-info}/WHEEL +1 -1
- {defi_state_querier-0.5.7.dist-info → defi_state_querier-0.5.9.dist-info}/LICENSE +0 -0
- {defi_state_querier-0.5.7.dist-info → defi_state_querier-0.5.9.dist-info}/top_level.txt +0 -0
defi_services/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.5.
|
1
|
+
__version__ = "0.5.9"
|
@@ -14,16 +14,17 @@ class CosmosStateProcessor:
|
|
14
14
|
if self.chain_id in MulticallContract.mapping:
|
15
15
|
data = cosmos.query_balances(address, tokens)
|
16
16
|
else:
|
17
|
-
|
18
|
-
|
19
|
-
for item in
|
17
|
+
result = cosmos.query_coin_balances(address=address)
|
18
|
+
data = {}
|
19
|
+
for item in result:
|
20
20
|
denom = item.get('denom', "").lower()
|
21
21
|
amount = int(item.get('amount', None))
|
22
22
|
decimal = Denoms.all.get(denom, {}).get("decimal", 0)
|
23
|
-
|
23
|
+
data[denom] = amount / 10 ** decimal
|
24
|
+
|
24
25
|
return data
|
25
26
|
|
26
|
-
def run(self, address: str, queries: list):
|
27
|
+
def run(self, address: str, queries: list, *args, **kwargs):
|
27
28
|
result = []
|
28
29
|
tokens = [query.get('entity_id').lower() for query in queries if query.get('query_type') == 'token_balance']
|
29
30
|
token_balances = self.get_token_balance(address, tokens)
|
@@ -14,8 +14,10 @@ class CosmosTokenServices:
|
|
14
14
|
def __init__(self, lcd: str, rest_uri: str, chain_id: str):
|
15
15
|
self.chain_id = chain_id
|
16
16
|
self.lcd = lcd
|
17
|
+
|
17
18
|
self.rest_uri = rest_uri
|
18
19
|
self.client = CosmWasmRestClient(RestClient(rest_address=rest_uri))
|
20
|
+
|
19
21
|
self.decimals = Denoms.cosmos
|
20
22
|
self.decimals.update(Denoms.orai)
|
21
23
|
|
@@ -23,34 +25,34 @@ class CosmosTokenServices:
|
|
23
25
|
def query_coin_balances(self, address: str):
|
24
26
|
responses = []
|
25
27
|
endpoint = '/cosmos/bank/v1beta1/balances/'
|
26
|
-
|
27
|
-
|
28
|
+
|
29
|
+
response = requests.get(self.lcd + endpoint + address, timeout=60).content
|
30
|
+
results = json.loads(response)
|
31
|
+
|
32
|
+
responses += results['balances']
|
33
|
+
pagination = results['pagination']['next_key']
|
34
|
+
|
35
|
+
while pagination is not None:
|
36
|
+
response = requests.get(self.lcd + endpoint + '?pagination.key=' + quote(str(pagination)), timeout=60)
|
37
|
+
results = json.loads(response.content)
|
38
|
+
|
28
39
|
responses += results['balances']
|
29
40
|
pagination = results['pagination']['next_key']
|
30
|
-
|
31
|
-
|
32
|
-
requests.get(self.lcd + endpoint + '?pagination.key=' + quote(str(pagination)), timeout=60).content)
|
33
|
-
responses += results['balances']
|
34
|
-
pagination = results['pagination']['next_key']
|
35
|
-
return responses
|
36
|
-
except Exception:
|
37
|
-
raise Exception
|
41
|
+
|
42
|
+
return responses
|
38
43
|
|
39
44
|
# queries the balance of a given denom for a single account.
|
40
45
|
def query_balances_by_denom(self, address, denom):
|
41
46
|
endpoint = '/cosmos/bank/v1beta1/balances/'
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
except Exception:
|
46
|
-
raise Exception
|
47
|
+
|
48
|
+
response = requests.get(self.lcd + endpoint + address + '/by_denom?denom=' + denom, timeout=60)
|
49
|
+
return json.loads(response.content)
|
47
50
|
|
48
51
|
def query_token_decimal(self):
|
49
52
|
endpoint = '/cosmos/bank/v1beta1/denoms_metadata'
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
raise Exception
|
53
|
+
|
54
|
+
response = requests.get(self.lcd + endpoint, timeout=60)
|
55
|
+
return json.loads(response.content)
|
54
56
|
|
55
57
|
def query_balances(self, address: str, tokens: list):
|
56
58
|
balance_query, cw20_tokens = self.get_balance_function_info(address, tokens)
|
@@ -93,7 +95,7 @@ class CosmosTokenServices:
|
|
93
95
|
balances[tokens[idx]] = int(balance_data[idx])
|
94
96
|
|
95
97
|
for token in tokens:
|
96
|
-
if token
|
98
|
+
if decimals.get(token) is not None:
|
97
99
|
balances[token] /= 10**decimals[token]
|
98
100
|
else:
|
99
101
|
balances[token] /= 10**self.decimals.get(token, {}).get("decimal", 0)
|
@@ -361,6 +361,6 @@ class UniswapV3Services(DexProtocolServices):
|
|
361
361
|
return user_data
|
362
362
|
|
363
363
|
def checksum_address(self, address):
|
364
|
-
if self.
|
364
|
+
if self.web3.is_address(address):
|
365
365
|
address = self.web3.to_checksum_address(address)
|
366
366
|
return address
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: defi-state-querier
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.9
|
4
4
|
Summary: Calculate apy, apr, and wallet information,... in decentralized applications.
|
5
5
|
Home-page: https://github.com/Centic-io/defi-state-querier
|
6
6
|
Author: Viet-Bang Pham
|
@@ -12,11 +12,11 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Requires-Python: >=3.6
|
13
13
|
Description-Content-Type: text/markdown
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: web3
|
16
|
-
Requires-Dist: query-blockchain-state-lib
|
17
|
-
Requires-Dist: python-dotenv
|
18
|
-
Requires-Dist: pymongo
|
19
|
-
Requires-Dist: cosmpy
|
15
|
+
Requires-Dist: web3>=6.0.0
|
16
|
+
Requires-Dist: query-blockchain-state-lib>=1.0.1
|
17
|
+
Requires-Dist: python-dotenv>=1.0.0
|
18
|
+
Requires-Dist: pymongo>=4.3.3
|
19
|
+
Requires-Dist: cosmpy>=0.9.2
|
20
20
|
|
21
21
|
# defi-state-querier
|
22
22
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
defi_services/__init__.py,sha256=
|
1
|
+
defi_services/__init__.py,sha256=JXLyhF5WmLgRZBfWGz9zWe2g5ISKSLpn2jp8yLaC-s4,22
|
2
2
|
defi_services/abis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
defi_services/abis/multicall_v3_abi.py,sha256=0aPxjrJJFU17fODjvYFRDn5Y5J1yi_AJKc8v1uohNGY,12352
|
4
4
|
defi_services/abis/dex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -313,7 +313,7 @@ defi_services/constants/entities/vault_services.py,sha256=IMmQc15wS1KA7EuQqM_Ara
|
|
313
313
|
defi_services/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
314
314
|
defi_services/jobs/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
315
315
|
defi_services/jobs/processors/call_state_processor.py,sha256=WseX0OaMA5D_ANYofrz7W2BooSMdHlGRay4NuiABmM4,436
|
316
|
-
defi_services/jobs/processors/cosmos_state_processor.py,sha256=
|
316
|
+
defi_services/jobs/processors/cosmos_state_processor.py,sha256=u9CdGF41XQlxe3IyXV2ocdHdaq1aLeonOZOIpCPNojY,1831
|
317
317
|
defi_services/jobs/processors/multi_call_state_processor.py,sha256=AksswGMSyStbnvkQcBVb0Y2tdpkUgc1CWoeSiMpGy8U,462
|
318
318
|
defi_services/jobs/processors/multi_state_processor.py,sha256=Od7Y8zPz7xj0L-_0YuK4wg_94fX8Q1PquuKUUYteIJU,5731
|
319
319
|
defi_services/jobs/processors/solana_state_processor.py,sha256=szsBYrkEV8kBzuA_iaSVescnwKJ2MHoTbut5kORbWTs,4065
|
@@ -325,7 +325,7 @@ defi_services/jobs/queriers/solana_state_querier.py,sha256=TQELYo6GUoF8s-LfetqYb
|
|
325
325
|
defi_services/jobs/queriers/state_querier.py,sha256=q7cAW395urZjcWTpqw8m_nDunLyyTuAXJ3DRx_1HOxo,7384
|
326
326
|
defi_services/jobs/queriers/substrate_state_querier.py,sha256=_T0Dk06sP_uBKaxgj2J_EBtJDoq-hi8jU7Np4iuO0LA,3858
|
327
327
|
defi_services/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
328
|
-
defi_services/services/cosmos_token_services.py,sha256
|
328
|
+
defi_services/services/cosmos_token_services.py,sha256=pRw_rEhoofd6V1-KwU74ZHjhg6PsXSznK6eD1ASyROA,5108
|
329
329
|
defi_services/services/dex_protocol_services.py,sha256=J93P7kwy1v98aeA95ErT7jDCCOAelFuCNiTXl3PVFFo,6656
|
330
330
|
defi_services/services/nft_services.py,sha256=vKva0OJQTTxgP1lrZ5ij2sw2N44JxN5dfLLtvNJB6aA,2188
|
331
331
|
defi_services/services/protocol_services.py,sha256=3Yca433xGXowcV4EjFoQ90AJHg-SfuOBsDF7aMCJ8Zk,7626
|
@@ -343,7 +343,7 @@ defi_services/services/dex/sushiswap_service.py,sha256=1_vCvLjQZmjOK55xUpotAgrQK
|
|
343
343
|
defi_services/services/dex/sushiswap_v2_service.py,sha256=QyOVdTv06sWR_SYphxGGxla3eMN3Q8sRjXU6vPPTr4Q,3834
|
344
344
|
defi_services/services/dex/sushiswap_v3_service.py,sha256=fTBJfbyU4nSei_XCWxHKRZxzPRNwLrda3VORgKRAnYo,3141
|
345
345
|
defi_services/services/dex/uniswap_v2_service.py,sha256=ps8_-JW0ZjqFCLicap1zY0kenBoa3t43hZZNKI33WI0,10476
|
346
|
-
defi_services/services/dex/uniswap_v3_service.py,sha256=
|
346
|
+
defi_services/services/dex/uniswap_v3_service.py,sha256=lr3-CqJJ52ivyJWnQNEt2-V95gOMHc1_z529y_9TwZ8,18662
|
347
347
|
defi_services/services/dex/dex_info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
348
348
|
defi_services/services/dex/dex_info/pancakeswap_info.py,sha256=dLtYR9_ZpKN3dme5gDZ-Oi7gnYRx2GMRRI1D9eQ3y5w,2075
|
349
349
|
defi_services/services/dex/dex_info/quickswap_info.py,sha256=79ul5xG6rKa2IVj2ptJrQzTyG9A5vweHodU28B1lpro,963
|
@@ -464,8 +464,8 @@ defi_services/utils/market_service.py,sha256=imPtPHBkpEx5JnhqeIWYqbCjsIEm8IKBYHN
|
|
464
464
|
defi_services/utils/memory_storage.py,sha256=BOT8laB0iVSCGE-oDlpWJQLbSC6X2blKX4zuQbs4inc,851
|
465
465
|
defi_services/utils/sqrt_price_math.py,sha256=9lgUeWFT4wjl3Vq3b7-jZ2bGvvZx7dDBSfVnM3lsZ8o,5575
|
466
466
|
defi_services/utils/thread_proxy.py,sha256=5Z8biAyEReUkh3vfJSvEv7GwMe3CsE5M8CbghkQtePw,2951
|
467
|
-
defi_state_querier-0.5.
|
468
|
-
defi_state_querier-0.5.
|
469
|
-
defi_state_querier-0.5.
|
470
|
-
defi_state_querier-0.5.
|
471
|
-
defi_state_querier-0.5.
|
467
|
+
defi_state_querier-0.5.9.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
|
468
|
+
defi_state_querier-0.5.9.dist-info/METADATA,sha256=saz1Kln8tBSkn6p0HylJIVXaIZ-Ch65wuLdN1b4ZsMQ,4412
|
469
|
+
defi_state_querier-0.5.9.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
470
|
+
defi_state_querier-0.5.9.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
|
471
|
+
defi_state_querier-0.5.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|