diff --git a/src/action/execute/create_margin_order.rs b/src/action/execute/create_margin_order.rs index 0712b57..51fae5a 100644 --- a/src/action/execute/create_margin_order.rs +++ b/src/action/execute/create_margin_order.rs @@ -127,6 +127,12 @@ fn create_margin_open_order( return Err(StdError::generic_err("not valid collateral").into()); } + if let Some(price) = &trigger_price { + if price.rate.is_zero() { + return Err(StdError::generic_err("trigger_price: The rate cannot be zero").into()); + } + } + let order = MarginOrder::new_open( &info.sender, &position, @@ -222,6 +228,12 @@ fn create_margin_close_order( return Err(StdError::generic_err("this position had an order already assigned").into()); }; + if let Some(price) = &trigger_price { + if price.rate.is_zero() { + return Err(StdError::generic_err("trigger_price: The rate cannot be zero").into()); + } + } + let order = MarginOrder::new_close( &info.sender, mtp.position, diff --git a/src/action/execute/create_spot_order.rs b/src/action/execute/create_spot_order.rs index 2f128e3..87a0edc 100644 --- a/src/action/execute/create_spot_order.rs +++ b/src/action/execute/create_spot_order.rs @@ -24,6 +24,12 @@ pub fn create_spot_order( return Err(StdError::not_found("order price").into()); } + if let Some(price) = &order_price { + if price.rate.is_zero() { + return Err(StdError::generic_err("order_price: The rate cannot be zero").into()); + } + } + check_denom_error( &order_source_denom, &order_target_denom,