@orderly.network/portfolio 3.0.0-beta.0 → 3.0.0-beta.2

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.d.mts CHANGED
@@ -110,6 +110,11 @@ declare const useAssetsHistoryData: (localKey: string, options?: {
110
110
  snapshot_time?: number | undefined;
111
111
  }[];
112
112
  readonly volumeUpdateDate: any;
113
+ readonly todayPerformance: {
114
+ pnl: number;
115
+ roi: number;
116
+ vol: number;
117
+ } | null;
113
118
  };
114
119
  type useAssetsHistoryDataReturn = ReturnType<typeof useAssetsHistoryData>;
115
120
 
@@ -143,6 +148,11 @@ declare const useAssetsChartScript: () => {
143
148
  snapshot_time?: number | undefined;
144
149
  }[];
145
150
  readonly volumeUpdateDate: any;
151
+ readonly todayPerformance: {
152
+ pnl: number;
153
+ roi: number;
154
+ vol: number;
155
+ } | null;
146
156
  readonly totalOrderClaimedReward: [number | undefined, {
147
157
  refresh: () => void;
148
158
  }];
@@ -223,6 +233,11 @@ declare const usePerformanceScript: () => {
223
233
  snapshot_time?: number | undefined;
224
234
  }[];
225
235
  volumeUpdateDate: any;
236
+ todayPerformance: {
237
+ pnl: number;
238
+ roi: number;
239
+ vol: number;
240
+ } | null;
226
241
  totalOrderClaimedReward: [number | undefined, {
227
242
  refresh: () => void;
228
243
  }];
package/dist/index.d.ts CHANGED
@@ -110,6 +110,11 @@ declare const useAssetsHistoryData: (localKey: string, options?: {
110
110
  snapshot_time?: number | undefined;
111
111
  }[];
112
112
  readonly volumeUpdateDate: any;
113
+ readonly todayPerformance: {
114
+ pnl: number;
115
+ roi: number;
116
+ vol: number;
117
+ } | null;
113
118
  };
114
119
  type useAssetsHistoryDataReturn = ReturnType<typeof useAssetsHistoryData>;
115
120
 
@@ -143,6 +148,11 @@ declare const useAssetsChartScript: () => {
143
148
  snapshot_time?: number | undefined;
144
149
  }[];
145
150
  readonly volumeUpdateDate: any;
151
+ readonly todayPerformance: {
152
+ pnl: number;
153
+ roi: number;
154
+ vol: number;
155
+ } | null;
146
156
  readonly totalOrderClaimedReward: [number | undefined, {
147
157
  refresh: () => void;
148
158
  }];
@@ -223,6 +233,11 @@ declare const usePerformanceScript: () => {
223
233
  snapshot_time?: number | undefined;
224
234
  }[];
225
235
  volumeUpdateDate: any;
236
+ todayPerformance: {
237
+ pnl: number;
238
+ roi: number;
239
+ vol: number;
240
+ } | null;
226
241
  totalOrderClaimedReward: [number | undefined, {
227
242
  refresh: () => void;
228
243
  }];
package/dist/index.js CHANGED
@@ -845,9 +845,24 @@ var init_assetHistory = __esm({
845
845
  init_assetHistory_widget();
846
846
  }
847
847
  });
