diff --git a/bindings-test/src/multitest.rs b/bindings-test/src/multitest.rs index 94faf49a..ced0e14c 100644 --- a/bindings-test/src/multitest.rs +++ b/bindings-test/src/multitest.rs @@ -330,7 +330,12 @@ impl Module for ElysModule { .find(|mtp| mtp.id == id && mtp.address == address) .cloned() { - Ok(to_json_binary(&PerpetualMtpResponse { mtp: Some(mtp) })?) + Ok(to_json_binary(&PerpetualMtpResponse { + mtp: Some(MtpAndPrice { + mtp: mtp, + trading_asset_price: Decimal::zero(), + }), + })?) } else { return Err(Error::new(StdError::not_found( "perpetual trading position", diff --git a/bindings-test/src/tests.rs b/bindings-test/src/tests.rs index 1cd94204..a5985291 100644 --- a/bindings-test/src/tests.rs +++ b/bindings-test/src/tests.rs @@ -225,7 +225,7 @@ fn query_single_mtp() { let mtp_found: PerpetualMtpResponse = app.wrap().query(&req).unwrap(); - assert_eq!(mtps[0], mtp_found.mtp.unwrap()); + assert_eq!(mtps[0], mtp_found.mtp.unwrap().mtp); } #[test] diff --git a/bindings/src/query_resp.rs b/bindings/src/query_resp.rs index 8fabf976..b822a3e1 100644 --- a/bindings/src/query_resp.rs +++ b/bindings/src/query_resp.rs @@ -74,7 +74,7 @@ pub struct PerpetualQueryPositionsResponse { #[cw_serde] pub struct PerpetualMtpResponse { - pub mtp: Option, + pub mtp: Option, } #[cw_serde] diff --git a/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs b/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs index 376978a5..a66e1428 100644 --- a/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs +++ b/contracts/trade-shield-contract/src/action/execute/create_perpetual_order.rs @@ -326,7 +326,7 @@ fn create_perpetual_close_order( .into()); } - if price.quote_denom != mtp.trading_asset { + if price.quote_denom != mtp.mtp.trading_asset { return Err(StdError::generic_err( "trigger_price: The quote denom should be the trading asset denom", ) @@ -371,14 +371,14 @@ fn create_perpetual_close_order( let order = PerpetualOrderV2::new_close( &info.sender, - mtp.position, + mtp.mtp.position, &order_type, - &coin(mtp.collateral.i128() as u128, &mtp.collateral_asset), - &mtp.trading_asset, - &mtp.leverage, + &coin(mtp.mtp.collateral.i128() as u128, &mtp.mtp.collateral_asset), + &mtp.mtp.trading_asset, + &mtp.mtp.leverage, position_id, &trigger_price, - &Some(mtp.take_profit_price), + &Some(mtp.mtp.take_profit_price), &orders, )?; @@ -409,8 +409,12 @@ fn create_perpetual_close_order( let number_of_executed_order = NUMBER_OF_EXECUTED_ORDER.load(deps.storage)? + 1; NUMBER_OF_EXECUTED_ORDER.save(deps.storage, &number_of_executed_order)?; - let msg = - ElysMsg::perpetual_close_position(creator, position_id, mtp.custody.i128(), &info.sender); + let msg = ElysMsg::perpetual_close_position( + creator, + position_id, + mtp.mtp.custody.i128(), + &info.sender, + ); let reply_info_max_id = MAX_REPLY_ID.load(deps.storage)?; diff --git a/contracts/trade-shield-contract/src/action/query/get_perpetual_position.rs b/contracts/trade-shield-contract/src/action/query/get_perpetual_position.rs index 05c22a21..fb6dd607 100644 --- a/contracts/trade-shield-contract/src/action/query/get_perpetual_position.rs +++ b/contracts/trade-shield-contract/src/action/query/get_perpetual_position.rs @@ -14,7 +14,7 @@ pub fn get_perpetual_position( None => return Err(StdError::not_found("perpetual trading position").into()), }; - let mtp_plus = PerpetualPositionPlus::new(mtp, deps.storage, &querier)?; + let mtp_plus = PerpetualPositionPlus::new(mtp.mtp, deps.storage, &querier)?; Ok(GetPerpetualPositionResp { mtp: mtp_plus }) } diff --git a/contracts/trade-shield-contract/src/action/sudo/process_orders.rs b/contracts/trade-shield-contract/src/action/sudo/process_orders.rs index 5a9904fc..15383f5d 100644 --- a/contracts/trade-shield-contract/src/action/sudo/process_orders.rs +++ b/contracts/trade-shield-contract/src/action/sudo/process_orders.rs @@ -214,7 +214,7 @@ fn process_perpetual_order( } }; - let amount = mtp.custody.i128(); + let amount = mtp.mtp.custody.i128(); ( ElysMsg::perpetual_close_position( creator,