@kodiak-finance/orderly-ui-positions 2.9.2 → 2.9.3

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
@@ -7,9 +7,8 @@ var orderlyTypes = require('@kodiak-finance/orderly-types');
7
7
  var orderlyUtils = require('@kodiak-finance/orderly-utils');
8
8
  var orderlyHooks = require('@kodiak-finance/orderly-hooks');
9
9
  var jsxRuntime = require('react/jsx-runtime');
10
- var immer = require('immer');
11
- var orderlyPerp = require('@kodiak-finance/orderly-perp');
12
10
  var orderlyReactApp = require('@kodiak-finance/orderly-react-app');
11
+ var orderlyPerp = require('@kodiak-finance/orderly-perp');
13
12
  var orderlyUiConnector = require('@kodiak-finance/orderly-ui-connector');
14
13
  var orderlyUiLeverage = require('@kodiak-finance/orderly-ui-leverage');
15
14
  var orderlyUiShare = require('@kodiak-finance/orderly-ui-share');
@@ -34,7 +33,7 @@ var ConfirmHeader = (props) => {
34
33
  "button",
35
34
  {
36
35
  onClick: props.onClose,
37
- className: "oui-absolute oui-right-0 oui-top-0 oui-p-2 oui-text-base-contrast-54 hover:oui-text-base-contrast-80",
36
+ className: "oui-absolute oui-end-0 oui-top-0 oui-p-2 oui-text-base-contrast-54 hover:oui-text-base-contrast-80",
38
37
  children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.CloseIcon, { size: 18, color: "white" })
39
38
  }
40
39
  )
@@ -603,6 +602,102 @@ var FundingFeeButton = ({ fee, symbol, start_t, end_t }) => {
603
602
  )
604
603
  ] });
605
604
  };
