Querier
Querier Contract Address: inj1kfjff5f0xjy7gece36watkqtscpycv666tqq7t
The Querier Contract is a quality of life service developed to provide simplified protocol queries. It provides advanced, aggregated query functionality by interacting with various on-chain modules such as the token, market, and price oracle contracts.
Interrelation with Other Contracts
The Neptune Querier contract depends on and interacts with:
Token Contract: Queries the weighted stake essential for account health calculations.
Market Contract: Provides account states, collateral, debt information, and market parameters.
Price Oracle Contract: Supplies current asset pricing data required for evaluating collateral and debt.
Query Messages
1. Get Account Health
The querier contract calls the token contract via a smart query (GetHealthWeightedStake
) to obtain the weighted stake of an account. This value is fundamental for computing the account's overall health.
The Account Health is conceptually computed as:
A value of less than 1 indicates that the account is undercollateralized and may require liquidation.
Query: get_account_health
Purpose: Retrieves the health of a specified account by aggregating collateral, debt, and weighted stake information.
Query Input:
addr
Addr
Injetive wallet address
Yes
account_index
uint8
sub account's index ID
Yes
Query Response:
Here, a result of "0.98" indicates that the account health is 98% of the safe threshold. Values below 1 denote undercollateralization and places the account in a liquidable state.
response
Decimal256
Current account health
2. Get Collateral Discount
For accounts with health below 1, the protocol applies discounts on collateral assets. The discount calculation is based on:
Protocol parameters from the market configuration.
The specific collateral state.
The computed account health.
This process is encapsulated in the get_discount
function. Only accounts with qualify, as healthy accounts (with health ≥ 1) do not receive discounts.
Query: get_collateral_discount
Purpose: Calculates the applicable discounts for collateral assets held by an undercollateralized account.
Query Input:
addr
addr
Injetive wallet address
Yes
account_index
uint8
sub account's index ID
Yes
Query Response:
This indicates that the native inj
asset receives a 10% discount, while the specified CW20 token receives a 5% discount.
asset_info
AssetInfo
Object containing the type of token and either a denom or a contract address
asset_info.
type
string
"native_token"
or "token"
asset_info.
denom
string
Denomination of the token (if type
= native_token
)
asset_info.
contract_addr
addr
Contract address of the token (if type
= token
)
discount
decimal256
The discount value for this particular collateral token
3. Get Liquidation Request
When an account is undercollateralized (account health is < 1), a liquidation request is computed to determine the amount of debt to be repaid and collateral to be received. This involves:
Determining the accounts repayable debt.
Identifying which collaterals are available for liquidation.
Calculating:
Ask Assets: The collateral assets to be liquidated.
Offer Assets: The corresponding debt amounts to be repaid.
The final liquidation request, if valid, contains both mappings and only returns a result if:
There is a non-zero debt to be repaid.
There is a non-zero collateral liquidation amount.
Query: get_liquidation_request
Purpose: Generates a liquidation request for an account that is determined to be undercollateralized. This request details both the collateral (ask assets) to be liquidated and the debt (offer assets) to be repaid.
Query Input:
account_addr
Addr
The account address to be checked or liquidated
Yes
account_index
uint8
The sub-account index ID
Yes
collateral_priority
AssetInfo[]
Ordered list of collateral token types to be liquidated first, second, etc
No
collateral_priority.
type
string
The collateral token "type". Can be "native_token"
or "token"
Yes
collateral_priority.
denom
string
The collateral token address. Can be denom
or token_address
Yes
debt_priority
AssetInfo[]
Ordered list of debts to be repaid first, second, etc
No
debt_priority.
type
string
The debt token "type". Can be "native_token"
or "token"
Yes
debt_priority.
denom
string
The debt token address. Can be denom
or token_address
Yes
Query Response:
If the account is healthy or no liquidation is triggered, the query returns null
.
ask_assets
NeptuneMap<AssetInfo, LiquidationAmounts>
Object listing the collateral assets to be liquidated
ask_assets.
denom
object
Collateral details for a specific token
ask_assets.
denom.
amount
Uint256
The amount of collateral to be liquidated
ask_assets.
denom.
min_discount
Decimal256
Any applicable discount applied to collateral value
offer_assets
NeptuneMap<AssetInfo, Uint256>
Object listing the debt to be repaid
offer_assets.
denom
Uint256
The amount of debt that must be repaid for liquidation
4. Get Market Metadata
The contract also computes key market ratios:
Utilization Ratio:
Redemption Ratio:
These ratios are essential for monitoring market performance and liquidity.
Query: get_market_metadata
Purpose: Retrieves metadata for available markets, including the utilization and redemption ratios.
Query Input:
start_after
AssetInfo
Object specifying which token to start after
No
start_after.
native_token
object
Token type. Can be native_token
or token
Yes
start_after.
native_token.
denom
string
Token address. Can be denom
or contract_address
Yes
limit
uint32
How many records to fetch starting after target token
No
Query Response:
native_token
AssetInfo
Object specifying token denom and market metadata
native_token.
denom
string
Token address. Can be denom
or contract_address
native_token.
utilization_ratio
Decimal256
The current utilization ratio for the tokens market
native_token.
redemption_ratio
Decimal256
The current redemption ratio from nToken<>Token
Last updated