[EVM] React Hooks SDK
Overview
Overview of Orderly Hooks SDK
@orderly.network/hooks
The hooks libraries provides a series of React hooks for React developers to ensure a seamless integration experience. This library is a package built on top of @orderly.network/core
and @orderly.network/perp
.
Coding standards
- If the hook returns an array, then the first element will be the actual data, and the second element will be an object containing some supporting functions.
- All hooks ending with
stream
will update in real-time, via relevant Websocket subscriptions. - All hooks ending with
subscription
subscribe to relevant Websocket API and allow to pass in a function. - All hooks ending with
query
is a wrapper of an API request.
List of hooks
REST & WS API
The REST API hooks can be used to facilitate interacting with Orderly REST & Websocket APIs.
- useQuery -
GET
Public API - usePrivateQuery -
GET
Private API - usePrivateInfiniteQuery - A version of
usePrivateQuery
that supports infinite scrolling - useLazyQuery
- useMutation -
POST
APIs - useWS - WebSocket client
- useWsStatus - WebSocket client status
useSWR
- Reexport from this npm package
Utility
These utility hooks provide ways to help handle UI states and some state management logic.
- useConfig - An instance of the
ConfigStore
- useEventEmitter - An instance of the
EventEmitter
- useLocalStorage - Management (CRUD) of localStorage
- useSessionStorage - Management (CRUD) of sessionStorage
- useMediaQuery - Evaluates a media query to a boolean
useConstant
- Reexport from this npm packageuseDebounce
- Reexport from this npm package
Account
- useAccount: Retrieves the current account info and status. With this hook you can also create an account and create an
orderlyKey
- useAccountInfo - Fetches account information
- useAccountInstance - Returns
Account
singleton - useWalletConnector - Handles wallet connection
- useWalletSubscription - Subscribe to wallet transactionsvia WebSocket
- useLeverage - Retrieves the current account leverage
- useMarginRatio - Margin information
- useSettleSubscription - Subscribe to PnL settlement via WebSocket
- useDaily - Retrieving daily user volume
Assets
- 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
Markets
- useOrderbookStream - Orderbook stream
- useIndexPrice - Get the index price of a single symbol
- useMarkPrice - Get the mark price of a single symbol
- useMarkPricesStream - Get the mark price of all symbols
- useMarketTradeStream - Get the market trades history of a symbol
- useMarkets - Retrieve all listed symbols and its market data
- useMarketsStream - Retrieve all listed symbols and its market data
- useTickerStream - Get the symbol market data stream
- useSymbolsInfo - Get the symbol market data stream
- useSymbolPriceRange - Get the price range for the specified symbol with an optional price
Orders
- useOrderEntry - Order placement
- useOrderStream - Retrieving, editing and cancelling orders
Positions
- usePositionStream - Position management
- usePoster - Generates a poster image based on position information
Funding
- useFundingRate - Funding rate information
Referral
- useCheckReferralCode - Check if referral code exists
- useGetReferralCode - Obtain referral code via
account_id
- useDaily - Returns
perp_volume
based on start and end time - useRefereeInfo - Retrieve referee info
- useRefereeRebateSummary - Provide statistics on referee rebates per date
- useReferralInfo - Retrieve referral info
- useReferralRebateSummary - Provide statistics on referral rebates per date