Assets
Overview
@orderly.network/hooks
provides the following hooks to get data regarding a user’s assets. This can be used under different use cases.
- useCollateral - retrieves information about a user’s collateral
- useMaxQty - retrieves the maximum quantity a user can place based on the symbol, side, leverage etc.
- useChain - Chain information
- useChains - Retrieves the list of supported chains
- useDeposit - retrieves a Withdraw tokens from Orderly smart contract balance helper
- useHoldingStream - Retrieves user’s assets
Functions regarding asset calculations are provided by @orderly.network/perp
Deposit status
Subscribe to the relevant websocket topic to get updates on the deposit status.
import { useWS } from "@orderly.network/hooks";
//...
export const Example = () => {
const ws = useWS();
useEffect(() => {
const unsubscribe = ws.subscribe(
{
id: "wallet",
event: "subscribe",
topic: "wallet",
ts: Date.now()
},
{
onMessage: (data: any) => {
//
}
}
);
return () => {
unsubscribe();
};
}, [ws]);
};
Withdrawal status
Subscribe to the relevant websocket topic to get updates on the withdrawal status.
import { useWS } from "@orderly.network/hooks";
//...
export const Example = () => {
const ws = useWS();
useEffect(() => {
const unsubscribe = ws.subscribe(
{
id: "wallet",
event: "subscribe",
topic: "wallet",
ts: Date.now()
},
{
onMessage: (data: any) => {
//
}
}
);
return () => {
unsubscribe();
};
}, [ws]);
};