defi-state-querier 0.5.5__py3-none-any.whl → 0.5.6__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/constants/cosmos_decimals_constant.py +10 -0
- defi_services/jobs/processors/cosmos_state_processor.py +15 -4
- defi_services/services/cosmos_token_services.py +5 -4
- {defi_state_querier-0.5.5.dist-info → defi_state_querier-0.5.6.dist-info}/METADATA +1 -1
- {defi_state_querier-0.5.5.dist-info → defi_state_querier-0.5.6.dist-info}/RECORD +9 -9
- {defi_state_querier-0.5.5.dist-info → defi_state_querier-0.5.6.dist-info}/LICENSE +0 -0
- {defi_state_querier-0.5.5.dist-info → defi_state_querier-0.5.6.dist-info}/WHEEL +0 -0
- {defi_state_querier-0.5.5.dist-info → defi_state_querier-0.5.6.dist-info}/top_level.txt +0 -0
defi_services/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.5.
|
1
|
+
__version__ = "0.5.6"
|
@@ -292,3 +292,13 @@ class Denoms:
|
|
292
292
|
"decimal": 6
|
293
293
|
}
|
294
294
|
}
|
295
|
+
all = {**orai, **cosmos}
|
296
|
+
|
297
|
+
|
298
|
+
class MulticallContract:
|
299
|
+
mapping = {
|
300
|
+
"orai": {
|
301
|
+
"multicall_balance": "orai1dyljypavg7qpt5d72a48a4pyg38d580aat55qql6tdcwfgydy6jsznk0h5",
|
302
|
+
"multicall": "orai1q7x644gmf7h8u8y6y8t9z9nnwl8djkmspypr6mxavsk9ual7dj0sxpmgwd"
|
303
|
+
}
|
304
|
+
}
|
@@ -1,15 +1,26 @@
|
|
1
|
-
from defi_services.constants.cosmos_decimals_constant import Denoms
|
1
|
+
from defi_services.constants.cosmos_decimals_constant import Denoms, MulticallContract
|
2
|
+
from defi_services.constants.network_constants import Chains
|
2
3
|
from defi_services.services.cosmos_token_services import CosmosTokenServices
|
3
4
|
|
4
5
|
|
5
6
|
class CosmosStateProcessor:
|
6
|
-
def __init__(self, lcd: str, rest_uri: str):
|
7
|
+
def __init__(self, lcd: str, rest_uri: str = None, chain_id: str = Chains.oraichain):
|
8
|
+
self.chain_id = chain_id
|
7
9
|
self.lcd = lcd
|
8
10
|
self.rest_uri = rest_uri
|
9
11
|
|
10
12
|
def get_token_balance(self, address, tokens):
|
11
|
-
cosmos = CosmosTokenServices(self.lcd, self.rest_uri)
|
12
|
-
|
13
|
+
cosmos = CosmosTokenServices(self.lcd, self.rest_uri, self.chain_id)
|
14
|
+
if self.chain_id in MulticallContract.mapping:
|
15
|
+
data = cosmos.query_balances(address, tokens)
|
16
|
+
else:
|
17
|
+
data = cosmos.query_coin_balances(address=address)
|
18
|
+
result = {}
|
19
|
+
for item in data:
|
20
|
+
denom = item.get('denom', "").lower()
|
21
|
+
amount = int(item.get('amount', None))
|
22
|
+
decimal = Denoms.all.get(denom, {}).get("decimal", 0)
|
23
|
+
result[denom] = amount / 10 ** decimal
|
13
24
|
return data
|
14
25
|
|
15
26
|
def run(self, address: str, queries: list):
|
@@ -7,11 +7,12 @@ from cosmpy.cosmwasm.rest_client import RestClient
|
|
7
7
|
from cosmpy.cosmwasm.rest_client import CosmWasmRestClient
|
8
8
|
from cosmpy.protos.cosmwasm.wasm.v1.query_pb2 import QuerySmartContractStateRequest
|
9
9
|
|
10
|
-
from defi_services.constants.cosmos_decimals_constant import Denoms
|
10
|
+
from defi_services.constants.cosmos_decimals_constant import Denoms, MulticallContract
|
11
11
|
|
12
12
|
|
13
13
|
class CosmosTokenServices:
|
14
|
-
def __init__(self, lcd: str, rest_uri: str):
|
14
|
+
def __init__(self, lcd: str, rest_uri: str, chain_id: str):
|
15
|
+
self.chain_id = chain_id
|
15
16
|
self.lcd = lcd
|
16
17
|
self.rest_uri = rest_uri
|
17
18
|
self.client = CosmWasmRestClient(RestClient(rest_address=rest_uri))
|
@@ -60,7 +61,7 @@ class CosmosTokenServices:
|
|
60
61
|
"data": self.encode_data({"token_info": {}})
|
61
62
|
})
|
62
63
|
queries.append({
|
63
|
-
"address": "
|
64
|
+
"address": MulticallContract.mapping.get(self.chain_id).get("multicall_balance"),
|
64
65
|
"data": self.encode_data(balance_query)
|
65
66
|
})
|
66
67
|
query = {
|
@@ -70,7 +71,7 @@ class CosmosTokenServices:
|
|
70
71
|
}
|
71
72
|
query = json.dumps(query).encode('utf-8')
|
72
73
|
request_ = QuerySmartContractStateRequest(
|
73
|
-
address="
|
74
|
+
address=MulticallContract.mapping.get(self.chain_id).get("multicall"), query_data=query)
|
74
75
|
response_ = self.client.SmartContractState(request_)
|
75
76
|
decoded_data = self.decode_response_data(response_, cw20_tokens, tokens)
|
76
77
|
return decoded_data
|
@@ -1,4 +1,4 @@
|
|
1
|
-
defi_services/__init__.py,sha256=
|
1
|
+
defi_services/__init__.py,sha256=CMH34Gt1AqO7z_TqRj94XwohGoVCf8aes0djkqm45mk,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
|
@@ -295,7 +295,7 @@ defi_services/abis/vault/lido/lido_wsteth.py,sha256=DJhMToJS43vV2r5WP2kZSiagt7R8
|
|
295
295
|
defi_services/abis/vault/lido/lidor_accounting_oracle_hash_consensus.py,sha256=TWCLaccDgvWJZZKLAeoznYgGi3g3M_hFqoo3KE_L7K8,21039
|
296
296
|
defi_services/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
297
297
|
defi_services/constants/chain_constant.py,sha256=aU7xLaQYLro-7sI5Jpyi0tEHhEQcchyxlxEEJaotFMM,1018
|
298
|
-
defi_services/constants/cosmos_decimals_constant.py,sha256=
|
298
|
+
defi_services/constants/cosmos_decimals_constant.py,sha256=SjFkFbkvxVAk0jtok_1EaBh69ZE8S1fFAbVn6bdJO4s,13635
|
299
299
|
defi_services/constants/db_constant.py,sha256=gDMFFjhPOgQHuS9sPOTFbsfSdIfdWQEE4tGlxHQhNsE,2566
|
300
300
|
defi_services/constants/mongo_constant.py,sha256=qsDIq2Gg5MkBGaEOh4Fd9y6fOOidF4gGPnQwtaPon3E,398
|
301
301
|
defi_services/constants/network_constants.py,sha256=aCUhPFOA9oAMXrIrw67wfEvc4B3HcTlCCz9U1Ku4o50,13574
|
@@ -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=eZa2fO5Vh4n_VTJjKSHTud325KjHvFA_e8NcywDEun4,1813
|
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=-QGmhS-WtwJbOnOFQ7CuM10glPgzZvYPtPlCE6IZIKM,5248
|
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
|
@@ -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.6.dist-info/LICENSE,sha256=6jmfxa8nUIwfKnzZUxAHJSJ_IS7h7mpbJq26cWjoo-o,1063
|
468
|
+
defi_state_querier-0.5.6.dist-info/METADATA,sha256=jksOD0A7CWoHH9ykENU3VhLBGav0P_DA5MWriPxQ74o,4417
|
469
|
+
defi_state_querier-0.5.6.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
470
|
+
defi_state_querier-0.5.6.dist-info/top_level.txt,sha256=C-OTxHK6MknKK-nAbEzCPDUl1M6pktRhgJrmsozdf6g,14
|
471
|
+
defi_state_querier-0.5.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|