605
+ var calculatePositions = (positions2, symbolsInfo, accountInfo, tpslOrders) => {
606
+ return positions2.map((item) => {
607
+ const info = symbolsInfo[item.symbol];
608
+ const notional = orderlyPerp.positions.notional(item.position_qty, item.mark_price);
609
+ const account3 = accountInfo.find(
610
+ (acc) => acc.account_id === item.account_id
611
+ );
612
+ const baseMMR = info?.("base_mmr");
613
+ const baseIMR = info?.("base_imr");
614
+ if (!baseMMR || !baseIMR) {
615
+ return item;
616
+ }
617
+ const MMR = orderlyPerp.positions.MMR({
618
+ baseMMR,
619
+ baseIMR,
620
+ IMRFactor: account3?.imr_factor[item.symbol] ?? 0,
621
+ positionNotional: notional,
622
+ IMR_factor_power: 4 / 5
623
+ });
624
+ const mm = orderlyPerp.positions.maintenanceMargin({
625
+ positionQty: item.position_qty,
626
+ markPrice: item.mark_price,
627
+ MMR
628
+ });
629
+ const unrealPnl = orderlyPerp.positions.unrealizedPnL({
630
+ qty: item.position_qty,
631
+ openPrice: item?.average_open_price,
632
+ markPrice: item.mark_price
633
+ });
634
+ const maxLeverage = item.leverage || 1;
635
+ const imr = orderlyPerp.account.IMR({
636
+ maxLeverage,
637
+ baseIMR,
638
+ IMR_Factor: account3?.imr_factor[item.symbol] ?? 0,
639
+ positionNotional: notional,
640
+ ordersNotional: 0,
641
+ IMR_factor_power: 4 / 5
642
+ });
643
+ const unrealPnlROI = orderlyPerp.positions.unrealizedPnLROI({
644
+ positionQty: item.position_qty,
645
+ openPrice: item.average_open_price,
646
+ IMR: imr,
647
+ unrealizedPnL: unrealPnl
648
+ });
649
+ let unrealPnl_index = 0;
650
+ let unrealPnlROI_index = 0;
651
+ if (item.index_price) {
652
+ unrealPnl_index = orderlyPerp.positions.unrealizedPnL({
653
+ qty: item.position_qty,
654
+ openPrice: item?.average_open_price,
655
+ markPrice: item.index_price
656
+ });
657
+ unrealPnlROI_index = orderlyPerp.positions.unrealizedPnLROI({
658
+ positionQty: item.position_qty,
659
+ openPrice: item.average_open_price,
660
+ IMR: imr,
661
+ unrealizedPnL: unrealPnl_index
662
+ });
663
+ }
664
+ const filteredTPSLOrders = tpslOrders.filter(
665
+ (tpslOrder) => tpslOrder.account_id === item.account_id
666
+ );
667
+ const tpsl = formatTPSL(filteredTPSLOrders, item.symbol, item.margin_mode);
668
+ return {
669
+ ...item,
670
+ ...tpsl,
671
+ mmr: MMR,
672
+ mm,
673
+ notional,
674
+ unrealized_pnl: unrealPnl,
675
+ unrealized_pnl_ROI: unrealPnlROI,
676
+ unrealized_pnl_ROI_index: unrealPnlROI_index
677
+ };
678
+ });
679
+ };
680
+ function formatTPSL(tpslOrders, symbol, marginMode) {
681
+ if (Array.isArray(tpslOrders) && tpslOrders.length) {
682
+ const { fullPositionOrder, partialPositionOrders } = orderlyHooks.findPositionTPSLFromOrders(tpslOrders, symbol, marginMode);
683
+ const full_tp_sl = fullPositionOrder ? orderlyHooks.findTPSLFromOrder(fullPositionOrder) : void 0;
684
+ const partialPossitionOrder = partialPositionOrders && partialPositionOrders.length ? partialPositionOrders[0] : void 0;
685
+ const partial_tp_sl = partialPossitionOrder ? orderlyHooks.findTPSLFromOrder(partialPossitionOrder) : void 0;
686
+ return {
687
+ full_tp_sl: {
688
+ tp_trigger_price: full_tp_sl?.tp_trigger_price,
689
+ sl_trigger_price: full_tp_sl?.sl_trigger_price,
690
+ algo_order: fullPositionOrder
691
+ },
692
+ partial_tp_sl: {
693
+ order_num: partialPositionOrders?.length ?? 0,
694
+ tp_trigger_price: partial_tp_sl?.tp_trigger_price,
695
+ sl_trigger_price: partial_tp_sl?.sl_trigger_price,
696
+ algo_order: partialPossitionOrder
697
+ }
698
+ };
699
+ }
700
+ }
606
701
  var signatureMiddleware = (account3, accountId) => {
607
702
  const apiBaseUrl = orderlyHooks.useConfig("apiBaseUrl");
608
703
  return (useSWRNext) => {
@@ -652,6 +747,48 @@ var useSubAccountQuery = (query, options) => {
652
747
  }
653
748
  );
654
749
  };
750
+ function useSubAccountTPSL(subAccountIds) {
751
+ const ee = orderlyHooks.useEventEmitter();
752
+ const { data: algoOrdersResponse, mutate: mutateTPSLOrders } = useSubAccountQuery(
753
+ `/v1/algo/orders?size=100&page=1&status=${orderlyTypes.OrderStatus.INCOMPLETE}`,
754
+ {
755
+ accountId: subAccountIds,
756
+ formatter: (data) => data,
757
+ revalidateOnFocus: false
758
+ }
759
+ );
760
+ const tpslOrders = React3.useMemo(() => {
761
+ if (!Array.isArray(algoOrdersResponse)) {
762
+ return [];
763
+ }
764
+ const algoOrders = algoOrdersResponse?.map(
765
+ (item, index) => item.rows.map((order) => ({
766
+ ...order,
767
+ account_id: subAccountIds[index]
768
+ }))
769
+ )?.flat();
770
+ return algoOrders?.filter(
771
+ (order) => [orderlyTypes.AlgoOrderRootType.POSITIONAL_TP_SL, orderlyTypes.AlgoOrderRootType.TP_SL].includes(
772
+ order.algo_type
773
+ )
774
+ );
775
+ }, [algoOrdersResponse, subAccountIds]);
776
+ const refresh = orderlyHooks.useDebouncedCallback(() => {
777
+ mutateTPSLOrders();
778
+ }, 200);
779
+ React3.useEffect(() => {
780
+ const handler = (position) => {
781
+ if (position.account_id) {
782
+ refresh();
783
+ }
784
+ };
785
+ ee.on("tpsl:updateOrder", handler);
786
+ return () => {
787
+ ee.off("tpsl:updateOrder", handler);
788
+ };
789
+ }, [ee]);
790
+ return { tpslOrders, mutateTPSLOrders };
791
+ }
655
792
 
