Skip to content

Commit 16f950a

Browse files
committed
add new sim messages
1 parent 612ea5a commit 16f950a

File tree

3 files changed

+91
-5
lines changed

3 files changed

+91
-5
lines changed

packages/neutron-sdk/src/bindings/dex/msg.rs

+39
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,42 @@ pub enum DexMsg {
9898
pick_best_route: bool,
9999
},
100100
}
101+
102+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
103+
#[serde(rename_all = "snake_case")]
104+
pub struct PlaceLimitOrder {
105+
/// Account to which TokenOut is credited or that will be allowed to
106+
/// withdraw or cancel a maker order
107+
receiver: String,
108+
/// Token being “sold”
109+
token_in: String,
110+
/// Token being “bought”
111+
token_out: String,
112+
/// Limit tick for a limit order, specified in terms of TokenIn to TokenOut
113+
tick_index_in_to_out: i64,
114+
/// Amount of TokenIn to be traded
115+
amount_in: Uint128,
116+
/// Type of limit order to be used. Must be one of:
117+
/// GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME
118+
order_type: LimitOrderType,
119+
// expirationTime is only valid if orderType == GOOD_TIL_TIME.
120+
/// Expiration time for order. Only valid for GOOD_TIL_TIME limit orders
121+
expiration_time: Option<u64>,
122+
/// Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType
123+
max_amount_out: Option<Uint128>,
124+
}
125+
126+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
127+
#[serde(rename_all = "snake_case")]
128+
pub struct MultiHopSwap {
129+
/// Account to which TokenOut is credited
130+
receiver: String,
131+
/// Array of possible routes
132+
routes: Vec<MultiHopRoute>,
133+
/// Amount of TokenIn to swap
134+
amount_in: Uint128,
135+
/// Minimum price that that must be satisfied for a route to succeed
136+
exit_limit_price: PrecDec,
137+
/// If true all routes are run and the route with the best price is used
138+
pick_best_route: bool,
139+
}

packages/neutron-sdk/src/bindings/dex/query.rs

+37-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
use crate::bindings::dex::msg::{MultiHopSwap, PlaceLimitOrder};
12
use crate::bindings::dex::types::{
23
DepositRecord, LimitOrderTranche, LimitOrderTrancheUser, LimitOrderType, MultiHopRoute, Params,
34
Pool, PoolMetadata, PoolReserves, PrecDec, TickLiquidity,
45
};
56
use crate::bindings::query::{PageRequest, PageResponse};
7+
use crate::stargate::dex::types::{MultiHopSwapResponse, PlaceLimitOrderResponse};
68
use cosmwasm_std::{Coin, Int128};
79
use schemars::JsonSchema;
810
use serde::{Deserialize, Serialize};
@@ -18,7 +20,9 @@ pub enum DexQuery {
1820
tranche_key: String,
1921
},
2022
/// Queries a list of LimitOrderTrancheMap items.
21-
LimitOrderTrancheUserAll { pagination: Option<PageRequest> },
23+
LimitOrderTrancheUserAll {
24+
pagination: Option<PageRequest>,
25+
},
2226
/// Queries a list of LimitOrderTrancheUser items for a given address.
2327
LimitOrderTrancheUserAllByAddress {
2428
address: String,
@@ -57,7 +61,9 @@ pub enum DexQuery {
5761
tranche_key: String,
5862
},
5963
/// Queries a list of InactiveLimitOrderTranche items.
60-
InactiveLimitOrderTrancheAll { pagination: Option<PageRequest> },
64+
InactiveLimitOrderTrancheAll {
65+
pagination: Option<PageRequest>,
66+
},
6167
/// Queries a list of PoolReserves items.
6268
PoolReservesAll {
6369
pair_id: String,
@@ -101,11 +107,25 @@ pub enum DexQuery {
101107
},
102108
/// Queries a pool by ID
103109
#[serde(rename = "pool_by_id")]
104-
PoolByID { pool_id: u64 },
110+
PoolByID {
111+
pool_id: u64,
112+
},
105113
/// Queries a PoolMetadata by ID
106-
PoolMetadata { id: u64 },
114+
PoolMetadata {
115+
id: u64,
116+
},
107117
/// Queries a list of PoolMetadata items.
108-
PoolMetadataAll { pagination: Option<PageRequest> },
118+
PoolMetadataAll {
119+
pagination: Option<PageRequest>,
120+
},
121+
122+
SimulatePlaceLimitOrder {
123+
msg: PlaceLimitOrder,
124+
},
125+
126+
SimulateMultihopSwap {
127+
msg: MultiHopSwap,
128+
},
109129
}
110130

111131
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
@@ -229,3 +249,15 @@ pub struct AllPoolMetadataResponse {
229249
pub pool_metadata: Vec<PoolMetadata>,
230250
pub pagination: Option<PageResponse>,
231251
}
252+
253+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
254+
#[serde(rename_all = "snake_case")]
255+
pub struct SimulatePlaceLimitOrderResponse {
256+
pub resp: PlaceLimitOrderResponse,
257+
}
258+
259+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
260+
#[serde(rename_all = "snake_case")]
261+
pub struct SimulateMultiHopSwapResponse {
262+
pub resp: MultiHopSwapResponse,
263+
}

packages/neutron-sdk/src/stargate/dex/types.rs

+15
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ pub struct MultiHopSwapRequest {
198198
pub pick_best_route: bool,
199199
}
200200

201+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
202+
pub struct MultiHopSwapResponse {
203+
pub coin_out: Coin,
204+
pub route: Vec<String>,
205+
pub dust: Vec<Coin>,
206+
}
207+
201208
impl From<MultiHopSwapRequest> for MsgMultiHopSwap {
202209
fn from(v: MultiHopSwapRequest) -> MsgMultiHopSwap {
203210
MsgMultiHopSwap {
@@ -558,6 +565,14 @@ pub struct EstimatePlaceLimitOrderResponse {
558565
pub swap_out_coin: Coin,
559566
}
560567

568+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
569+
pub struct PlaceLimitOrderResponse {
570+
pub tranche_key: String,
571+
pub coin_in: Option<Coin>,
572+
pub taker_coin_out: Option<Coin>,
573+
pub taker_coin_in: Option<Coin>,
574+
}
575+
561576
impl From<EstimatePlaceLimitOrderRequest> for QueryEstimatePlaceLimitOrderRequest {
562577
fn from(v: EstimatePlaceLimitOrderRequest) -> QueryEstimatePlaceLimitOrderRequest {
563578
QueryEstimatePlaceLimitOrderRequest {

0 commit comments

Comments
 (0)