@orderly.network/trading 2.11.3-rc.0 → 2.12.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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { useAccount, useLocalStorage, useConfig, useWalletConnector, useMutation, useChains, useReferralInfo, useCurEpochEstimate, TWType, useEpochInfo, usePositionStream, useOrderStream, useFundingDetails, useFundingRateBySymbol, useFundingRate, useSymbolsInfo, useOrderbookStream, useEventEmitter, useCollateral, useMarginRatio, useLeverage, useDebouncedCallback, useMediaQuery, useAssetsHistory, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolCloseTimeInterval, useMarketTradeStream, useAccountInstance, useComputedLTV, useTickerStream } from '@orderly.network/hooks';
1
+ import { useAccount, useLocalStorage, useConfig, useWalletConnector, useMutation, useChains, useReferralInfo, useCurEpochEstimate, TWType, useEpochInfo, usePositionStream, useOrderStream, useFundingDetails, useFundingRateBySymbol, useFundingRate, useSymbolsInfo, useOrderbookStream, useEventEmitter, useCollateral, useMarginRatio, useLeverage, useDebouncedCallback, useMediaQuery, useAssetsHistory, useGetRwaSymbolInfo, useBadgeBySymbol, useGetRwaSymbolOpenStatus, useGetRwaSymbolCloseTimeInterval, useMarketTradeStream, useAccountInstance, useComputedLTV, useTickerStream } from '@orderly.network/hooks';
2
2
  import React12, { forwardRef, useMemo, createContext, useContext, useState, useCallback, useEffect, useRef, createElement } from 'react';
3
3
  import { useDataTap, useAppContext } from '@orderly.network/react-app';
4
4
  import { AccountStatusEnum, ChainNamespace, AlgoOrderRootType, OrderStatus, OrderSide, AssetHistoryStatusEnum, AssetHistorySideEnum, TradingviewFullscreenKey, OrderEntrySortKeys, EMPTY_LIST } from '@orderly.network/types';
@@ -20,7 +20,7 @@ import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, close
20
20
  import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
21
21
  import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable, arrayMove } from '@dnd-kit/sortable';
22
22
  import { CSS } from '@dnd-kit/utilities';
23
- import { SymbolInfoBarWidget, MarketsSheetWidget, HorizontalMarketsWidget, SideMarketsWidget, SymbolInfoBarFullWidget } from '@orderly.network/markets';
23
+ import { SymbolInfoBarWidget, SymbolInfoBarRiskNotice, MarketsSheetWidget, HorizontalMarketsWidget, SideMarketsWidget, SymbolInfoBarFullWidget } from '@orderly.network/markets';
24
24
 
25
25
  var __defProp = Object.defineProperty;
26
26
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -2791,14 +2791,21 @@ var init_markPrice_desktop = __esm({
2791
2791
  if (bids.length === 0 && asks.length === 0) {
2792
2792
  return 0;
2793
2793
  }
2794
- const bid1 = Number.isNaN(bids[0][0]) ? 0 : bids[0][0];
2795
- const index = asks.reverse().findIndex((item) => !Number.isNaN(item[0]));
2796
- let ask1 = 0;
2794
+ const bidRaw = bids[0]?.[0];
2795
+ const bid1 = bidRaw === void 0 || Number.isNaN(bidRaw) ? new Decimal(0) : new Decimal(bidRaw);
2796
+ const asksReversed = [...asks].reverse();
2797
+ const index = asksReversed.findIndex((item) => !Number.isNaN(item[0]));
2798
+ let ask1 = new Decimal(0);
2797
2799
  if (index !== -1) {
2798
- ask1 = Number.isNaN(asks[index][0]) ? 0 : asks[index][0];
2800
+ const askRaw = asksReversed[index][0];
2801
+ ask1 = Number.isNaN(askRaw) ? new Decimal(0) : new Decimal(askRaw);
2799
2802
  }
2800
- const dValue = new Decimal(ask1).sub(bid1).div(new Decimal(ask1).add(bid1).div(2));
2801
- return Math.ceil(dValue.toNumber() * 1e6 + 0.1) / 1e4;
2803
+ const mid = ask1.add(bid1).div(2);
2804
+ if (mid.isZero()) {
2805
+ return 0;
2806
+ }
2807
+ const dValue = ask1.sub(bid1).div(mid);
2808
+ return dValue.mul(1e6).add(0.1).toDecimalPlaces(0, Decimal.ROUND_CEIL).div(1e4).toNumber();
2802
2809
  }, [asks, bids]);
