1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Decimal256, Timestamp, Uint128, Uint256};
use cw20::Denom;
use kujira_std::{Asset, Precision};
/// Standard interface to query contract state
#[cw_serde]
pub enum QueryMsg {
/// Current config. Returns [ConfigResponse]
Config {},
/// Simulate an market swap based on the current order book. Returns [terraswap::pair::SimulationResponse]
Simulation { offer_asset: Asset },
/// Query a specific order by idx. Returns [OrderResponse]
Order { order_idx: Uint128 },
/// Paginate user orders. Upper limit of 30 per page. Returns [OrdersResponse]
OrdersByUser {
address: Addr,
start_after: Option<Uint128>,
limit: Option<u8>,
},
/// Query a specific price. Returns [PriceResponse]
Price { price: Decimal256 },
/// Returns the order totals of the current order book, paged out from the spread. Returns [BookResponse]
Book {
limit: Option<u8>,
offset: Option<u8>,
},
}
#[cw_serde]
pub struct ConfigResponse {
/// See [InstantiateMsg::owner]
pub owner: Addr,
/// See [InstantiateMsg::denoms]
pub denoms: [Denom; 2],
/// See [InstantiateMsg::price_precision]
pub price_precision: Precision,
/// See [InstantiateMsg::decimal_delta]
pub decimal_delta: i8,
/// When a book is bootstrapping, it can accept orders but trades are not yet executed
pub is_bootstrapping: bool,
/// See [InstantiateMsg::fee_taker]
pub fee_taker: Decimal256,
/// See [InstantiateMsg::fee_maker]
pub fee_maker: Decimal256,
/// See [InstantiateMsg::fee_address]
pub fee_address: Addr,
}
#[cw_serde]
pub struct OrderResponse {
/// A unnique ID for the order
pub idx: Uint128,
/// The address used to place the order
pub owner: Addr,
/// THe quote price of this order
pub quote_price: Decimal256,
/// The denom offered
pub offer_denom: Denom,
/// The remaining order amount
pub offer_amount: Uint256,
/// Amount of filled order awaiting withdrawal
pub filled_amount: Uint256,
/// Timestamp of original creation
pub created_at: Timestamp,
/// Offer amount at time of creation
pub original_offer_amount: Uint256,
}
#[cw_serde]
pub struct OrdersResponse {
pub orders: Vec<OrderResponse>,
}
#[cw_serde]
pub struct PoolResponse {
/// THe quote price of this pool
pub quote_price: Decimal256,
/// The offer denom for this pool
pub offer_denom: Denom,
/// Total amount of all offers in this pool
pub total_offer_amount: Uint256,
}
#[cw_serde]
pub struct PriceResponse {
/// The two offer pools for this price. The [PoolResponse::offer_denom] will match the order supplied in [InstantiateMsg::denoms]
pub pools: [PoolResponse; 2],
}
#[cw_serde]
pub struct BookResponse {
pub base: Vec<PoolResponse>,
pub quote: Vec<PoolResponse>,
}
#[cw_serde]
pub struct SimulationResponse {
pub return_amount: Uint256,
pub spread_amount: Uint256,
pub commission_amount: Uint256,
}