@orderly.network/hooks 2.7.4 → 2.8.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 +108 -3
- package/dist/index.d.ts +108 -3
- package/dist/index.js +310 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -12,12 +12,12 @@ var lodash = require('lodash');
|
|
|
12
12
|
var useSWRInfinite = require('swr/infinite');
|
|
13
13
|
var ramda = require('ramda');
|
|
14
14
|
var perp = require('@orderly.network/perp');
|
|
15
|
+
var useSWRSubscription = require('swr/subscription');
|
|
15
16
|
var amplitude = require('@amplitude/analytics-browser');
|
|
16
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
17
18
|
var defaultEvmAdapter = require('@orderly.network/default-evm-adapter');
|
|
18
19
|
var defaultSolanaAdapter = require('@orderly.network/default-solana-adapter');
|
|
19
20
|
var web3ProviderEthers = require('@orderly.network/web3-provider-ethers');
|
|
20
|
-
var useSWRSubscription = require('swr/subscription');
|
|
21
21
|
var zustand = require('zustand');
|
|
22
22
|
var immer = require('zustand/middleware/immer');
|
|
23
23
|
var useDebounce = require('use-debounce');
|
|
@@ -49,8 +49,8 @@ var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
|
49
49
|
var useSWRMutation__default = /*#__PURE__*/_interopDefault(useSWRMutation);
|
|
50
50
|
var useConstant__default = /*#__PURE__*/_interopDefault(useConstant);
|
|
51
51
|
var useSWRInfinite__default = /*#__PURE__*/_interopDefault(useSWRInfinite);
|
|
52
|
-
var amplitude__namespace = /*#__PURE__*/_interopNamespace(amplitude);
|
|
53
52
|
var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscription);
|
|
53
|
+
var amplitude__namespace = /*#__PURE__*/_interopNamespace(amplitude);
|
|
54
54
|
|
|
55
55
|
var __defProp = Object.defineProperty;
|
|
56
56
|
var __export = (target, all) => {
|
|
@@ -61,9 +61,9 @@ var __export = (target, all) => {
|
|
|
61
61
|
// src/version.ts
|
|
62
62
|
if (typeof window !== "undefined") {
|
|
63
63
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
64
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.
|
|
64
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.8.0";
|
|
65
65
|
}
|
|
66
|
-
var version_default = "2.
|
|
66
|
+
var version_default = "2.8.0";
|
|
67
67
|
var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
|
|
68
68
|
var noCacheConfig = {
|
|
69
69
|
dedupingInterval: 0,
|
|
@@ -717,12 +717,12 @@ var useDaily = (options) => {
|
|
|
717
717
|
start_date,
|
|
718
718
|
end_date
|
|
719
719
|
)}`;
|
|
720
|
-
const { data: dailyVolume, mutate:
|
|
720
|
+
const { data: dailyVolume, mutate: mutate6 } = usePrivateQuery(url, {
|
|
721
721
|
revalidateOnFocus: true
|
|
722
722
|
});
|
|
723
723
|
return {
|
|
724
724
|
data: dailyVolume,
|
|
725
|
-
mutate:
|
|
725
|
+
mutate: mutate6
|
|
726
726
|
};
|
|
727
727
|
};
|
|
728
728
|
var useReferralRebateSummary = (params) => {
|
|
@@ -834,14 +834,14 @@ var useRefereeRebateSummary = (params) => {
|
|
|
834
834
|
}
|
|
835
835
|
const {
|
|
836
836
|
data,
|
|
837
|
-
mutate:
|
|
837
|
+
mutate: mutate6,
|
|
838
838
|
isLoading
|
|
839
839
|
} = usePrivateQuery(url, {
|
|
840
840
|
revalidateOnFocus: true
|
|
841
841
|
});
|
|
842
842
|
return {
|
|
843
843
|
data,
|
|
844
|
-
mutate:
|
|
844
|
+
mutate: mutate6,
|
|
845
845
|
isLoading
|
|
846
846
|
};
|
|
847
847
|
};
|
|
@@ -2206,8 +2206,57 @@ var useFeeState = () => {
|
|
|
2206
2206
|
errorRetryCount: 3,
|
|
2207
2207
|
...noCacheConfig
|
|
2208
2208
|
});
|
|
2209
|
-
const
|
|
2210
|
-
const
|
|
2209
|
+
const ws = useWS();
|
|
2210
|
+
const topic = "account";
|
|
2211
|
+
const { data: wsAccountData } = useSWRSubscription__default.default(
|
|
2212
|
+
"account",
|
|
2213
|
+
(_, { next }) => {
|
|
2214
|
+
const unsubscribe = ws.subscribe(topic, {
|
|
2215
|
+
onMessage: (message) => {
|
|
2216
|
+
next(null, message);
|
|
2217
|
+
}
|
|
2218
|
+
});
|
|
2219
|
+
return () => {
|
|
2220
|
+
unsubscribe?.();
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
);
|
|
2224
|
+
const takerFeeBps = React2.useMemo(() => {
|
|
2225
|
+
if (wsAccountData?.accountDetail?.futuresTakerFeeRate) {
|
|
2226
|
+
return wsAccountData?.accountDetail?.futuresTakerFeeRate;
|
|
2227
|
+
}
|
|
2228
|
+
return accountInfo?.futures_taker_fee_rate;
|
|
2229
|
+
}, [
|
|
2230
|
+
accountInfo?.futures_taker_fee_rate,
|
|
2231
|
+
wsAccountData?.accountDetail?.futuresTakerFeeRate
|
|
2232
|
+
]);
|
|
2233
|
+
const makerFeeBps = React2.useMemo(() => {
|
|
2234
|
+
if (wsAccountData?.accountDetail?.futuresMakerFeeRate) {
|
|
2235
|
+
return wsAccountData?.accountDetail?.futuresMakerFeeRate;
|
|
2236
|
+
}
|
|
2237
|
+
return accountInfo?.futures_maker_fee_rate;
|
|
2238
|
+
}, [
|
|
2239
|
+
accountInfo?.futures_maker_fee_rate,
|
|
2240
|
+
wsAccountData?.accountDetail?.futuresMakerFeeRate
|
|
2241
|
+
]);
|
|
2242
|
+
const rwaTakerFeeBps = React2.useMemo(() => {
|
|
2243
|
+
if (wsAccountData?.accountDetail?.rwaFuturesTakerFeeRate) {
|
|
2244
|
+
return wsAccountData?.accountDetail?.rwaFuturesTakerFeeRate;
|
|
2245
|
+
}
|
|
2246
|
+
return accountInfo?.rwa_taker_fee_rate;
|
|
2247
|
+
}, [
|
|
2248
|
+
accountInfo?.rwa_taker_fee_rate,
|
|
2249
|
+
wsAccountData?.accountDetail?.rwaFuturesTakerFeeRate
|
|
2250
|
+
]);
|
|
2251
|
+
const rwaMakerFeeBps = React2.useMemo(() => {
|
|
2252
|
+
if (wsAccountData?.accountDetail?.rwaFuturesMakerFeeRate) {
|
|
2253
|
+
return wsAccountData?.accountDetail?.rwaFuturesMakerFeeRate;
|
|
2254
|
+
}
|
|
2255
|
+
return accountInfo?.rwa_maker_fee_rate;
|
|
2256
|
+
}, [
|
|
2257
|
+
accountInfo?.rwa_maker_fee_rate,
|
|
2258
|
+
wsAccountData?.accountDetail?.rwaFuturesMakerFeeRate
|
|
2259
|
+
]);
|
|
2211
2260
|
const refereeRebate = referralData?.referee_info?.referee_rebate_rate;
|
|
2212
2261
|
const takerFee = React2.useMemo(() => {
|
|
2213
2262
|
if (isAccountLoading || takerFeeBps === null || takerFeeBps === void 0) {
|
|
@@ -2243,12 +2292,50 @@ var useFeeState = () => {
|
|
|
2243
2292
|
);
|
|
2244
2293
|
return formatFractionAsPercent(effective);
|
|
2245
2294
|
}, [makerFeeBps, refereeRebate, isReferralLoading]);
|
|
2295
|
+
const rwaTakerFee = React2.useMemo(() => {
|
|
2296
|
+
if (isAccountLoading || rwaTakerFeeBps === null || rwaTakerFeeBps === void 0) {
|
|
2297
|
+
return "-";
|
|
2298
|
+
}
|
|
2299
|
+
return formatFractionAsPercent(bpsToFraction(rwaTakerFeeBps));
|
|
2300
|
+
}, [isAccountLoading, rwaTakerFeeBps]);
|
|
2301
|
+
const rwaMakerFee = React2.useMemo(() => {
|
|
2302
|
+
if (isAccountLoading || rwaMakerFeeBps === null || rwaMakerFeeBps === void 0) {
|
|
2303
|
+
return "-";
|
|
2304
|
+
}
|
|
2305
|
+
return formatFractionAsPercent(bpsToFraction(rwaMakerFeeBps));
|
|
2306
|
+
}, [isAccountLoading, rwaMakerFeeBps]);
|
|
2307
|
+
const rwaEffectiveTakerFee = React2.useMemo(() => {
|
|
2308
|
+
if (isAccountLoading || rwaTakerFeeBps === null || rwaTakerFeeBps === void 0 || isReferralLoading) {
|
|
2309
|
+
return "-";
|
|
2310
|
+
}
|
|
2311
|
+
const effective = computeEffectiveFromBps(
|
|
2312
|
+
rwaTakerFeeBps,
|
|
2313
|
+
ORDERLY_MAKER_FEE_BPS,
|
|
2314
|
+
refereeRebate
|
|
2315
|
+
);
|
|
2316
|
+
return formatFractionAsPercent(effective);
|
|
2317
|
+
}, [isAccountLoading, rwaTakerFeeBps, refereeRebate, isReferralLoading]);
|
|
2318
|
+
const rwaEffectiveMakerFee = React2.useMemo(() => {
|
|
2319
|
+
if (isAccountLoading || rwaMakerFeeBps === null || rwaMakerFeeBps === void 0 || isReferralLoading) {
|
|
2320
|
+
return "-";
|
|
2321
|
+
}
|
|
2322
|
+
const effective = computeEffectiveFromBps(
|
|
2323
|
+
rwaMakerFeeBps,
|
|
2324
|
+
ORDERLY_MAKER_FEE_BPS,
|
|
2325
|
+
refereeRebate
|
|
2326
|
+
);
|
|
2327
|
+
return formatFractionAsPercent(effective);
|
|
2328
|
+
}, [isAccountLoading, rwaMakerFeeBps, refereeRebate, isReferralLoading]);
|
|
2246
2329
|
return {
|
|
2247
2330
|
takerFee,
|
|
2248
2331
|
makerFee,
|
|
2249
2332
|
refereeRebate,
|
|
2250
2333
|
effectiveTakerFee,
|
|
2251
|
-
effectiveMakerFee
|
|
2334
|
+
effectiveMakerFee,
|
|
2335
|
+
rwaTakerFee,
|
|
2336
|
+
rwaMakerFee,
|
|
2337
|
+
rwaEffectiveTakerFee,
|
|
2338
|
+
rwaEffectiveMakerFee
|
|
2252
2339
|
};
|
|
2253
2340
|
};
|
|
2254
2341
|
var apiKeyMap = {
|
|
@@ -2595,6 +2682,15 @@ var useAppStore = zustand.create()(
|
|
|
2595
2682
|
// "setSymbolsInfo"
|
|
2596
2683
|
);
|
|
2597
2684
|
},
|
|
2685
|
+
setRwaSymbolsInfo: (rwaSymbolsInfo) => {
|
|
2686
|
+
set(
|
|
2687
|
+
(state) => {
|
|
2688
|
+
state.rwaSymbolsInfo = rwaSymbolsInfo;
|
|
2689
|
+
},
|
|
2690
|
+
false
|
|
2691
|
+
// "setRwaSymbolsInfo"
|
|
2692
|
+
);
|
|
2693
|
+
},
|
|
2598
2694
|
setFundingRates: (fundingRates) => {
|
|
2599
2695
|
set(
|
|
2600
2696
|
(state) => {
|
|
@@ -2665,7 +2761,138 @@ var useAppStore = zustand.create()(
|
|
|
2665
2761
|
var useAccountInfo2 = () => useAppStore((state) => state.accountInfo);
|
|
2666
2762
|
var usePortfolio = () => useAppStore((state) => state.portfolio);
|
|
2667
2763
|
|
|
2668
|
-
// src/orderly/
|
|
2764
|
+
// src/orderly/useRwaSymbolsInfo.ts
|
|
2765
|
+
var isCurrentlyTrading = (nextClose, status, currentTime = Date.now()) => {
|
|
2766
|
+
return currentTime < nextClose && status === "open";
|
|
2767
|
+
};
|
|
2768
|
+
var isCurrentlyClosed = (nextOpen, status, currentTime = Date.now()) => {
|
|
2769
|
+
return currentTime < nextOpen && status === "close";
|
|
2770
|
+
};
|
|
2771
|
+
var useRwaSymbolsInfo = () => {
|
|
2772
|
+
const symbolsInfo = useAppStore((state) => state.rwaSymbolsInfo);
|
|
2773
|
+
return React2.useMemo(() => createGetter({ ...symbolsInfo }), [symbolsInfo]);
|
|
2774
|
+
};
|
|
2775
|
+
var useRwaSymbolsInfoStore = () => {
|
|
2776
|
+
return useAppStore((state) => state.rwaSymbolsInfo);
|
|
2777
|
+
};
|
|
2778
|
+
var computeSymbolState = (rwaSymbol, currentTime) => {
|
|
2779
|
+
const { status, next_close, next_open } = rwaSymbol;
|
|
2780
|
+
const isOpen = isCurrentlyTrading(next_close, status, currentTime);
|
|
2781
|
+
let closeTimeInterval;
|
|
2782
|
+
let openTimeInterval;
|
|
2783
|
+
if (next_close && typeof next_close === "number" && next_close > currentTime) {
|
|
2784
|
+
closeTimeInterval = Math.max(0, Math.floor((next_close - currentTime) / 1e3));
|
|
2785
|
+
}
|
|
2786
|
+
if (next_open && typeof next_open === "number" && next_open > currentTime) {
|
|
2787
|
+
openTimeInterval = Math.max(0, Math.floor((next_open - currentTime) / 1e3));
|
|
2788
|
+
}
|
|
2789
|
+
return {
|
|
2790
|
+
isRwa: true,
|
|
2791
|
+
open: isOpen,
|
|
2792
|
+
nextOpen: next_open || void 0,
|
|
2793
|
+
nextClose: next_close || void 0,
|
|
2794
|
+
closeTimeInterval,
|
|
2795
|
+
openTimeInterval
|
|
2796
|
+
};
|
|
2797
|
+
};
|
|
2798
|
+
var useRwaSymbolsRuntimeStore = zustand.create((set, get3) => ({
|
|
2799
|
+
computedStates: {},
|
|
2800
|
+
currentTime: Date.now(),
|
|
2801
|
+
timerId: void 0,
|
|
2802
|
+
startTimer: () => {
|
|
2803
|
+
const state = get3();
|
|
2804
|
+
if (state.timerId) {
|
|
2805
|
+
clearInterval(state.timerId);
|
|
2806
|
+
}
|
|
2807
|
+
const timerId = setInterval(() => {
|
|
2808
|
+
const currentTime = Date.now();
|
|
2809
|
+
const rwaSymbolsInfo = useAppStore.getState().rwaSymbolsInfo;
|
|
2810
|
+
if (!rwaSymbolsInfo) {
|
|
2811
|
+
set({ currentTime });
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
const computedStates = {};
|
|
2815
|
+
Object.entries(rwaSymbolsInfo).forEach(([symbol, rwaSymbol]) => {
|
|
2816
|
+
computedStates[symbol] = computeSymbolState(rwaSymbol, currentTime);
|
|
2817
|
+
});
|
|
2818
|
+
set({ computedStates, currentTime });
|
|
2819
|
+
}, 1e3);
|
|
2820
|
+
set({ timerId });
|
|
2821
|
+
},
|
|
2822
|
+
stopTimer: () => {
|
|
2823
|
+
const state = get3();
|
|
2824
|
+
if (state.timerId) {
|
|
2825
|
+
clearInterval(state.timerId);
|
|
2826
|
+
set({ timerId: void 0 });
|
|
2827
|
+
}
|
|
2828
|
+
},
|
|
2829
|
+
updateComputedStates: (rwaSymbolsInfo) => {
|
|
2830
|
+
const currentTime = get3().currentTime;
|
|
2831
|
+
const computedStates = {};
|
|
2832
|
+
Object.entries(rwaSymbolsInfo).forEach(([symbol, rwaSymbol]) => {
|
|
2833
|
+
computedStates[symbol] = computeSymbolState(rwaSymbol, currentTime);
|
|
2834
|
+
});
|
|
2835
|
+
set({ computedStates });
|
|
2836
|
+
}
|
|
2837
|
+
}));
|
|
2838
|
+
var useInitRwaSymbolsRuntime = () => {
|
|
2839
|
+
const rwaSymbolsInfo = useRwaSymbolsInfoStore();
|
|
2840
|
+
const { startTimer, stopTimer, updateComputedStates } = useRwaSymbolsRuntimeStore();
|
|
2841
|
+
React2.useEffect(() => {
|
|
2842
|
+
if (rwaSymbolsInfo && Object.keys(rwaSymbolsInfo).length > 0) {
|
|
2843
|
+
updateComputedStates(rwaSymbolsInfo);
|
|
2844
|
+
startTimer();
|
|
2845
|
+
}
|
|
2846
|
+
return () => {
|
|
2847
|
+
stopTimer();
|
|
2848
|
+
};
|
|
2849
|
+
}, [rwaSymbolsInfo, startTimer, stopTimer, updateComputedStates]);
|
|
2850
|
+
};
|
|
2851
|
+
var useGetRwaSymbolInfo = (symbol) => {
|
|
2852
|
+
const computedState = useRwaSymbolsRuntimeStore(
|
|
2853
|
+
(state) => state.computedStates[symbol]
|
|
2854
|
+
);
|
|
2855
|
+
return React2.useMemo(() => {
|
|
2856
|
+
if (!computedState) {
|
|
2857
|
+
return { isRwa: false };
|
|
2858
|
+
}
|
|
2859
|
+
return computedState;
|
|
2860
|
+
}, [computedState]);
|
|
2861
|
+
};
|
|
2862
|
+
var useGetRwaSymbolOpenStatus = (symbol) => {
|
|
2863
|
+
const { isRwa, open } = useGetRwaSymbolInfo(symbol);
|
|
2864
|
+
return React2.useMemo(() => {
|
|
2865
|
+
return { isRwa, open };
|
|
2866
|
+
}, [isRwa, open]);
|
|
2867
|
+
};
|
|
2868
|
+
var filterTimeInterval = (timeInterval, isRwa, thresholdMinutes) => {
|
|
2869
|
+
if (!isRwa || !timeInterval) {
|
|
2870
|
+
return void 0;
|
|
2871
|
+
}
|
|
2872
|
+
return timeInterval > thresholdMinutes * 60 ? void 0 : timeInterval;
|
|
2873
|
+
};
|
|
2874
|
+
var useGetRwaSymbolCloseTimeInterval = (symbol, thresholdMinutes = 30) => {
|
|
2875
|
+
const { isRwa, open, closeTimeInterval, nextClose } = useGetRwaSymbolInfo(symbol);
|
|
2876
|
+
return React2.useMemo(() => {
|
|
2877
|
+
const filteredInterval = filterTimeInterval(
|
|
2878
|
+
closeTimeInterval,
|
|
2879
|
+
isRwa,
|
|
2880
|
+
thresholdMinutes
|
|
2881
|
+
);
|
|
2882
|
+
return { isRwa, open, closeTimeInterval: filteredInterval, nextClose };
|
|
2883
|
+
}, [isRwa, open, closeTimeInterval, nextClose, thresholdMinutes]);
|
|
2884
|
+
};
|
|
2885
|
+
var useGetRwaSymbolOpenTimeInterval = (symbol, thresholdMinutes = 30) => {
|
|
2886
|
+
const { isRwa, open, openTimeInterval, nextOpen } = useGetRwaSymbolInfo(symbol);
|
|
2887
|
+
return React2.useMemo(() => {
|
|
2888
|
+
const filteredInterval = filterTimeInterval(
|
|
2889
|
+
openTimeInterval,
|
|
2890
|
+
isRwa,
|
|
2891
|
+
thresholdMinutes
|
|
2892
|
+
);
|
|
2893
|
+
return { isRwa, open, openTimeInterval: filteredInterval, nextOpen };
|
|
2894
|
+
}, [isRwa, open, openTimeInterval, nextOpen, thresholdMinutes]);
|
|
2895
|
+
};
|
|
2669
2896
|
var useSymbolsInfo = () => {
|
|
2670
2897
|
const symbolsInfo = useAppStore((state) => state.symbolsInfo);
|
|
2671
2898
|
return React2.useMemo(() => createGetter({ ...symbolsInfo }), [symbolsInfo]);
|
|
@@ -2679,7 +2906,8 @@ var MarketsType = /* @__PURE__ */ ((MarketsType2) => {
|
|
|
2679
2906
|
MarketsType2[MarketsType2["FAVORITES"] = 0] = "FAVORITES";
|
|
2680
2907
|
MarketsType2[MarketsType2["RECENT"] = 1] = "RECENT";
|
|
2681
2908
|
MarketsType2[MarketsType2["ALL"] = 2] = "ALL";
|
|
2682
|
-
MarketsType2[MarketsType2["
|
|
2909
|
+
MarketsType2[MarketsType2["RWA"] = 3] = "RWA";
|
|
2910
|
+
MarketsType2[MarketsType2["NEW_LISTING"] = 4] = "NEW_LISTING";
|
|
2683
2911
|
return MarketsType2;
|
|
2684
2912
|
})(MarketsType || {});
|
|
2685
2913
|
var MarketsStorageKey = "orderly_markets";
|
|
@@ -2826,11 +3054,12 @@ var useMarketsStore = () => {
|
|
|
2826
3054
|
var useMarkets = (type = 2 /* ALL */) => {
|
|
2827
3055
|
const { data: futures } = useMarketsStream();
|
|
2828
3056
|
const symbolsInfo = useSymbolsInfo();
|
|
3057
|
+
const rwaSymbolsInfo = useRwaSymbolsInfo();
|
|
2829
3058
|
const [markets, setMarkets] = React2.useState([]);
|
|
2830
3059
|
const store = useMarketsStore();
|
|
2831
3060
|
const { favorites, recent, newListing } = store;
|
|
2832
3061
|
React2.useEffect(() => {
|
|
2833
|
-
const markets2 = addFieldToMarkets(futures, symbolsInfo);
|
|
3062
|
+
const markets2 = addFieldToMarkets(futures, symbolsInfo, rwaSymbolsInfo);
|
|
2834
3063
|
const filterList = filterMarkets({
|
|
2835
3064
|
markets: markets2,
|
|
2836
3065
|
favorites,
|
|
@@ -2842,9 +3071,10 @@ var useMarkets = (type = 2 /* ALL */) => {
|
|
|
2842
3071
|
}, [futures, symbolsInfo, favorites, recent, newListing, type]);
|
|
2843
3072
|
return [markets, store];
|
|
2844
3073
|
};
|
|
2845
|
-
var addFieldToMarkets = (futures, symbolsInfo) => {
|
|
3074
|
+
var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
2846
3075
|
return (futures || [])?.map((item) => {
|
|
2847
3076
|
const info = symbolsInfo[item.symbol];
|
|
3077
|
+
const rwaInfo = !rwaSymbolsInfo.isNil ? rwaSymbolsInfo[item.symbol]() : null;
|
|
2848
3078
|
return {
|
|
2849
3079
|
...item,
|
|
2850
3080
|
quote_dp: info("quote_dp"),
|
|
@@ -2856,7 +3086,11 @@ var addFieldToMarkets = (futures, symbolsInfo) => {
|
|
|
2856
3086
|
change: item.change,
|
|
2857
3087
|
close: item["24h_close"],
|
|
2858
3088
|
open: item["24h_open"]
|
|
2859
|
-
})
|
|
3089
|
+
}),
|
|
3090
|
+
isRwa: !!rwaInfo,
|
|
3091
|
+
rwaNextOpen: rwaInfo?.next_open,
|
|
3092
|
+
rwaNextClose: rwaInfo?.next_close,
|
|
3093
|
+
rwaStatus: rwaInfo?.status
|
|
2860
3094
|
};
|
|
2861
3095
|
});
|
|
2862
3096
|
};
|
|
@@ -2865,7 +3099,9 @@ var filterMarkets = (params) => {
|
|
|
2865
3099
|
let curData = [];
|
|
2866
3100
|
if (type === 2 /* ALL */) {
|
|
2867
3101
|
curData = markets;
|
|
2868
|
-
} else if (type === 3 /*
|
|
3102
|
+
} else if (type === 3 /* RWA */) {
|
|
3103
|
+
curData = markets.filter((item) => item.isRwa);
|
|
3104
|
+
} else if (type === 4 /* NEW_LISTING */) {
|
|
2869
3105
|
curData = markets.filter((item) => isNewListing(item.created_time)).sort((a, b) => b.created_time - a.created_time);
|
|
2870
3106
|
} else {
|
|
2871
3107
|
const storageData = type === 0 /* FAVORITES */ ? favorites : type === 1 /* RECENT */ ? recent : newListing;
|
|
@@ -4755,7 +4991,7 @@ var generateLeverageLevers = (max2) => {
|
|
|
4755
4991
|
return result;
|
|
4756
4992
|
};
|
|
4757
4993
|
var useLeverage = () => {
|
|
4758
|
-
const { data, mutate:
|
|
4994
|
+
const { data, mutate: mutate6 } = usePrivateQuery(
|
|
4759
4995
|
"/v1/client/info",
|
|
4760
4996
|
{
|
|
4761
4997
|
revalidateOnFocus: false
|
|
@@ -4771,12 +5007,12 @@ var useLeverage = () => {
|
|
|
4771
5007
|
async (data2) => {
|
|
4772
5008
|
const res = await update(data2);
|
|
4773
5009
|
if (res.success) {
|
|
4774
|
-
return
|
|
5010
|
+
return mutate6();
|
|
4775
5011
|
} else {
|
|
4776
5012
|
throw new Error(res.message);
|
|
4777
5013
|
}
|
|
4778
5014
|
},
|
|
4779
|
-
[update,
|
|
5015
|
+
[update, mutate6]
|
|
4780
5016
|
);
|
|
4781
5017
|
const memoizedCurLeverage = React2.useMemo(() => {
|
|
4782
5018
|
if (data?.max_leverage !== void 0) {
|
|
@@ -5515,18 +5751,12 @@ var useCollateral = (options = { dp: 6 }) => {
|
|
|
5515
5751
|
var useLeverageBySymbol = (symbol) => {
|
|
5516
5752
|
const { state } = useAccount();
|
|
5517
5753
|
const ws = useWS();
|
|
5518
|
-
const [leverage, setLeverage] = React2.useState(void 0);
|
|
5519
5754
|
const { data } = usePrivateQuery(
|
|
5520
5755
|
symbol ? `/v1/client/leverage?symbol=${symbol}` : null,
|
|
5521
5756
|
{
|
|
5522
5757
|
revalidateOnFocus: false
|
|
5523
5758
|
}
|
|
5524
5759
|
);
|
|
5525
|
-
React2.useEffect(() => {
|
|
5526
|
-
if (data?.leverage) {
|
|
5527
|
-
setLeverage(data.leverage);
|
|
5528
|
-
}
|
|
5529
|
-
}, [data]);
|
|
5530
5760
|
React2.useEffect(() => {
|
|
5531
5761
|
if (!state.accountId || !symbol)
|
|
5532
5762
|
return;
|
|
@@ -5534,13 +5764,19 @@ var useLeverageBySymbol = (symbol) => {
|
|
|
5534
5764
|
onMessage: (data2) => {
|
|
5535
5765
|
const res = data2?.accountDetail?.symbolLeverage || {};
|
|
5536
5766
|
if (res.symbol === symbol) {
|
|
5537
|
-
|
|
5767
|
+
const key = [`/v1/client/leverage?symbol=${symbol}`, state.accountId];
|
|
5768
|
+
useSWR.mutate(key, (prevData) => {
|
|
5769
|
+
return {
|
|
5770
|
+
...prevData,
|
|
5771
|
+
leverage: res.leverage
|
|
5772
|
+
};
|
|
5773
|
+
});
|
|
5538
5774
|
}
|
|
5539
5775
|
}
|
|
5540
5776
|
});
|
|
5541
5777
|
return () => unsubscribe?.();
|
|
5542
5778
|
}, [symbol, state.accountId]);
|
|
5543
|
-
return leverage;
|
|
5779
|
+
return data?.leverage;
|
|
5544
5780
|
};
|
|
5545
5781
|
|
|
5546
5782
|
// src/orderly/useMaxQty.ts
|
|
@@ -6026,7 +6262,7 @@ var useChainInfo = () => {
|
|
|
6026
6262
|
};
|
|
6027
6263
|
var useHoldingStream = () => {
|
|
6028
6264
|
const ws = useWS();
|
|
6029
|
-
const { data, isLoading, mutate:
|
|
6265
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
6030
6266
|
"/v1/client/holding",
|
|
6031
6267
|
{
|
|
6032
6268
|
formatter: (data2) => {
|
|
@@ -6050,7 +6286,7 @@ var useHoldingStream = () => {
|
|
|
6050
6286
|
onMessage: (data2) => {
|
|
6051
6287
|
const holding = data2?.balances ?? {};
|
|
6052
6288
|
if (holding) {
|
|
6053
|
-
|
|
6289
|
+
mutate6((prevData) => {
|
|
6054
6290
|
return prevData?.map((item) => {
|
|
6055
6291
|
const token = holding[item.token];
|
|
6056
6292
|
if (token) {
|
|
@@ -6537,7 +6773,8 @@ var useDeposit = (options) => {
|
|
|
6537
6773
|
track2(types.TrackerEventName.depositSuccess, {
|
|
6538
6774
|
wallet: state?.connectWallet?.name,
|
|
6539
6775
|
network: targetChain?.network_infos.name,
|
|
6540
|
-
quantity
|
|
6776
|
+
quantity,
|
|
6777
|
+
currency: options.srcToken
|
|
6541
6778
|
});
|
|
6542
6779
|
return result;
|
|
6543
6780
|
}).catch((e) => {
|
|
@@ -9666,7 +9903,7 @@ var useAssetsHistory = (options, config) => {
|
|
|
9666
9903
|
}
|
|
9667
9904
|
return `/v1/asset/history?${searchParams.toString()}`;
|
|
9668
9905
|
};
|
|
9669
|
-
const { data, isLoading, mutate:
|
|
9906
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
9670
9907
|
getKey(),
|
|
9671
9908
|
{
|
|
9672
9909
|
formatter: (data2) => data2,
|
|
@@ -9678,7 +9915,7 @@ var useAssetsHistory = (options, config) => {
|
|
|
9678
9915
|
(data2) => {
|
|
9679
9916
|
const isUpdate = typeof config?.shouldUpdateOnWalletChanged === "function" ? config.shouldUpdateOnWalletChanged(data2) : true;
|
|
9680
9917
|
if (isUpdate) {
|
|
9681
|
-
|
|
9918
|
+
mutate6();
|
|
9682
9919
|
}
|
|
9683
9920
|
},
|
|
9684
9921
|
// delay in ms
|
|
@@ -9850,7 +10087,7 @@ var useTransferHistory = (parmas) => {
|
|
|
9850
10087
|
}
|
|
9851
10088
|
return `/v1/internal_transfer_history?${search.toString()}`;
|
|
9852
10089
|
}, [page, size, fromId, toId, dataRange, main_sub_only]);
|
|
9853
|
-
const { data, isLoading, mutate:
|
|
10090
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
9854
10091
|
memoizedQueryKey,
|
|
9855
10092
|
{
|
|
9856
10093
|
// initialSize: 1,
|
|
@@ -9868,9 +10105,9 @@ var useTransferHistory = (parmas) => {
|
|
|
9868
10105
|
return React2.useMemo(
|
|
9869
10106
|
() => [
|
|
9870
10107
|
parsedData ?? types.EMPTY_LIST,
|
|
9871
|
-
{ meta: data?.meta, isLoading, mutate:
|
|
10108
|
+
{ meta: data?.meta, isLoading, mutate: mutate6 }
|
|
9872
10109
|
],
|
|
9873
|
-
[parsedData, data?.meta, isLoading,
|
|
10110
|
+
[parsedData, data?.meta, isLoading, mutate6]
|
|
9874
10111
|
);
|
|
9875
10112
|
};
|
|
9876
10113
|
var useVaultsHistory = (parmas) => {
|
|
@@ -9886,7 +10123,7 @@ var useVaultsHistory = (parmas) => {
|
|
|
9886
10123
|
}
|
|
9887
10124
|
return `/v1/account_sv_transaction_history?${search.toString()}`;
|
|
9888
10125
|
}, [page, size, dataRange]);
|
|
9889
|
-
const { data, isLoading, mutate:
|
|
10126
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
9890
10127
|
memoizedQueryKey,
|
|
9891
10128
|
{
|
|
9892
10129
|
formatter: (data2) => data2,
|
|
@@ -9901,8 +10138,8 @@ var useVaultsHistory = (parmas) => {
|
|
|
9901
10138
|
return data.rows;
|
|
9902
10139
|
}, [data, infos]);
|
|
9903
10140
|
return React2.useMemo(
|
|
9904
|
-
() => [parsedData ?? types.EMPTY_LIST, { meta: data?.meta, isLoading, mutate:
|
|
9905
|
-
[parsedData, data?.meta, isLoading,
|
|
10141
|
+
() => [parsedData ?? types.EMPTY_LIST, { meta: data?.meta, isLoading, mutate: mutate6 }],
|
|
10142
|
+
[parsedData, data?.meta, isLoading, mutate6]
|
|
9906
10143
|
);
|
|
9907
10144
|
};
|
|
9908
10145
|
var MaintenanceStatus = /* @__PURE__ */ ((MaintenanceStatus2) => {
|
|
@@ -10264,7 +10501,7 @@ var publicQueryOptions = {
|
|
|
10264
10501
|
dedupingInterval: 1e3 * 60 * 60 * 24
|
|
10265
10502
|
};
|
|
10266
10503
|
var usePublicDataObserver = () => {
|
|
10267
|
-
const { setSymbolsInfo, setFundingRates } = useAppStore(
|
|
10504
|
+
const { setSymbolsInfo, setFundingRates, setRwaSymbolsInfo } = useAppStore(
|
|
10268
10505
|
(state) => state.actions
|
|
10269
10506
|
);
|
|
10270
10507
|
const { updateMarket } = useMarketStore((state) => state.actions);
|
|
@@ -10296,6 +10533,27 @@ var usePublicDataObserver = () => {
|
|
|
10296
10533
|
setSymbolsInfo(obj);
|
|
10297
10534
|
}
|
|
10298
10535
|
});
|
|
10536
|
+
useQuery(`/v1/public/rwa/info`, {
|
|
10537
|
+
...publicQueryOptions,
|
|
10538
|
+
onSuccess(data) {
|
|
10539
|
+
if (!data || !data?.length) {
|
|
10540
|
+
return {};
|
|
10541
|
+
}
|
|
10542
|
+
const obj = {};
|
|
10543
|
+
for (let index = 0; index < data.length; index++) {
|
|
10544
|
+
const item = data[index];
|
|
10545
|
+
const arr = item.symbol.split("_");
|
|
10546
|
+
obj[item.symbol] = {
|
|
10547
|
+
...item,
|
|
10548
|
+
base: arr[1],
|
|
10549
|
+
quote: arr[2],
|
|
10550
|
+
type: arr[0],
|
|
10551
|
+
name: `${arr[1]}-${arr[0]}`
|
|
10552
|
+
};
|
|
10553
|
+
}
|
|
10554
|
+
setRwaSymbolsInfo(obj);
|
|
10555
|
+
}
|
|
10556
|
+
});
|
|
10299
10557
|
useQuery(`/v1/public/funding_rates`, {
|
|
10300
10558
|
...publicQueryOptions,
|
|
10301
10559
|
onSuccess(data) {
|
|
@@ -10355,6 +10613,7 @@ var DataCenterProvider = ({
|
|
|
10355
10613
|
children
|
|
10356
10614
|
}) => {
|
|
10357
10615
|
const { error, done } = usePreLoadData();
|
|
10616
|
+
useInitRwaSymbolsRuntime();
|
|
10358
10617
|
const calculatorService = useCalculatorService();
|
|
10359
10618
|
usePublicDataObserver();
|
|
10360
10619
|
useWSObserver(calculatorService);
|
|
@@ -16720,7 +16979,7 @@ var useApiKeyManager = (queryParams) => {
|
|
|
16720
16979
|
const { account: account9, state, isSubAccount } = useAccount();
|
|
16721
16980
|
const { keyInfo } = queryParams || {};
|
|
16722
16981
|
const keyInfoPrams = getQueryParamsFromObject(keyInfo);
|
|
16723
|
-
const { data, mutate:
|
|
16982
|
+
const { data, mutate: mutate6, error, isLoading } = usePrivateQuery(
|
|
16724
16983
|
`/v1/client/key_info${keyInfoPrams.length > 0 ? `?${keyInfoPrams}` : ""}`,
|
|
16725
16984
|
{
|
|
16726
16985
|
formatter: (data2) => data2?.rows
|
|
@@ -16774,7 +17033,7 @@ var useApiKeyManager = (queryParams) => {
|
|
|
16774
17033
|
return [
|
|
16775
17034
|
data,
|
|
16776
17035
|
{
|
|
16777
|
-
refresh:
|
|
17036
|
+
refresh: mutate6,
|
|
16778
17037
|
error,
|
|
16779
17038
|
isLoading,
|
|
16780
17039
|
generateOrderlyKey,
|
|
@@ -17855,6 +18114,8 @@ exports.findTPSLFromOrder = findTPSLFromOrder;
|
|
|
17855
18114
|
exports.findTPSLOrderPriceFromOrder = findTPSLOrderPriceFromOrder;
|
|
17856
18115
|
exports.getMinNotional = getMinNotional;
|
|
17857
18116
|
exports.getPriceKey = getPriceKey;
|
|
18117
|
+
exports.isCurrentlyClosed = isCurrentlyClosed;
|
|
18118
|
+
exports.isCurrentlyTrading = isCurrentlyTrading;
|
|
17858
18119
|
exports.noCacheConfig = noCacheConfig;
|
|
17859
18120
|
exports.parseJSON = parseJSON;
|
|
17860
18121
|
exports.useAccount = useAccount;
|
|
@@ -17894,10 +18155,15 @@ exports.useFundingRatesStore = useFundingRatesStore;
|
|
|
17894
18155
|
exports.useGetClaimed = useGetClaimed;
|
|
17895
18156
|
exports.useGetEnv = useGetEnv;
|
|
17896
18157
|
exports.useGetReferralCode = useGetReferralCode;
|
|
18158
|
+
exports.useGetRwaSymbolCloseTimeInterval = useGetRwaSymbolCloseTimeInterval;
|
|
18159
|
+
exports.useGetRwaSymbolInfo = useGetRwaSymbolInfo;
|
|
18160
|
+
exports.useGetRwaSymbolOpenStatus = useGetRwaSymbolOpenStatus;
|
|
18161
|
+
exports.useGetRwaSymbolOpenTimeInterval = useGetRwaSymbolOpenTimeInterval;
|
|
17897
18162
|
exports.useHoldingStream = useHoldingStream;
|
|
17898
18163
|
exports.useIndexPrice = useIndexPrice;
|
|
17899
18164
|
exports.useIndexPricesStream = useIndexPricesStream;
|
|
17900
18165
|
exports.useInfiniteQuery = useInfiniteQuery;
|
|
18166
|
+
exports.useInitRwaSymbolsRuntime = useInitRwaSymbolsRuntime;
|
|
17901
18167
|
exports.useInternalTransfer = useInternalTransfer;
|
|
17902
18168
|
exports.useKeyStore = useKeyStore;
|
|
17903
18169
|
exports.useLazyQuery = useLazyQuery;
|
|
@@ -17947,6 +18213,8 @@ exports.useRefereeRebateSummary = useRefereeRebateSummary;
|
|
|
17947
18213
|
exports.useReferralInfo = useReferralInfo;
|
|
17948
18214
|
exports.useReferralRebateSummary = useReferralRebateSummary;
|
|
17949
18215
|
exports.useRestrictedInfo = useRestrictedInfo;
|
|
18216
|
+
exports.useRwaSymbolsInfo = useRwaSymbolsInfo;
|
|
18217
|
+
exports.useRwaSymbolsInfoStore = useRwaSymbolsInfoStore;
|
|
17950
18218
|
exports.useSessionStorage = useSessionStorage;
|
|
17951
18219
|
exports.useSettleSubscription = useSettleSubscription;
|
|
17952
18220
|
exports.useSimpleDI = useSimpleDI;
|