diff --git a/front_end_script/README.md b/front_end_script/README.md index a5f0f1d..b1b02ce 100644 --- a/front_end_script/README.md +++ b/front_end_script/README.md @@ -161,7 +161,13 @@ createMarginOrder( #### Exemple ```javascript -createMarginOrder("short", { denom: "BTC", amount: "2" }, "4.3", "ETH", "2.2"); +createMarginOrder( + "short", + { denom: "uusdc", amount: "2002" }, + "4.3", + "ueth", + "2.2" +); ``` ### 7. cancelMarginOrder(order_id) diff --git a/src/action/execute/create_margin_order.rs b/src/action/execute/create_margin_order.rs index a9344a1..0c03648 100644 --- a/src/action/execute/create_margin_order.rs +++ b/src/action/execute/create_margin_order.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_json_binary, Coin, Decimal, Int128, SubMsg}; +use cosmwasm_std::{to_json_binary, Coin, Decimal, Int128, StdError, SubMsg}; use crate::msg::ReplyType; @@ -21,6 +21,12 @@ pub fn create_margin_order( return Err(ContractError::CollateralAmount); } + if position == MarginPosition::Short && collateral.denom == "uusdc" { + return Err( + StdError::generic_err("the collateral asset for a short can only be USDC").into(), + ); + } + cw_utils::must_pay(&info, &info.funds[0].denom)?; let borrow_token = Coin {