@orderly.network/trading 2.9.1 → 2.10.0-alpha.1
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +148 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
package/dist/index.d.mts
CHANGED
|
@@ -430,10 +430,12 @@ declare const useFundingRateModalScript: (options: FundingRateOptions) => {
|
|
|
430
430
|
capFunding: string;
|
|
431
431
|
floorFunding: string;
|
|
432
432
|
lastFundingRate: string | undefined;
|
|
433
|
-
estFundingRate: string | undefined;
|
|
434
433
|
estFundingFee: string;
|
|
435
434
|
lastFundingRateAnnualized: string | undefined;
|
|
436
|
-
|
|
435
|
+
estFundingRateByTimeframe: {
|
|
436
|
+
timeframe: "1H" | "4H" | "1D" | "7D" | "30D" | "1Y";
|
|
437
|
+
value: string;
|
|
438
|
+
}[];
|
|
437
439
|
};
|
|
438
440
|
type FundingRateModalState = ReturnType<typeof useFundingRateModalScript>;
|
|
439
441
|
|
package/dist/index.d.ts
CHANGED
|
@@ -430,10 +430,12 @@ declare const useFundingRateModalScript: (options: FundingRateOptions) => {
|
|
|
430
430
|
capFunding: string;
|
|
431
431
|
floorFunding: string;
|
|
432
432
|
lastFundingRate: string | undefined;
|
|
433
|
-
estFundingRate: string | undefined;
|
|
434
433
|
estFundingFee: string;
|
|
435
434
|
lastFundingRateAnnualized: string | undefined;
|
|
436
|
-
|
|
435
|
+
estFundingRateByTimeframe: {
|
|
436
|
+
timeframe: "1H" | "4H" | "1D" | "7D" | "30D" | "1Y";
|
|
437
|
+
value: string;
|
|
438
|
+
}[];
|
|
437
439
|
};
|
|
438
440
|
type FundingRateModalState = ReturnType<typeof useFundingRateModalScript>;
|
|
439
441
|
|
package/dist/index.js
CHANGED
|
@@ -2505,40 +2505,6 @@ var init_header_desktop = __esm({
|
|
|
2505
2505
|
};
|
|
2506
2506
|
}
|
|
2507
2507
|
});
|
|
2508
|
-
var MiddlePriceView;
|
|
2509
|
-
var init_midPriceView = __esm({
|
|
2510
|
-
"src/components/base/orderBook/midPriceView.tsx"() {
|
|
2511
|
-
MiddlePriceView = (props) => {
|
|
2512
|
-
const {
|
|
2513
|
-
markPrice = 0,
|
|
2514
|
-
lastPrice,
|
|
2515
|
-
quote_dp,
|
|
2516
|
-
className,
|
|
2517
|
-
iconSize = 18
|
|
2518
|
-
} = props;
|
|
2519
|
-
const [prevLastPrice, middlePrice] = lastPrice;
|
|
2520
|
-
const down = middlePrice < prevLastPrice;
|
|
2521
|
-
const up = middlePrice > prevLastPrice;
|
|
2522
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2523
|
-
ui.Flex,
|
|
2524
|
-
{
|
|
2525
|
-
gap: 1,
|
|
2526
|
-
className: ui.cn(
|
|
2527
|
-
up ? "oui-text-trade-profit" : down ? "oui-text-trade-loss" : "",
|
|
2528
|
-
className
|
|
2529
|
-
),
|
|
2530
|
-
children: [
|
|
2531
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text.numeral, { dp: quote_dp, intensity: 98, children: middlePrice }),
|
|
2532
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { width: 19, children: [
|
|
2533
|
-
down && /* @__PURE__ */ jsxRuntime.jsx(ui.ArrowDownShortIcon, { size: iconSize, color: "danger", opacity: 1 }),
|
|
2534
|
-
up && /* @__PURE__ */ jsxRuntime.jsx(ui.ArrowUpShortIcon, { size: iconSize, color: "success", opacity: 1 })
|
|
2535
|
-
] })
|
|
2536
|
-
]
|
|
2537
|
-
}
|
|
2538
|
-
);
|
|
2539
|
-
};
|
|
2540
|
-
}
|
|
2541
|
-
});
|
|
2542
2508
|
var MarkPriceView, DesktopLayout2, MobileLayout2, FlagIcon;
|
|
2543
2509
|
var init_markPrice = __esm({
|
|
2544
2510
|
"src/components/base/orderBook/markPrice.tsx"() {
|
|
@@ -2644,12 +2610,114 @@ var init_markPrice = __esm({
|
|
|
2644
2610
|
};
|
|
2645
2611
|
}
|
|
2646
2612
|
});
|
|
2613
|
+
var UNDERLINE_CLASS, MiddlePriceView, DesktopLayout3, MobileLayout3;
|
|
2614
|
+
var init_midPriceView = __esm({
|
|
2615
|
+
"src/components/base/orderBook/midPriceView.tsx"() {
|
|
2616
|
+
UNDERLINE_CLASS = "oui-cursor-pointer oui-underline oui-decoration-dashed oui-decoration-1 oui-underline-offset-4 oui-decoration-base-contrast oui-inline-flex";
|
|
2617
|
+
MiddlePriceView = (props) => {
|
|
2618
|
+
const { isMobile } = ui.useScreen();
|
|
2619
|
+
return isMobile ? /* @__PURE__ */ jsxRuntime.jsx(MobileLayout3, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(DesktopLayout3, { ...props });
|
|
2620
|
+
};
|
|
2621
|
+
DesktopLayout3 = (props) => {
|
|
2622
|
+
const { lastPrice, quote_dp, className, iconSize = 18 } = props;
|
|
2623
|
+
const { t } = i18n.useTranslation();
|
|
2624
|
+
const [prevLastPrice, middlePrice] = lastPrice;
|
|
2625
|
+
const down = middlePrice < prevLastPrice;
|
|
2626
|
+
const up = middlePrice > prevLastPrice;
|
|
2627
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2628
|
+
ui.Tooltip,
|
|
2629
|
+
{
|
|
2630
|
+
content: t("trading.orderBook.middlePrice.tooltip"),
|
|
2631
|
+
className: "oui-max-w-[240px]",
|
|
2632
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: UNDERLINE_CLASS, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2633
|
+
ui.Flex,
|
|
2634
|
+
{
|
|
2635
|
+
gap: 1,
|
|
2636
|
+
className: ui.cn(
|
|
2637
|
+
up ? "oui-text-trade-profit" : down ? "oui-text-trade-loss" : "",
|
|
2638
|
+
className
|
|
2639
|
+
),
|
|
2640
|
+
children: [
|
|
2641
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text.numeral, { dp: quote_dp, intensity: 98, children: middlePrice }),
|
|
2642
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { width: 19, children: [
|
|
2643
|
+
down && /* @__PURE__ */ jsxRuntime.jsx(ui.ArrowDownShortIcon, { size: iconSize, color: "danger", opacity: 1 }),
|
|
2644
|
+
up && /* @__PURE__ */ jsxRuntime.jsx(ui.ArrowUpShortIcon, { size: iconSize, color: "success", opacity: 1 })
|
|
2645
|
+
] })
|
|
2646
|
+
]
|
|
2647
|
+
}
|
|
2648
|
+
) })
|
|
2649
|
+
}
|
|
2650
|
+
);
|
|
2651
|
+
};
|
|
2652
|
+
MobileLayout3 = (props) => {
|
|
2653
|
+
const { lastPrice, quote_dp, className, iconSize = 18 } = props;
|
|
2654
|
+
const [open, setOpen] = React12.useState(false);
|
|
2655
|
+
const { t } = i18n.useTranslation();
|
|
2656
|
+
const [prevLastPrice, middlePrice] = lastPrice;
|
|
2657
|
+
const down = middlePrice < prevLastPrice;
|
|
2658
|
+
const up = middlePrice > prevLastPrice;
|
|
2659
|
+
const handleTriggerClick = () => setOpen(true);
|
|
2660
|
+
const handleKeyDown = (e) => {
|
|
2661
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2662
|
+
e.preventDefault();
|
|
2663
|
+
setOpen(true);
|
|
2664
|
+
}
|
|
2665
|
+
};
|
|
2666
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2668
|
+
"span",
|
|
2669
|
+
{
|
|
2670
|
+
role: "button",
|
|
2671
|
+
tabIndex: 0,
|
|
2672
|
+
className: UNDERLINE_CLASS,
|
|
2673
|
+
onClick: handleTriggerClick,
|
|
2674
|
+
onKeyDown: handleKeyDown,
|
|
2675
|
+
"aria-label": t("trading.orderBook.middlePrice.tooltip"),
|
|
2676
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2677
|
+
ui.Flex,
|
|
2678
|
+
{
|
|
2679
|
+
gap: 1,
|
|
2680
|
+
className: ui.cn(
|
|
2681
|
+
up ? "oui-text-trade-profit" : down ? "oui-text-trade-loss" : "",
|
|
2682
|
+
className
|
|
2683
|
+
),
|
|
2684
|
+
children: [
|
|
2685
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text.numeral, { dp: quote_dp, intensity: 98, children: middlePrice }),
|
|
2686
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { width: 19, children: [
|
|
2687
|
+
down && /* @__PURE__ */ jsxRuntime.jsx(ui.ArrowDownShortIcon, { size: iconSize, color: "danger", opacity: 1 }),
|
|
2688
|
+
up && /* @__PURE__ */ jsxRuntime.jsx(ui.ArrowUpShortIcon, { size: iconSize, color: "success", opacity: 1 })
|
|
2689
|
+
] })
|
|
2690
|
+
]
|
|
2691
|
+
}
|
|
2692
|
+
)
|
|
2693
|
+
}
|
|
2694
|
+
),
|
|
2695
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2696
|
+
ui.SimpleDialog,
|
|
2697
|
+
{
|
|
2698
|
+
size: "xs",
|
|
2699
|
+
open,
|
|
2700
|
+
onOpenChange: setOpen,
|
|
2701
|
+
title: t("common.tips"),
|
|
2702
|
+
actions: {
|
|
2703
|
+
primary: {
|
|
2704
|
+
label: t("common.ok"),
|
|
2705
|
+
onClick: () => setOpen(false)
|
|
2706
|
+
}
|
|
2707
|
+
},
|
|
2708
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("trading.orderBook.middlePrice.tooltip") })
|
|
2709
|
+
}
|
|
2710
|
+
)
|
|
2711
|
+
] });
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2647
2715
|
var DesktopMarkPrice, Spread;
|
|
2648
2716
|
var init_markPrice_desktop = __esm({
|
|
2649
2717
|
"src/components/desktop/orderBook/markPrice.desktop.tsx"() {
|
|
2650
|
-
init_orderContext();
|
|
2651
|
-
init_midPriceView();
|
|
2652
2718
|
init_markPrice();
|
|
2719
|
+
init_midPriceView();
|
|
2720
|
+
init_orderContext();
|
|
2653
2721
|
DesktopMarkPrice = (props) => {
|
|
2654
2722
|
const { markPrice = 0, lastPrice, asks, bids, symbolInfo } = props;
|
|
2655
2723
|
const { showTotal } = useOrderBookContext();
|
|
@@ -2872,12 +2940,25 @@ var init_fundingRate_ui = __esm({
|
|
|
2872
2940
|
};
|
|
2873
2941
|
}
|
|
2874
2942
|
});
|
|
2875
|
-
exports.useFundingRateModalScript = void 0;
|
|
2943
|
+
var TIMEFRAME_CONFIG; exports.useFundingRateModalScript = void 0;
|
|
2876
2944
|
var init_fundingRateModal_script = __esm({
|
|
2877
2945
|
"src/components/mobile/fundingRateModal/fundingRateModal.script.tsx"() {
|
|
2946
|
+
TIMEFRAME_CONFIG = [
|
|
2947
|
+
{ key: "1H", hours: 1 },
|
|
2948
|
+
{ key: "4H", hours: 4 },
|
|
2949
|
+
{ key: "1D", hours: 24 },
|
|
2950
|
+
{ key: "7D", hours: 168 },
|
|
2951
|
+
{ key: "30D", hours: 720 },
|
|
2952
|
+
{ key: "1Y", hours: 8760 }
|
|
2953
|
+
];
|
|
2878
2954
|
exports.useFundingRateModalScript = (options) => {
|
|
2879
2955
|
const { data, isLoading } = hooks.useFundingDetails(options.symbol);
|
|
2880
|
-
const {
|
|
2956
|
+
const {
|
|
2957
|
+
last_funding_rate,
|
|
2958
|
+
est_funding_rate,
|
|
2959
|
+
next_funding_time,
|
|
2960
|
+
last_funding_rate_timestamp
|
|
2961
|
+
} = hooks.useFundingRateBySymbol(options.symbol) ?? {};
|
|
2881
2962
|
const [{ aggregated, rows }] = hooks.usePositionStream(options.symbol);
|
|
2882
2963
|
const { notional } = aggregated ?? {};
|
|
2883
2964
|
const fundingPeriod = React12.useMemo(() => {
|
|
@@ -2904,12 +2985,6 @@ var init_fundingRateModal_script = __esm({
|
|
|
2904
2985
|
}
|
|
2905
2986
|
return `${new utils.Decimal(last_funding_rate).mul(100).toNumber()}%`;
|
|
2906
2987
|
}, [last_funding_rate]);
|
|
2907
|
-
const estFundingRate = React12.useMemo(() => {
|
|
2908
|
-
if (!est_funding_rate) {
|
|
2909
|
-
return void 0;
|
|
2910
|
-
}
|
|
2911
|
-
return `${new utils.Decimal(est_funding_rate).mul(100).toNumber()}%`;
|
|
2912
|
-
}, [est_funding_rate]);
|
|
2913
2988
|
const estFundingFee = React12.useMemo(() => {
|
|
2914
2989
|
if (!est_funding_rate || !notional || rows.length === 0) {
|
|
2915
2990
|
return "--";
|
|
@@ -2929,23 +3004,30 @@ var init_fundingRateModal_script = __esm({
|
|
|
2929
3004
|
const annualized = calculateAnnualizedRate(rate, data.funding_period);
|
|
2930
3005
|
return annualized ? `${annualized}%` : void 0;
|
|
2931
3006
|
}, [last_funding_rate, data?.funding_period]);
|
|
2932
|
-
const
|
|
2933
|
-
if (!
|
|
2934
|
-
|
|
3007
|
+
const settlementIntervalHours = React12.useMemo(() => {
|
|
3008
|
+
if (!next_funding_time || !last_funding_rate_timestamp) return 8;
|
|
3009
|
+
const diff = next_funding_time - last_funding_rate_timestamp;
|
|
3010
|
+
return diff / 36e5;
|
|
3011
|
+
}, [next_funding_time, last_funding_rate_timestamp]);
|
|
3012
|
+
const estFundingRateByTimeframe = React12.useMemo(() => {
|
|
3013
|
+
if (est_funding_rate === void 0 || est_funding_rate === null || settlementIntervalHours <= 0) {
|
|
3014
|
+
return [];
|
|
2935
3015
|
}
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
3016
|
+
return TIMEFRAME_CONFIG.map(({ key, hours }) => {
|
|
3017
|
+
const rate = new utils.Decimal(est_funding_rate).mul(hours).div(settlementIntervalHours).mul(100);
|
|
3018
|
+
const str = rate.toFixed(5);
|
|
3019
|
+
const trimmed = str.replace(/\.?0+$/, "") || "0";
|
|
3020
|
+
return { timeframe: key, value: `${trimmed}%` };
|
|
3021
|
+
});
|
|
3022
|
+
}, [est_funding_rate, settlementIntervalHours]);
|
|
2940
3023
|
return {
|
|
2941
3024
|
fundingPeriod,
|
|
2942
3025
|
capFunding,
|
|
2943
3026
|
floorFunding,
|
|
2944
3027
|
lastFundingRate,
|
|
2945
|
-
estFundingRate,
|
|
2946
3028
|
estFundingFee,
|
|
2947
3029
|
lastFundingRateAnnualized,
|
|
2948
|
-
|
|
3030
|
+
estFundingRateByTimeframe
|
|
2949
3031
|
};
|
|
2950
3032
|
};
|
|
2951
3033
|
}
|
|
@@ -2960,10 +3042,9 @@ var init_fundingRateModal_ui = __esm({
|
|
|
2960
3042
|
capFunding,
|
|
2961
3043
|
floorFunding,
|
|
2962
3044
|
lastFundingRate,
|
|
2963
|
-
estFundingRate,
|
|
2964
3045
|
estFundingFee,
|
|
2965
3046
|
lastFundingRateAnnualized,
|
|
2966
|
-
|
|
3047
|
+
estFundingRateByTimeframe
|
|
2967
3048
|
} = props;
|
|
2968
3049
|
const renderRow = (label, value, annualizedValue) => {
|
|
2969
3050
|
if (!value) {
|
|
@@ -3000,10 +3081,13 @@ var init_fundingRateModal_ui = __esm({
|
|
|
3000
3081
|
lastFundingRate,
|
|
3001
3082
|
lastFundingRateAnnualized
|
|
3002
3083
|
),
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3084
|
+
estFundingRateByTimeframe.map(
|
|
3085
|
+
({ timeframe, value }) => renderRow(
|
|
3086
|
+
t("trading.fundingRate.estFundingRateWithTimeframe", {
|
|
3087
|
+
timeframe
|
|
3088
|
+
}),
|
|
3089
|
+
value
|
|
3090
|
+
)
|
|
3007
3091
|
),
|
|
3008
3092
|
renderRow(t("trading.fundingRate.estimatedFundingFee"), estFundingFee),
|
|
3009
3093
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { my: 4, className: "oui-w-full", intensity: 8 }),
|
|
@@ -7787,7 +7871,7 @@ var LazyOrderBookAndTradesWidget = React12__default.default.lazy(
|
|
|
7787
7871
|
};
|
|
7788
7872
|
})
|
|
7789
7873
|
);
|
|
7790
|
-
var
|
|
7874
|
+
var DesktopLayout4 = (props) => {
|
|
7791
7875
|
const {
|
|
7792
7876
|
resizeable,
|
|
7793
7877
|
panelSize,
|
|
@@ -8617,7 +8701,7 @@ var MaybeEqual = () => {
|
|
|
8617
8701
|
}
|
|
8618
8702
|
);
|
|
8619
8703
|
};
|
|
8620
|
-
var
|
|
8704
|
+
var MobileLayout4 = (props) => {
|
|
8621
8705
|
const { t } = i18n.useTranslation();
|
|
8622
8706
|
const { isRwa, open, closeTimeInterval } = hooks.useGetRwaSymbolInfo(props.symbol);
|
|
8623
8707
|
React12.useEffect(() => {
|
|
@@ -8722,7 +8806,7 @@ var MobileLayout3 = (props) => {
|
|
|
8722
8806
|
onOpenChange: props.onOpenMarketsSheetChange,
|
|
8723
8807
|
classNames: {
|
|
8724
8808
|
body: "oui-h-full oui-pb-0",
|
|
8725
|
-
content: "oui-w-[
|
|
8809
|
+
content: "!oui-w-[372px] !oui-max-w-[372px] !oui-p-0"
|
|
8726
8810
|
},
|
|
8727
8811
|
contentProps: { side: "left", closeable: false },
|
|
8728
8812
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -8756,10 +8840,10 @@ var MobileLayout3 = (props) => {
|
|
|
8756
8840
|
var Trading = (props) => {
|
|
8757
8841
|
const { isMobile } = ui.useScreen();
|
|
8758
8842
|
if (isMobile) {
|
|
8759
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8843
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MobileLayout4, { ...props });
|
|
8760
8844
|
}
|
|
8761
8845
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8762
|
-
|
|
8846
|
+
DesktopLayout4,
|
|
8763
8847
|
{
|
|
8764
8848
|
className: "oui-h-[calc(100vh_-_48px_-_29px)] oui-bg-base-10",
|
|
8765
8849
|
...props
|