@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.mjs
CHANGED
|
@@ -14,12 +14,12 @@ import { debounce } from 'lodash';
|
|
|
14
14
|
import useSWRInfinite, { unstable_serialize } from 'swr/infinite';
|
|
15
15
|
import { pathOr, min, max, omit, prop, pick, compose, head, mergeDeepRight, isNil, propOr, path, lensIndex, over } from 'ramda';
|
|
16
16
|
import { account, order, positions } from '@orderly.network/perp';
|
|
17
|
+
import useSWRSubscription from 'swr/subscription';
|
|
17
18
|
import * as amplitude from '@amplitude/analytics-browser';
|
|
18
19
|
import { jsx } from 'react/jsx-runtime';
|
|
19
20
|
import { DefaultEVMWalletAdapter } from '@orderly.network/default-evm-adapter';
|
|
20
21
|
import { DefaultSolanaWalletAdapter } from '@orderly.network/default-solana-adapter';
|
|
21
22
|
import { EthersProvider } from '@orderly.network/web3-provider-ethers';
|
|
22
|
-
import useSWRSubscription from 'swr/subscription';
|
|
23
23
|
import { create } from 'zustand';
|
|
24
24
|
import { immer } from 'zustand/middleware/immer';
|
|
25
25
|
import { useDebouncedCallback } from 'use-debounce';
|
|
@@ -36,9 +36,9 @@ var __export = (target, all) => {
|
|
|
36
36
|
// src/version.ts
|
|
37
37
|
if (typeof window !== "undefined") {
|
|
38
38
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
39
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.
|
|
39
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.8.0";
|
|
40
40
|
}
|
|
41
|
-
var version_default = "2.
|
|
41
|
+
var version_default = "2.8.0";
|
|
42
42
|
var fetcher = (url, init2 = {}, queryOptions) => get(url, init2, queryOptions?.formatter);
|
|
43
43
|
var noCacheConfig = {
|
|
44
44
|
dedupingInterval: 0,
|
|
@@ -692,12 +692,12 @@ var useDaily = (options) => {
|
|
|
692
692
|
start_date,
|
|
693
693
|
end_date
|
|
694
694
|
)}`;
|
|
695
|
-
const { data: dailyVolume, mutate:
|
|
695
|
+
const { data: dailyVolume, mutate: mutate6 } = usePrivateQuery(url, {
|
|
696
696
|
revalidateOnFocus: true
|
|
697
697
|
});
|
|
698
698
|
return {
|
|
699
699
|
data: dailyVolume,
|
|
700
|
-
mutate:
|
|
700
|
+
mutate: mutate6
|
|
701
701
|
};
|
|
702
702
|
};
|
|
703
703
|
var useReferralRebateSummary = (params) => {
|
|
@@ -809,14 +809,14 @@ var useRefereeRebateSummary = (params) => {
|
|
|
809
809
|
}
|
|
810
810
|
const {
|
|
811
811
|
data,
|
|
812
|
-
mutate:
|
|
812
|
+
mutate: mutate6,
|
|
813
813
|
isLoading
|
|
814
814
|
} = usePrivateQuery(url, {
|
|
815
815
|
revalidateOnFocus: true
|
|
816
816
|
});
|
|
817
817
|
return {
|
|
818
818
|
data,
|
|
819
|
-
mutate:
|
|
819
|
+
mutate: mutate6,
|
|
820
820
|
isLoading
|
|
821
821
|
};
|
|
822
822
|
};
|
|
@@ -2181,8 +2181,57 @@ var useFeeState = () => {
|
|
|
2181
2181
|
errorRetryCount: 3,
|
|
2182
2182
|
...noCacheConfig
|
|
2183
2183
|
});
|
|
2184
|
-
const
|
|
2185
|
-
const
|
|
2184
|
+
const ws = useWS();
|
|
2185
|
+
const topic = "account";
|
|
2186
|
+
const { data: wsAccountData } = useSWRSubscription(
|
|
2187
|
+
"account",
|
|
2188
|
+
(_, { next }) => {
|
|
2189
|
+
const unsubscribe = ws.subscribe(topic, {
|
|
2190
|
+
onMessage: (message) => {
|
|
2191
|
+
next(null, message);
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
return () => {
|
|
2195
|
+
unsubscribe?.();
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
);
|
|
2199
|
+
const takerFeeBps = useMemo(() => {
|
|
2200
|
+
if (wsAccountData?.accountDetail?.futuresTakerFeeRate) {
|
|
2201
|
+
return wsAccountData?.accountDetail?.futuresTakerFeeRate;
|
|
2202
|
+
}
|
|
2203
|
+
return accountInfo?.futures_taker_fee_rate;
|
|
2204
|
+
}, [
|
|
2205
|
+
accountInfo?.futures_taker_fee_rate,
|
|
2206
|
+
wsAccountData?.accountDetail?.futuresTakerFeeRate
|
|
2207
|
+
]);
|
|
2208
|
+
const makerFeeBps = useMemo(() => {
|
|
2209
|
+
if (wsAccountData?.accountDetail?.futuresMakerFeeRate) {
|
|
2210
|
+
return wsAccountData?.accountDetail?.futuresMakerFeeRate;
|
|
2211
|
+
}
|
|
2212
|
+
return accountInfo?.futures_maker_fee_rate;
|
|
2213
|
+
}, [
|
|
2214
|
+
accountInfo?.futures_maker_fee_rate,
|
|
2215
|
+
wsAccountData?.accountDetail?.futuresMakerFeeRate
|
|
2216
|
+
]);
|
|
2217
|
+
const rwaTakerFeeBps = useMemo(() => {
|
|
2218
|
+
if (wsAccountData?.accountDetail?.rwaFuturesTakerFeeRate) {
|
|
2219
|
+
return wsAccountData?.accountDetail?.rwaFuturesTakerFeeRate;
|
|
2220
|
+
}
|
|
2221
|
+
return accountInfo?.rwa_taker_fee_rate;
|
|
2222
|
+
}, [
|
|
2223
|
+
accountInfo?.rwa_taker_fee_rate,
|
|
2224
|
+
wsAccountData?.accountDetail?.rwaFuturesTakerFeeRate
|
|
2225
|
+
]);
|
|
2226
|
+
const rwaMakerFeeBps = useMemo(() => {
|
|
2227
|
+
if (wsAccountData?.accountDetail?.rwaFuturesMakerFeeRate) {
|
|
2228
|
+
return wsAccountData?.accountDetail?.rwaFuturesMakerFeeRate;
|
|
2229
|
+
}
|
|
2230
|
+
return accountInfo?.rwa_maker_fee_rate;
|
|
2231
|
+
}, [
|
|
2232
|
+
accountInfo?.rwa_maker_fee_rate,
|
|
2233
|
+
wsAccountData?.accountDetail?.rwaFuturesMakerFeeRate
|
|
2234
|
+
]);
|
|
2186
2235
|
const refereeRebate = referralData?.referee_info?.referee_rebate_rate;
|
|
2187
2236
|
const takerFee = useMemo(() => {
|
|
2188
2237
|
if (isAccountLoading || takerFeeBps === null || takerFeeBps === void 0) {
|
|
@@ -2218,12 +2267,50 @@ var useFeeState = () => {
|
|
|
2218
2267
|
);
|
|
2219
2268
|
return formatFractionAsPercent(effective);
|
|
2220
2269
|
}, [makerFeeBps, refereeRebate, isReferralLoading]);
|
|
2270
|
+
const rwaTakerFee = useMemo(() => {
|
|
2271
|
+
if (isAccountLoading || rwaTakerFeeBps === null || rwaTakerFeeBps === void 0) {
|
|
2272
|
+
return "-";
|
|
2273
|
+
}
|
|
2274
|
+
return formatFractionAsPercent(bpsToFraction(rwaTakerFeeBps));
|
|
2275
|
+
}, [isAccountLoading, rwaTakerFeeBps]);
|
|
2276
|
+
const rwaMakerFee = useMemo(() => {
|
|
2277
|
+
if (isAccountLoading || rwaMakerFeeBps === null || rwaMakerFeeBps === void 0) {
|
|
2278
|
+
return "-";
|
|
2279
|
+
}
|
|
2280
|
+
return formatFractionAsPercent(bpsToFraction(rwaMakerFeeBps));
|
|
2281
|
+
}, [isAccountLoading, rwaMakerFeeBps]);
|
|
2282
|
+
const rwaEffectiveTakerFee = useMemo(() => {
|
|
2283
|
+
if (isAccountLoading || rwaTakerFeeBps === null || rwaTakerFeeBps === void 0 || isReferralLoading) {
|
|
2284
|
+
return "-";
|
|
2285
|
+
}
|
|
2286
|
+
const effective = computeEffectiveFromBps(
|
|
2287
|
+
rwaTakerFeeBps,
|
|
2288
|
+
ORDERLY_MAKER_FEE_BPS,
|
|
2289
|
+
refereeRebate
|
|
2290
|
+
);
|
|
2291
|
+
return formatFractionAsPercent(effective);
|
|
2292
|
+
}, [isAccountLoading, rwaTakerFeeBps, refereeRebate, isReferralLoading]);
|
|
2293
|
+
const rwaEffectiveMakerFee = useMemo(() => {
|
|
2294
|
+
if (isAccountLoading || rwaMakerFeeBps === null || rwaMakerFeeBps === void 0 || isReferralLoading) {
|
|
2295
|
+
return "-";
|
|
2296
|
+
}
|
|
2297
|
+
const effective = computeEffectiveFromBps(
|
|
2298
|
+
rwaMakerFeeBps,
|
|
2299
|
+
ORDERLY_MAKER_FEE_BPS,
|
|
2300
|
+
refereeRebate
|
|
2301
|
+
);
|
|
2302
|
+
return formatFractionAsPercent(effective);
|
|
2303
|
+
}, [isAccountLoading, rwaMakerFeeBps, refereeRebate, isReferralLoading]);
|
|
2221
2304
|
return {
|
|
2222
2305
|
takerFee,
|
|
2223
2306
|
makerFee,
|
|
2224
2307
|
refereeRebate,
|
|
2225
2308
|
effectiveTakerFee,
|
|
2226
|
-
effectiveMakerFee
|
|
2309
|
+
effectiveMakerFee,
|
|
2310
|
+
rwaTakerFee,
|
|
2311
|
+
rwaMakerFee,
|
|
2312
|
+
rwaEffectiveTakerFee,
|
|
2313
|
+
rwaEffectiveMakerFee
|
|
2227
2314
|
};
|
|
2228
2315
|
};
|
|
2229
2316
|
var apiKeyMap = {
|
|
@@ -2570,6 +2657,15 @@ var useAppStore = create()(
|
|
|
2570
2657
|
// "setSymbolsInfo"
|
|
2571
2658
|
);
|
|
2572
2659
|
},
|
|
2660
|
+
setRwaSymbolsInfo: (rwaSymbolsInfo) => {
|
|
2661
|
+
set(
|
|
2662
|
+
(state) => {
|
|
2663
|
+
state.rwaSymbolsInfo = rwaSymbolsInfo;
|
|
2664
|
+
},
|
|
2665
|
+
false
|
|
2666
|
+
// "setRwaSymbolsInfo"
|
|
2667
|
+
);
|
|
2668
|
+
},
|
|
2573
2669
|
setFundingRates: (fundingRates) => {
|
|
2574
2670
|
set(
|
|
2575
2671
|
(state) => {
|
|
@@ -2640,7 +2736,138 @@ var useAppStore = create()(
|
|
|
2640
2736
|
var useAccountInfo2 = () => useAppStore((state) => state.accountInfo);
|
|
2641
2737
|
var usePortfolio = () => useAppStore((state) => state.portfolio);
|
|
2642
2738
|
|
|
2643
|
-
// src/orderly/
|
|
2739
|
+
// src/orderly/useRwaSymbolsInfo.ts
|
|
2740
|
+
var isCurrentlyTrading = (nextClose, status, currentTime = Date.now()) => {
|
|
2741
|
+
return currentTime < nextClose && status === "open";
|
|
2742
|
+
};
|
|
2743
|
+
var isCurrentlyClosed = (nextOpen, status, currentTime = Date.now()) => {
|
|
2744
|
+
return currentTime < nextOpen && status === "close";
|
|
2745
|
+
};
|
|
2746
|
+
var useRwaSymbolsInfo = () => {
|
|
2747
|
+
const symbolsInfo = useAppStore((state) => state.rwaSymbolsInfo);
|
|
2748
|
+
return useMemo(() => createGetter({ ...symbolsInfo }), [symbolsInfo]);
|
|
2749
|
+
};
|
|
2750
|
+
var useRwaSymbolsInfoStore = () => {
|
|
2751
|
+
return useAppStore((state) => state.rwaSymbolsInfo);
|
|
2752
|
+
};
|
|
2753
|
+
var computeSymbolState = (rwaSymbol, currentTime) => {
|
|
2754
|
+
const { status, next_close, next_open } = rwaSymbol;
|
|
2755
|
+
const isOpen = isCurrentlyTrading(next_close, status, currentTime);
|
|
2756
|
+
let closeTimeInterval;
|
|
2757
|
+
let openTimeInterval;
|
|
2758
|
+
if (next_close && typeof next_close === "number" && next_close > currentTime) {
|
|
2759
|
+
closeTimeInterval = Math.max(0, Math.floor((next_close - currentTime) / 1e3));
|
|
2760
|
+
}
|
|
2761
|
+
if (next_open && typeof next_open === "number" && next_open > currentTime) {
|
|
2762
|
+
openTimeInterval = Math.max(0, Math.floor((next_open - currentTime) / 1e3));
|
|
2763
|
+
}
|
|
2764
|
+
return {
|
|
2765
|
+
isRwa: true,
|
|
2766
|
+
open: isOpen,
|
|
2767
|
+
nextOpen: next_open || void 0,
|
|
2768
|
+
nextClose: next_close || void 0,
|
|
2769
|
+
closeTimeInterval,
|
|
2770
|
+
openTimeInterval
|
|
2771
|
+
};
|
|
2772
|
+
};
|
|
2773
|
+
var useRwaSymbolsRuntimeStore = create((set, get3) => ({
|
|
2774
|
+
computedStates: {},
|
|
2775
|
+
currentTime: Date.now(),
|
|
2776
|
+
timerId: void 0,
|
|
2777
|
+
startTimer: () => {
|
|
2778
|
+
const state = get3();
|
|
2779
|
+
if (state.timerId) {
|
|
2780
|
+
clearInterval(state.timerId);
|
|
2781
|
+
}
|
|
2782
|
+
const timerId = setInterval(() => {
|
|
2783
|
+
const currentTime = Date.now();
|
|
2784
|
+
const rwaSymbolsInfo = useAppStore.getState().rwaSymbolsInfo;
|
|
2785
|
+
if (!rwaSymbolsInfo) {
|
|
2786
|
+
set({ currentTime });
|
|
2787
|
+
return;
|
|
2788
|
+
}
|
|
2789
|
+
const computedStates = {};
|
|
2790
|
+
Object.entries(rwaSymbolsInfo).forEach(([symbol, rwaSymbol]) => {
|
|
2791
|
+
computedStates[symbol] = computeSymbolState(rwaSymbol, currentTime);
|
|
2792
|
+
});
|
|
2793
|
+
set({ computedStates, currentTime });
|
|
2794
|
+
}, 1e3);
|
|
2795
|
+
set({ timerId });
|
|
2796
|
+
},
|
|
2797
|
+
stopTimer: () => {
|
|
2798
|
+
const state = get3();
|
|
2799
|
+
if (state.timerId) {
|
|
2800
|
+
clearInterval(state.timerId);
|
|
2801
|
+
set({ timerId: void 0 });
|
|
2802
|
+
}
|
|
2803
|
+
},
|
|
2804
|
+
updateComputedStates: (rwaSymbolsInfo) => {
|
|
2805
|
+
const currentTime = get3().currentTime;
|
|
2806
|
+
const computedStates = {};
|
|
2807
|
+
Object.entries(rwaSymbolsInfo).forEach(([symbol, rwaSymbol]) => {
|
|
2808
|
+
computedStates[symbol] = computeSymbolState(rwaSymbol, currentTime);
|
|
2809
|
+
});
|
|
2810
|
+
set({ computedStates });
|
|
2811
|
+
}
|
|
2812
|
+
}));
|
|
2813
|
+
var useInitRwaSymbolsRuntime = () => {
|
|
2814
|
+
const rwaSymbolsInfo = useRwaSymbolsInfoStore();
|
|
2815
|
+
const { startTimer, stopTimer, updateComputedStates } = useRwaSymbolsRuntimeStore();
|
|
2816
|
+
useEffect(() => {
|
|
2817
|
+
if (rwaSymbolsInfo && Object.keys(rwaSymbolsInfo).length > 0) {
|
|
2818
|
+
updateComputedStates(rwaSymbolsInfo);
|
|
2819
|
+
startTimer();
|
|
2820
|
+
}
|
|
2821
|
+
return () => {
|
|
2822
|
+
stopTimer();
|
|
2823
|
+
};
|
|
2824
|
+
}, [rwaSymbolsInfo, startTimer, stopTimer, updateComputedStates]);
|
|
2825
|
+
};
|
|
2826
|
+
var useGetRwaSymbolInfo = (symbol) => {
|
|
2827
|
+
const computedState = useRwaSymbolsRuntimeStore(
|
|
2828
|
+
(state) => state.computedStates[symbol]
|
|
2829
|
+
);
|
|
2830
|
+
return useMemo(() => {
|
|
2831
|
+
if (!computedState) {
|
|
2832
|
+
return { isRwa: false };
|
|
2833
|
+
}
|
|
2834
|
+
return computedState;
|
|
2835
|
+
}, [computedState]);
|
|
2836
|
+
};
|
|
2837
|
+
var useGetRwaSymbolOpenStatus = (symbol) => {
|
|
2838
|
+
const { isRwa, open } = useGetRwaSymbolInfo(symbol);
|
|
2839
|
+
return useMemo(() => {
|
|
2840
|
+
return { isRwa, open };
|
|
2841
|
+
}, [isRwa, open]);
|
|
2842
|
+
};
|
|
2843
|
+
var filterTimeInterval = (timeInterval, isRwa, thresholdMinutes) => {
|
|
2844
|
+
if (!isRwa || !timeInterval) {
|
|
2845
|
+
return void 0;
|
|
2846
|
+
}
|
|
2847
|
+
return timeInterval > thresholdMinutes * 60 ? void 0 : timeInterval;
|
|
2848
|
+
};
|
|
2849
|
+
var useGetRwaSymbolCloseTimeInterval = (symbol, thresholdMinutes = 30) => {
|
|
2850
|
+
const { isRwa, open, closeTimeInterval, nextClose } = useGetRwaSymbolInfo(symbol);
|
|
2851
|
+
return useMemo(() => {
|
|
2852
|
+
const filteredInterval = filterTimeInterval(
|
|
2853
|
+
closeTimeInterval,
|
|
2854
|
+
isRwa,
|
|
2855
|
+
thresholdMinutes
|
|
2856
|
+
);
|
|
2857
|
+
return { isRwa, open, closeTimeInterval: filteredInterval, nextClose };
|
|
2858
|
+
}, [isRwa, open, closeTimeInterval, nextClose, thresholdMinutes]);
|
|
2859
|
+
};
|
|
2860
|
+
var useGetRwaSymbolOpenTimeInterval = (symbol, thresholdMinutes = 30) => {
|
|
2861
|
+
const { isRwa, open, openTimeInterval, nextOpen } = useGetRwaSymbolInfo(symbol);
|
|
2862
|
+
return useMemo(() => {
|
|
2863
|
+
const filteredInterval = filterTimeInterval(
|
|
2864
|
+
openTimeInterval,
|
|
2865
|
+
isRwa,
|
|
2866
|
+
thresholdMinutes
|
|
2867
|
+
);
|
|
2868
|
+
return { isRwa, open, openTimeInterval: filteredInterval, nextOpen };
|
|
2869
|
+
}, [isRwa, open, openTimeInterval, nextOpen, thresholdMinutes]);
|
|
2870
|
+
};
|
|
2644
2871
|
var useSymbolsInfo = () => {
|
|
2645
2872
|
const symbolsInfo = useAppStore((state) => state.symbolsInfo);
|
|
2646
2873
|
return useMemo(() => createGetter({ ...symbolsInfo }), [symbolsInfo]);
|
|
@@ -2654,7 +2881,8 @@ var MarketsType = /* @__PURE__ */ ((MarketsType2) => {
|
|
|
2654
2881
|
MarketsType2[MarketsType2["FAVORITES"] = 0] = "FAVORITES";
|
|
2655
2882
|
MarketsType2[MarketsType2["RECENT"] = 1] = "RECENT";
|
|
2656
2883
|
MarketsType2[MarketsType2["ALL"] = 2] = "ALL";
|
|
2657
|
-
MarketsType2[MarketsType2["
|
|
2884
|
+
MarketsType2[MarketsType2["RWA"] = 3] = "RWA";
|
|
2885
|
+
MarketsType2[MarketsType2["NEW_LISTING"] = 4] = "NEW_LISTING";
|
|
2658
2886
|
return MarketsType2;
|
|
2659
2887
|
})(MarketsType || {});
|
|
2660
2888
|
var MarketsStorageKey = "orderly_markets";
|
|
@@ -2801,11 +3029,12 @@ var useMarketsStore = () => {
|
|
|
2801
3029
|
var useMarkets = (type = 2 /* ALL */) => {
|
|
2802
3030
|
const { data: futures } = useMarketsStream();
|
|
2803
3031
|
const symbolsInfo = useSymbolsInfo();
|
|
3032
|
+
const rwaSymbolsInfo = useRwaSymbolsInfo();
|
|
2804
3033
|
const [markets, setMarkets] = useState([]);
|
|
2805
3034
|
const store = useMarketsStore();
|
|
2806
3035
|
const { favorites, recent, newListing } = store;
|
|
2807
3036
|
useEffect(() => {
|
|
2808
|
-
const markets2 = addFieldToMarkets(futures, symbolsInfo);
|
|
3037
|
+
const markets2 = addFieldToMarkets(futures, symbolsInfo, rwaSymbolsInfo);
|
|
2809
3038
|
const filterList = filterMarkets({
|
|
2810
3039
|
markets: markets2,
|
|
2811
3040
|
favorites,
|
|
@@ -2817,9 +3046,10 @@ var useMarkets = (type = 2 /* ALL */) => {
|
|
|
2817
3046
|
}, [futures, symbolsInfo, favorites, recent, newListing, type]);
|
|
2818
3047
|
return [markets, store];
|
|
2819
3048
|
};
|
|
2820
|
-
var addFieldToMarkets = (futures, symbolsInfo) => {
|
|
3049
|
+
var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
2821
3050
|
return (futures || [])?.map((item) => {
|
|
2822
3051
|
const info = symbolsInfo[item.symbol];
|
|
3052
|
+
const rwaInfo = !rwaSymbolsInfo.isNil ? rwaSymbolsInfo[item.symbol]() : null;
|
|
2823
3053
|
return {
|
|
2824
3054
|
...item,
|
|
2825
3055
|
quote_dp: info("quote_dp"),
|
|
@@ -2831,7 +3061,11 @@ var addFieldToMarkets = (futures, symbolsInfo) => {
|
|
|
2831
3061
|
change: item.change,
|
|
2832
3062
|
close: item["24h_close"],
|
|
2833
3063
|
open: item["24h_open"]
|
|
2834
|
-
})
|
|
3064
|
+
}),
|
|
3065
|
+
isRwa: !!rwaInfo,
|
|
3066
|
+
rwaNextOpen: rwaInfo?.next_open,
|
|
3067
|
+
rwaNextClose: rwaInfo?.next_close,
|
|
3068
|
+
rwaStatus: rwaInfo?.status
|
|
2835
3069
|
};
|
|
2836
3070
|
});
|
|
2837
3071
|
};
|
|
@@ -2840,7 +3074,9 @@ var filterMarkets = (params) => {
|
|
|
2840
3074
|
let curData = [];
|
|
2841
3075
|
if (type === 2 /* ALL */) {
|
|
2842
3076
|
curData = markets;
|
|
2843
|
-
} else if (type === 3 /*
|
|
3077
|
+
} else if (type === 3 /* RWA */) {
|
|
3078
|
+
curData = markets.filter((item) => item.isRwa);
|
|
3079
|
+
} else if (type === 4 /* NEW_LISTING */) {
|
|
2844
3080
|
curData = markets.filter((item) => isNewListing(item.created_time)).sort((a, b) => b.created_time - a.created_time);
|
|
2845
3081
|
} else {
|
|
2846
3082
|
const storageData = type === 0 /* FAVORITES */ ? favorites : type === 1 /* RECENT */ ? recent : newListing;
|
|
@@ -4730,7 +4966,7 @@ var generateLeverageLevers = (max2) => {
|
|
|
4730
4966
|
return result;
|
|
4731
4967
|
};
|
|
4732
4968
|
var useLeverage = () => {
|
|
4733
|
-
const { data, mutate:
|
|
4969
|
+
const { data, mutate: mutate6 } = usePrivateQuery(
|
|
4734
4970
|
"/v1/client/info",
|
|
4735
4971
|
{
|
|
4736
4972
|
revalidateOnFocus: false
|
|
@@ -4746,12 +4982,12 @@ var useLeverage = () => {
|
|
|
4746
4982
|
async (data2) => {
|
|
4747
4983
|
const res = await update(data2);
|
|
4748
4984
|
if (res.success) {
|
|
4749
|
-
return
|
|
4985
|
+
return mutate6();
|
|
4750
4986
|
} else {
|
|
4751
4987
|
throw new Error(res.message);
|
|
4752
4988
|
}
|
|
4753
4989
|
},
|
|
4754
|
-
[update,
|
|
4990
|
+
[update, mutate6]
|
|
4755
4991
|
);
|
|
4756
4992
|
const memoizedCurLeverage = useMemo(() => {
|
|
4757
4993
|
if (data?.max_leverage !== void 0) {
|
|
@@ -5490,18 +5726,12 @@ var useCollateral = (options = { dp: 6 }) => {
|
|
|
5490
5726
|
var useLeverageBySymbol = (symbol) => {
|
|
5491
5727
|
const { state } = useAccount();
|
|
5492
5728
|
const ws = useWS();
|
|
5493
|
-
const [leverage, setLeverage] = useState(void 0);
|
|
5494
5729
|
const { data } = usePrivateQuery(
|
|
5495
5730
|
symbol ? `/v1/client/leverage?symbol=${symbol}` : null,
|
|
5496
5731
|
{
|
|
5497
5732
|
revalidateOnFocus: false
|
|
5498
5733
|
}
|
|
5499
5734
|
);
|
|
5500
|
-
useEffect(() => {
|
|
5501
|
-
if (data?.leverage) {
|
|
5502
|
-
setLeverage(data.leverage);
|
|
5503
|
-
}
|
|
5504
|
-
}, [data]);
|
|
5505
5735
|
useEffect(() => {
|
|
5506
5736
|
if (!state.accountId || !symbol)
|
|
5507
5737
|
return;
|
|
@@ -5509,13 +5739,19 @@ var useLeverageBySymbol = (symbol) => {
|
|
|
5509
5739
|
onMessage: (data2) => {
|
|
5510
5740
|
const res = data2?.accountDetail?.symbolLeverage || {};
|
|
5511
5741
|
if (res.symbol === symbol) {
|
|
5512
|
-
|
|
5742
|
+
const key = [`/v1/client/leverage?symbol=${symbol}`, state.accountId];
|
|
5743
|
+
mutate(key, (prevData) => {
|
|
5744
|
+
return {
|
|
5745
|
+
...prevData,
|
|
5746
|
+
leverage: res.leverage
|
|
5747
|
+
};
|
|
5748
|
+
});
|
|
5513
5749
|
}
|
|
5514
5750
|
}
|
|
5515
5751
|
});
|
|
5516
5752
|
return () => unsubscribe?.();
|
|
5517
5753
|
}, [symbol, state.accountId]);
|
|
5518
|
-
return leverage;
|
|
5754
|
+
return data?.leverage;
|
|
5519
5755
|
};
|
|
5520
5756
|
|
|
5521
5757
|
// src/orderly/useMaxQty.ts
|
|
@@ -6001,7 +6237,7 @@ var useChainInfo = () => {
|
|
|
6001
6237
|
};
|
|
6002
6238
|
var useHoldingStream = () => {
|
|
6003
6239
|
const ws = useWS();
|
|
6004
|
-
const { data, isLoading, mutate:
|
|
6240
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
6005
6241
|
"/v1/client/holding",
|
|
6006
6242
|
{
|
|
6007
6243
|
formatter: (data2) => {
|
|
@@ -6025,7 +6261,7 @@ var useHoldingStream = () => {
|
|
|
6025
6261
|
onMessage: (data2) => {
|
|
6026
6262
|
const holding = data2?.balances ?? {};
|
|
6027
6263
|
if (holding) {
|
|
6028
|
-
|
|
6264
|
+
mutate6((prevData) => {
|
|
6029
6265
|
return prevData?.map((item) => {
|
|
6030
6266
|
const token = holding[item.token];
|
|
6031
6267
|
if (token) {
|
|
@@ -6512,7 +6748,8 @@ var useDeposit = (options) => {
|
|
|
6512
6748
|
track2(TrackerEventName.depositSuccess, {
|
|
6513
6749
|
wallet: state?.connectWallet?.name,
|
|
6514
6750
|
network: targetChain?.network_infos.name,
|
|
6515
|
-
quantity
|
|
6751
|
+
quantity,
|
|
6752
|
+
currency: options.srcToken
|
|
6516
6753
|
});
|
|
6517
6754
|
return result;
|
|
6518
6755
|
}).catch((e) => {
|
|
@@ -9641,7 +9878,7 @@ var useAssetsHistory = (options, config) => {
|
|
|
9641
9878
|
}
|
|
9642
9879
|
return `/v1/asset/history?${searchParams.toString()}`;
|
|
9643
9880
|
};
|
|
9644
|
-
const { data, isLoading, mutate:
|
|
9881
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
9645
9882
|
getKey(),
|
|
9646
9883
|
{
|
|
9647
9884
|
formatter: (data2) => data2,
|
|
@@ -9653,7 +9890,7 @@ var useAssetsHistory = (options, config) => {
|
|
|
9653
9890
|
(data2) => {
|
|
9654
9891
|
const isUpdate = typeof config?.shouldUpdateOnWalletChanged === "function" ? config.shouldUpdateOnWalletChanged(data2) : true;
|
|
9655
9892
|
if (isUpdate) {
|
|
9656
|
-
|
|
9893
|
+
mutate6();
|
|
9657
9894
|
}
|
|
9658
9895
|
},
|
|
9659
9896
|
// delay in ms
|
|
@@ -9825,7 +10062,7 @@ var useTransferHistory = (parmas) => {
|
|
|
9825
10062
|
}
|
|
9826
10063
|
return `/v1/internal_transfer_history?${search.toString()}`;
|
|
9827
10064
|
}, [page, size, fromId, toId, dataRange, main_sub_only]);
|
|
9828
|
-
const { data, isLoading, mutate:
|
|
10065
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
9829
10066
|
memoizedQueryKey,
|
|
9830
10067
|
{
|
|
9831
10068
|
// initialSize: 1,
|
|
@@ -9843,9 +10080,9 @@ var useTransferHistory = (parmas) => {
|
|
|
9843
10080
|
return useMemo(
|
|
9844
10081
|
() => [
|
|
9845
10082
|
parsedData ?? EMPTY_LIST,
|
|
9846
|
-
{ meta: data?.meta, isLoading, mutate:
|
|
10083
|
+
{ meta: data?.meta, isLoading, mutate: mutate6 }
|
|
9847
10084
|
],
|
|
9848
|
-
[parsedData, data?.meta, isLoading,
|
|
10085
|
+
[parsedData, data?.meta, isLoading, mutate6]
|
|
9849
10086
|
);
|
|
9850
10087
|
};
|
|
9851
10088
|
var useVaultsHistory = (parmas) => {
|
|
@@ -9861,7 +10098,7 @@ var useVaultsHistory = (parmas) => {
|
|
|
9861
10098
|
}
|
|
9862
10099
|
return `/v1/account_sv_transaction_history?${search.toString()}`;
|
|
9863
10100
|
}, [page, size, dataRange]);
|
|
9864
|
-
const { data, isLoading, mutate:
|
|
10101
|
+
const { data, isLoading, mutate: mutate6 } = usePrivateQuery(
|
|
9865
10102
|
memoizedQueryKey,
|
|
9866
10103
|
{
|
|
9867
10104
|
formatter: (data2) => data2,
|
|
@@ -9876,8 +10113,8 @@ var useVaultsHistory = (parmas) => {
|
|
|
9876
10113
|
return data.rows;
|
|
9877
10114
|
}, [data, infos]);
|
|
9878
10115
|
return useMemo(
|
|
9879
|
-
() => [parsedData ?? EMPTY_LIST, { meta: data?.meta, isLoading, mutate:
|
|
9880
|
-
[parsedData, data?.meta, isLoading,
|
|
10116
|
+
() => [parsedData ?? EMPTY_LIST, { meta: data?.meta, isLoading, mutate: mutate6 }],
|
|
10117
|
+
[parsedData, data?.meta, isLoading, mutate6]
|
|
9881
10118
|
);
|
|
9882
10119
|
};
|
|
9883
10120
|
var MaintenanceStatus = /* @__PURE__ */ ((MaintenanceStatus2) => {
|
|
@@ -10239,7 +10476,7 @@ var publicQueryOptions = {
|
|
|
10239
10476
|
dedupingInterval: 1e3 * 60 * 60 * 24
|
|
10240
10477
|
};
|
|
10241
10478
|
var usePublicDataObserver = () => {
|
|
10242
|
-
const { setSymbolsInfo, setFundingRates } = useAppStore(
|
|
10479
|
+
const { setSymbolsInfo, setFundingRates, setRwaSymbolsInfo } = useAppStore(
|
|
10243
10480
|
(state) => state.actions
|
|
10244
10481
|
);
|
|
10245
10482
|
const { updateMarket } = useMarketStore((state) => state.actions);
|
|
@@ -10271,6 +10508,27 @@ var usePublicDataObserver = () => {
|
|
|
10271
10508
|
setSymbolsInfo(obj);
|
|
10272
10509
|
}
|
|
10273
10510
|
});
|
|
10511
|
+
useQuery(`/v1/public/rwa/info`, {
|
|
10512
|
+
...publicQueryOptions,
|
|
10513
|
+
onSuccess(data) {
|
|
10514
|
+
if (!data || !data?.length) {
|
|
10515
|
+
return {};
|
|
10516
|
+
}
|
|
10517
|
+
const obj = {};
|
|
10518
|
+
for (let index = 0; index < data.length; index++) {
|
|
10519
|
+
const item = data[index];
|
|
10520
|
+
const arr = item.symbol.split("_");
|
|
10521
|
+
obj[item.symbol] = {
|
|
10522
|
+
...item,
|
|
10523
|
+
base: arr[1],
|
|
10524
|
+
quote: arr[2],
|
|
10525
|
+
type: arr[0],
|
|
10526
|
+
name: `${arr[1]}-${arr[0]}`
|
|
10527
|
+
};
|
|
10528
|
+
}
|
|
10529
|
+
setRwaSymbolsInfo(obj);
|
|
10530
|
+
}
|
|
10531
|
+
});
|
|
10274
10532
|
useQuery(`/v1/public/funding_rates`, {
|
|
10275
10533
|
...publicQueryOptions,
|
|
10276
10534
|
onSuccess(data) {
|
|
@@ -10330,6 +10588,7 @@ var DataCenterProvider = ({
|
|
|
10330
10588
|
children
|
|
10331
10589
|
}) => {
|
|
10332
10590
|
const { error, done } = usePreLoadData();
|
|
10591
|
+
useInitRwaSymbolsRuntime();
|
|
10333
10592
|
const calculatorService = useCalculatorService();
|
|
10334
10593
|
usePublicDataObserver();
|
|
10335
10594
|
useWSObserver(calculatorService);
|
|
@@ -16695,7 +16954,7 @@ var useApiKeyManager = (queryParams) => {
|
|
|
16695
16954
|
const { account: account9, state, isSubAccount } = useAccount();
|
|
16696
16955
|
const { keyInfo } = queryParams || {};
|
|
16697
16956
|
const keyInfoPrams = getQueryParamsFromObject(keyInfo);
|
|
16698
|
-
const { data, mutate:
|
|
16957
|
+
const { data, mutate: mutate6, error, isLoading } = usePrivateQuery(
|
|
16699
16958
|
`/v1/client/key_info${keyInfoPrams.length > 0 ? `?${keyInfoPrams}` : ""}`,
|
|
16700
16959
|
{
|
|
16701
16960
|
formatter: (data2) => data2?.rows
|
|
@@ -16749,7 +17008,7 @@ var useApiKeyManager = (queryParams) => {
|
|
|
16749
17008
|
return [
|
|
16750
17009
|
data,
|
|
16751
17010
|
{
|
|
16752
|
-
refresh:
|
|
17011
|
+
refresh: mutate6,
|
|
16753
17012
|
error,
|
|
16754
17013
|
isLoading,
|
|
16755
17014
|
generateOrderlyKey,
|
|
@@ -17789,6 +18048,6 @@ var usePositionClose = (options) => {
|
|
|
17789
18048
|
};
|
|
17790
18049
|
};
|
|
17791
18050
|
|
|
17792
|
-
export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, EpochStatus, ExtendedConfigStore, MaintenanceStatus, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore2 as useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
18051
|
+
export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, EpochStatus, ExtendedConfigStore, MaintenanceStatus, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore2 as useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
17793
18052
|
//# sourceMappingURL=out.js.map
|
|
17794
18053
|
//# sourceMappingURL=index.mjs.map
|