@orderly.network/hooks 0.0.30 → 0.0.32
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.js +22 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1801,6 +1801,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
|
|
|
1801
1801
|
}
|
|
1802
1802
|
const [trades, setTrades] = useState([]);
|
|
1803
1803
|
const [isLoading, setIsLoading] = useState(false);
|
|
1804
|
+
useState(() => symbol);
|
|
1804
1805
|
const { limit = 50 } = options;
|
|
1805
1806
|
const ws = useWS();
|
|
1806
1807
|
useEffect(() => {
|
|
@@ -1825,23 +1826,30 @@ var useMarketTradeStream = (symbol, options = {}) => {
|
|
|
1825
1826
|
);
|
|
1826
1827
|
}, [symbol]);
|
|
1827
1828
|
useEffect(() => {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1829
|
+
const unsubscript = ws.subscribe(
|
|
1830
|
+
{
|
|
1831
|
+
id: `${symbol}@trade`,
|
|
1832
|
+
event: "subscribe",
|
|
1833
|
+
topic: `${symbol}@trade`,
|
|
1834
|
+
ts: Date.now()
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
onMessage: (data) => {
|
|
1838
|
+
setTrades((prev) => {
|
|
1839
|
+
const arr = [__spreadProps(__spreadValues({}, data), { ts: Date.now() }), ...prev];
|
|
1840
|
+
if (arr.length > limit) {
|
|
1841
|
+
arr.pop();
|
|
1842
|
+
}
|
|
1843
|
+
return arr;
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1839
1846
|
}
|
|
1840
|
-
|
|
1847
|
+
);
|
|
1841
1848
|
return () => {
|
|
1842
1849
|
unsubscript == null ? void 0 : unsubscript();
|
|
1843
1850
|
};
|
|
1844
|
-
}, [symbol
|
|
1851
|
+
}, [symbol]);
|
|
1852
|
+
console.log("trades", trades);
|
|
1845
1853
|
return { data: trades, isLoading };
|
|
1846
1854
|
};
|
|
1847
1855
|
var useMarginRatio = () => {
|
|
@@ -1849,7 +1857,7 @@ var useMarginRatio = () => {
|
|
|
1849
1857
|
const { data: markPrices } = useMarkPricesStream();
|
|
1850
1858
|
const { totalCollateral } = useCollateral();
|
|
1851
1859
|
const marginRatio = useMemo(() => {
|
|
1852
|
-
if (!rows || !markPrices || !totalCollateral) {
|
|
1860
|
+
if (!rows || !markPrices || !totalCollateral || rows.length === 0) {
|
|
1853
1861
|
return 0;
|
|
1854
1862
|
}
|
|
1855
1863
|
const ratio = account.totalMarginRatio({
|