@orderly.network/hooks 1.1.4-alpha.0 → 1.1.4-alpha.2
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +41 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,9 +28,9 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
|
|
|
28
28
|
// src/version.ts
|
|
29
29
|
if (typeof window !== "undefined") {
|
|
30
30
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
31
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.1.4-alpha.
|
|
31
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.1.4-alpha.2";
|
|
32
32
|
}
|
|
33
|
-
var version_default = "1.1.4-alpha.
|
|
33
|
+
var version_default = "1.1.4-alpha.2";
|
|
34
34
|
var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
|
|
35
35
|
var OrderlyContext = React.createContext({
|
|
36
36
|
// configStore: new MemoryConfigStore(),
|
|
@@ -751,6 +751,37 @@ var useOpenInterest = (symbol) => {
|
|
|
751
751
|
};
|
|
752
752
|
});
|
|
753
753
|
};
|
|
754
|
+
var useFetures = () => {
|
|
755
|
+
const { data, isLoading, error } = useQuery(
|
|
756
|
+
`/v1/public/futures`,
|
|
757
|
+
{
|
|
758
|
+
revalidateOnFocus: false
|
|
759
|
+
}
|
|
760
|
+
);
|
|
761
|
+
const [sortedData, setSortedData] = React.useState(data);
|
|
762
|
+
useWS();
|
|
763
|
+
React.useEffect(() => {
|
|
764
|
+
}, []);
|
|
765
|
+
React.useEffect(() => {
|
|
766
|
+
if (data) {
|
|
767
|
+
const sortedData2 = data.sort((a, b) => {
|
|
768
|
+
return 0;
|
|
769
|
+
});
|
|
770
|
+
setSortedData(sortedData2);
|
|
771
|
+
}
|
|
772
|
+
}, [data]);
|
|
773
|
+
const sortBy = React.useCallback((key) => {
|
|
774
|
+
}, [data]);
|
|
775
|
+
const filterBy = React.useCallback((key) => {
|
|
776
|
+
}, [data]);
|
|
777
|
+
return {
|
|
778
|
+
data: sortedData,
|
|
779
|
+
sortBy,
|
|
780
|
+
filterBy,
|
|
781
|
+
isLoading,
|
|
782
|
+
error
|
|
783
|
+
};
|
|
784
|
+
};
|
|
754
785
|
|
|
755
786
|
// src/orderly/useTickerStream.ts
|
|
756
787
|
var useTickerStream = (symbol) => {
|
|
@@ -791,16 +822,22 @@ var useTickerStream = (symbol) => {
|
|
|
791
822
|
const { data: markPrice } = useMarkPrice(symbol);
|
|
792
823
|
const { data: indexPrice } = useIndexPrice(symbol);
|
|
793
824
|
const { data: openInterest } = useOpenInterest(symbol);
|
|
825
|
+
const { data: futures } = useFetures();
|
|
794
826
|
const value = React.useMemo(() => {
|
|
795
827
|
if (!info)
|
|
796
828
|
return null;
|
|
797
829
|
if (!ticker)
|
|
798
830
|
return info;
|
|
831
|
+
const futureIndex = futures?.findIndex((item) => item.symbol === symbol);
|
|
832
|
+
let _oi = openInterest;
|
|
833
|
+
if (!_oi && futureIndex !== -1 && futures) {
|
|
834
|
+
_oi = futures[futureIndex].open_interest;
|
|
835
|
+
}
|
|
799
836
|
const config = {
|
|
800
837
|
...info,
|
|
801
838
|
mark_price: markPrice,
|
|
802
839
|
index_price: indexPrice,
|
|
803
|
-
open_interest:
|
|
840
|
+
open_interest: _oi
|
|
804
841
|
};
|
|
805
842
|
if (ticker.open !== void 0) {
|
|
806
843
|
config["24h_open"] = ticker.open;
|
|
@@ -822,7 +859,7 @@ var useTickerStream = (symbol) => {
|
|
|
822
859
|
config["24h_change"] = new utils.Decimal(ticker.close).minus(ticker.open);
|
|
823
860
|
}
|
|
824
861
|
return config;
|
|
825
|
-
}, [info, symbol, ticker]);
|
|
862
|
+
}, [info, symbol, ticker, futures, openInterest]);
|
|
826
863
|
return value;
|
|
827
864
|
};
|
|
828
865
|
|