diff --git a/Cargo.lock b/Cargo.lock index 6406a7e..a55bb90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#3c831143e4eb7998433322e85f167c88166d087f" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#15cd9798050948db3295a2f2b57d506d5e4acf80" dependencies = [ "bech32 0.9.1", "chrono", @@ -1151,8 +1151,8 @@ dependencies = [ [[package]] name = "neutron-std" -version = "5.0.0" -source = "git+https://github.com/neutron-org/neutron-std?branch=main#b17f083c0617dab1daa5c6dfb69bc63255006499" +version = "6.0.0" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#f8c350c9de7fe02b383bd10a9c2bbdf13e854d44" dependencies = [ "bech32 0.9.1", "chrono", @@ -1176,7 +1176,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=main#b17f083c0617dab1daa5c6dfb69bc63255006499" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#f8c350c9de7fe02b383bd10a9c2bbdf13e854d44" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index df4272e..db1f583 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -1,3 +1,5 @@ +use std::str::FromStr; + use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, @@ -8,6 +10,7 @@ use neutron_std::types::neutron::dex::{ DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal, }; +use neutron_std::types::neutron::util::precdec::PrecDec; const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -88,7 +91,7 @@ pub fn execute( token_in, token_out, tick_index_in_to_out, - limit_sell_price: Some(limit_sell_price), + limit_sell_price: Some(PrecDec::from_str(&limit_sell_price)?.to_prec_dec_string()), amount_in, order_type, expiration_time, @@ -120,7 +123,7 @@ pub fn execute( receiver, routes, amount_in, - exit_limit_price, + exit_limit_price: PrecDec::from_str(&exit_limit_price)?.to_prec_dec_string(), pick_best_route, })), } @@ -241,7 +244,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { receiver, routes, amount_in, - exit_limit_price, + PrecDec::from_str(&exit_limit_price)?.to_prec_dec_string(), pick_best_route, )?)?), @@ -292,9 +295,15 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &dex_querier.simulate_withdrawal(Some(msg))?, )?), - QueryMsg::SimulatePlaceLimitOrder { msg } => Ok(to_json_binary( - &dex_querier.simulate_place_limit_order(Some(msg))?, - )?), + QueryMsg::SimulatePlaceLimitOrder { msg } => { + let mut msg = msg; + if let Some(price) = msg.limit_sell_price { + msg.limit_sell_price = Some(PrecDec::from_str(&price)?.to_prec_dec_string()); + } + Ok(to_json_binary( + &dex_querier.simulate_place_limit_order(Some(msg))?, + )?) + } QueryMsg::SimulateWithdrawFilledLimitOrder { msg } => Ok(to_json_binary( &dex_querier.simulate_withdraw_filled_limit_order(Some(msg))?, @@ -304,9 +313,13 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &dex_querier.simulate_cancel_limit_order(Some(msg))?, )?), - QueryMsg::SimulateMultiHopSwap { msg } => Ok(to_json_binary( - &dex_querier.simulate_multi_hop_swap(Some(msg))?, - )?), + QueryMsg::SimulateMultiHopSwap { msg } => { + let mut msg = msg; + msg.exit_limit_price = PrecDec::from_str(&msg.exit_limit_price)?.to_prec_dec_string(); + Ok(to_json_binary( + &dex_querier.simulate_multi_hop_swap(Some(msg))?, + )?) + } } }