Terra mantle client
Project description
Mantle client
Utility for loading mantle query on python.
⚠️ This is a simple utility created for creating jupyter notes, so I don't recommend using it to create actual production applications.
Examples
https://github.com/Anchor-Protocol/anchor-notebooks
Install
This module supports python 3.5 and later.
pip3 install 'gql>=3.0.0a6' 'graphql-core>=3.1.5' # install_requires
pip3 install terra-mantle
Wasm query only
wasm_query = {
'marketState': {
# target contract address
'contractAddress': 'terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal', # moneyMarket.market
# contract query (see json query spec for each contract)
'query': {
'state': {}
}
},
'govState': {
'contractAddress': 'terra16ckeuu7c6ggu52a8se005mg5c0kd2kmuun63cu', # gov
'query': {
'state': {}
}
}
}
mantle_result = mantle(wasm_query=wasm_query)
print(mantle_result)
# {'govState': {'poll_count': 110, 'total_deposit': '70000000000', 'total_share': '1309541381956'}, 'marketState': {'anc_emission_rate': '20381363.85157231012364762', 'global_interest_index': '1.062740798331278019', 'global_reward_index': '707.107532763988032671', 'last_interest_updated': 5154819, 'last_reward_updated': 5154819, 'prev_aterra_supply': '36698053286894', 'prev_exchange_rate': '1.082316326902926201', 'total_liabilities': '3755322038128.157685932163911878', 'total_reserves': '0.185800322580727577'}}
Endpoint options
# default mantle_endpoint is 'https://tequila-mantle.anchorprotocol.com'
mantle(wasm_query=wasm_query, mantle_endpoint='https://mantle.anchorprotocol.com')
With graphql query
from mantle import mantle
# graphql query variables
query_variables = {
'wallet_address': 'terra12hnhh5vtyg5juqnzm43970nh4fw42pt27nw9g9'
}
# graphql query
query = """
query queryName ($wallet_address: String!) {
LastSyncedHeight
nativeTokenBalances: BankBalancesAddress(Address: $wallet_address) {
Result {
Denom
Amount
}
}
}
"""
# this "dict" will convert to `WasmContractsContractAddressStore()` query like this.
#
# marketState: WasmContractsContractAddressStore(
# ContractAddress: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal"
# QueryMsg: "{\"state\": {}}"
# ) {
# Result
# }
# govState: WasmContractsContractAddressStore(
# ContractAddress: "terra16ckeuu7c6ggu52a8se005mg5c0kd2kmuun63cu"
# QueryMsg: "{\"state\": {}}"
# ) {
# Result
# }
wasm_query = {
'marketState': {
'contractAddress': 'terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal', # moneyMarket.market
'query': {
'state': {}
}
},
'govState': {
'contractAddress': 'terra16ckeuu7c6ggu52a8se005mg5c0kd2kmuun63cu', # gov
'query': {
'state': {}
}
}
}
mantle_result = mantle(wasm_query=wasm_query, query=query,
query_variables=query_variables)
print(mantle_result)
# {'LastSyncedHeight': 5154821, 'govState': {'poll_count': 110, 'total_deposit': '70000000000', 'total_share': '1309541381956'}, 'marketState': {'anc_emission_rate': '20381363.85157231012364762', 'global_interest_index': '1.062740798331278019', 'global_reward_index': '707.107532763988032671', 'last_interest_updated': 5154819, 'last_reward_updated': 5154819, 'prev_aterra_supply': '36698053286894', 'prev_exchange_rate': '1.082316326902926201', 'total_liabilities': '3755322038128.157685932163911878', 'total_reserves': '0.185800322580727577'}, 'nativeTokenBalances': {'Result': [{'Amount': '60642415', 'Denom': 'uluna'}, {'Amount': '4336036504', 'Denom': 'uusd'}]}}
License
This software is licensed under the Apache 2.0 license. Read more about it here.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terra_mantle-0.1.6-py3-none-any.whl.
File metadata
- Download URL: terra_mantle-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e8e8c5725dd2d0a1b45ec74a9d0cb6722bcc8656d45605d3ae7a5c4f7abee71
|
|
| MD5 |
e1fd335787d5afa54f86dbab1e772c6e
|
|
| BLAKE2b-256 |
b55cfd8b5c485cee9a49cf9e2c2c88941437382c9ac72f5808f54b4812d376bf
|