656
793
  // src/components/positions/combinePositions.script.ts
657
794
  var useCombinePositionsScript = (props) => {
@@ -665,12 +802,10 @@ var useCombinePositionsScript = (props) => {
665
802
  selectedAccount
666
803
  } = props;
667
804
  const { pagination, setPage } = orderlyUi.usePagination({ pageSize: 50 });
668
- React3.useEffect(() => {
669
- setPage(1);
670
- }, [symbol]);
671
805
  const symbolsInfo = orderlyHooks.useSymbolsInfo();
672
806
  const { state } = orderlyHooks.useAccount();
673
- const [oldPositions, , { isLoading }] = orderlyHooks.usePositionStream(symbol, {
807
+ const { t } = orderlyI18n.useTranslation();
808
+ const [mainAccountPositions, , { isLoading }] = orderlyHooks.usePositionStream(symbol, {
674
809
  calcMode,
675
810
  includedPendingOrder
676
811
  });
@@ -679,90 +814,37 @@ var useCombinePositionsScript = (props) => {
679
814
  isLoading: isPositionLoading,
680
815
  mutate: mutatePositions
681
816
  } = orderlyHooks.usePrivateQuery("/v1/client/aggregate/positions", {
682
- // formatter: (data) => data,
683
817
  errorRetryCount: 3
684
818
  });
819
+ const { allAccountIds, subAccountIds } = React3.useMemo(() => {
820
+ const uniqueIds = new Set(
821
+ newPositions.filter((item) => item.account_id).map((item) => item.account_id).filter(Boolean)
822
+ );
823
+ const allAccountIds2 = Array.from(uniqueIds);
824
+ const subAccountIds2 = allAccountIds2.filter(
825
+ (item) => item !== state.mainAccountId
826
+ );
827
+ return { allAccountIds: allAccountIds2, subAccountIds: subAccountIds2 };
828
+ }, [newPositions, state.mainAccountId]);
685
829
  const { data: accountInfo = [], isLoading: isAccountInfoLoading } = useSubAccountQuery("/v1/client/info", {
686
- accountId: newPositions.map((item) => item.account_id),
830
+ accountId: allAccountIds,
687
831
  revalidateOnFocus: false
688
832
  });
689
- const processPositions = immer.produce(
690
- newPositions.filter((acc) => acc.account_id !== state.mainAccountId),
691
- (draft) => {
692
- for (const item of draft) {
693
- const info = symbolsInfo[item.symbol];
694
- const notional = orderlyPerp.positions.notional(item.position_qty, item.mark_price);
695
- const account3 = accountInfo.find(
696
- (acc) => acc.account_id === item.account_id
697
- );
698
- const baseMMR = info?.("base_mmr");
699
- const baseIMR = info?.("base_imr");
700
- if (!baseMMR || !baseIMR) {
701
- continue;
702
- }
703
- const MMR = orderlyPerp.positions.MMR({
704
- baseMMR,
705
- baseIMR,
706
- IMRFactor: account3?.imr_factor[item.symbol] ?? 0,
707
- positionNotional: notional,
708
- IMR_factor_power: 4 / 5
709
- });
710
- const mm = orderlyPerp.positions.maintenanceMargin({
711
- positionQty: item.position_qty,
712
- markPrice: item.mark_price,
713
- MMR
714
- });
715
- const unrealPnl = orderlyPerp.positions.unrealizedPnL({
716
- qty: item.position_qty,
717
- openPrice: item?.average_open_price,
718
- // markPrice: unRealizedPrice,
719
- markPrice: item.mark_price
720
- });
721
- const maxLeverage = item.leverage || 1;
722
- const imr = orderlyPerp.account.IMR({
723
- maxLeverage,
724
- baseIMR,
725
- IMR_Factor: account3?.imr_factor[item.symbol] ?? 0,
726
- positionNotional: notional,
727
- ordersNotional: 0,
728
- IMR_factor_power: 4 / 5
729
- });
730
- const unrealPnlROI = orderlyPerp.positions.unrealizedPnLROI({
731
- positionQty: item.position_qty,
732
- openPrice: item.average_open_price,
733
- IMR: imr,
734
- unrealizedPnL: unrealPnl
735
- });
736
- let unrealPnl_index = 0;
737
- let unrealPnlROI_index = 0;
738
- if (item.index_price) {
739
- unrealPnl_index = orderlyPerp.positions.unrealizedPnL({
740
- qty: item.position_qty,
741
- openPrice: item?.average_open_price,
742
- // markPrice: unRealizedPrice,
743
- markPrice: item.index_price
744
- });
745
- unrealPnlROI_index = orderlyPerp.positions.unrealizedPnLROI({
746
- positionQty: item.position_qty,
747
- openPrice: item.average_open_price,
748
- IMR: imr,
749
- unrealizedPnL: unrealPnl_index
750
- });
751
- }
752
- item.mmr = MMR;
753
- item.mm = mm;
754
- item.notional = notional;
755
- item.unrealized_pnl = unrealPnl;
756
- item.unrealized_pnl_ROI = unrealPnlROI;
757
- item.unrealized_pnl_ROI_index = unrealPnlROI_index;
758
- }
759
- }
760
- );
761
- const dataSource = orderlyReactApp.useDataTap(
762
- [...oldPositions?.rows, ...processPositions].filter(
763
- (acc) => acc.position_qty !== 0
764
- )
765
- ) ?? [];
833
+ const { tpslOrders, mutateTPSLOrders } = useSubAccountTPSL(subAccountIds);
834
+ const subAccountPositions = React3.useMemo(() => {
835
+ return calculatePositions(
836
+ newPositions.filter((item) => item.account_id !== state.mainAccountId),
837
+ symbolsInfo,
838
+ accountInfo,
839
+ tpslOrders
840
+ );
841
+ }, [newPositions, symbolsInfo, accountInfo, state.mainAccountId, tpslOrders]);
842
+ const allPositions = React3.useMemo(() => {
843
+ return [...mainAccountPositions?.rows, ...subAccountPositions].filter(
844
+ (item) => item.position_qty !== 0
845
+ );
846
+ }, [mainAccountPositions, subAccountPositions]);
847
+ const dataSource = orderlyReactApp.useDataTap(allPositions) ?? [];
766
848
  const filtered = React3.useMemo(() => {
767
849
  if (!selectedAccount || selectedAccount === "All accounts" /* ALL */) {
768
850
  return dataSource;
@@ -778,35 +860,41 @@ var useCombinePositionsScript = (props) => {
778
860
  const groupDataSource = React3.useMemo(() => {
779
861
  return groupDataByAccount(filtered, {
780
862
  mainAccountId: state.mainAccountId,
863
+ mainAccountLabel: t("common.mainAccount"),
781
864
  subAccounts: state.subAccounts
782
865
  });
783
- }, [filtered, state.mainAccountId, state.subAccounts]);
784
- const mergedLoading = React3.useMemo(() => {
785
- return isLoading || isPositionLoading || isAccountInfoLoading;
786
- }, [isLoading, isPositionLoading, isAccountInfoLoading]);
866
+ }, [filtered, state.mainAccountId, state.subAccounts, t]);
867
+ const loading = isLoading || isPositionLoading || isAccountInfoLoading;
868
+ React3.useEffect(() => {
869
+ setPage(1);
870
+ }, [symbol]);
871
+ const mutateList = React3.useCallback(() => {
872
+ mutatePositions();
873
+ mutateTPSLOrders();
874
+ }, []);
787
875
  return {
788
876
  tableData: groupDataSource,
789
- isLoading: mergedLoading,
877
+ isLoading: loading,
790
878
  pnlNotionalDecimalPrecision,
791
879
  sharePnLConfig,
792
880
  symbol,
793
881
  onSymbolChange,
794
882
  pagination,
795
- mutatePositions
883
+ mutatePositions: mutateList
796
884
  };
797
885
  };
798
886
  var groupDataByAccount = (data, options) => {
799
- const { mainAccountId = "", subAccounts = [] } = options;
887
+ const { mainAccountId = "", mainAccountLabel, subAccounts = [] } = options;
800
888
  const map = /* @__PURE__ */ new Map();
801
889
  for (const item of data) {
802
890
  const accountId = item.account_id || mainAccountId;
803
- const findSubAccount = subAccounts.find((acc) => acc.id === accountId);
891
+ const findSubAccount = subAccounts.find((item2) => item2.id === accountId);
804
892
  if (map.has(accountId)) {
805
893
  map.get(accountId)?.children?.push(item);
806
894
  } else {
807
895
  map.set(accountId, {
808
- id: accountId,
809
- description: accountId === mainAccountId ? orderlyI18n.i18n.t("common.mainAccount") : findSubAccount?.description || orderlyUi.formatAddress(findSubAccount?.id || ""),
896
+ account_id: accountId,
897
+ description: accountId === mainAccountId ? mainAccountLabel : findSubAccount?.description || orderlyUi.formatAddress(findSubAccount?.id || ""),
810
898
  children: [item]
811
899
  });
812
900
  }
@@ -1390,7 +1478,7 @@ var ReversePositionWidget = (props) => {
1390
1478
  open: visible,
1391
1479
  onOpenChange,
1392
1480
  size: "sm",
1393
- title: orderlyI18n.i18n.t("positions.reverse.title"),
1481
+ title: t("positions.reverse.title"),
1394
1482
  classNames: {
1395
1483
  content: "oui-border oui-border-line-6"
1396
1484
  },
@@ -1538,29 +1626,29 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
1538
1626
  dp: 2
1539
1627
  }
1540
1628
  );
1541
- const positions3 = orderlyHooks.usePositions();
1629
+ const positions2 = orderlyHooks.usePositions();
1542
1630
  const total_cross_unsettled_pnl = React3.useMemo(() => {
1543
- return positions3?.filter((item) => (item.margin_mode ?? "CROSS") === "CROSS").reduce((acc, item) => acc.add(item.unsettled_pnl), new orderlyUtils.Decimal(0));
1544
- }, [positions3]);
1631
+ return positions2?.filter((item) => (item.margin_mode ?? "CROSS") === "CROSS").reduce((acc, item) => acc.add(item.unsettled_pnl), new orderlyUtils.Decimal(0));
1632
+ }, [positions2]);
1545
1633
  const fundingRates = orderlyHooks.useAppStore((state) => state.fundingRates);
1546
1634
  const symbolsInfo = orderlyHooks.useAppStore((state) => state.symbolsInfo);
1547
1635
  const accountInfo = orderlyHooks.useAppStore((state) => state.accountInfo);
1548
1636
  const { data: markPrice } = orderlyHooks.useMarkPrice(symbol);
1549
1637
  const totalUnsettlementPnl = React3.useMemo(() => {
1550
- if (!positions3?.length) {
1638
+ if (!positions2?.length) {
1551
1639
  return null;
1552
1640
  }
1553
- return positions3.reduce((acc, item) => {
1641
+ return positions2.reduce((acc, item) => {
1554
1642
  const itemAny = item;
1555
1643
  const positionUnsettlementPnl = itemAny["unsettlement_pnl"] ?? item.unsettled_pnl ?? 0;
1556
1644
  return acc.add(positionUnsettlementPnl);
1557
1645
  }, new orderlyUtils.Decimal(0));
1558
- }, [positions3]);
1646
+ }, [positions2]);
1559
1647
  const currentPosition = React3.useMemo(() => {
1560
- return positions3?.find(
1648
+ return positions2?.find(
1561
1649
  (item) => item.symbol === symbol && item.margin_mode === orderlyTypes.MarginMode.ISOLATED
1562
1650
  );
1563
- }, [positions3]);
1651
+ }, [positions2]);
1564
1652
  const notional = React3.useMemo(() => {
1565
1653
  if (!currentPosition) return null;
1566
1654
  return new orderlyUtils.Decimal(currentPosition.notional);
@@ -1622,7 +1710,7 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
1622
1710
  positionNotional: currentPositionNotional,
1623
1711
  IMR_factor_power: 4 / 5
1624
1712
  });
1625
- positions3?.filter((item) => item.symbol !== symbol).map((item) => {
1713
+ positions2?.filter((item) => item.symbol !== symbol).map((item) => {
1626
1714
  const itemSymbolInfo = symbolsInfo[item.symbol];
1627
1715
  const itemIMRFactor = accountInfo.imr_factor[item.symbol] ?? itemSymbolInfo?.imr_factor ?? 0;
1628
1716
  const itemNotional = item.notional ?? new orderlyUtils.Decimal(item.position_qty).mul(item.mark_price).abs().toNumber();
@@ -1662,7 +1750,7 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
1662
1750
  symbol,
1663
1751
  accountInfo,
1664
1752
  notional,
1665
- positions3,
1753
+ positions2,
1666
1754
  finalMargin,
1667
1755
  markPrice
1668
1756
  ]);
@@ -1987,8 +2075,8 @@ var Quantity = ({
1987
2075
  input: "oui-text-sm oui-font-semibold oui-text-base-contrast-98",
1988
2076
  // override default additional padding so value can sit closer to suffix
1989
2077
  additional: "oui-px-0",
1990
- prefix: "oui-pl-3 oui-pr-2 oui-text-sm oui-text-base-contrast-54",
1991
- suffix: "oui-pl-2 oui-pr-3 oui-text-sm oui-text-base-contrast-54"
2078
+ prefix: "oui-ps-3 oui-pe-2 oui-text-sm oui-text-base-contrast-54",
2079
+ suffix: "oui-ps-2 oui-pe-3 oui-text-sm oui-text-base-contrast-54"
1992
2080
  }
1993
2081
  }
1994
2082
  ),
@@ -3165,14 +3253,14 @@ var TriggerPriceItem = (props) => {
3165
3253
  ).toNumber();
3166
3254
  const type = orderType === orderlyTypes.AlgoOrderType.TAKE_PROFIT ? "TP" : "SL";
3167
3255
  return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { children: [
3168
- /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 54, className: "oui-mr-1", children: `${type} PnL:` }),
3256
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 54, className: "oui-me-1", children: `${type} PnL:` }),
3169
3257
  /* @__PURE__ */ jsxRuntime.jsx(
3170
3258
  orderlyUi.Text.formatted,
3171
3259
  {
3172
3260
  rule: "price",
3173
3261
  className: pnl === 0 ? "oui-text-base-contrast-36" : pnl > 0 ? "oui-text-trade-profit oui-gap-0" : "oui-text-trade-loss oui-gap-0",
3174
3262
  prefix: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: pnl === 0 ? "" : pnl > 0 ? "+" : "-" }),
3175
- suffix: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 36, className: "oui-ml-1", children: "USDC" }),
3263
+ suffix: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 36, className: "oui-ms-1", children: "USDC" }),
3176
3264
  children: `${Math.abs(pnl)}`
