@orderly.network/portfolio 2.11.1-alpha.0 → 2.11.2-alpha.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.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +109 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
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
|
@@ -4115,7 +4115,7 @@ var init_useAssetHistory = __esm({
|
|
|
4115
4115
|
);
|
|
4116
4116
|
const [userStatistics] = hooks.useUserStatistics();
|
|
4117
4117
|
const todayVolume = React12.useMemo(
|
|
4118
|
-
() => userStatistics?.
|
|
4118
|
+
() => userStatistics?.perp_trading_volume_today ?? 0,
|
|
4119
4119
|
[userStatistics]
|
|
4120
4120
|
);
|
|
4121
4121
|
const lastBalanceEventRef = React12.useRef(0);
|
|
@@ -4272,6 +4272,7 @@ var init_useAssetHistory = __esm({
|
|
|
4272
4272
|
...lastItem2,
|
|
4273
4273
|
date: getUTCStr(today),
|
|
4274
4274
|
perp_volume: todayVol,
|
|
4275
|
+
base_account_value: lastItem2?.account_value ?? 0,
|
|
4275
4276
|
account_value: totalValue2 !== null ? totalValue2 : lastItem2?.account_value ?? 0,
|
|
4276
4277
|
pnl: calculateLastPnl({
|
|
4277
4278
|
lastItem: lastItem2,
|
|
@@ -4330,6 +4331,25 @@ var init_useAssetHistory = __esm({
|
|
|
4330
4331
|
totalTransferOut,
|
|
4331
4332
|
todayVolume
|
|
4332
4333
|
]);
|
|
4334
|
+
const todayPerformance = React12.useMemo(() => {
|
|
4335
|
+
if (!Array.isArray(calculatedData) || calculatedData.length === 0) {
|
|
4336
|
+
return null;
|
|
4337
|
+
}
|
|
4338
|
+
const todayRow = calculatedData[calculatedData.length - 1];
|
|
4339
|
+
if (!todayRow.__isCalculated) {
|
|
4340
|
+
return null;
|
|
4341
|
+
}
|
|
4342
|
+
const baseAccountValue = typeof todayRow.base_account_value === "number" ? todayRow.base_account_value : todayRow.account_value ?? 0;
|
|
4343
|
+
let roi = utils.zero;
|
|
4344
|
+
if (baseAccountValue) {
|
|
4345
|
+
roi = new utils.Decimal(todayRow.pnl).div(baseAccountValue);
|
|
4346
|
+
}
|
|
4347
|
+
return {
|
|
4348
|
+
pnl: todayRow.pnl,
|
|
4349
|
+
roi: roi.toNumber(),
|
|
4350
|
+
vol: todayRow.perp_volume ?? 0
|
|
4351
|
+
};
|
|
4352
|
+
}, [calculatedData]);
|
|
4333
4353
|
const aggregateValue = React12.useMemo(() => {
|
|
4334
4354
|
let vol = utils.zero;
|
|
4335
4355
|
let pnl = utils.zero;
|
|
@@ -4369,7 +4389,8 @@ var init_useAssetHistory = __esm({
|
|
|
4369
4389
|
// calculatedData,
|
|
4370
4390
|
aggregateValue,
|
|
4371
4391
|
createFakeData,
|
|
4372
|
-
volumeUpdateDate: data?.[data.length - 1]?.date ?? ""
|
|
4392
|
+
volumeUpdateDate: data?.[data.length - 1]?.date ?? "",
|
|
4393
|
+
todayPerformance
|
|
4373
4394
|
};
|
|
4374
4395
|
};
|
|
4375
4396
|
}
|
|
@@ -4479,7 +4500,7 @@ var init_performance_ui = __esm({
|
|
|
4479
4500
|
formatForChart = (value, dp = 2) => {
|
|
4480
4501
|
if (value == null) return 0;
|
|
4481
4502
|
const decimal = new utils.Decimal(value);
|
|
4482
|
-
return Number(decimal.toFixed(dp, utils.Decimal.
|
|
4503
|
+
return Number(decimal.toFixed(dp, utils.Decimal.ROUND_HALF_UP));
|
|
4483
4504
|
};
|
|
4484
4505
|
PerformanceUI = (props) => {
|
|
4485
4506
|
const {
|
|
@@ -5084,7 +5105,7 @@ var init_apiManager_script = __esm({
|
|
|
5084
5105
|
hideCreateDialog();
|
|
5085
5106
|
setGenerateKey({
|
|
5086
5107
|
key,
|
|
5087
|
-
|
|
5108
|
+
secretKey,
|
|
5088
5109
|
ip,
|
|
5089
5110
|
permissions: scope?.split(",")?.map((e) => capitalizeFirstChar(e)).join(", ")
|
|
5090
5111
|
});
|
|
@@ -5505,7 +5526,7 @@ var init_createdApiKey = __esm({
|
|
|
5505
5526
|
copyIconSize: 16,
|
|
5506
5527
|
className: "oui-break-all",
|
|
5507
5528
|
onCopy: props.onCopyApiSecretKey,
|
|
5508
|
-
children: props.generateKey?.
|
|
5529
|
+
children: props.generateKey?.secretKey
|
|
5509
5530
|
}
|
|
5510
5531
|
),
|
|
5511
5532
|
" "
|
|
@@ -5949,18 +5970,24 @@ var init_apiManager_ui = __esm({
|
|
|
5949
5970
|
dataIndex: "orderly_key",
|
|
5950
5971
|
width: 150,
|
|
5951
5972
|
render: (value) => {
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5973
|
+
const fullKey = typeof value === "string" ? value : `${value ?? ""}`;
|
|
5974
|
+
const displayKey = formatKey(fullKey);
|
|
5975
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
|
|
5976
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-overflow-hidden oui-overflow-ellipsis", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { rule: "", children: displayKey }) }),
|
|
5977
|
+
!!fullKey && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { width: 16, height: 16, className: "oui-cursor-pointer", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5978
|
+
ui.CopyIcon,
|
|
5979
|
+
{
|
|
5980
|
+
color: "white",
|
|
5981
|
+
opacity: 0.54,
|
|
5982
|
+
size: 16,
|
|
5983
|
+
onClick: (e) => {
|
|
5984
|
+
e.stopPropagation();
|
|
5985
|
+
navigator.clipboard.writeText(fullKey);
|
|
5986
|
+
props.onCopyApiKey?.(fullKey);
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
) })
|
|
5990
|
+
] });
|
|
5964
5991
|
}
|
|
5965
5992
|
},
|
|
5966
5993
|
{
|
|
@@ -6763,8 +6790,10 @@ init_assetChart();
|
|
|
6763
6790
|
|
|
6764
6791
|
// src/pages/overview/portfolioChartsMobile/portfolioChartsMobile.script.ts
|
|
6765
6792
|
init_type();
|
|
6793
|
+
init_overviewContext();
|
|
6766
6794
|
var usePortfolioChartsState = () => {
|
|
6767
6795
|
const [data] = hooks.usePositionStream();
|
|
6796
|
+
const overview = useOverviewContext();
|
|
6768
6797
|
const [visible, setVisible] = hooks.useLocalStorage(
|
|
6769
6798
|
ORDERLY_ASSETS_VISIBLE_KEY,
|
|
6770
6799
|
true
|
|
@@ -6773,6 +6802,9 @@ var usePortfolioChartsState = () => {
|
|
|
6773
6802
|
return ui.modal.show(PerformanceMobileSheetId);
|
|
6774
6803
|
}, []);
|
|
6775
6804
|
return {
|
|
6805
|
+
todaysPnl: overview?.todayPerformance?.pnl ?? null,
|
|
6806
|
+
todaysRoi: overview?.todayPerformance?.roi ?? null,
|
|
6807
|
+
todaysVol: overview?.todayPerformance?.vol ?? null,
|
|
6776
6808
|
unrealPnL: data?.aggregated.total_unreal_pnl,
|
|
6777
6809
|
unrealROI: data?.totalUnrealizedROI,
|
|
6778
6810
|
visible,
|
|
@@ -6781,7 +6813,15 @@ var usePortfolioChartsState = () => {
|
|
|
6781
6813
|
};
|
|
6782
6814
|
};
|
|
6783
6815
|
var PortfolioChartsMobileUI = (props) => {
|
|
6784
|
-
const {
|
|
6816
|
+
const {
|
|
6817
|
+
data,
|
|
6818
|
+
invisible,
|
|
6819
|
+
todaysPnl,
|
|
6820
|
+
todaysRoi,
|
|
6821
|
+
todaysVol,
|
|
6822
|
+
visible,
|
|
6823
|
+
onPerformanceClick
|
|
6824
|
+
} = props;
|
|
6785
6825
|
const { t } = i18n.useTranslation();
|
|
6786
6826
|
const colorId = React12.useId();
|
|
6787
6827
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -6789,62 +6829,55 @@ var PortfolioChartsMobileUI = (props) => {
|
|
|
6789
6829
|
{
|
|
6790
6830
|
p: 4,
|
|
6791
6831
|
width: "100%",
|
|
6792
|
-
|
|
6793
|
-
justify: "between",
|
|
6832
|
+
direction: "column",
|
|
6794
6833
|
className: ui.cn(
|
|
6795
6834
|
"oui-relative oui-overflow-hidden oui-rounded-2xl oui-border oui-border-solid oui-border-line-12 oui-bg-base-9"
|
|
6796
6835
|
),
|
|
6797
6836
|
children: [
|
|
6798
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
6799
|
-
ui.Flex,
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
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,
|
|
6837
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", justify: "between", itemAlign: "start", mb: 3, children: [
|
|
6838
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 1, children: [
|
|
6839
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 54, children: t("portfolio.overview.todaysPnl") }),
|
|
6840
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "start", itemAlign: "center", gapX: 1, children: [
|
|
6841
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text.pnl, { coloring: true, size: "base", weight: "semibold", visible, children: invisible || todaysPnl == null ? "--" : todaysPnl }),
|
|
6842
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6843
|
+
ui.Text.roi,
|
|
6826
6844
|
{
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6845
|
+
coloring: true,
|
|
6846
|
+
rule: "percentages",
|
|
6847
|
+
size: "sm",
|
|
6848
|
+
weight: "semibold",
|
|
6849
|
+
prefix: "(",
|
|
6850
|
+
suffix: ")",
|
|
6851
|
+
visible,
|
|
6852
|
+
children: invisible || todaysRoi == null ? "--" : todaysRoi
|
|
6835
6853
|
}
|
|
6836
6854
|
)
|
|
6837
|
-
]
|
|
6838
|
-
}
|
|
6839
|
-
|
|
6855
|
+
] })
|
|
6856
|
+
] }),
|
|
6857
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 1, itemAlign: "end", children: [
|
|
6858
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 54, children: t("portfolio.overview.todaysVol") }),
|
|
6859
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6860
|
+
ui.Text.numeral,
|
|
6861
|
+
{
|
|
6862
|
+
size: "sm",
|
|
6863
|
+
rule: "human",
|
|
6864
|
+
dp: 2,
|
|
6865
|
+
visible,
|
|
6866
|
+
prefix: "$",
|
|
6867
|
+
children: invisible || todaysVol == null ? "--" : todaysVol
|
|
6868
|
+
}
|
|
6869
|
+
)
|
|
6870
|
+
] })
|
|
6871
|
+
] }),
|
|
6840
6872
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6841
6873
|
ui.Flex,
|
|
6842
6874
|
{
|
|
6843
6875
|
width: "100%",
|
|
6844
6876
|
justify: "center",
|
|
6845
6877
|
itemAlign: "center",
|
|
6846
|
-
|
|
6847
|
-
|
|
6878
|
+
mb: 3,
|
|
6879
|
+
className: "oui-px-1",
|
|
6880
|
+
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
6881
|
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: colorId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
6849
6882
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6850
6883
|
"stop",
|
|
@@ -6875,9 +6908,22 @@ var PortfolioChartsMobileUI = (props) => {
|
|
|
6875
6908
|
fill: `url(#${colorId})`
|
|
6876
6909
|
}
|
|
6877
6910
|
)
|
|
6878
|
-
] }) })
|
|
6911
|
+
] }) }) })
|
|
6879
6912
|
}
|
|
6880
|
-
)
|
|
6913
|
+
),
|
|
6914
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { width: "100%", justify: "start", itemAlign: "center", mt: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6915
|
+
ui.Text,
|
|
6916
|
+
{
|
|
6917
|
+
size: "xs",
|
|
6918
|
+
intensity: 54,
|
|
6919
|
+
className: "oui-flex oui-items-center oui-justify-start oui-gap-1",
|
|
6920
|
+
onClick: onPerformanceClick,
|
|
6921
|
+
children: [
|
|
6922
|
+
t("portfolio.overview.performance"),
|
|
6923
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.ChevronRightIcon, { className: "oui-text-base-contrast-54" })
|
|
6924
|
+
]
|
|
6925
|
+
}
|
|
6926
|
+
) })
|
|
6881
6927
|
]
|
|
6882
6928
|
}
|
|
6883
6929
|
);
|