defi-state-querier
Description
Return the asset list of an address in a blockchain. These assets are native token, tokens, nft, and the assets locked in protocols.
Requirement
- Accuracy
- Fastest speed
- Post all requests in a call with maximum batch size and workers
Input
- address: str (lower case or upper case)
- block_number: int
- chain_id: string. Eg:
0x1,0x38 - query: array
- query_id: id of query
- entity_id: token address, nft or id of protocols like
aave-v2,compound, andpancakeswap-amm - query_type: one of keywords -
token_balance,ntf_balance,deposit_borrow,protocol_reward, andprotocol_apy.
Output
[
{
"query_id": "<query_id>",
"entity_id": "<token_address>",
"query_type": "token_balance",
"token_balance": 173.84
},
{
"query_id": "<query_id>",
"entity_id": "<nft_address>",
"query_type": "nft_balance",
"nft_balance": 11
},
{
"query_id": "<query_id>",
"entity_id": "<protocol_id>",
"query_type": "deposit_borrow",
"deposit_borrow": {
"<protocol_address>": {
"<asset_address_1>": {
"borrow_amount": 184.4,
"deposit_amount": 331.5
},
"<asset_address_2>": {
"borrow_amount": 184.4,
"deposit_amount": 331.5
}
}
}
},
{
"query_id": "<query_id>",
"entity_id": "<protocol_id>",
"query_type": "protocol_reward",
"protocol_reward": {
"<reward_address>": {
"amount": 1.4
}
}
},
{
"query_id": "<query_id>",
"entity_id": "<protocol_id>",
"query_type": "protocol_apy",
"protocol_apy": {
"<protocol_address>": {
"<asset_address_1>": {
"total_deposit": 331.5,
"total_borrow": 184.4,
"deposit_apy": 0.051,
"borrow_apy": 0.067,
}
}
}
}
]
Query state data
Preparation
Get some information of protocols in their github or documents.
[1] Create abi files having format like erc20 token abi or aave v3 lending abi.
[2] Get basic information of protocols and save in a python file like aave_v2_eth.py.
Infrastructure
Important files
[1] state_querier.py - create function information, encode function calls, push function calls, and decode response data.
[2] state_processor.py - receive input, combine all encoded function calls in a batch, execute function call batch, process response data, and return output.
[3] protocol_services.py - protocol service pattern file, all protocols should follow this file like aave_v2_services.py. There are 4 main functions of a service: get service info, get token list related to protocol, get asset information supported by protocol (dapp), get all information of function calls, and process response data.
[4] token_services.py - get information of erc 20 function calls and process response data.
Examples
[1] token_information.py - example of using state querier.
[2] wallet_information.py - example of using state processor.
Metadata
Release files for defi-state-querier 0.5.35
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| defi_state_querier-0.5.35.tar.gz | 448.8 kB | Without provenance | Details for defi_state_querier-0.5.35.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| defi_state_querier-0.5.35-py3-none-any.whl | Python 3 | none | any | Details for defi_state_querier-0.5.35-py3-none-any.whl |
Total release size: 1.2 MB
Release files / defi_state_querier-0.5.35.tar.gz
| Download URL | defi_state_querier-0.5.35.tar.gz |
|---|---|
| Size | 448.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fd0b7c19aff494483a6eee35ea481acd6b9586b642a34a1a526c2f1899bb4ec
|
|
BLAKE2b-256 checksum How to use checksums |
50d27a00713cb12bd641bc7d90b422d700e72eeb115d9bd62060baccd563e825
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / defi_state_querier-0.5.35-py3-none-any.whl
| Download URL | defi_state_querier-0.5.35-py3-none-any.whl |
|---|---|
| Size | 716.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbf6b464ce008395fb49c6831315bc4188adce7bb1a7153d9a6c62cb65eb1852
|
|
BLAKE2b-256 checksum How to use checksums |
a3a3c8f4c9dd7653f13c6f826f76778f15f40ff6daec3487b4c647b5efa52ee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for defi-state-querier 0.5.35
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.