@orderly.network/ui-share 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.mjs CHANGED
@@ -10,6 +10,7 @@ import { formatNum, Decimal } from '@orderly.network/utils';
10
10
  var useSharePnLScript = (props) => {
11
11
  const { pnl, hide } = props;
12
12
  const entity = pnl?.entity;
13
+ const brokerName = pnl?.brokerName;
13
14
  const symbolInfo = useSymbolsInfo();
14
15
  const { getFirstRefCode } = useReferralInfo();
15
16
  const referralInfo = useMemo(() => {
@@ -35,6 +36,7 @@ var useSharePnLScript = (props) => {
35
36
  quoteDp: quote_dp,
36
37
  referralInfo,
37
38
  shareOptions: pnl,
39
+ brokerName,
38
40
  hide
39
41
  };
40
42
  };
@@ -60,7 +62,7 @@ var Poster = forwardRef((props, parentRef) => {
60
62
  }
61
63
  );
62
64
  });
63
- function getPnLPosterData(position, message, domain, pnlType, options, baseDp, quoteDp, referral) {
65
+ function getPnLPosterData(position, message, domain, pnlType, options, baseDp, quoteDp, referral, brokerName) {
64
66
  const { t } = useTranslation();
65
67
  const { symbol, currency } = processSymbol(position.symbol);
66
68
  const positionData = {
@@ -69,6 +71,10 @@ function getPnLPosterData(position, message, domain, pnlType, options, baseDp, q
69
71
  side: position.side,
70
72
  marginMode: position.marginMode
71
73
  };
74
+ const normalizedBrokerName = brokerName?.trim();
75
+ if (normalizedBrokerName) {
76
+ positionData["brokerName"] = normalizedBrokerName;
77
+ }
72
78
  switch (pnlType) {
73
79
  case "pnl": {
74
80
  if (position.pnl != null) {
@@ -182,17 +188,16 @@ function getPnLPosterData(position, message, domain, pnlType, options, baseDp, q
182
188
  }
183
189
  function processSymbol(symbol) {
184
190
  const tokens = symbol.split("_");
185
- if (tokens.length !== 3) {
191
+ if (tokens.length < 3) {
186
192
  return {
187
193
  symbol,
188
194
  currency: "USDC"
189
195
  };
190
196
  }
191
- const [symbol1, symbol2, symbol3] = tokens;
192
- const formattedString = `${symbol2}-${symbol1}`;
197
+ const [, base, quote] = tokens;
193
198
  return {
194
- symbol: formattedString,
195
- currency: symbol3 || "USDC"
199
+ symbol: base,
200
+ currency: quote || "USDC"
196
201
  };
197
202
  }
198
203
  function formatShareTime(input) {
@@ -802,7 +807,8 @@ var DesktopSharePnLContent = (props) => {
802
807
  shareOption,
803
808
  props.baseDp,
804
809
  props.quoteDp,
805
- props.referral
810
+ props.referral,
811
+ props.brokerName
806
812
  );
807
813
  const onCopy = () => {
808
814
  posterRef.current?.copy().then(() => {
@@ -1205,7 +1211,8 @@ var MobileSharePnLContent = (props) => {
1205
1211
  shareOption,
1206
1212
  props.baseDp,
1207
1213
  props.quoteDp,
1208
- props.referral
1214
+ props.referral,
1215
+ props.brokerName
1209
1216
  );
1210
1217
  const carouselRef = useRef();
1211
1218
  const aspectRatio = 552 / 310;
@@ -1498,7 +1505,15 @@ var ChoicesFillIcon = () => {
1498
1505
  );
1499
1506
  };
1500
1507
  var DesktopSharePnL = (props) => {
1501
- const { entity, baseDp, quoteDp, referralInfo, shareOptions, hide } = props;
1508
+ const {
1509
+ entity,
1510
+ baseDp,
1511
+ quoteDp,
1512
+ referralInfo,
1513
+ shareOptions,
1514
+ hide,
1515
+ brokerName
1516
+ } = props;
1502
1517
  if (!shareOptions || !entity) {
1503
1518
  return null;
1504
1519
  }
@@ -1510,12 +1525,21 @@ var DesktopSharePnL = (props) => {
1510
1525
  baseDp,
1511
1526
  quoteDp,
1512
1527
  referral: referralInfo,
1513
- shareOptions
1528
+ shareOptions,
1529
+ brokerName
1514
1530
  }
1515
1531
  );
1516
1532
  };
1517
1533
  var MobileSharePnL = (props) => {
1518
- const { entity, baseDp, quoteDp, referralInfo, shareOptions, hide } = props;
1534
+ const {
1535
+ entity,
1536
+ baseDp,
1537
+ quoteDp,
1538
+ referralInfo,
1539
+ shareOptions,
1540
+ hide,
1541
+ brokerName
1542
+ } = props;
1519
1543
  if (!shareOptions || !entity) {
1520
1544
  return null;
1521
1545
  }
@@ -1527,7 +1551,8 @@ var MobileSharePnL = (props) => {
1527
1551
  baseDp,
1528
1552
  quoteDp,
1529
1553
  referral: referralInfo,
1530
- shareOptions
1554
+ shareOptions,
1555
+ brokerName
1531
1556
  }
1532
1557
  );
1533
1558
  };