Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
docs: create margin order update
Browse files Browse the repository at this point in the history
  • Loading branch information
politeWall committed Dec 6, 2023
1 parent 071e393 commit 6c93868
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
16 changes: 9 additions & 7 deletions front_end_script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,20 @@ getSpotOrders(
);
```

### 6. createMarginOrder(position, collateral, leverage, borrow_asset, take_profit_price, order_type, trigger_price)
### 6. createMarginOrder(position, collateral, leverage, trading_asset, take_profit_price, order_type, trigger_price)

This function allows you to create a margin order by sending a transaction to the CosmWasm contract.

#### Parameters

- `position` (String): The type of position for the margin order (e.g., "long", "short").
- `collateral` (Coin {demom: String , amount : String}): The amount of collateral for the margin order.
- `leverage` (String): The leverage for the margin order.
- `borrow_asset` (String): The asset to borrow for the margin order.
- `take_profit_price` (String): The price at which the order will take profit.
- `position` (String): The type of position for the margin order (e.g., "long", "short"). Can be null if it's not a LimitOpen or MarketOpen type
- `leverage` (String): The leverage for the margin order.Can be null if it's not a LimitOpen or MarketOpen type
- `trading_asset` (String): The asset to borrow for the margin order. Can be null if it's not a LimitOpen or MarketOpen type
- `take_profit_price` (String): The price at which the order will take profit. Can be null if it's not a LimitOpen or MarketOpen type
- `order_type` (String): The type of the order (e.g., "stop_loss", "limit_sell", "limit_buy").
- `trigger_price` ({`base_denom`:String, `quote_denom`:String, `rate` :String} or null): Price relates two assets exchange rate that the user should define, can only be null if the order type is "market_type"
- `position_id` (u64) Can be null if it's not a LimitClose, MarketClose or StopLoss type

#### Usage

Expand All @@ -169,10 +170,11 @@ createMarginOrder(
"position_type",
"collateral",
"leverage_value",
"borrow_asset",
"trading_asset",
"take_profit_price",
"order_type",
"trigger_price"
"position_id"
);
```

Expand All @@ -187,6 +189,7 @@ createMarginOrder(
"2.2"
"limit_buy",
{ base_denom: "ueth", quote_denom: "uusdc", rate: "2076.5" }
null
);
```

Expand Down Expand Up @@ -216,7 +219,6 @@ This function retrieves information about a specific margin order by querying a

#### Parameters

- `address` (String): The address associated with the margin order.
- `order_id` (String): The unique identifier for the order you want to retrieve.

#### Usage
Expand Down
11 changes: 5 additions & 6 deletions front_end_script/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ async function getSpotOrder(order_id) {
}

async function createSpotOrder(
order_amm_routes,
order_price,
order_type,
amount_send,
Expand All @@ -62,7 +61,6 @@ async function createSpotOrder(
const executeFee = calculateFee(300_000, gasPrice);
const msg = {
create_spot_order: {
order_amm_routes: order_amm_routes,
order_price: order_price,
order_type: order_type,
order_source_denom: denom_send,
Expand Down Expand Up @@ -185,10 +183,11 @@ async function createMarginOrder(
position_type,
collateral,
leverage_value,
borrow_asset,
trading_asset,
take_profit_price,
order_type,
trigger_price
trigger_price,
position_id
) {
const gasPrice = GasPrice.fromString(GASPRICE);
const sender_wallet = await DirectSecp256k1HdWallet.fromMnemonic(
Expand All @@ -203,9 +202,9 @@ async function createMarginOrder(
const msg = {
create_margin_order: {
position_type: position_type,
collateral: collateral,
leverage_value: leverage_value,
borrow_asset: borrow_asset,
trading_asset: trading_asset,
position_id: position_id,
take_profit_price: take_profit_price,
order_type: order_type,
trigger_price: trigger_price,
Expand Down

0 comments on commit 6c93868

Please sign in to comment.