3177
3265
  }
3178
3266
  )
@@ -3429,7 +3517,7 @@ var useColumn = (config) => {
3429
3517
  {
3430
3518
  title: t("common.symbol"),
3431
3519
  dataIndex: "symbol",
3432
- fixed: "left",
3520
+ fixed: "start",
3433
3521
  width: 200,
3434
3522
  onSort: (r1, r2) => {
3435
3523
  return r1.symbol?.localeCompare(r2.symbol || "");
@@ -3477,7 +3565,7 @@ var useColumn = (config) => {
3477
3565
  return a.position_qty - b.position_qty;
3478
3566
  },
3479
3567
  width: 120,
3480
- className: "oui-pl-6",
3568
+ className: "oui-ps-6",
3481
3569
  // rule: "price",
3482
3570
  // numeralProps: {
3483
3571
  // coloring: true,
@@ -3704,14 +3792,14 @@ var useColumn = (config) => {
3704
3792
  // title: t("common.qty"),
3705
3793
  // dataIndex: "close_qty",
3706
3794
  // width: 100,
3707
- // fixed: "right",
3795
+ // fixed: "end",
3708
3796
  // render: renderQuantityInput,
3709
3797
  // },
3710
3798
  // {
3711
3799
  // title: t("common.price"),
3712
3800
  // dataIndex: "close_price",
3713
3801
  // width: 100,
3714
- // fixed: "right",
3802
+ // fixed: "end",
3715
3803
  // render: renderPriceInput,
3716
3804
  // // render: (value: string) => <PriceInput />,
3717
3805
  // },
@@ -3720,7 +3808,7 @@ var useColumn = (config) => {
3720
3808
  dataIndex: "close_position",
3721
3809
  align: "right",
3722
3810
  width: positionReverse ? 100 : 70,
3723
- fixed: "right",
3811
+ fixed: "end",
3724
3812
  render(_, record) {
3725
3813
  return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { gapX: 2, justify: "end", children: [
3726
3814
  /* @__PURE__ */ jsxRuntime.jsx(ClosePositionWidget, {}),
@@ -3729,7 +3817,13 @@ var useColumn = (config) => {
3729
3817
  }
3730
3818
  }
3731
3819
  ],
3732
- [pnlNotionalDecimalPrecision, sharePnLConfig, t, positionReverse]
3820
+ [
3821
+ onSymbolChange,
3822
+ pnlNotionalDecimalPrecision,
3823
+ sharePnLConfig,
3824
+ t,
3825
+ positionReverse
3826
+ ]
3733
3827
  );
3734
3828
  return column;
3735
3829
  };
@@ -3772,9 +3866,9 @@ var SymbolToken = (props) => {
3772
3866
  var UnrealPnL = (props) => {
3773
3867
  const { item } = props;
3774
3868
  const { t } = orderlyI18n.useTranslation();
3775
- const unrealPnlLabel = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-right", children: [
3869
+ const unrealPnlLabel = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-end", children: [
3776
3870
  /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 36, className: "oui-underline oui-decoration-dotted", children: t("common.unrealizedPnl") }),
3777
- /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 20, className: "oui-ml-0.5", children: "(USDC)" })
3871
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 20, className: "oui-ms-0.5", children: "(USDC)" })
3778
3872
  ] });
