neutron_sdk/bindings/dex/
query.rs

1use crate::bindings::dex::types::{
2    DepositRecord, LimitOrderTranche, LimitOrderTrancheUser, LimitOrderType, MultiHopRoute, Params,
3    Pool, PoolMetadata, PoolReserves, PrecDec, TickLiquidity,
4};
5use crate::bindings::query::{PageRequest, PageResponse};
6use cosmwasm_std::{Coin, Int128};
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
11#[serde(rename_all = "snake_case")]
12pub enum DexQuery {
13    /// Parameters queries the parameters of the module.
14    Params {},
15    /// Queries a LimitOrderTrancheUser by index.
16    LimitOrderTrancheUser {
17        address: String,
18        tranche_key: String,
19    },
20    /// Queries a list of LimitOrderTrancheMap items.
21    LimitOrderTrancheUserAll { pagination: Option<PageRequest> },
22    /// Queries a list of LimitOrderTrancheUser items for a given address.
23    LimitOrderTrancheUserAllByAddress {
24        address: String,
25        pagination: Option<PageRequest>,
26    },
27    /// Queries a LimitOrderTranche by index.
28    LimitOrderTranche {
29        pair_id: String,
30        tick_index: i64,
31        token_in: String,
32        tranche_key: String,
33    },
34    /// Queries a list of LimitOrderTranche items for a given pairID / TokenIn combination.
35    LimitOrderTrancheAll {
36        pair_id: String,
37        token_in: String,
38        pagination: Option<PageRequest>,
39    },
40    /// Queries a list of UserDeposits items.
41    UserDepositAll {
42        address: String,
43        include_pool_data: bool,
44        pagination: Option<PageRequest>,
45    },
46    /// Queries a list of TickLiquidity items.
47    TickLiquidityAll {
48        pair_id: String,
49        token_in: String,
50        pagination: Option<PageRequest>,
51    },
52    /// Queries a InactiveLimitOrderTranche by index.
53    InactiveLimitOrderTranche {
54        pair_id: String,
55        tick_index: i64,
56        token_in: String,
57        tranche_key: String,
58    },
59    /// Queries a list of InactiveLimitOrderTranche items.
60    InactiveLimitOrderTrancheAll { pagination: Option<PageRequest> },
61    /// Queries a list of PoolReserves items.
62    PoolReservesAll {
63        pair_id: String,
64        token_in: String,
65        pagination: Option<PageRequest>,
66    },
67    /// Queries a PoolReserve by index
68    PoolReserves {
69        pair_id: String,
70        token_in: String,
71        tick_index: i64,
72        fee: u64,
73    },
74    /// Queries the simulated result of a multihop swap
75    EstimateMultiHopSwap {
76        creator: String,
77        receiver: String,
78        routes: Vec<MultiHopRoute>,
79        amount_in: Int128,
80        exit_limit_price: PrecDec,
81        pick_best_route: bool,
82    },
83    /// Queries the simulated result of a PlaceLimit order
84    EstimatePlaceLimitOrder {
85        creator: String,
86        receiver: String,
87        token_in: String,
88        token_out: String,
89        tick_index_in_to_out: i64,
90        amount_in: Int128,
91        order_type: LimitOrderType,
92        // expirationTime is only valid iff orderType == GOOD_TIL_TIME.
93        expiration_time: Option<u64>,
94        max_amount_out: Option<Int128>,
95    },
96    /// Queries a pool by pair, tick and fee
97    Pool {
98        pair_id: String,
99        tick_index: i64,
100        fee: u64,
101    },
102    /// Queries a pool by ID
103    #[serde(rename = "pool_by_id")]
104    PoolByID { pool_id: u64 },
105    /// Queries a PoolMetadata by ID
106    PoolMetadata { id: u64 },
107    /// Queries a list of PoolMetadata items.
108    PoolMetadataAll { pagination: Option<PageRequest> },
109}
110
111#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
112#[serde(rename_all = "snake_case")]
113pub struct ParamsResponse {
114    pub params: Params,
115}
116
117#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
118#[serde(rename_all = "snake_case")]
119pub struct LimitOrderTrancheUserResponse {
120    pub limit_order_tranche_user: Option<LimitOrderTrancheUser>,
121}
122
123#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
124#[serde(rename_all = "snake_case")]
125pub struct AllLimitOrderTrancheUserResponse {
126    #[serde(default)]
127    pub limit_order_tranche_user: Vec<LimitOrderTrancheUser>,
128    pub pagination: Option<PageResponse>,
129}
130
131#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
132#[serde(rename_all = "snake_case")]
133pub struct AllUserLimitOrdersResponse {
134    #[serde(default)]
135    pub limit_orders: Vec<LimitOrderTrancheUser>,
136    pub pagination: Option<PageResponse>,
137}
138
139#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
140#[serde(rename_all = "snake_case")]
141pub struct LimitOrderTrancheResponse {
142    pub limit_order_tranche: Option<LimitOrderTranche>,
143}
144
145#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
146#[serde(rename_all = "snake_case")]
147pub struct AllLimitOrderTrancheResponse {
148    #[serde(default)]
149    pub limit_order_tranche: Vec<LimitOrderTranche>,
150    pub pagination: Option<PageResponse>,
151}
152
153#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
154#[serde(rename_all = "snake_case")]
155pub struct AllUserDepositsResponse {
156    #[serde(default)]
157    pub deposits: Vec<DepositRecord>,
158    pub pagination: Option<PageResponse>,
159}
160
161#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
162#[serde(rename_all = "snake_case")]
163pub struct AllTickLiquidityResponse {
164    pub tick_liquidity: Vec<TickLiquidity>,
165    pub pagination: Option<PageResponse>,
166}
167
168#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
169#[serde(rename_all = "snake_case")]
170pub struct InactiveLimitOrderTrancheResponse {
171    pub inactive_limit_order_tranche: LimitOrderTranche,
172}
173
174#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
175#[serde(rename_all = "snake_case")]
176pub struct AllInactiveLimitOrderTrancheResponse {
177    pub inactive_limit_order_tranche: Vec<LimitOrderTranche>,
178    pub pagination: Option<PageResponse>,
179}
180
181#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
182#[serde(rename_all = "snake_case")]
183pub struct AllPoolReservesResponse {
184    pub pool_reserves: Vec<PoolReserves>,
185    pub pagination: Option<PageResponse>,
186}
187
188#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
189#[serde(rename_all = "snake_case")]
190pub struct PoolReservesResponse {
191    pub pool_reserves: PoolReserves,
192}
193
194#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
195#[serde(rename_all = "snake_case")]
196pub struct EstimateMultiHopSwapResponse {
197    pub coin_out: Coin,
198}
199
200#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
201#[serde(rename_all = "snake_case")]
202pub struct EstimatePlaceLimitOrderResponse {
203    /// Total amount of coin used for the limit order
204    /// You can derive makerLimitInCoin using the equation: totalInCoin = swapInCoin + makerLimitInCoin
205    pub total_in_coin: Coin,
206    /// Total amount of the token in that was immediately swapped for swapOutCoin
207    pub swap_in_coin: Coin,
208    /// Total amount of coin received from the taker portion of the limit order
209    /// This is the amount of coin immediately available in the users account after executing the
210    /// limit order. It does not include any future proceeds from the maker portion which will have withdrawn in the future
211    pub swap_out_coin: Coin,
212}
213
214#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
215#[serde(rename_all = "snake_case")]
216pub struct PoolResponse {
217    pub pool: Pool,
218}
219
220#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
221#[serde(rename_all = "snake_case")]
222pub struct PoolMetadataResponse {
223    pub pool_metadata: PoolMetadata,
224}
225
226#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
227#[serde(rename_all = "snake_case")]
228pub struct AllPoolMetadataResponse {
229    pub pool_metadata: Vec<PoolMetadata>,
230    pub pagination: Option<PageResponse>,
231}