Skip to main content

Market Contract Queries

GetAllMarkets returns all markets.

GetAllCollaterals returns all collaterals.

GetAccounts returns a list of accounts within the market starting after the provided address up to the provided limit.

GetAllAccounts returns a list of accounts starting after the provided address up to a provided limit.

GetUserAccounts returns all accounts held by a specified address.

GetParams returns the contract parameters.

GetState returns the market state with aggregate information for lend, borrow, and collateral by token.

Note: each user can have several margin accounts, which are isolated from one another. Each Account can be uniquely identified by address: Addr and account_index: u8

Query Messages

GetAllMarkets { .. }
RUST
pub enum QueryMsg {
    /// Returns all markets.
    #[returns(AssetMap<StateMarketInfo>)]
    GetAllMarkets { start_after: Option<AssetInfo>, limit: Option<u32> },
}

GetAllCollaterals { .. }
RUST
pub enum QueryMsg {
    /// Returns all markets.
    #[returns(AssetMap<StateCollateralInfo>)]
    GetAllCollaterals { start_after: Option<AssetInfo>, limit: Option<u32> },
}

GetAccounts { .. }
RUST
pub enum QueryMsg {
    /// Returns a list of accounts.
    #[returns(neptune_common::neptune_map::NeptuneMap<(Addr, u8), Account>)]
    GetAccounts { accounts: Vec<(Addr, u8)> },
}

GetAllAccounts { .. }
RUST
pub enum QueryMsg {
    /// Returns a list of accounts
    /// starting after the provided address
    /// up to the provided limit.
    #[returns(neptune_common::neptune_map::NeptuneMap<(Addr, u8), Account>)]
    GetAllAccounts { start_after: Option<(Addr, u8)>, limit: Option<u32> },
}

GetUserAccounts { .. }
RUST
pub enum QueryMsg {
    /// Returns all accounts held by a specified address.
    #[returns(neptune_common::neptune_map::NeptuneMap<u8, Account>)]
    GetUserAccounts { addr: Addr },
}

GetParams { .. }
RUST
pub enum QueryMsg {
    /// Returns the contract parameters.
    #[returns(Params)]
    GetParams {},
}

GetState { .. }
RUST
pub enum QueryMsg {
    /// Returns the contract state
    #[returns(State)]
    GetState {},
}

Market Query Response

StateMarketInfo, StateCollateralInfo and Account are defined below in these Common Data Types along with Pool, PoolAccount, MarketAssetDetails and CollateralDetails.

StateMarketInfo
RUST
pub struct StateMarketInfo {
    pub time_last_distributed_interest: Timestamp,
    pub utilization_accumulator:        Decimal256,
    pub lending_principal:              Uint256,
    pub debt_pool:                      Pool,
    pub market_asset_details:           MarketAssetDetails,
}

StateCollateralInfo
RUST
pub struct StateCollateralInfo {
    pub collateral_details: CollateralDetails,
    pub collateral_pool:    Pool,
}

Account
RUST
pub struct Account {
    pub last_tx_height:           u64,
    pub debt_pool_accounts:       AssetMap<PoolAccount>,
    pub collateral_pool_accounts: AssetMap<PoolAccount>,
}

Pool
RUST
pub struct Pool {
    pub balance: Uint256,
    pub shares: Uint256,
}

PoolAccount
RUST
pub struct PoolAccount {
    pub principal: Uint256,
    pub shares: Uint256,
}

MarketAssetDetails
RUST
pub struct MarketAssetDetails {
    pub receipt_addr:            Addr,
    pub borrow_halt_utilization: Decimal256,
    pub interest_fee:            Decimal256,
    pub borrow_cap:              Option<Uint256>,
    pub enabled:                 bool,
}

CollateralDetails
RUST
pub struct CollateralDetails {
    pub collateral_type: AssetType,
    pub liquidation_ltv: Decimal256,
    pub allowable_ltv:   Decimal256,
    pub max_discount:    Decimal256,
    pub min_discount:    Decimal256,
    pub collateral_cap:  Option<Uint256>,
    pub enabled:         bool,
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.