@orderly.network/ui-positions 3.0.0-beta.1 → 3.0.0-beta.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.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.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { registerSimpleDialog, registerSimpleSheet, useModal, SimpleDialog, useScreen, Flex, Text, Badge, Divider, toast, modal, CloseIcon, Button, ThrottledButton, ArrowDownShortIcon, ArrowUpShortIcon, IconButton, TokenIcon, cn, Input, inputFormatter, Slider, Statistic, Grid, ExclamationFillIcon, Tooltip, DataTable, ListView, SimpleSheet, usePagination, DataFilter, PopoverRoot, PopoverTrigger, PopoverContent, Checkbox, formatAddress, Box, HoverCard, AddCircleIcon, ChevronRightIcon, ArrowLeftRightIcon, capitalizeFirstLetter, ShareIcon, EditIcon, Select
|
|
1
|
+
import { registerSimpleDialog, registerSimpleSheet, useModal, SimpleDialog, useScreen, Flex, Text, Badge, Divider, toast, modal, CloseIcon, Button, ThrottledButton, SymbolBadge as SymbolBadge$1, ArrowDownShortIcon, ArrowUpShortIcon, IconButton, TokenIcon, cn, Input, inputFormatter, Slider, Statistic, Grid, ExclamationFillIcon, Tooltip, DataTable, ListView, SimpleSheet, usePagination, DataFilter, PopoverRoot, PopoverTrigger, PopoverContent, Checkbox, formatAddress, Box, HoverCard, AddCircleIcon, Tips, ChevronRightIcon, ArrowLeftRightIcon, capitalizeFirstLetter, ShareIcon, EditIcon, Select } from '@orderly.network/ui';
|
|
2
2
|
import React2, { createContext, useMemo, useState, useCallback, useContext, useEffect, useRef } from 'react';
|
|
3
3
|
import { i18n, useTranslation } from '@orderly.network/i18n';
|
|
4
4
|
import { OrderSide, MarginMode, OrderType, EMPTY_LIST, AccountStatusEnum, TrackerEventName, OrderStatus, AlgoOrderRootType, PositionType, AlgoOrderType } from '@orderly.network/types';
|
|
5
5
|
import { commifyOptional, Decimal, formatNum, getTimestamp, commify } from '@orderly.network/utils';
|
|
6
|
+
import { useLocalStorage, useSymbolsInfo, useMarkPrice, usePositionStream, useSubAccountMutation, useMutation, useBadgeBySymbol, useCollateral, usePositions, useAppStore, usePrivateInfiniteQuery, useBoolean, useSessionStorage, useAccount, usePrivateQuery, useTrack, usePositionClose, useSWR, fetcher, useEventEmitter, useDebouncedCallback, useGetRwaSymbolOpenStatus, useTpslPriceChecker, useConfig, findPositionTPSLFromOrders, findTPSLFromOrder, useReferralInfo, useLeverageBySymbol, utils, useMaxLeverage } from '@orderly.network/hooks';
|
|
6
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { useLocalStorage, useSymbolsInfo, useMarkPrice, usePositionStream, useSubAccountMutation, useMutation, useCollateral, usePositions, useAppStore, usePrivateInfiniteQuery, useBoolean, useSessionStorage, useAccount, usePrivateQuery, useTrack, usePositionClose, useSWR, fetcher, useEventEmitter, useDebouncedCallback, useGetRwaSymbolOpenStatus, useTpslPriceChecker, useConfig, findPositionTPSLFromOrders, findTPSLFromOrder, useReferralInfo, useLeverageBySymbol, utils, useMaxLeverage } from '@orderly.network/hooks';
|
|
8
8
|
import { useDataTap, useOrderEntryFormErrorMsg } from '@orderly.network/react-app';
|
|
9
9
|
import { account, positions } from '@orderly.network/perp';
|
|
10
10
|
import { AuthGuardDataTable } from '@orderly.network/ui-connector';
|
|
@@ -14,6 +14,11 @@ import { CloseToLiqPriceIcon, TPSLSheetId, TPSLDialogId, TPSLDetailSheetId, TPSL
|
|
|
14
14
|
import { subDays, differenceInDays } from 'date-fns';
|
|
15
15
|
|
|
16
16
|
// src/index.ts
|
|
17
|
+
var SymbolBadge = ({ symbol }) => {
|
|
18
|
+
const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(symbol);
|
|
19
|
+
const badge = brokerName ?? brokerId ?? void 0;
|
|
20
|
+
return /* @__PURE__ */ jsx(SymbolBadge$1, { badge, fullName: brokerNameRaw });
|
|
21
|
+
};
|
|
17
22
|
var ConfirmHeader = (props) => {
|
|
18
23
|
const { hideCloseIcon = false } = props;
|
|
19
24
|
return /* @__PURE__ */ jsxs("div", { className: "oui-relative oui-w-full oui-border-b oui-border-line-4 oui-pb-3", children: [
|
|
@@ -170,9 +175,10 @@ var LimitConfirmDialog = (props) => {
|
|
|
170
175
|
Text.formatted,
|
|
171
176
|
{
|
|
172
177
|
rule: "symbol",
|
|
173
|
-
formatString: "base
|
|
178
|
+
formatString: "base",
|
|
174
179
|
size: "base",
|
|
175
180
|
showIcon: true,
|
|
181
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: order.symbol }),
|
|
176
182
|
children: order.symbol
|
|
177
183
|
}
|
|
178
184
|
),
|
|
@@ -320,8 +326,10 @@ var FundingFeeHistoryUI = ({ total, symbol, start_t, end_t }) => {
|
|
|
320
326
|
Text.formatted,
|
|
321
327
|
{
|
|
322
328
|
rule: "symbol",
|
|
329
|
+
formatString: "base",
|
|
323
330
|
className: "oui-font-semibold",
|
|
324
331
|
intensity: 98,
|
|
332
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
|
|
325
333
|
children: symbol
|
|
326
334
|
}
|
|
327
335
|
)
|
|
@@ -404,7 +412,7 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
|
|
|
404
412
|
dataIndex: "created_time",
|
|
405
413
|
width: 120,
|
|
406
414
|
render: (value) => {
|
|
407
|
-
return /* @__PURE__ */ jsx(Text.formatted, { rule: "date", children: value });
|
|
415
|
+
return /* @__PURE__ */ jsx(Text.formatted, { rule: "date", suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: value }), children: value });
|
|
408
416
|
}
|
|
409
417
|
},
|
|
410
418
|
{
|
|
@@ -1116,9 +1124,10 @@ var ReversePosition = (props) => {
|
|
|
1116
1124
|
size: "base",
|
|
1117
1125
|
weight: "semibold",
|
|
1118
1126
|
rule: "symbol",
|
|
1119
|
-
formatString: "base
|
|
1127
|
+
formatString: "base",
|
|
1120
1128
|
intensity: 98,
|
|
1121
1129
|
showIcon: true,
|
|
1130
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
|
|
1122
1131
|
children: symbol
|
|
1123
1132
|
}
|
|
1124
1133
|
),
|
|
@@ -1587,16 +1596,19 @@ var RwaStatusTag = ({ symbol }) => {
|
|
|
1587
1596
|
return null;
|
|
1588
1597
|
}
|
|
1589
1598
|
return /* @__PURE__ */ jsx(
|
|
1590
|
-
|
|
1599
|
+
Tips,
|
|
1591
1600
|
{
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1601
|
+
title: t("common.tips"),
|
|
1602
|
+
content: /* @__PURE__ */ jsx(Text, { color: open ? "success" : "danger", children: open ? t("trading.rwa.marketHours") : t("trading.rwa.outsideMarketHours") }),
|
|
1603
|
+
trigger: /* @__PURE__ */ jsx(Box, { p: 2, className: "oui-flex oui-cursor-pointer oui-items-center", children: /* @__PURE__ */ jsx(
|
|
1604
|
+
Box,
|
|
1605
|
+
{
|
|
1606
|
+
width: 4,
|
|
1607
|
+
height: 4,
|
|
1608
|
+
r: "full",
|
|
1609
|
+
className: cn(open ? "oui-bg-success" : "oui-bg-danger")
|
|
1610
|
+
}
|
|
1611
|
+
) })
|
|
1600
1612
|
}
|
|
1601
1613
|
);
|
|
1602
1614
|
};
|
|
@@ -1633,17 +1645,7 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1633
1645
|
if (!currentPosition) return null;
|
|
1634
1646
|
return new Decimal(currentPosition.notional);
|
|
1635
1647
|
}, [currentPosition]);
|
|
1636
|
-
const unSettledPnl =
|
|
1637
|
-
if (!currentPosition || !notional || !fundingRates) return null;
|
|
1638
|
-
const fundingRate = fundingRates[currentPosition.symbol];
|
|
1639
|
-
return notional.sub(new Decimal(currentPosition.cost_position)).sub(
|
|
1640
|
-
new Decimal(currentPosition.position_qty).mul(
|
|
1641
|
-
new Decimal(fundingRate.sum_unitary_funding ?? 0).sub(
|
|
1642
|
-
new Decimal(currentPosition.last_sum_unitary_funding)
|
|
1643
|
-
)
|
|
1644
|
-
)
|
|
1645
|
-
);
|
|
1646
|
-
}, [notional, currentPosition, fundingRates]);
|
|
1648
|
+
const unSettledPnl = currentPosition?.unsettled_pnl;
|
|
1647
1649
|
const imr = useMemo(() => {
|
|
1648
1650
|
if (!currentPosition || !symbolsInfo?.[symbol] || !notional) {
|
|
1649
1651
|
return null;
|
|
@@ -1671,12 +1673,12 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1671
1673
|
}
|
|
1672
1674
|
const positionNotional = notional;
|
|
1673
1675
|
const imrValue = imr;
|
|
1674
|
-
const unsettledPnlValue = unSettledPnl ??
|
|
1676
|
+
const unsettledPnlValue = unSettledPnl ?? 0;
|
|
1675
1677
|
return account.maxReduce({
|
|
1676
1678
|
isolatedPositionMargin: isolatedMargin,
|
|
1677
1679
|
positionNotional: positionNotional.toNumber(),
|
|
1678
1680
|
imr: imrValue.toNumber(),
|
|
1679
|
-
positionUnsettledPnL: unsettledPnlValue
|
|
1681
|
+
positionUnsettledPnL: unsettledPnlValue
|
|
1680
1682
|
});
|
|
1681
1683
|
}, [
|
|
1682
1684
|
total_cross_unsettled_pnl,
|
|
@@ -1693,14 +1695,14 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1693
1695
|
const currentSymbolInfo = symbolsInfo[symbol];
|
|
1694
1696
|
const currentPositionNotional = notional?.toNumber() ?? 0;
|
|
1695
1697
|
const currentPositionIMRFactor = accountInfo.imr_factor[symbol] ?? currentSymbolInfo.imr_factor ?? 0;
|
|
1696
|
-
|
|
1698
|
+
positions.MMR({
|
|
1697
1699
|
baseMMR: currentSymbolInfo.base_mmr ?? 0,
|
|
1698
1700
|
baseIMR: currentSymbolInfo.base_imr ?? 0,
|
|
1699
1701
|
IMRFactor: currentPositionIMRFactor,
|
|
1700
1702
|
positionNotional: currentPositionNotional,
|
|
1701
1703
|
IMR_factor_power: 4 / 5
|
|
1702
1704
|
});
|
|
1703
|
-
|
|
1705
|
+
positions2?.filter((item) => item.symbol !== symbol).map((item) => {
|
|
1704
1706
|
const itemSymbolInfo = symbolsInfo[item.symbol];
|
|
1705
1707
|
const itemIMRFactor = accountInfo.imr_factor[item.symbol] ?? itemSymbolInfo?.imr_factor ?? 0;
|
|
1706
1708
|
const itemNotional = item.notional ?? new Decimal(item.position_qty).mul(item.mark_price).abs().toNumber();
|
|
@@ -1718,18 +1720,19 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1718
1720
|
mmr: itemMMR
|
|
1719
1721
|
};
|
|
1720
1722
|
}) ?? [];
|
|
1721
|
-
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
positionQty: currentPosition.position_qty,
|
|
1727
|
-
|
|
1728
|
-
|
|
1723
|
+
new Decimal(finalMargin).add(currentPosition.unsettled_pnl ?? 0).toNumber();
|
|
1724
|
+
const sumUnitaryFunding = fundingRates?.[symbol]?.sum_unitary_funding ?? 0;
|
|
1725
|
+
const liqPrice = positions.liquidationPriceIsolated({
|
|
1726
|
+
isolatedPositionMargin: finalMargin,
|
|
1727
|
+
costPosition: currentPosition.cost_position ?? 0,
|
|
1728
|
+
positionQty: currentPosition.position_qty ?? 0,
|
|
1729
|
+
sumUnitaryFunding,
|
|
1730
|
+
lastSumUnitaryFunding: currentPosition.last_sum_unitary_funding ?? 0,
|
|
1729
1731
|
baseMMR: currentSymbolInfo.base_mmr ?? 0,
|
|
1730
1732
|
baseIMR: currentSymbolInfo.base_imr ?? 0,
|
|
1731
1733
|
IMRFactor: currentPositionIMRFactor,
|
|
1732
|
-
|
|
1734
|
+
referencePrice: markPrice,
|
|
1735
|
+
leverage: currentPosition.leverage ?? 0
|
|
1733
1736
|
});
|
|
1734
1737
|
return liqPrice;
|
|
1735
1738
|
}, [
|
|
@@ -1875,7 +1878,7 @@ var useAdjustMarginScript = (props) => {
|
|
|
1875
1878
|
sliderValue,
|
|
1876
1879
|
maxAmount: maxAmount ?? 0,
|
|
1877
1880
|
currentMargin,
|
|
1878
|
-
liquidationPrice
|
|
1881
|
+
liquidationPrice,
|
|
1879
1882
|
effectiveLeverage: effectiveLeverage ?? 0,
|
|
1880
1883
|
isLoading,
|
|
1881
1884
|
isAdd,
|
|
@@ -2115,10 +2118,11 @@ var SymbolInfo = ({ symbol }) => {
|
|
|
2115
2118
|
Text.formatted,
|
|
2116
2119
|
{
|
|
2117
2120
|
rule: "symbol",
|
|
2118
|
-
formatString: "base
|
|
2121
|
+
formatString: "base",
|
|
2119
2122
|
size: "base",
|
|
2120
2123
|
weight: "semibold",
|
|
2121
2124
|
intensity: 98,
|
|
2125
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
|
|
2122
2126
|
children: symbol
|
|
2123
2127
|
}
|
|
2124
2128
|
)
|
|
@@ -2297,7 +2301,16 @@ var MobileClosePosition = (props) => {
|
|
|
2297
2301
|
const orderType = isMarketClose ? t("orderEntry.orderType.market") : t("orderEntry.orderType.limit");
|
|
2298
2302
|
const orderSide = isBuy ? /* @__PURE__ */ jsx(Badge, { color: "success", size: "xs", children: t("common.buy") }) : /* @__PURE__ */ jsx(Badge, { color: "danger", size: "xs", children: t("common.sell") });
|
|
2299
2303
|
const header = /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", children: [
|
|
2300
|
-
/* @__PURE__ */ jsx(
|
|
2304
|
+
/* @__PURE__ */ jsx(
|
|
2305
|
+
Text.formatted,
|
|
2306
|
+
{
|
|
2307
|
+
rule: "symbol",
|
|
2308
|
+
formatString: "base",
|
|
2309
|
+
showIcon: true,
|
|
2310
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: position.symbol }),
|
|
2311
|
+
children: position.symbol
|
|
2312
|
+
}
|
|
2313
|
+
),
|
|
2301
2314
|
/* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
2302
2315
|
/* @__PURE__ */ jsx(Badge, { color: "neutral", size: "xs", children: orderType }),
|
|
2303
2316
|
orderSide
|
|
@@ -3032,6 +3045,25 @@ var PartialTPSL = (props) => {
|
|
|
3032
3045
|
] })
|
|
3033
3046
|
] });
|
|
3034
3047
|
};
|
|
3048
|
+
var PositionSymbolCell = (props) => {
|
|
3049
|
+
const { symbol, onSymbolChange, className, formatString, ...rest } = props;
|
|
3050
|
+
const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(symbol);
|
|
3051
|
+
return /* @__PURE__ */ jsx(
|
|
3052
|
+
Text.symbolBadge,
|
|
3053
|
+
{
|
|
3054
|
+
...rest,
|
|
3055
|
+
className: cn(className, "oui-cursor-pointer"),
|
|
3056
|
+
badge: brokerName ?? brokerId ?? void 0,
|
|
3057
|
+
fullName: brokerNameRaw,
|
|
3058
|
+
onClick: (e) => {
|
|
3059
|
+
onSymbolChange?.({ symbol });
|
|
3060
|
+
e.stopPropagation();
|
|
3061
|
+
e.preventDefault();
|
|
3062
|
+
},
|
|
3063
|
+
children: symbol
|
|
3064
|
+
}
|
|
3065
|
+
);
|
|
3066
|
+
};
|
|
3035
3067
|
var ReversePositionButton = (props) => {
|
|
3036
3068
|
const { position } = props;
|
|
3037
3069
|
return /* @__PURE__ */ jsx(
|
|
@@ -3075,6 +3107,7 @@ var useShareButtonScript = (props) => {
|
|
|
3075
3107
|
const { position, sharePnLConfig, iconSize } = props;
|
|
3076
3108
|
const { getFirstRefCode } = useReferralInfo();
|
|
3077
3109
|
const symbolsInfo = useSymbolsInfo();
|
|
3110
|
+
const { brokerNameRaw } = useBadgeBySymbol(position.symbol);
|
|
3078
3111
|
const refCode = useMemo(() => {
|
|
3079
3112
|
return getFirstRefCode()?.code;
|
|
3080
3113
|
}, [getFirstRefCode]);
|
|
@@ -3153,7 +3186,8 @@ var useShareButtonScript = (props) => {
|
|
|
3153
3186
|
marginMode: position.margin_mode
|
|
3154
3187
|
},
|
|
3155
3188
|
refCode,
|
|
3156
|
-
...sharePnLConfig
|
|
3189
|
+
...sharePnLConfig,
|
|
3190
|
+
brokerName: sharePnLConfig?.brokerName ?? brokerNameRaw
|
|
3157
3191
|
}
|
|
3158
3192
|
});
|
|
3159
3193
|
};
|
|
@@ -3476,44 +3510,38 @@ var useColumn = (config) => {
|
|
|
3476
3510
|
onSort: (r1, r2) => {
|
|
3477
3511
|
return r1.symbol?.localeCompare(r2.symbol || "");
|
|
3478
3512
|
},
|
|
3479
|
-
render: (value, record) => /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3513
|
+
render: (value, record) => /* @__PURE__ */ jsxs(Flex, { gap: 2, className: "oui-py-1", children: [
|
|
3480
3514
|
/* @__PURE__ */ jsx(
|
|
3481
3515
|
Box,
|
|
3482
3516
|
{
|
|
3483
3517
|
width: 4,
|
|
3484
|
-
height:
|
|
3518
|
+
height: 24,
|
|
3485
3519
|
className: cn(
|
|
3486
|
-
"oui-h-[
|
|
3520
|
+
"oui-h-[42px] oui-rounded-[1px]",
|
|
3487
3521
|
record.position_qty > 0 ? "oui-bg-trade-profit" : "oui-bg-trade-loss"
|
|
3488
3522
|
)
|
|
3489
3523
|
}
|
|
3490
3524
|
),
|
|
3491
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", children: [
|
|
3492
|
-
/* @__PURE__ */
|
|
3493
|
-
Text.formatted,
|
|
3494
|
-
{
|
|
3495
|
-
formatString: "base-type",
|
|
3496
|
-
className: "oui-cursor-pointer",
|
|
3497
|
-
onClick: (e) => {
|
|
3498
|
-
onSymbolChange?.({ symbol: value });
|
|
3499
|
-
e.stopPropagation();
|
|
3500
|
-
e.preventDefault();
|
|
3501
|
-
},
|
|
3502
|
-
children: `${value.split("_")[1]}-PERP`
|
|
3503
|
-
}
|
|
3504
|
-
),
|
|
3505
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
3525
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
3526
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
3506
3527
|
/* @__PURE__ */ jsx(
|
|
3507
|
-
|
|
3528
|
+
PositionSymbolCell,
|
|
3508
3529
|
{
|
|
3509
3530
|
symbol: value,
|
|
3510
|
-
|
|
3511
|
-
modalId: SymbolLeverageDialogId,
|
|
3512
|
-
marginMode: record.margin_mode
|
|
3531
|
+
onSymbolChange
|
|
3513
3532
|
}
|
|
3514
3533
|
),
|
|
3515
3534
|
/* @__PURE__ */ jsx(RwaStatusTag, { symbol: value })
|
|
3516
|
-
] })
|
|
3535
|
+
] }),
|
|
3536
|
+
/* @__PURE__ */ jsx(Flex, { gap: 1, wrap: "wrap", children: /* @__PURE__ */ jsx(
|
|
3537
|
+
LeverageBadge,
|
|
3538
|
+
{
|
|
3539
|
+
symbol: value,
|
|
3540
|
+
leverage: record.leverage,
|
|
3541
|
+
modalId: SymbolLeverageDialogId,
|
|
3542
|
+
marginMode: record.margin_mode
|
|
3543
|
+
}
|
|
3544
|
+
) })
|
|
3517
3545
|
] })
|
|
3518
3546
|
] })
|
|
3519
3547
|
},
|
|
@@ -3785,31 +3813,37 @@ var SymbolToken = (props) => {
|
|
|
3785
3813
|
const { item } = props;
|
|
3786
3814
|
const isBuy = item.position_qty > 0;
|
|
3787
3815
|
const { t } = useTranslation();
|
|
3788
|
-
return /* @__PURE__ */
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3816
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
3817
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
3818
|
+
/* @__PURE__ */ jsx(
|
|
3819
|
+
Text.formatted,
|
|
3820
|
+
{
|
|
3821
|
+
rule: "symbol",
|
|
3822
|
+
formatString: "base",
|
|
3823
|
+
size: "2xs",
|
|
3824
|
+
showIcon: true,
|
|
3825
|
+
onClick: () => {
|
|
3826
|
+
props.onSymbolChange?.({ symbol: item.symbol });
|
|
3827
|
+
},
|
|
3828
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: item.symbol }),
|
|
3829
|
+
children: item.symbol
|
|
3830
|
+
}
|
|
3831
|
+
),
|
|
3832
|
+
/* @__PURE__ */ jsx(RwaStatusTag, { symbol: item.symbol })
|
|
3833
|
+
] }),
|
|
3834
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", wrap: "wrap", children: [
|
|
3835
|
+
/* @__PURE__ */ jsx(Badge, { color: isBuy ? "success" : "danger", size: "xs", children: isBuy ? t("common.long") : t("common.short") }),
|
|
3836
|
+
/* @__PURE__ */ jsx(
|
|
3837
|
+
LeverageBadge,
|
|
3838
|
+
{
|
|
3839
|
+
symbol: item.symbol,
|
|
3840
|
+
leverage: item.leverage,
|
|
3841
|
+
modalId: SymbolLeverageSheetId,
|
|
3842
|
+
marginMode: item.margin_mode
|
|
3843
|
+
}
|
|
3844
|
+
)
|
|
3845
|
+
] })
|
|
3846
|
+
] });
|
|
3813
3847
|
};
|
|
3814
3848
|
var UnrealPnL = (props) => {
|
|
3815
3849
|
const { item } = props;
|
|
@@ -4448,7 +4482,7 @@ var usePositionHistoryColumn = (props) => {
|
|
|
4448
4482
|
title: t("common.symbol"),
|
|
4449
4483
|
dataIndex: "symbol",
|
|
4450
4484
|
fixed: "left",
|
|
4451
|
-
width:
|
|
4485
|
+
width: 250,
|
|
4452
4486
|
onSort: (r1, r2) => {
|
|
4453
4487
|
return r1.symbol?.localeCompare(r2.symbol || "");
|
|
4454
4488
|
},
|
|
@@ -4639,6 +4673,19 @@ var SymbolInfo2 = (props) => {
|
|
|
4639
4673
|
)
|
|
4640
4674
|
);
|
|
4641
4675
|
}
|
|
4676
|
+
if (record.margin_mode != null) {
|
|
4677
|
+
list.push(
|
|
4678
|
+
/* @__PURE__ */ jsx(
|
|
4679
|
+
Badge,
|
|
4680
|
+
{
|
|
4681
|
+
color: "neutral",
|
|
4682
|
+
size: "xs",
|
|
4683
|
+
children: record.margin_mode === MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross")
|
|
4684
|
+
},
|
|
4685
|
+
`margin-mode-${record.margin_mode}`
|
|
4686
|
+
)
|
|
4687
|
+
);
|
|
4688
|
+
}
|
|
4642
4689
|
list.push(
|
|
4643
4690
|
/* @__PURE__ */ jsx(
|
|
4644
4691
|
LeverageBadge2,
|
|
@@ -4651,7 +4698,7 @@ var SymbolInfo2 = (props) => {
|
|
|
4651
4698
|
);
|
|
4652
4699
|
return list;
|
|
4653
4700
|
}, [record, t]);
|
|
4654
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2,
|
|
4701
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, className: "oui-py-1", children: [
|
|
4655
4702
|
/* @__PURE__ */ jsx(
|
|
4656
4703
|
Box,
|
|
4657
4704
|
{
|
|
@@ -4663,21 +4710,15 @@ var SymbolInfo2 = (props) => {
|
|
|
4663
4710
|
)
|
|
4664
4711
|
}
|
|
4665
4712
|
),
|
|
4666
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", children: [
|
|
4713
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
4667
4714
|
/* @__PURE__ */ jsx(
|
|
4668
|
-
|
|
4715
|
+
PositionSymbolCell,
|
|
4669
4716
|
{
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
onClick: (e) => {
|
|
4673
|
-
onSymbolChange?.({ symbol: record.symbol });
|
|
4674
|
-
e.stopPropagation();
|
|
4675
|
-
e.preventDefault();
|
|
4676
|
-
},
|
|
4677
|
-
children: `${record.symbol.split("_")[1]}-PERP`
|
|
4717
|
+
symbol: record.symbol,
|
|
4718
|
+
onSymbolChange
|
|
4678
4719
|
}
|
|
4679
4720
|
),
|
|
4680
|
-
/* @__PURE__ */ jsx(Flex, { gap: 1, children: tags })
|
|
4721
|
+
/* @__PURE__ */ jsx(Flex, { gap: 1, wrap: "wrap", children: tags })
|
|
4681
4722
|
] })
|
|
4682
4723
|
] });
|
|
4683
4724
|
};
|
|
@@ -4789,6 +4830,15 @@ var areDatesEqual = (date1, date2) => {
|
|
|
4789
4830
|
};
|
|
4790
4831
|
|
|
4791
4832
|
// src/components/positionHistory/positionHistory.script.tsx
|
|
4833
|
+
var normalizeMarginMode = (value) => {
|
|
4834
|
+
if (value === 1 || value === MarginMode.ISOLATED) {
|
|
4835
|
+
return MarginMode.ISOLATED;
|
|
4836
|
+
}
|
|
4837
|
+
if (value === 0 || value === MarginMode.CROSS) {
|
|
4838
|
+
return MarginMode.CROSS;
|
|
4839
|
+
}
|
|
4840
|
+
return void 0;
|
|
4841
|
+
};
|
|
4792
4842
|
var usePositionHistoryScript = (props) => {
|
|
4793
4843
|
const {
|
|
4794
4844
|
onSymbolChange,
|
|
@@ -4808,20 +4858,16 @@ var usePositionHistoryScript = (props) => {
|
|
|
4808
4858
|
symbol ? `/v1/position_history?symbol=${symbol}&limit=1000` : "/v1/position_history?limit=1000",
|
|
4809
4859
|
{
|
|
4810
4860
|
formatter(data2) {
|
|
4811
|
-
return (data2.rows ?? null)?.map(
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
margin_mode: item.margin_mode === 1 || item.margin_mode === MarginMode.ISOLATED ? MarginMode.ISOLATED : MarginMode.CROSS,
|
|
4819
|
-
netPnL
|
|
4820
|
-
};
|
|
4821
|
-
}
|
|
4822
|
-
return item;
|
|
4861
|
+
return (data2.rows ?? null)?.map((item) => {
|
|
4862
|
+
const result = {
|
|
4863
|
+
...item,
|
|
4864
|
+
margin_mode: normalizeMarginMode(item.margin_mode)
|
|
4865
|
+
};
|
|
4866
|
+
if (item.realized_pnl != null && item.accumulated_funding_fee != null && item.trading_fee != null) {
|
|
4867
|
+
result.netPnL = item.realized_pnl - item.accumulated_funding_fee - item.trading_fee;
|
|
4823
4868
|
}
|
|
4824
|
-
|
|
4869
|
+
return result;
|
|
4870
|
+
});
|
|
4825
4871
|
},
|
|
4826
4872
|
revalidateOnFocus: true
|
|
4827
4873
|
}
|
|
@@ -5003,9 +5049,10 @@ var SymbolToken2 = (props) => {
|
|
|
5003
5049
|
{
|
|
5004
5050
|
intensity: 80,
|
|
5005
5051
|
rule: "symbol",
|
|
5006
|
-
formatString: "base
|
|
5052
|
+
formatString: "base",
|
|
5007
5053
|
size: "sm",
|
|
5008
5054
|
prefix: /* @__PURE__ */ jsx(Badge, { color: isBuy ? "success" : "danger", size: "xs", children: isBuy ? t("common.buy") : t("common.sell") }),
|
|
5055
|
+
suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol }),
|
|
5009
5056
|
onClick: () => {
|
|
5010
5057
|
props.onSymbolChange?.({ symbol });
|
|
5011
5058
|
},
|
|
@@ -5092,8 +5139,13 @@ var PositionHistoryType = (props) => {
|
|
|
5092
5139
|
)
|
|
5093
5140
|
);
|
|
5094
5141
|
}
|
|
5142
|
+
if (record.margin_mode != null) {
|
|
5143
|
+
list.push(
|
|
5144
|
+
/* @__PURE__ */ jsx(Badge, { color: "neutral", size: "xs", children: record.margin_mode === MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross") }, `margin-${record.margin_mode}`)
|
|
5145
|
+
);
|
|
5146
|
+
}
|
|
5095
5147
|
return list;
|
|
5096
|
-
}, [record]);
|
|
5148
|
+
}, [record, t]);
|
|
5097
5149
|
return /* @__PURE__ */ jsx(Flex, { gap: 1, children: tags });
|
|
5098
5150
|
};
|
|
5099
5151
|
var ClosedQty = (props) => {
|
|
@@ -5308,7 +5360,7 @@ var Header = (props) => {
|
|
|
5308
5360
|
]
|
|
5309
5361
|
}
|
|
5310
5362
|
),
|
|
5311
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "end",
|
|
5363
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "end", children: [
|
|
5312
5364
|
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 36, children: t("positions.history.column.netPnl") }),
|
|
5313
5365
|
/* @__PURE__ */ jsxs(Flex, { gapX: 1, children: [
|
|
5314
5366
|
/* @__PURE__ */ jsx("button", { onClick: showAlert, children: /* @__PURE__ */ jsx(Text.numeral, { size: "xs", coloring: true, children: props.item.netPnL ?? "--" }) }),
|
|
@@ -5546,16 +5598,8 @@ var useLiquidationColumn = (props) => {
|
|
|
5546
5598
|
{
|
|
5547
5599
|
title: t("common.symbol"),
|
|
5548
5600
|
dataIndex: "Symbol",
|
|
5549
|
-
|
|
5550
|
-
render: (_, record) => /* @__PURE__ */ jsx(Flex, { direction: "column", itemAlign: "start", children: record.positions_by_perp?.map((item) => /* @__PURE__ */ jsx(
|
|
5551
|
-
Text.formatted,
|
|
5552
|
-
{
|
|
5553
|
-
rule: "symbol",
|
|
5554
|
-
formatString: "base-quote",
|
|
5555
|
-
children: item.symbol
|
|
5556
|
-
},
|
|
5557
|
-
item.symbol
|
|
5558
|
-
)) })
|
|
5601
|
+
width: 120,
|
|
5602
|
+
render: (_, record) => /* @__PURE__ */ jsx(Flex, { direction: "column", itemAlign: "start", children: record.positions_by_perp?.map((item) => /* @__PURE__ */ jsx(PositionSymbolCell, { symbol: item.symbol }, item.symbol)) })
|
|
5559
5603
|
},
|
|
5560
5604
|
// Price (USDC)
|
|
5561
5605
|
{
|
|
@@ -5723,9 +5767,15 @@ var Header2 = (props) => {
|
|
|
5723
5767
|
Text.formatted,
|
|
5724
5768
|
{
|
|
5725
5769
|
rule: "symbol",
|
|
5726
|
-
formatString: "base
|
|
5770
|
+
formatString: "base",
|
|
5727
5771
|
size: "xs",
|
|
5728
5772
|
intensity: 80,
|
|
5773
|
+
suffix: /* @__PURE__ */ jsx(
|
|
5774
|
+
SymbolBadge,
|
|
5775
|
+
{
|
|
5776
|
+
symbol: props.item.positions_by_perp?.[0]?.symbol || ""
|
|
5777
|
+
}
|
|
5778
|
+
),
|
|
5729
5779
|
children: props.item.positions_by_perp?.[0]?.symbol || ""
|
|
5730
5780
|
}
|
|
5731
5781
|
) }) }) }),
|