Market
Market Contract Address: inj1nc7gjkf2mhp34a6gquhurg8qahnw5kxs5u3s4u
The Market Contract is a core component of the Neptune Protocol, responsible for handling various financial operations such as lending, borrowing, collateral management, flash loans and liquidations. It provides a robust and flexible interface for users to interact with the Neptune financial ecosystem.
Query Messages
1. Get All Markets
Query: get_all_markets
Purpose: Returns a paginated list of all markets available in the Neptune Protocol, including their current state, interest rates, utilization metrics, and market-specific parameters. Supports pagination through start_after and limit parameters. If pagnation is not used, returns all markets.
Query Input:
Query Response:
native_token
AssetInfo
Contains details about the native token
native_token.
denom
string
The denomination of the native token
time_last_distributed_interest
Timestamp
The timestamp of the last interest distribution
utilization_accumulator
Decimal256
The accumulated utilization value
lending_principal
Uint256
The principal amount currently lent
debt_pool
Pool
Contains details about the debt pool
debt_pool.
balance
Uint256
The balance of the debt pool
debt_pool.
shares
Uint256
The shares of the debt pool
market_asset_details
MarketAssetDetails
Contains details about the market asset
market_asset_details.
receipt_addr
Addr
The receipt address for the market asset
market_asset_details.
borrow_halt_utilization
Decimal256
The utilization level at which borrowing halts
market_asset_details.
interest_fee
Decimal256
The interest fee applied to the market asset
market_asset_details.
borrow_cap
Uint256
The borrowing cap for the market asset. Can be null
market_asset_details.
enabled
boolean
Indicates if the market asset is enabled
2. Get All Collaterals
Query: get_all_collaterals
Purpose: Fetches a paginated list of all collateral assets available in the Neptune Protocol, including their LTV ratios, liquidation parameters, collateral caps, and current pool states. Supports pagination through start_after and limit parameters. If pagnation is not used, returns all collaterals.
Query Input:
Query Response:
native_token
AssetInfo
Contains details about the native token
native_token.
denom
string
The denomination of the native token
collateral_details
CollateralDetails
Contains details about the collateral
collateral_details.
collateral_type
AssetType
The type of collateral (e.g., regular)
collateral_details.
liquidation_ltv
Decimal256
The loan-to-value ratio for liquidation
collateral_details.
allowable_ltv
Decimal256
The allowable loan-to-value ratio
collateral_details.
max_discount
Decimal256
The maximum discount applied to the collateral
collateral_details.
min_discount
Decimal256
The minimum discount applied to the collateral
collateral_details.
collateral_cap
Uint256
The cap on the amount of collateral
collateral_details.
enabled
boolean
Indicates if the collateral is enabled
collateral_pool
Pool
Contains details about the collateral pool
collateral_pool.
balance
Uint256
The balance of the collateral pool
collateral_pool.
shares
Uint256
The shares of the collateral pool
3. Get State
Query: get_state
Purpose: Retrieves a comprehensive snapshot of the entire market contract state, combining both the market assets data and collateral assets data in a single query. This provides a complete view of all markets and collaterals without pagination.
Query Input:
Query Response:
4. Get User Accounts
Query: get_user_accounts
Purpose: Retrieves detailed information about all sub-accounts associated with a specific wallet address, including their debt positions and collateral deposits across different assets.
Query Input:
addr
Addr
Injective wallet address
Query Response:
[0]
uint8
sub account index number
debt_pool_accounts
array<[AssetInfo, PoolAccount]>
Contains details about the user's debt pools
debt_pool_accounts[].
native_token.
denom
string
The denomination of the native token in the debt pool
debt_pool_accounts[].
principal
Uint256
The principal amount in the debt pool
debt_pool_accounts[].
shares
Uint256
The shares in the debt pool
collateral_pool_accounts
array<[AssetInfo, PoolAccount]>
Contains details about the user's collateral pools
collateral_pool_accounts[].
token.
contract_addr
Addr
The contract address of the token in the collateral pool
collateral_pool_accounts[].
native_token.
denom
string
The denomination of the native token in the collateral pool
collateral_pool_accounts[].
principal
Uint256
The principal amount in the collateral pool
collateral_pool_accounts[].
shares
Uint256
The shares in the collateral pool
5. Get All Accounts
Query: get_all_accounts
Purpose: Returns a paginated list of all margin accounts across all users in the protocol, including their debt and collateral positions. Supports efficient pagination through [address, index] cursor and limit parameters.
Query Input:
start_after
[Addr, uint8]
The address and index to start the query after
start_after[0]
Addr
The address to start after
start_after[1]
uint8
The account index to start after
limit
uint32
The maximum number of accounts to return
Query Response:
debt_pool_accounts
array<[AssetInfo, PoolAccount]>
Contains details about the account's debt pools
debt_pool_accounts[].
native_token.
denom
string
The denomination of the native token in the debt pool
debt_pool_accounts[].
principal
Uint256
The principal amount in the debt pool
debt_pool_accounts[].
shares
Uint256
The shares in the debt pool
collateral_pool_accounts
array<[AssetInfo, PoolAccount]>
Contains details about the account's collateral pools
collateral_pool_accounts[].
token.
contract_addr
Addr
The contract address of the token in the collateral pool
collateral_pool_accounts[].
native_token.
denom
string
The denomination of the native token in the collateral pool
collateral_pool_accounts[].
principal
Uint256
The principal amount in the collateral pool
collateral_pool_accounts[].
shares
Uint256
The shares in the collateral pool
6. Get Params
Query: get_params
Purpose: Retrieves the protocol's global configuration parameters, including liquidation settings, staking parameters, fee structures, flash loan settings, and core token addresses (hINJ and NEPT).
Query Input:
Query Response:
time_window_nanos
uint64
Number of nanoseconds that an oracle price is valid for
partial_liquidation_threshold
Uint256
Minimum account value to avoid complete liquidation. Represented in USD with 18 decimal precision
staking_health_modifier
Decimal256
The maximum health increase provided by NEPT staking
stake_collateral_ratio
Decimal256
The required ratio of weighted staked NEPT to collateral value
stake_flash_loan_ratio
Decimal256
The required ratio of weighted staked NEPT to flash loan value
target_liquidation_health
Decimal256
The account health target to bring an account up to from a liquidation action
dynamic_discount_width
Decimal256
The required change in account health below 1.0 to achieve the maximum discount on a collateral asset
liquidation_fee
Decimal256
The coefficient used to calculate the liquidation protocol fee
flash_loan_fee
Decimal256
The coefficient used to calculate the flash loan fee
flash_loans_enabled
boolean
Whether flash loans are enabled
hinj
AssetInfo
AssetInfo for the hINJ token
hinj.
token.
contract_addr
Addr
The contract address of the hINJ token
nept
AssetInfo
AssetInfo for the NEPT token
nept.
native_token.
denom
string
The denomination of NEPT native token
Execute Messages
1. Receive
Execute: receive
Purpose: Handles incoming CW20 token transfers through the CW20 hook mechanism, allowing the contract to process token-specific operations based on the encoded instructions in the message.
2. Lend
Execute: lend
Purpose: Allows users to provide assets to the lending pool, which increases the pool's liquidity and enables the lender to receive nTokens representing their lending position.
funds
Coin
The amount and denomination of tokens to lend
Yes
3. Redeem
Execute: redeem
Purpose: Allows users to withdraw their lending deposits by burning their nTokens in exchange for the underlying asset plus any accrued interest.
sender
Addr
Wallet address of the user redeeming tokens
Yes
contract
Addr
nToken contract address that is initiating the redeem operation
Yes
msg
Cw20ReceiveMsg
CW20 hook message wrapping the redeem instruction
Yes
msg.send
object
Nested message instructing the market contract regarding the redeem sub-message
Yes
msg.
send.
amount
Uint128
The amount of nTokens to be redeemed
Yes
msg.
send.
contract
Addr
Market contract address that should process the redeem sub-message
Yes
msg.
send.
msg
Binary
Base64 encoded sub-message (which decodes to { "redeem": {} }
)
Yes
funds
Coin
Not used in this operation. Must be set to "0"
Yes
3.1 Deposit Collateral (Native Token)
Execute: deposit_collateral
Purpose: Enables users to deposit native tokens as collateral into a specified margin account, which can then be used to secure borrowed positions.
account_index
uint8
The index of the account to deposit collateral into
Yes
funds
Coin
The amount and denomination of tokens to deposit as collateral
Yes
3.2 Deposit Collateral (CW20 Token)
Execute: deposit_collateral
Purpose: Enables users to deposit CW20 tokens as collateral into a specified margin account, which can then be used to secure borrowed positions.
Example: Applicable to hINJ
token
sender
addr
Wallet address of the user depositing tokens (CW20 sender)
Yes
contract
addr
CW20 token contract address initiating the deposit operation
Yes
msg
Cw20ReceiveMsg
Container for the CW20 hook message payload
Yes
msg.
send
object
The CW20 hook message instructing the market contract on how to process the collateral deposit
Yes
msg.
send.
amount
uint128
The amount of tokens to be deposited as collateral
Yes
msg.
send.
contract
addr
The market contract address that will process the deposit collateral request
Yes
msg.
send.
msg
binary
A Base64-encoded sub-message instructing the market contract to execute the deposit collateral operation
Yes
funds
coin
Not used for this operation. Must be set to "0"
Yes
4. Withdraw Collateral
Execute: withdraw_collateral
Purpose: Allows users to withdraw their deposited collateral from a margin account, provided the withdrawal doesn't violate the account's minimum collateralization requirements.
account_index
uint8
The index of the account to withdraw collateral from
Yes
asset_info
AssetInfo
Information about the asset being withdrawn
Yes
asset_info.
native_token
object
Token type
Yes
asset_info.
native_token.
denom
string
Token address
Yes
shares
Uint256
The number of shares to withdraw
Yes
5. Borrow
Execute: borrow
Purpose: Enables users to borrow assets against their deposited collateral, subject to the account's collateralization ratio requirements and market's borrowing limits.
account_index
uint8
The index of the account to withdraw collateral from
Yes
amount
Uint256
Amount of tokens to borrow
Yes
asset_info
AssetInfo
Information about the asset being withdrawn
Yes
asset_info.
native_token
object
Token type
Yes
asset_info.
native_token.
denom
string
Token address
Yes
6. Return
Execute: return
Purpose: Allows users to repay borrowed assets to their margin account, reducing their debt position and associated interest accrual.
account_index
uint8
The index of the account to return tokens to
Yes
funds
Coin
The amount and denomination of tokens to return
Yes
7. Inject
Execute: inject
Purpose: Enables privileged addresses to inject liquidity into market pools (lending, borrowing, or collateral) to manage pool balances, compound rewards, or adjust yields. Injecting into lending or collateral pools increases their value, while injecting into borrow pools decreases the system's debt.
injection_type
RewardType
Target market pool to inject liquidty to. Can lend
, borrow
, or collateral
Yes
funds
Coin
The amount and denomination of tokens to inject
Yes
8. Borrow Flashloan
Execute: borrow_flash_loan
Purpose: Initiates a flash loan operation, allowing a user to temporarily borrow specified assets for short-lived, atomic operations (e.g., arbitrage, liquidation, or other custom strategies). The borrowed funds are sent directly to a designated flash loan receiver contract along with an array of messages (msgs
) that instruct the receiver on how to utilize the funds. The entire operation must be completed within one transaction, with the borrowed funds being returned prior to the execution of the final protocol checks.
NOTE: A user's access to use flash loans, and the flash loan capacity, is gated by the value of their staked NEPT tokens.
Execute JSON:
assets
array<[AssetInfo, Uint256]>
A list of asset-amount pairs representing the tokens to be borrowed
Yes
assets[0].
native_token
object
Token type
Yes
assets[0].
native_token.
denom
string
Token address
Yes
assets[1]
Uint256
Amount of tokens to be flashloaned
Yes
msgs
array<CosmosMsg_for_InjectiveMsgWrapper>
A list of sub messages to be forwarded and executed by the receiver address
Yes
receiver
Addr
The Flashloan Receiver address
Yes
9. Return Flashloan
Execute: return_flash_loan
Purpose: Used to repay the funds borrowed via a flash loan. Once the flash loan receiver (or borrower) completes its operations utilizing the temporarily provided liquidity, this call returns the exact borrowed amount(s) back to the market contract. The returned funds are then verified by a subsequent check to ensure the entire flash loan is repaid within the same transaction.
NOTE: The total amount of tokens to be repaid is equal to amount_borrowed + floashloan_fee
Execute JSON:
assets
array<[AssetInfo, Uint256]>
A list of asset-amount pairs representing the tokens to be repaid
Yes
assets[0].
native_token
object
Token type
Yes
assets[0].
native_token.
denom
string
Token address
Yes
assets[1]
Uint256
Amount of tokens to be repaid
Yes
10. Assert Flashloan Repaid
Execute: assert_flash_loan_repaid
Purpose: Ensures that all funds borrowed via a flashloan have been fully repaid within the same transaction. This check is executed after the corresponding return_flash_loan
call, and if the repayment is incomplete, the entire transaction will revert.
Execute JSON:
11. Liquidate
Execute: liquidate
Purpose: Performs the liquidation of an undercollateralized margin account. This call allows a liquidator to repay a portion of the outstanding debt in a margin account that has fallen below the required collateralization threshold. In exchange, the liquidator seizes a discounted share of the account's collateral. The parameters ensure that the repaid amount does not exceed the account's outstanding debt and that the collateral received reflects the value of the repaid debt adjusted by the liquidation discount.
Execute JSON:
account_index
uint8
The index of the margin account to be liquidated
Yes
repayment_amount
Uint256
The amount of debt to be repaid by the liquidator
Yes
asset_info
AssetInfo
The asset information representing the collateral type
Yes
asset_info.
native_token
object
Token type
Yes
asset_info.
native_token.
denom
string
Token address
Yes
12. Update Market Asset
Execute: update_market_asset
Purpose: Allows privileged addresses to modify market-specific parameters such as interest rates, utilization caps, and operational status for a given asset market.
NOTE: Only whitelisted addresses can execute update_market_asset
Execute JSON:
asset
AssetInfo
Describes the asset for which the market configuration is to be updated
Yes
asset.
native_token
object
Token type
Yes
asset.
native_token.
denom
string
Token address
Yes
market_asset_details
MarketAssetDetails
Contains the updated market asset parameters
Yes
market_asset_details.
receipt_addr
Addr
The matching CW20 nToken address
Yes
market_asset_details.
borrow_halt_utilization
Decimal256
Utilization threshold to halt borrowing
Yes
market_asset_details.
interest_fee
Decimal256
The interest fee applied on borrows
Yes
market_asset_details.
borrow_cap
Uint256
The borrowing cap for the asset. Can be null
Yes
market_asset_details.
enabled
boolean
Indicates if the market asset is active
Yes
13. Update Collateral Asset
Execute: update_collateral_asset
Purpose: Allows privileged addresses to modify collateral-specific parameters such as LTV ratios, liquidation thresholds, and collateral caps for a given asset.
NOTE: Only whitelisted addresses can execute update_collateral_asset
Execute JSON:
asset
AssetInfo
Describes the asset for which the collateral configuration is to be updated
Yes
asset.
native_token
object
Token type
Yes
asset.
native_token.
denom
string
Token address
Yes
collateral_asset_info
CollateralDetails
Contains the updated collateral asset parameters
Yes
collateral_asset_info.
allowable_ltv
Decimal256
The allowable loan-to-value ratio for the collateral asset
Yes
collateral_asset_info.
collateral_cap
Uint256
The cap on the amount of collateral that can be used in the market
Yes
collateral_asset_info.
collateral_type
AssetType
The type of collateral (regular or receipt_token)
Yes
collateral_asset_info.
enabled
boolean
Indicates if the collateral asset is enabled
Yes
collateral_asset_info.
liquidation_ltv
Decimal256
The loan-to-value ratio at which the collateral is subject to liquidation
Yes
collateral_asset_info.
max_discount
Decimal256
The maximum discount applied to the collateral during liquidation
Yes
collateral_asset_info.
min_discount
Decimal256
The minimum discount applied to the collateral during liquidation
Yes
14. Distribute Interest
Execute: distribute_interest
Purpose: Updates the protocol's interest rate calculations and distributes accrued interest from borrowers to lenders, maintaining accurate accounting of lending and borrowing positions.
Execute JSON:
assets
array<AssetInfo>
A list of asset information for which interest is to be distributed
Yes
assets[].
native_token
object
Token type
Yes
assets[].
native_token.
denom
string
Token address
Yes
Last updated