@orderly.network/ui-orders 2.10.2 → 2.11.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -289,7 +289,7 @@ var init_shareButton_script = __esm({
289
289
  const refCode = React2.useMemo(() => {
290
290
  return getFirstRefCode()?.code;
291
291
  }, [getFirstRefCode]);
292
- const leverage = hooks.useLeverageBySymbol(order.symbol);
292
+ const leverage = hooks.useLeverageBySymbol(order.symbol, order.margin_mode);
293
293
  const showModal = () => {
294
294
  ui.modal.show(props.modalId, {
295
295
  pnl: {
@@ -827,6 +827,9 @@ var init_activedPriceCell = __esm({
827
827
  algo_order_id: order.algo_order_id,
828
828
  activated_price: value
829
829
  };
830
+ if (order.margin_mode !== void 0) {
831
+ data.margin_mode = order.margin_mode;
832
+ }
830
833
  editAlgoOrder(order.algo_order_id.toString(), data).then((result) => {
831
834
  closePopover();
832
835
  setValue(value);
@@ -965,6 +968,9 @@ var init_priceCell = __esm({
965
968
  if (order.client_order_id) {
966
969
  data.client_order_id = order.client_order_id;
967
970
  }
971
+ if (order.margin_mode !== void 0) {
972
+ data.margin_mode = order.margin_mode;
973
+ }
968
974
  if (isAlgoOrder) {
969
975
  order_id = order.algo_order_id;
970
976
  data = {
@@ -1393,6 +1399,9 @@ var init_quantityCell = __esm({
1393
1399
  if (order?.tag !== void 0) {
1394
1400
  params["order_tag"] = order.tag;
1395
1401
  }
1402
+ if (order.margin_mode !== void 0) {
1403
+ params.margin_mode = order.margin_mode;
1404
+ }
1396
1405
  let future;
1397
1406
  if ("algo_type" in order && order.algo_type === types.AlgoOrderRootType.TP_SL) {
1398
1407
  future = onUpdateTPSLOrder(order, params);
@@ -1558,7 +1567,10 @@ var init_quantityCell = __esm({
1558
1567
  confirmOpen,
1559
1568
  order
1560
1569
  } = props;
1561
- const maxBuyQty = hooks.useMaxQty(symbol, order.side, order.reduce_only);
1570
+ const maxBuyQty = hooks.useMaxQty(symbol, order.side, {
1571
+ reduceOnly: order.reduce_only,
1572
+ marginMode: order.margin_mode ?? types.MarginMode.CROSS
1573
+ });
1562
1574
  const maxQty = React2.useMemo(() => {
1563
1575
  if (reduce_only) {
1564
1576
  return Math.abs(positionQty ?? 0);
@@ -1793,6 +1805,9 @@ var init_trailingCallbackCell = __esm({
1793
1805
  callback_value: isCallbackValue ? value : void 0,
1794
1806
  callback_rate: isCallbackRate ? `${Number(value) / 100}` : void 0
1795
1807
  };
1808
+ if (order.margin_mode !== void 0) {
1809
+ data.margin_mode = order.margin_mode;
1810
+ }
1796
1811
  editAlgoOrder(order.algo_order_id.toString(), data).then((result) => {
1797
1812
  closePopover();
1798
1813
  setValue(value);
@@ -1909,6 +1924,9 @@ var init_triggerPriceCell = __esm({
1909
1924
  trigger_price: value,
1910
1925
  algo_order_id: order.algo_order_id
1911
1926
  };
1927
+ if (order.margin_mode !== void 0) {
1928
+ data.margin_mode = order.margin_mode;
1929
+ }
1912
1930
  editAlgoOrder(`${order.algo_order_id}`, data).then((result) => {
1913
1931
  closePopover();
1914
1932
  setValue(value);
@@ -4709,6 +4727,7 @@ var init_useEditOrderEntry = __esm({
4709
4727
  side: order.side,
4710
4728
  reduce_only: order.reduce_only,
4711
4729
  order_type: orderType,
4730
+ margin_mode: order.margin_mode,
4712
4731
  // TODO: trailing stop order edit price twice, order.price will be 0
4713
4732
  order_price: order.price || void 0,
4714
4733
  order_quantity: order.quantity,
@@ -4769,7 +4788,10 @@ var init_useEditOrderEntry = __esm({
4769
4788
  });
4770
4789
  function useEditOrderMaxQty(order, positionQty) {
4771
4790
  const { reduce_only } = order;
4772
- const maxQty = hooks.useMaxQty(order.symbol, order.side, reduce_only);
4791
+ const maxQty = hooks.useMaxQty(order.symbol, order.side, {
4792
+ reduceOnly: reduce_only,
4793
+ marginMode: order.margin_mode ?? types.MarginMode.CROSS
4794
+ });
4773
4795
  return React2.useMemo(() => {
4774
4796
  if (reduce_only) {
4775
4797
  return Math.abs(positionQty ?? 0);