@orderly.network/ui-positions 3.0.0-beta.0 → 3.0.0-beta.10
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +179 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -130
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.d.mts
CHANGED
|
@@ -104,7 +104,7 @@ declare const usePositionHistoryScript: (props: PositionHistoryProps$1) => {
|
|
|
104
104
|
value: any;
|
|
105
105
|
}) => void;
|
|
106
106
|
symbol: string | undefined;
|
|
107
|
-
filterDays: 1 |
|
|
107
|
+
filterDays: 1 | 30 | 7 | 90 | null;
|
|
108
108
|
updateFilterDays: (days: 1 | 7 | 30 | 90) => void;
|
|
109
109
|
pnlNotionalDecimalPrecision: number | undefined;
|
|
110
110
|
onSort: (options?: _orderly_network_ui.TableSort) => void;
|
|
@@ -147,7 +147,7 @@ declare const useLiquidationScript: (props: LiquidationProps) => {
|
|
|
147
147
|
from?: Date;
|
|
148
148
|
to?: Date;
|
|
149
149
|
};
|
|
150
|
-
filterDays: 1 |
|
|
150
|
+
filterDays: 1 | 30 | 7 | 90 | null;
|
|
151
151
|
updateFilterDays: (days: 1 | 7 | 30 | 90) => void;
|
|
152
152
|
filterItems: any[];
|
|
153
153
|
onFilter: (filter: {
|
package/dist/index.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ declare const usePositionHistoryScript: (props: PositionHistoryProps$1) => {
|
|
|
104
104
|
value: any;
|
|
105
105
|
}) => void;
|
|
106
106
|
symbol: string | undefined;
|
|
107
|
-
filterDays: 1 |
|
|
107
|
+
filterDays: 1 | 30 | 7 | 90 | null;
|
|
108
108
|
updateFilterDays: (days: 1 | 7 | 30 | 90) => void;
|
|
109
109
|
pnlNotionalDecimalPrecision: number | undefined;
|
|
110
110
|
onSort: (options?: _orderly_network_ui.TableSort) => void;
|
|
@@ -147,7 +147,7 @@ declare const useLiquidationScript: (props: LiquidationProps) => {
|
|
|
147
147
|
from?: Date;
|
|
148
148
|
to?: Date;
|
|
149
149
|
};
|
|
150
|
-
filterDays: 1 |
|
|
150
|
+
filterDays: 1 | 30 | 7 | 90 | null;
|
|
151
151
|
updateFilterDays: (days: 1 | 7 | 30 | 90) => void;
|
|
152
152
|
filterItems: any[];
|
|
153
153
|
onFilter: (filter: {
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ var React2 = require('react');
|
|
|
5
5
|
var i18n = require('@orderly.network/i18n');
|
|
6
6
|
var types = require('@orderly.network/types');
|
|
7
7
|
var utils = require('@orderly.network/utils');
|
|
8
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
var hooks = require('@orderly.network/hooks');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
10
|
var reactApp = require('@orderly.network/react-app');
|
|
11
11
|
var perp = require('@orderly.network/perp');
|
|
12
12
|
var uiConnector = require('@orderly.network/ui-connector');
|
|
@@ -20,6 +20,11 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
20
20
|
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
|
+
var SymbolBadge = ({ symbol }) => {
|
|
24
|
+
const { brokerId, brokerName, brokerNameRaw } = hooks.useBadgeBySymbol(symbol);
|
|
25
|
+
const badge = brokerName ?? brokerId ?? void 0;
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.SymbolBadge, { badge, fullName: brokerNameRaw });
|
|
27
|
+
};
|
|
23
28
|
var ConfirmHeader = (props) => {
|
|
24
29
|
const { hideCloseIcon = false } = props;
|
|
25
30
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-relative oui-w-full oui-border-b oui-border-line-4 oui-pb-3", children: [
|
|
@@ -176,9 +181,10 @@ var LimitConfirmDialog = (props) => {
|
|
|
176
181
|
ui.Text.formatted,
|
|
177
182
|
{
|
|
178
183
|
rule: "symbol",
|
|
179
|
-
formatString: "base
|
|
184
|
+
formatString: "base",
|
|
180
185
|
size: "base",
|
|
181
186
|
showIcon: true,
|
|
187
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol: order.symbol }),
|
|
182
188
|
children: order.symbol
|
|
183
189
|
}
|
|
184
190
|
),
|
|
@@ -326,8 +332,10 @@ var FundingFeeHistoryUI = ({ total, symbol, start_t, end_t }) => {
|
|
|
326
332
|
ui.Text.formatted,
|
|
327
333
|
{
|
|
328
334
|
rule: "symbol",
|
|
335
|
+
formatString: "base",
|
|
329
336
|
className: "oui-font-semibold",
|
|
330
337
|
intensity: 98,
|
|
338
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol }),
|
|
331
339
|
children: symbol
|
|
332
340
|
}
|
|
333
341
|
)
|
|
@@ -410,7 +418,7 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
|
|
|
410
418
|
dataIndex: "created_time",
|
|
411
419
|
width: 120,
|
|
412
420
|
render: (value) => {
|
|
413
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { rule: "date", children: value });
|
|
421
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { rule: "date", suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol: value }), children: value });
|
|
414
422
|
}
|
|
415
423
|
},
|
|
416
424
|
{
|
|
@@ -1122,9 +1130,10 @@ var ReversePosition = (props) => {
|
|
|
1122
1130
|
size: "base",
|
|
1123
1131
|
weight: "semibold",
|
|
1124
1132
|
rule: "symbol",
|
|
1125
|
-
formatString: "base
|
|
1133
|
+
formatString: "base",
|
|
1126
1134
|
intensity: 98,
|
|
1127
1135
|
showIcon: true,
|
|
1136
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol }),
|
|
1128
1137
|
children: symbol
|
|
1129
1138
|
}
|
|
1130
1139
|
),
|
|
@@ -1593,16 +1602,19 @@ var RwaStatusTag = ({ symbol }) => {
|
|
|
1593
1602
|
return null;
|
|
1594
1603
|
}
|
|
1595
1604
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1596
|
-
ui.
|
|
1605
|
+
ui.Tips,
|
|
1597
1606
|
{
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1607
|
+
title: t("common.tips"),
|
|
1608
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { color: open ? "success" : "danger", children: open ? t("trading.rwa.marketHours") : t("trading.rwa.outsideMarketHours") }),
|
|
1609
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { p: 2, className: "oui-flex oui-cursor-pointer oui-items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1610
|
+
ui.Box,
|
|
1611
|
+
{
|
|
1612
|
+
width: 4,
|
|
1613
|
+
height: 4,
|
|
1614
|
+
r: "full",
|
|
1615
|
+
className: ui.cn(open ? "oui-bg-success" : "oui-bg-danger")
|
|
1616
|
+
}
|
|
1617
|
+
) })
|
|
1606
1618
|
}
|
|
1607
1619
|
);
|
|
1608
1620
|
};
|
|
@@ -1639,17 +1651,7 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1639
1651
|
if (!currentPosition) return null;
|
|
1640
1652
|
return new utils.Decimal(currentPosition.notional);
|
|
1641
1653
|
}, [currentPosition]);
|
|
1642
|
-
const unSettledPnl =
|
|
1643
|
-
if (!currentPosition || !notional || !fundingRates) return null;
|
|
1644
|
-
const fundingRate = fundingRates[currentPosition.symbol];
|
|
1645
|
-
return notional.sub(new utils.Decimal(currentPosition.cost_position)).sub(
|
|
1646
|
-
new utils.Decimal(currentPosition.position_qty).mul(
|
|
1647
|
-
new utils.Decimal(fundingRate.sum_unitary_funding ?? 0).sub(
|
|
1648
|
-
new utils.Decimal(currentPosition.last_sum_unitary_funding)
|
|
1649
|
-
)
|
|
1650
|
-
)
|
|
1651
|
-
);
|
|
1652
|
-
}, [notional, currentPosition, fundingRates]);
|
|
1654
|
+
const unSettledPnl = currentPosition?.unsettled_pnl;
|
|
1653
1655
|
const imr = React2.useMemo(() => {
|
|
1654
1656
|
if (!currentPosition || !symbolsInfo?.[symbol] || !notional) {
|
|
1655
1657
|
return null;
|
|
@@ -1677,12 +1679,12 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1677
1679
|
}
|
|
1678
1680
|
const positionNotional = notional;
|
|
1679
1681
|
const imrValue = imr;
|
|
1680
|
-
const unsettledPnlValue = unSettledPnl ??
|
|
1682
|
+
const unsettledPnlValue = unSettledPnl ?? 0;
|
|
1681
1683
|
return perp.account.maxReduce({
|
|
1682
1684
|
isolatedPositionMargin: isolatedMargin,
|
|
1683
1685
|
positionNotional: positionNotional.toNumber(),
|
|
1684
1686
|
imr: imrValue.toNumber(),
|
|
1685
|
-
positionUnsettledPnL: unsettledPnlValue
|
|
1687
|
+
positionUnsettledPnL: unsettledPnlValue
|
|
1686
1688
|
});
|
|
1687
1689
|
}, [
|
|
1688
1690
|
total_cross_unsettled_pnl,
|
|
@@ -1699,14 +1701,14 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1699
1701
|
const currentSymbolInfo = symbolsInfo[symbol];
|
|
1700
1702
|
const currentPositionNotional = notional?.toNumber() ?? 0;
|
|
1701
1703
|
const currentPositionIMRFactor = accountInfo.imr_factor[symbol] ?? currentSymbolInfo.imr_factor ?? 0;
|
|
1702
|
-
|
|
1704
|
+
perp.positions.MMR({
|
|
1703
1705
|
baseMMR: currentSymbolInfo.base_mmr ?? 0,
|
|
1704
1706
|
baseIMR: currentSymbolInfo.base_imr ?? 0,
|
|
1705
1707
|
IMRFactor: currentPositionIMRFactor,
|
|
1706
1708
|
positionNotional: currentPositionNotional,
|
|
1707
1709
|
IMR_factor_power: 4 / 5
|
|
1708
1710
|
});
|
|
1709
|
-
|
|
1711
|
+
positions2?.filter((item) => item.symbol !== symbol).map((item) => {
|
|
1710
1712
|
const itemSymbolInfo = symbolsInfo[item.symbol];
|
|
1711
1713
|
const itemIMRFactor = accountInfo.imr_factor[item.symbol] ?? itemSymbolInfo?.imr_factor ?? 0;
|
|
1712
1714
|
const itemNotional = item.notional ?? new utils.Decimal(item.position_qty).mul(item.mark_price).abs().toNumber();
|
|
@@ -1724,18 +1726,19 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1724
1726
|
mmr: itemMMR
|
|
1725
1727
|
};
|
|
1726
1728
|
}) ?? [];
|
|
1727
|
-
|
|
1728
|
-
const
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
positionQty: currentPosition.position_qty,
|
|
1733
|
-
|
|
1734
|
-
|
|
1729
|
+
new utils.Decimal(finalMargin).add(currentPosition.unsettled_pnl ?? 0).toNumber();
|
|
1730
|
+
const sumUnitaryFunding = fundingRates?.[symbol]?.sum_unitary_funding ?? 0;
|
|
1731
|
+
const liqPrice = perp.positions.liquidationPriceIsolated({
|
|
1732
|
+
isolatedPositionMargin: finalMargin,
|
|
1733
|
+
costPosition: currentPosition.cost_position ?? 0,
|
|
1734
|
+
positionQty: currentPosition.position_qty ?? 0,
|
|
1735
|
+
sumUnitaryFunding,
|
|
1736
|
+
lastSumUnitaryFunding: currentPosition.last_sum_unitary_funding ?? 0,
|
|
1735
1737
|
baseMMR: currentSymbolInfo.base_mmr ?? 0,
|
|
1736
1738
|
baseIMR: currentSymbolInfo.base_imr ?? 0,
|
|
1737
1739
|
IMRFactor: currentPositionIMRFactor,
|
|
1738
|
-
|
|
1740
|
+
referencePrice: markPrice,
|
|
1741
|
+
leverage: currentPosition.leverage ?? 0
|
|
1739
1742
|
});
|
|
1740
1743
|
return liqPrice;
|
|
1741
1744
|
}, [
|
|
@@ -1881,7 +1884,7 @@ var useAdjustMarginScript = (props) => {
|
|
|
1881
1884
|
sliderValue,
|
|
1882
1885
|
maxAmount: maxAmount ?? 0,
|
|
1883
1886
|
currentMargin,
|
|
1884
|
-
liquidationPrice
|
|
1887
|
+
liquidationPrice,
|
|
1885
1888
|
effectiveLeverage: effectiveLeverage ?? 0,
|
|
1886
1889
|
isLoading,
|
|
1887
1890
|
isAdd,
|
|
@@ -2121,10 +2124,11 @@ var SymbolInfo = ({ symbol }) => {
|
|
|
2121
2124
|
ui.Text.formatted,
|
|
2122
2125
|
{
|
|
2123
2126
|
rule: "symbol",
|
|
2124
|
-
formatString: "base
|
|
2127
|
+
formatString: "base",
|
|
2125
2128
|
size: "base",
|
|
2126
2129
|
weight: "semibold",
|
|
2127
2130
|
intensity: 98,
|
|
2131
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol }),
|
|
2128
2132
|
children: symbol
|
|
2129
2133
|
}
|
|
2130
2134
|
)
|
|
@@ -2303,7 +2307,16 @@ var MobileClosePosition = (props) => {
|
|
|
2303
2307
|
const orderType = isMarketClose ? t("orderEntry.orderType.market") : t("orderEntry.orderType.limit");
|
|
2304
2308
|
const orderSide = isBuy ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "success", size: "xs", children: t("common.buy") }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "danger", size: "xs", children: t("common.sell") });
|
|
2305
2309
|
const header = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", justify: "between", children: [
|
|
2306
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2310
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2311
|
+
ui.Text.formatted,
|
|
2312
|
+
{
|
|
2313
|
+
rule: "symbol",
|
|
2314
|
+
formatString: "base",
|
|
2315
|
+
showIcon: true,
|
|
2316
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol: position.symbol }),
|
|
2317
|
+
children: position.symbol
|
|
2318
|
+
}
|
|
2319
|
+
),
|
|
2307
2320
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
|
|
2308
2321
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "neutral", size: "xs", children: orderType }),
|
|
2309
2322
|
orderSide
|
|
@@ -3038,6 +3051,25 @@ var PartialTPSL = (props) => {
|
|
|
3038
3051
|
] })
|
|
3039
3052
|
] });
|
|
3040
3053
|
};
|
|
3054
|
+
var PositionSymbolCell = (props) => {
|
|
3055
|
+
const { symbol, onSymbolChange, className, formatString, ...rest } = props;
|
|
3056
|
+
const { brokerId, brokerName, brokerNameRaw } = hooks.useBadgeBySymbol(symbol);
|
|
3057
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3058
|
+
ui.Text.symbolBadge,
|
|
3059
|
+
{
|
|
3060
|
+
...rest,
|
|
3061
|
+
className: ui.cn(className, "oui-cursor-pointer"),
|
|
3062
|
+
badge: brokerName ?? brokerId ?? void 0,
|
|
3063
|
+
fullName: brokerNameRaw,
|
|
3064
|
+
onClick: (e) => {
|
|
3065
|
+
onSymbolChange?.({ symbol });
|
|
3066
|
+
e.stopPropagation();
|
|
3067
|
+
e.preventDefault();
|
|
3068
|
+
},
|
|
3069
|
+
children: symbol
|
|
3070
|
+
}
|
|
3071
|
+
);
|
|
3072
|
+
};
|
|
3041
3073
|
var ReversePositionButton = (props) => {
|
|
3042
3074
|
const { position } = props;
|
|
3043
3075
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3081,6 +3113,7 @@ var useShareButtonScript = (props) => {
|
|
|
3081
3113
|
const { position, sharePnLConfig, iconSize } = props;
|
|
3082
3114
|
const { getFirstRefCode } = hooks.useReferralInfo();
|
|
3083
3115
|
const symbolsInfo = hooks.useSymbolsInfo();
|
|
3116
|
+
const { brokerNameRaw } = hooks.useBadgeBySymbol(position.symbol);
|
|
3084
3117
|
const refCode = React2.useMemo(() => {
|
|
3085
3118
|
return getFirstRefCode()?.code;
|
|
3086
3119
|
}, [getFirstRefCode]);
|
|
@@ -3159,7 +3192,8 @@ var useShareButtonScript = (props) => {
|
|
|
3159
3192
|
marginMode: position.margin_mode
|
|
3160
3193
|
},
|
|
3161
3194
|
refCode,
|
|
3162
|
-
...sharePnLConfig
|
|
3195
|
+
...sharePnLConfig,
|
|
3196
|
+
brokerName: sharePnLConfig?.brokerName ?? brokerNameRaw
|
|
3163
3197
|
}
|
|
3164
3198
|
});
|
|
3165
3199
|
};
|
|
@@ -3482,44 +3516,38 @@ var useColumn = (config) => {
|
|
|
3482
3516
|
onSort: (r1, r2) => {
|
|
3483
3517
|
return r1.symbol?.localeCompare(r2.symbol || "");
|
|
3484
3518
|
},
|
|
3485
|
-
render: (value, record) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
3519
|
+
render: (value, record) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, className: "oui-py-1", children: [
|
|
3486
3520
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3487
3521
|
ui.Box,
|
|
3488
3522
|
{
|
|
3489
3523
|
width: 4,
|
|
3490
|
-
height:
|
|
3524
|
+
height: 24,
|
|
3491
3525
|
className: ui.cn(
|
|
3492
|
-
"oui-h-[
|
|
3526
|
+
"oui-h-[42px] oui-rounded-[1px]",
|
|
3493
3527
|
record.position_qty > 0 ? "oui-bg-trade-profit" : "oui-bg-trade-loss"
|
|
3494
3528
|
)
|
|
3495
3529
|
}
|
|
3496
3530
|
),
|
|
3497
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", children: [
|
|
3498
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3499
|
-
ui.Text.formatted,
|
|
3500
|
-
{
|
|
3501
|
-
formatString: "base-type",
|
|
3502
|
-
className: "oui-cursor-pointer",
|
|
3503
|
-
onClick: (e) => {
|
|
3504
|
-
onSymbolChange?.({ symbol: value });
|
|
3505
|
-
e.stopPropagation();
|
|
3506
|
-
e.preventDefault();
|
|
3507
|
-
},
|
|
3508
|
-
children: `${value.split("_")[1]}-PERP`
|
|
3509
|
-
}
|
|
3510
|
-
),
|
|
3511
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
|
|
3531
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
3532
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
|
|
3512
3533
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3513
|
-
|
|
3534
|
+
PositionSymbolCell,
|
|
3514
3535
|
{
|
|
3515
3536
|
symbol: value,
|
|
3516
|
-
|
|
3517
|
-
modalId: uiLeverage.SymbolLeverageDialogId,
|
|
3518
|
-
marginMode: record.margin_mode
|
|
3537
|
+
onSymbolChange
|
|
3519
3538
|
}
|
|
3520
3539
|
),
|
|
3521
3540
|
/* @__PURE__ */ jsxRuntime.jsx(RwaStatusTag, { symbol: value })
|
|
3522
|
-
] })
|
|
3541
|
+
] }),
|
|
3542
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 1, wrap: "wrap", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3543
|
+
LeverageBadge,
|
|
3544
|
+
{
|
|
3545
|
+
symbol: value,
|
|
3546
|
+
leverage: record.leverage,
|
|
3547
|
+
modalId: uiLeverage.SymbolLeverageDialogId,
|
|
3548
|
+
marginMode: record.margin_mode
|
|
3549
|
+
}
|
|
3550
|
+
) })
|
|
3523
3551
|
] })
|
|
3524
3552
|
] })
|
|
3525
3553
|
},
|
|
@@ -3791,31 +3819,37 @@ var SymbolToken = (props) => {
|
|
|
3791
3819
|
const { item } = props;
|
|
3792
3820
|
const isBuy = item.position_qty > 0;
|
|
3793
3821
|
const { t } = i18n.useTranslation();
|
|
3794
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
3795
|
-
ui.
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3822
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
3823
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
|
|
3824
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3825
|
+
ui.Text.formatted,
|
|
3826
|
+
{
|
|
3827
|
+
rule: "symbol",
|
|
3828
|
+
formatString: "base",
|
|
3829
|
+
size: "2xs",
|
|
3830
|
+
showIcon: true,
|
|
3831
|
+
onClick: () => {
|
|
3832
|
+
props.onSymbolChange?.({ symbol: item.symbol });
|
|
3833
|
+
},
|
|
3834
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol: item.symbol }),
|
|
3835
|
+
children: item.symbol
|
|
3836
|
+
}
|
|
3837
|
+
),
|
|
3838
|
+
/* @__PURE__ */ jsxRuntime.jsx(RwaStatusTag, { symbol: item.symbol })
|
|
3839
|
+
] }),
|
|
3840
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", wrap: "wrap", children: [
|
|
3841
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: isBuy ? "success" : "danger", size: "xs", children: isBuy ? t("common.long") : t("common.short") }),
|
|
3842
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3843
|
+
LeverageBadge,
|
|
3844
|
+
{
|
|
3845
|
+
symbol: item.symbol,
|
|
3846
|
+
leverage: item.leverage,
|
|
3847
|
+
modalId: uiLeverage.SymbolLeverageSheetId,
|
|
3848
|
+
marginMode: item.margin_mode
|
|
3849
|
+
}
|
|
3850
|
+
)
|
|
3851
|
+
] })
|
|
3852
|
+
] });
|
|
3819
3853
|
};
|
|
3820
3854
|
var UnrealPnL = (props) => {
|
|
3821
3855
|
const { item } = props;
|
|
@@ -4454,7 +4488,7 @@ var usePositionHistoryColumn = (props) => {
|
|
|
4454
4488
|
title: t("common.symbol"),
|
|
4455
4489
|
dataIndex: "symbol",
|
|
4456
4490
|
fixed: "left",
|
|
4457
|
-
width:
|
|
4491
|
+
width: 250,
|
|
4458
4492
|
onSort: (r1, r2) => {
|
|
4459
4493
|
return r1.symbol?.localeCompare(r2.symbol || "");
|
|
4460
4494
|
},
|
|
@@ -4645,6 +4679,19 @@ var SymbolInfo2 = (props) => {
|
|
|
4645
4679
|
)
|
|
4646
4680
|
);
|
|
4647
4681
|
}
|
|
4682
|
+
if (record.margin_mode != null) {
|
|
4683
|
+
list.push(
|
|
4684
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4685
|
+
ui.Badge,
|
|
4686
|
+
{
|
|
4687
|
+
color: "neutral",
|
|
4688
|
+
size: "xs",
|
|
4689
|
+
children: record.margin_mode === types.MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross")
|
|
4690
|
+
},
|
|
4691
|
+
`margin-mode-${record.margin_mode}`
|
|
4692
|
+
)
|
|
4693
|
+
);
|
|
4694
|
+
}
|
|
4648
4695
|
list.push(
|
|
4649
4696
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4650
4697
|
LeverageBadge2,
|
|
@@ -4657,7 +4704,7 @@ var SymbolInfo2 = (props) => {
|
|
|
4657
4704
|
);
|
|
4658
4705
|
return list;
|
|
4659
4706
|
}, [record, t]);
|
|
4660
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2,
|
|
4707
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, className: "oui-py-1", children: [
|
|
4661
4708
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4662
4709
|
ui.Box,
|
|
4663
4710
|
{
|
|
@@ -4669,21 +4716,15 @@ var SymbolInfo2 = (props) => {
|
|
|
4669
4716
|
)
|
|
4670
4717
|
}
|
|
4671
4718
|
),
|
|
4672
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", children: [
|
|
4719
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
4673
4720
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4674
|
-
|
|
4721
|
+
PositionSymbolCell,
|
|
4675
4722
|
{
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
onClick: (e) => {
|
|
4679
|
-
onSymbolChange?.({ symbol: record.symbol });
|
|
4680
|
-
e.stopPropagation();
|
|
4681
|
-
e.preventDefault();
|
|
4682
|
-
},
|
|
4683
|
-
children: `${record.symbol.split("_")[1]}-PERP`
|
|
4723
|
+
symbol: record.symbol,
|
|
4724
|
+
onSymbolChange
|
|
4684
4725
|
}
|
|
4685
4726
|
),
|
|
4686
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 1, children: tags })
|
|
4727
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 1, wrap: "wrap", children: tags })
|
|
4687
4728
|
] })
|
|
4688
4729
|
] });
|
|
4689
4730
|
};
|
|
@@ -4795,6 +4836,15 @@ var areDatesEqual = (date1, date2) => {
|
|
|
4795
4836
|
};
|
|
4796
4837
|
|
|
4797
4838
|
// src/components/positionHistory/positionHistory.script.tsx
|
|
4839
|
+
var normalizeMarginMode = (value) => {
|
|
4840
|
+
if (value === 1 || value === types.MarginMode.ISOLATED) {
|
|
4841
|
+
return types.MarginMode.ISOLATED;
|
|
4842
|
+
}
|
|
4843
|
+
if (value === 0 || value === types.MarginMode.CROSS) {
|
|
4844
|
+
return types.MarginMode.CROSS;
|
|
4845
|
+
}
|
|
4846
|
+
return void 0;
|
|
4847
|
+
};
|
|
4798
4848
|
var usePositionHistoryScript = (props) => {
|
|
4799
4849
|
const {
|
|
4800
4850
|
onSymbolChange,
|
|
@@ -4814,20 +4864,16 @@ var usePositionHistoryScript = (props) => {
|
|
|
4814
4864
|
symbol ? `/v1/position_history?symbol=${symbol}&limit=1000` : "/v1/position_history?limit=1000",
|
|
4815
4865
|
{
|
|
4816
4866
|
formatter(data2) {
|
|
4817
|
-
return (data2.rows ?? null)?.map(
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
margin_mode: item.margin_mode === 1 || item.margin_mode === types.MarginMode.ISOLATED ? types.MarginMode.ISOLATED : types.MarginMode.CROSS,
|
|
4825
|
-
netPnL
|
|
4826
|
-
};
|
|
4827
|
-
}
|
|
4828
|
-
return item;
|
|
4867
|
+
return (data2.rows ?? null)?.map((item) => {
|
|
4868
|
+
const result = {
|
|
4869
|
+
...item,
|
|
4870
|
+
margin_mode: normalizeMarginMode(item.margin_mode)
|
|
4871
|
+
};
|
|
4872
|
+
if (item.realized_pnl != null && item.accumulated_funding_fee != null && item.trading_fee != null) {
|
|
4873
|
+
result.netPnL = item.realized_pnl - item.accumulated_funding_fee - item.trading_fee;
|
|
4829
4874
|
}
|
|
4830
|
-
|
|
4875
|
+
return result;
|
|
4876
|
+
});
|
|
4831
4877
|
},
|
|
4832
4878
|
revalidateOnFocus: true
|
|
4833
4879
|
}
|
|
@@ -5009,9 +5055,10 @@ var SymbolToken2 = (props) => {
|
|
|
5009
5055
|
{
|
|
5010
5056
|
intensity: 80,
|
|
5011
5057
|
rule: "symbol",
|
|
5012
|
-
formatString: "base
|
|
5058
|
+
formatString: "base",
|
|
5013
5059
|
size: "sm",
|
|
5014
5060
|
prefix: /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: isBuy ? "success" : "danger", size: "xs", children: isBuy ? t("common.buy") : t("common.sell") }),
|
|
5061
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol }),
|
|
5015
5062
|
onClick: () => {
|
|
5016
5063
|
props.onSymbolChange?.({ symbol });
|
|
5017
5064
|
},
|
|
@@ -5098,8 +5145,13 @@ var PositionHistoryType = (props) => {
|
|
|
5098
5145
|
)
|
|
5099
5146
|
);
|
|
5100
5147
|
}
|
|
5148
|
+
if (record.margin_mode != null) {
|
|
5149
|
+
list.push(
|
|
5150
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "neutral", size: "xs", children: record.margin_mode === types.MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross") }, `margin-${record.margin_mode}`)
|
|
5151
|
+
);
|
|
5152
|
+
}
|
|
5101
5153
|
return list;
|
|
5102
|
-
}, [record]);
|
|
5154
|
+
}, [record, t]);
|
|
5103
5155
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 1, children: tags });
|
|
5104
5156
|
};
|
|
5105
5157
|
var ClosedQty = (props) => {
|
|
@@ -5314,7 +5366,7 @@ var Header = (props) => {
|
|
|
5314
5366
|
]
|
|
5315
5367
|
}
|
|
5316
5368
|
),
|
|
5317
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "end",
|
|
5369
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "end", children: [
|
|
5318
5370
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", intensity: 36, children: t("positions.history.column.netPnl") }),
|
|
5319
5371
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gapX: 1, children: [
|
|
5320
5372
|
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: showAlert, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text.numeral, { size: "xs", coloring: true, children: props.item.netPnL ?? "--" }) }),
|
|
@@ -5552,16 +5604,8 @@ var useLiquidationColumn = (props) => {
|
|
|
5552
5604
|
{
|
|
5553
5605
|
title: t("common.symbol"),
|
|
5554
5606
|
dataIndex: "Symbol",
|
|
5555
|
-
|
|
5556
|
-
render: (_, record) => /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "column", itemAlign: "start", children: record.positions_by_perp?.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5557
|
-
ui.Text.formatted,
|
|
5558
|
-
{
|
|
5559
|
-
rule: "symbol",
|
|
5560
|
-
formatString: "base-quote",
|
|
5561
|
-
children: item.symbol
|
|
5562
|
-
},
|
|
5563
|
-
item.symbol
|
|
5564
|
-
)) })
|
|
5607
|
+
width: 120,
|
|
5608
|
+
render: (_, record) => /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "column", itemAlign: "start", children: record.positions_by_perp?.map((item) => /* @__PURE__ */ jsxRuntime.jsx(PositionSymbolCell, { symbol: item.symbol }, item.symbol)) })
|
|
5565
5609
|
},
|
|
5566
5610
|
// Price (USDC)
|
|
5567
5611
|
{
|
|
@@ -5729,9 +5773,15 @@ var Header2 = (props) => {
|
|
|
5729
5773
|
ui.Text.formatted,
|
|
5730
5774
|
{
|
|
5731
5775
|
rule: "symbol",
|
|
5732
|
-
formatString: "base
|
|
5776
|
+
formatString: "base",
|
|
5733
5777
|
size: "xs",
|
|
5734
5778
|
intensity: 80,
|
|
5779
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5780
|
+
SymbolBadge,
|
|
5781
|
+
{
|
|
5782
|
+
symbol: props.item.positions_by_perp?.[0]?.symbol || ""
|
|
5783
|
+
}
|
|
5784
|
+
),
|
|
5735
5785
|
children: props.item.positions_by_perp?.[0]?.symbol || ""
|
|
5736
5786
|
}
|
|
5737
5787
|
) }) }) }),
|