3779
3873
  return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { gap: 3, children: [
3780
3874
  /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", className: "oui-text-2xs", itemAlign: "end", children: [
@@ -3801,7 +3895,7 @@ var UnrealPnL = (props) => {
3801
3895
  prefix: "(",
3802
3896
  suffix: ")",
3803
3897
  className: orderlyUi.cn(
3804
- "oui-ml-1",
3898
+ "oui-ms-1",
3805
3899
  item.unrealized_pnl_ROI > 0 ? "oui-text-success-darken" : "oui-text-danger-darken"
3806
3900
  ),
3807
3901
  children: item.unrealized_pnl_ROI
@@ -4230,7 +4324,7 @@ var PositionsRowProvider = (props) => {
4230
4324
  }
4231
4325
  return false;
4232
4326
  });
4233
- }, [submit]);
4327
+ }, [mutatePositions, quantity, submit, symbol, symbolInfo, t]);
4234
4328
  const memoizedValue = React3.useMemo(() => {
4235
4329
  return {
4236
4330
  quantity,
@@ -4477,7 +4571,7 @@ var usePositionHistoryColumn = (props) => {
4477
4571
  {
4478
4572
  title: t("common.symbol"),
4479
4573
  dataIndex: "symbol",
4480
- fixed: "left",
4574
+ fixed: "start",
4481
4575
  width: 250,
4482
4576
  onSort: (r1, r2) => {
4483
4577
  return r1.symbol?.localeCompare(r2.symbol || "");
@@ -4593,7 +4687,7 @@ var usePositionHistoryColumn = (props) => {
4593
4687
  render: (_, record) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.formatted, { rule: "date", formatString: "yyyy-MM-dd HH:mm:ss", children: record.last_update_time })
4594
4688
  }
4595
4689
  ],
4596
- [pnlNotionalDecimalPrecision, t]
4690
+ [onSymbolChange, pnlNotionalDecimalPrecision, props.sharePnLConfig, t]
4597
4691
  );
4598
4692
  return column;
4599
4693
  };
@@ -5025,7 +5119,7 @@ var useFilter = () => {
5025
5119
  return [sideFilter, statusFilter];
5026
5120
  }
5027
5121
  return [sideFilter, statusFilter, dateRangeFilter];
5028
- }, [side, status, dateRange]);
5122
+ }, [dateRange, isMobile, side, status, t]);
5029
5123
  return {
5030
5124
  filterItems,
5031
5125
  onFilter,
@@ -6020,7 +6114,7 @@ var Liquidation = (props) => {
6020
6114
  ] });