2803
2810
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
2804
2811
  Tooltip,
@@ -8306,9 +8313,18 @@ var DesktopLayout4 = (props) => {
8306
8313
  dataListMinHeight
8307
8314
  } = props;
8308
8315
  const { showCountdown, closeCountdown } = useShowRwaCountdown(props.symbol);
8316
+ const { brokerName } = useBadgeBySymbol(props.symbol);
8309
8317
  const symbolInfoBarHeight2 = useMemo(() => {
8310
- return showCountdown ? 104 : 56;
8311
- }, [showCountdown]);
8318
+ let height = 56;
8319
+ if (brokerName) {
8320
+ height += 46;
8321
+ height += 8;
8322
+ }
8323
+ if (showCountdown) {
8324
+ height += 48;
8325
+ }
8326
+ return height;
8327
+ }, [showCountdown, brokerName]);
8312
8328
  const { isRwa, open } = useGetRwaSymbolOpenStatus(props.symbol);
8313
8329
  useEffect(() => {
8314
8330
  if (isRwa && !open) {
@@ -8445,9 +8461,6 @@ var DesktopLayout4 = (props) => {
8445
8461
  Box,
8446
8462
  {
8447
8463
  className: "oui-trading-symbolInfoBar-container",
8448
- intensity: 900,
8449
- r: "2xl",
8450
- px: 3,
8451
8464
  width: "100%",
8452
8465
  style: {
8453
8466
  minHeight: symbolInfoBarHeight2,
@@ -9108,6 +9121,12 @@ var MaybeEqual = () => {
9108
9121
  var MobileLayout4 = (props) => {
9109
9122
  const { t } = useTranslation();
9110
9123
  const { isRwa, open, closeTimeInterval } = useGetRwaSymbolInfo(props.symbol);
9124
+ const { brokerId, brokerName, brokerNameRaw, displayName } = useBadgeBySymbol(
9125
+ props.symbol
9126
+ );
9127
+ const isCommunityListed = Boolean(brokerId ?? brokerName);
9128
+ const baseFromSymbol = props.symbol?.split("_")[1] ?? props.symbol ?? "";
9129
+ const symbolWithBroker = brokerName != null ? `${baseFromSymbol}-${brokerNameRaw}` : displayName ?? props.symbol ?? "";
9111
9130
  useEffect(() => {
9112
9131
  if (isRwa && !open) {
9113
9132
  showRwaOutsideMarketHoursNotify();
@@ -9201,7 +9220,17 @@ var MobileLayout4 = (props) => {
9201
9220
  )
9202
9221
  }
9203
9222
  );
9204
- const topBar = /* @__PURE__ */ jsxs(Box, { intensity: 900, className: "oui-rounded-xl", mx: 1, px: 3, py: 2, children: [
9223
+ const topBar = /* @__PURE__ */ jsxs(Box, { children: [
9224
+ /* @__PURE__ */ jsx(Flex, { mx: 1, children: /* @__PURE__ */ jsx(
9225
+ SymbolInfoBarRiskNotice,
9226
+ {
9227
+ visible: isCommunityListed,
9228
+ symbolWithBroker,
9229
+ brokerName: brokerNameRaw ?? brokerName ?? "",
9230
+ autoHeight: true,
9231
+ className: "oui-my-1"
9232
+ }
9233
+ ) }),
9205
9234
  symbolInfoBar,
9206
9235
  /* @__PURE__ */ jsx(
9207
9236
  SimpleSheet,
@@ -9209,7 +9238,7 @@ var MobileLayout4 = (props) => {
9209
9238
  open: props.openMarketsSheet,
9210
9239
  onOpenChange: props.onOpenMarketsSheetChange,
9211
9240
  classNames: {
9212
- body: "oui-h-full oui-pb-0",
9241
+ body: "oui-h-full oui-pb-0 ",
9213
9242
  content: "!oui-w-[372px] !oui-max-w-[372px] !oui-p-0"
9214
9243
  },
9215
9244
  contentProps: { side: "left", closeable: false },
@@ -9243,6 +9272,7 @@ var MobileLayout4 = (props) => {
9243
9272
  };
9244
9273
  var Trading = (props) => {
9245
9274
  const { isMobile } = useScreen();
9275
+ const { t } = useTranslation();
9246
9276
  if (isMobile) {
9247
9277
  return /* @__PURE__ */ jsx(MobileLayout4, { ...props });
9248
9278
  }