848
- var useFundingHistoryColumns;
848
+ var SymbolBadge, useFundingHistoryColumns;
849
849
  var init_column2 = __esm({
850
850
  "src/pages/overview/funding/column.tsx"() {
851
+ SymbolBadge = (props) => {
852
+ const { brokerId, brokerName, brokerNameRaw } = hooks.useBadgeBySymbol(
853
+ props.symbol
854
+ );
855
+ return /* @__PURE__ */ jsxRuntime.jsx(
856
+ ui.Text.symbolBadge,
857
+ {
858
+ badge: brokerName ?? brokerId ?? void 0,
859
+ fullName: brokerNameRaw,
860
+ className: "oui-cursor-pointer",
861
+ showIcon: true,
862
+ children: props.symbol
863
+ }
864
+ );
865
+ };
851
866
  useFundingHistoryColumns = () => {
852
867
  const { t } = i18n.useTranslation();
853
868
  const columns = React12.useMemo(() => {
@@ -856,10 +871,7 @@ var init_column2 = __esm({
856
871
  title: t("common.symbol"),
857
872
  dataIndex: "symbol",
858
873
  width: 80,
859
- rule: "symbol",
860
- textProps: {
861
- showIcon: true
862
- }
874
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol: value })
863
875
  },
864
876
  {
865
877
  title: t("common.time"),
@@ -987,9 +999,22 @@ var init_fundingHistory_ui = __esm({
987
999
  };
988
1000
  }
989
1001
  });
1002
+ var SymbolBadge2;
1003
+ var init_symbolBadge = __esm({
1004
+ "src/pages/overview/funding/symbolBadge.tsx"() {
1005
+ SymbolBadge2 = (props) => {
1006
+ const { brokerId, brokerName, brokerNameRaw } = hooks.useBadgeBySymbol(
1007
+ props.symbol
1008
+ );
1009
+ const badge = brokerName ?? brokerId ?? void 0;
1010
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.SymbolBadge, { badge, fullName: brokerNameRaw });
1011
+ };
1012
+ }
1013
+ });
990
1014
  var FundingHistoryMobile;
991
1015
  var init_fundingHistory_ui_mobile = __esm({
992
1016
  "src/pages/overview/funding/fundingHistory.ui.mobile.tsx"() {
1017
+ init_symbolBadge();
993
1018
  FundingHistoryMobile = (props) => {
994
1019
  const { dataSource: dataSource2, queryParameter, onFilter, isLoading, pagination } = props;
995
1020
  const symbols = hooks.useSymbolsInfo();
@@ -1026,11 +1051,16 @@ var init_fundingHistory_ui_mobile = __esm({
1026
1051
  ui.Text.formatted,
1027
1052
  {
1028
1053
  rule: "symbol",
1054
+ formatString: "base",
1029
1055
  className: "oui-text-base-contrast oui-mr-1 oui-text-sm",
1056
+ suffix: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 1, children: [
1057
+ " ",
1058
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "neutral", size: "xs", children: switchPaymentType(item.payment_type) }),
1059
+ /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge2, { symbol: item.symbol })
1060
+ ] }),
1030
1061
  children: item.symbol
1031
1062
  }
1032
1063
  ),
1033
- /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "neutral", size: "xs", children: switchPaymentType(item.payment_type) }),
1034
1064
  /* @__PURE__ */ jsxRuntime.jsx(
1035
1065
  ui.Text.formatted,
1036
1066
  {
@@ -4115,7 +4145,7 @@ var init_useAssetHistory = __esm({
4115
4145
  );
4116
4146
  const [userStatistics] = hooks.useUserStatistics();
4117
4147
  const todayVolume = React12.useMemo(
4118
- () => userStatistics?.perp_trading_volume_last_24_hours ?? 0,
4148
+ () => userStatistics?.perp_trading_volume_today ?? 0,
4119
4149
  [userStatistics]
4120
4150
  );
4121
4151
  const lastBalanceEventRef = React12.useRef(0);
@@ -4272,6 +4302,7 @@ var init_useAssetHistory = __esm({
4272
4302
  ...lastItem2,
4273
4303
  date: getUTCStr(today),
4274
4304
  perp_volume: todayVol,
4305
+ base_account_value: lastItem2?.account_value ?? 0,
4275
4306
  account_value: totalValue2 !== null ? totalValue2 : lastItem2?.account_value ?? 0,
4276
4307
  pnl: calculateLastPnl({
4277
4308
  lastItem: lastItem2,
@@ -4330,6 +4361,25 @@ var init_useAssetHistory = __esm({
4330
4361
  totalTransferOut,
4331
4362
  todayVolume
4332
4363
  ]);
4364
+ const todayPerformance = React12.useMemo(() => {
4365
+ if (!Array.isArray(calculatedData) || calculatedData.length === 0) {
4366
+ return null;
4367
+ }
4368
+ const todayRow = calculatedData[calculatedData.length - 1];
4369
+ if (!todayRow.__isCalculated) {
4370
+ return null;
4371
+ }
4372
+ const baseAccountValue = typeof todayRow.base_account_value === "number" ? todayRow.base_account_value : todayRow.account_value ?? 0;
4373
+ let roi = utils.zero;
4374
+ if (baseAccountValue) {
4375
+ roi = new utils.Decimal(todayRow.pnl).div(baseAccountValue);
4376
+ }
4377
+ return {
4378
+ pnl: todayRow.pnl,
4379
+ roi: roi.toNumber(),
4380
+ vol: todayRow.perp_volume ?? 0
4381
+ };
4382
+ }, [calculatedData]);
4333
4383
  const aggregateValue = React12.useMemo(() => {
4334
4384
  let vol = utils.zero;
4335
4385
  let pnl = utils.zero;
@@ -4369,7 +4419,8 @@ var init_useAssetHistory = __esm({
4369
4419
  // calculatedData,
4370
4420
  aggregateValue,
4371
4421
  createFakeData,
4372
- volumeUpdateDate: data?.[data.length - 1]?.date ?? ""
4422
+ volumeUpdateDate: data?.[data.length - 1]?.date ?? "",
4423
+ todayPerformance
4373
4424
  };
4374
4425
  };
4375
4426
  }
@@ -4479,7 +4530,7 @@ var init_performance_ui = __esm({
4479
4530
  formatForChart = (value, dp = 2) => {
4480
4531
  if (value == null) return 0;
4481
4532
  const decimal = new utils.Decimal(value);
4482
- return Number(decimal.toFixed(dp, utils.Decimal.ROUND_DOWN));
4533
+ return Number(decimal.toFixed(dp, utils.Decimal.ROUND_HALF_UP));
4483
4534
  };
4484
4535
  PerformanceUI = (props) => {
4485
4536
  const {
@@ -5084,7 +5135,7 @@ var init_apiManager_script = __esm({
5084
5135
  hideCreateDialog();
5085
5136
  setGenerateKey({
5086
5137
  key,
5087
- screctKey: secretKey,
5138
+ secretKey,
5088
5139
  ip,
5089
5140
  permissions: scope?.split(",")?.map((e) => capitalizeFirstChar(e)).join(", ")
5090
5141
  });
@@ -5505,7 +5556,7 @@ var init_createdApiKey = __esm({
5505
5556
  copyIconSize: 16,
5506
5557
  className: "oui-break-all",
5507
5558
  onCopy: props.onCopyApiSecretKey,
5508
- children: props.generateKey?.screctKey
5559
+ children: props.generateKey?.secretKey
5509
5560
  }
5510
5561
  ),
5511
5562
  " "
@@ -5949,18 +6000,24 @@ var init_apiManager_ui = __esm({
5949
6000
  dataIndex: "orderly_key",
5950
6001
  width: 150,
5951
6002
  render: (value) => {
5952
- return /* @__PURE__ */ jsxRuntime.jsx(
5953
- ui.Text.formatted,
5954
- {
5955
- rule: "",
5956
- copyable: true,
5957
- copyIconSize: 16,
5958
- onCopy: () => {
5959
- props.onCopyApiKey?.(value);
5960
- },
5961
- children: formatKey(value)
5962
- }
5963
- );
6003
+ const fullKey = typeof value === "string" ? value : `${value ?? ""}`;
6004
+ const displayKey = formatKey(fullKey);
6005
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
6006
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-overflow-hidden oui-overflow-ellipsis", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { rule: "", children: displayKey }) }),
6007
+ !!fullKey && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { width: 16, height: 16, className: "oui-cursor-pointer", children: /* @__PURE__ */ jsxRuntime.jsx(
6008
+ ui.CopyIcon,
6009
+ {
6010
+ color: "white",
6011
+ opacity: 0.54,
6012
+ size: 16,
6013
+ onClick: (e) => {
6014
+ e.stopPropagation();
6015
+ navigator.clipboard.writeText(fullKey);
6016
+ props.onCopyApiKey?.(fullKey);
6017
+ }
6018
+ }
6019
+ ) })
6020
+ ] });
5964
6021
  }
5965
6022
  },
5966
6023
  {
@@ -6763,8 +6820,10 @@ init_assetChart();
6763
6820
 
6764
6821
  // src/pages/overview/portfolioChartsMobile/portfolioChartsMobile.script.ts
6765
6822
  init_type();
6823
+ init_overviewContext();
6766
6824
  var usePortfolioChartsState = () => {
6767
6825
  const [data] = hooks.usePositionStream();
6826
+ const overview = useOverviewContext();
6768
6827
  const [visible, setVisible] = hooks.useLocalStorage(
6769
6828
  ORDERLY_ASSETS_VISIBLE_KEY,
6770
6829
  true
@@ -6773,6 +6832,9 @@ var usePortfolioChartsState = () => {
6773
6832
  return ui.modal.show(PerformanceMobileSheetId);
6774
6833
  }, []);
6775
6834
  return {
6835
+ todaysPnl: overview?.todayPerformance?.pnl ?? null,
6836
+ todaysRoi: overview?.todayPerformance?.roi ?? null,
6837
+ todaysVol: overview?.todayPerformance?.vol ?? null,
6776
6838
  unrealPnL: data?.aggregated.total_unreal_pnl,
6777
6839
  unrealROI: data?.totalUnrealizedROI,
6778
6840
  visible,
@@ -6781,7 +6843,15 @@ var usePortfolioChartsState = () => {
6781
6843
  };
6782
6844
  };
6783
6845
  var PortfolioChartsMobileUI = (props) => {
6784
- const { data, invisible, unrealPnL, unrealROI, visible, onPerformanceClick } = props;
6846
+ const {
6847
+ data,
6848
+ invisible,
6849
+ todaysPnl,
6850
+ todaysRoi,
6851
+ todaysVol,
6852
+ visible,
6853
+ onPerformanceClick
6854
+ } = props;
6785
6855
  const { t } = i18n.useTranslation();
6786
6856
  const colorId = React12.useId();
6787
6857
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -6789,62 +6859,55 @@ var PortfolioChartsMobileUI = (props) => {
6789
6859
  {
6790
6860
  p: 4,
6791
6861
  width: "100%",
6792
- itemAlign: "center",
6793
- justify: "between",
6862
+ direction: "column",
6794
6863
  className: ui.cn(
6795
6864
  "oui-relative oui-overflow-hidden oui-rounded-2xl oui-border oui-border-solid oui-border-line-12 oui-bg-base-9"
6796
6865
  ),
6797
6866
  children: [
6798
- /* @__PURE__ */ jsxRuntime.jsxs(
6799
- ui.Flex,
6800
- {
6801
- width: "100%",
6802
- justify: "center",
6803
- itemAlign: "start",
6804
- direction: "column",
6805
- gap: 2,
6806
- children: [
6807
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 54, children: t("common.unrealizedPnl") }),
6808
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "start", itemAlign: "center", children: [
6809
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text.pnl, { coloring: true, size: "base", weight: "semibold", visible, children: unrealPnL }),
6810
- /* @__PURE__ */ jsxRuntime.jsx(
6811
- ui.Text.roi,
6812
- {
6813
- coloring: true,
6814
- rule: "percentages",
6815
- size: "sm",
6816
- weight: "semibold",
6817
- prefix: "(",
6818
- suffix: ")",
6819
- visible,
6820
- children: unrealROI
6821
- }
6822
- )
6823
- ] }),
6824
- /* @__PURE__ */ jsxRuntime.jsxs(
6825
- ui.Text,
6867
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", justify: "between", itemAlign: "start", mb: 3, children: [
6868
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 1, children: [
6869
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 54, children: t("portfolio.overview.todaysPnl") }),
6870
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "start", itemAlign: "center", gapX: 1, children: [
6871
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text.pnl, { coloring: true, size: "base", weight: "semibold", visible, children: invisible || todaysPnl == null ? "--" : todaysPnl }),
6872
+ /* @__PURE__ */ jsxRuntime.jsx(
6873
+ ui.Text.roi,
6826
6874
  {
6827
- size: "xs",
6828
- intensity: 54,
6829
- className: "oui-flex oui-items-center oui-justify-start oui-gap-1",
6830
- onClick: onPerformanceClick,
6831
- children: [
6832
- t("portfolio.overview.performance"),
6833
- /* @__PURE__ */ jsxRuntime.jsx(ui.ChevronRightIcon, { className: "oui-text-base-contrast-54" })
6834
- ]
6875
+ coloring: true,
6876
+ rule: "percentages",
6877
+ size: "sm",
6878
+ weight: "semibold",
6879
+ prefix: "(",
6880
+ suffix: ")",
6881
+ visible,
6882
+ children: invisible || todaysRoi == null ? "--" : todaysRoi
6835
6883
  }
6836
6884
  )
6837
- ]
6838
- }
6839
- ),
6885
+ ] })
6886
+ ] }),
6887
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 1, itemAlign: "end", children: [
6888
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 54, children: t("portfolio.overview.todaysVol") }),
6889
+ /* @__PURE__ */ jsxRuntime.jsx(
6890
+ ui.Text.numeral,
6891
+ {
6892
+ size: "sm",
6893
+ rule: "human",
6894
+ dp: 2,
6895
+ visible,
6896
+ prefix: "$",
6897
+ children: invisible || todaysVol == null ? "--" : todaysVol
6898
+ }
6899
+ )
6900
+ ] })
6901
+ ] }),
6840
6902
  /* @__PURE__ */ jsxRuntime.jsx(
6841
6903
  ui.Flex,
6842
6904
  {
6843
6905
  width: "100%",
6844
6906
  justify: "center",
6845
6907
  itemAlign: "center",
6846
- direction: "column",
6847
- children: /* @__PURE__ */ jsxRuntime.jsx(chart.AreaChart, { data: data || types.EMPTY_LIST, width: 160, height: 52, children: !invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6908
+ mb: 3,
6909
+ className: "oui-px-1",
6910
+ children: /* @__PURE__ */ jsxRuntime.jsx(chart.ResponsiveContainer, { width: "100%", height: 52, children: /* @__PURE__ */ jsxRuntime.jsx(chart.AreaChart, { data: data || types.EMPTY_LIST, children: !invisible && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6848
6911
  /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
6849
6912
  /* @__PURE__ */ jsxRuntime.jsx(
6850
6913
  "stop",
@@ -6875,9 +6938,22 @@ var PortfolioChartsMobileUI = (props) => {
6875
6938
  fill: `url(#${colorId})`
6876
6939
  }
6877
6940
  )
6878
- ] }) })
6941
+ ] }) }) })
6879
6942
  }
6880
- )
6943
+ ),
6944
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { width: "100%", justify: "start", itemAlign: "center", mt: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(
6945
+ ui.Text,
6946
+ {
6947
+ size: "xs",
6948
+ intensity: 54,
6949
+ className: "oui-flex oui-items-center oui-justify-start oui-gap-1",
6950
+ onClick: onPerformanceClick,
6951
+ children: [
6952
+ t("portfolio.overview.performance"),
6953
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ChevronRightIcon, { className: "oui-text-base-contrast-54" })
6954
+ ]
6955
+ }
6956
+ ) })
6881
6957
  ]
6882
6958
  }
6883
6959
  );