6021
6115
  };
6022
6116
  var TooltipHeaderCell = (props) => {
6023
- return /* @__PURE__ */ jsxRuntime.jsx("th", { className: "oui-h-10 oui-border-b oui-border-line oui-text-left oui-text-base-contrast-36", children: /* @__PURE__ */ jsxRuntime.jsx(
6117
+ return /* @__PURE__ */ jsxRuntime.jsx("th", { className: "oui-h-10 oui-border-b oui-border-line oui-text-start oui-text-base-contrast-36", children: /* @__PURE__ */ jsxRuntime.jsx(
6024
6118
  orderlyUi.Tooltip,
6025
6119
  {
6026
6120
  content: props.tooltip,
@@ -6347,15 +6441,15 @@ var CloseType = /* @__PURE__ */ ((CloseType2) => {
6347
6441
  CloseType2["LOSS"] = "LOSS";
6348
6442
  return CloseType2;
6349
6443
  })(CloseType || {});
6350
- function getPositionsByCloseType(positions3, closeType) {
6351
- if (closeType === "ALL" /* ALL */) return positions3;
6444
+ function getPositionsByCloseType(positions2, closeType) {
6445
+ if (closeType === "ALL" /* ALL */) return positions2;
6352
6446
  if (closeType === "PROFIT" /* PROFIT */) {
6353
- return positions3.filter((p) => (p.unrealized_pnl ?? 0) > 0);
6447
+ return positions2.filter((p) => (p.unrealized_pnl ?? 0) > 0);
6354
6448
  }
6355
6449
  if (closeType === "LOSS" /* LOSS */) {
6356
- return positions3.filter((p) => (p.unrealized_pnl ?? 0) < 0);
6450
+ return positions2.filter((p) => (p.unrealized_pnl ?? 0) < 0);
6357
6451
  }
6358
- return positions3;
6452
+ return positions2;
6359
6453
  }
6360
6454
  var useCloseAllPositionsScript = (options) => {
6361
6455
  const { symbol, onSuccess } = options || {};
@@ -6376,7 +6470,7 @@ var useCloseAllPositionsScript = (options) => {
6376
6470
  "POST"
6377
6471
  );
6378
6472
  const buildOrdersFromPositions = React3.useCallback(
6379
- (positions3) => positions3.map((position) => {
6473
+ (positions2) => positions2.map((position) => {
6380
6474
  const side = position.position_qty > 0 ? orderlyTypes.OrderSide.SELL : orderlyTypes.OrderSide.BUY;
6381
6475
  const quantity = Math.abs(position.position_qty);
6382
6476
  return {