@orderly.network/hooks 1.1.4-rc.4 → 1.1.4
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/esm/configProvider.d.ts +17 -0
- package/esm/configProvider.d.ts.map +1 -0
- package/esm/configProvider.js +54 -0
- package/esm/dataProvider.d.ts +10 -0
- package/esm/dataProvider.d.ts.map +1 -0
- package/esm/dataProvider.js +29 -0
- package/esm/index.d.ts +33 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +30 -0
- package/esm/middleware/signatureMiddleware.d.ts +3 -0
- package/esm/middleware/signatureMiddleware.d.ts.map +1 -0
- package/esm/middleware/signatureMiddleware.js +32 -0
- package/esm/orderly/orderlyHooks.d.ts +30 -0
- package/esm/orderly/orderlyHooks.d.ts.map +1 -0
- package/esm/orderly/orderlyHooks.js +27 -0
- package/esm/orderly/useAccountInfo.d.ts +3 -0
- package/esm/orderly/useAccountInfo.d.ts.map +1 -0
- package/esm/orderly/useAccountInfo.js +4 -0
- package/esm/orderly/useChain.d.ts +6 -0
- package/esm/orderly/useChain.d.ts.map +1 -0
- package/esm/orderly/useChain.js +22 -0
- package/esm/orderly/useChains.d.ts +34 -0
- package/esm/orderly/useChains.d.ts.map +1 -0
- package/esm/orderly/useChains.js +159 -0
- package/esm/orderly/useCollateral.d.ts +16 -0
- package/esm/orderly/useCollateral.d.ts.map +1 -0
- package/esm/orderly/useCollateral.js +72 -0
- package/esm/orderly/useDeposit.d.ts +38 -0
- package/esm/orderly/useDeposit.d.ts.map +1 -0
- package/esm/orderly/useDeposit.js +270 -0
- package/esm/orderly/useFundingRate.d.ts +11 -0
- package/esm/orderly/useFundingRate.d.ts.map +1 -0
- package/esm/orderly/useFundingRate.js +40 -0
- package/esm/orderly/useFundingRates.d.ts +2 -0
- package/esm/orderly/useFundingRates.d.ts.map +1 -0
- package/esm/orderly/useFundingRates.js +21 -0
- package/esm/orderly/useHoldingStream.d.ts +7 -0
- package/esm/orderly/useHoldingStream.d.ts.map +1 -0
- package/esm/orderly/useHoldingStream.js +47 -0
- package/esm/orderly/useIndexPrice.d.ts +2 -0
- package/esm/orderly/useIndexPrice.d.ts.map +1 -0
- package/esm/orderly/useIndexPrice.js +17 -0
- package/esm/orderly/useLeverage.d.ts +2 -0
- package/esm/orderly/useLeverage.d.ts.map +1 -0
- package/esm/orderly/useLeverage.js +34 -0
- package/esm/orderly/useMarginRatio.d.ts +7 -0
- package/esm/orderly/useMarginRatio.d.ts.map +1 -0
- package/esm/orderly/useMarginRatio.js +41 -0
- package/esm/orderly/useMarkPrice.d.ts +4 -0
- package/esm/orderly/useMarkPrice.d.ts.map +1 -0
- package/esm/orderly/useMarkPrice.js +29 -0
- package/esm/orderly/useMarkPricesStream.d.ts +2 -0
- package/esm/orderly/useMarkPricesStream.d.ts.map +1 -0
- package/esm/orderly/useMarkPricesStream.js +26 -0
- package/esm/orderly/useMarketTradeStream.d.ts +9 -0
- package/esm/orderly/useMarketTradeStream.d.ts.map +1 -0
- package/esm/orderly/useMarketTradeStream.js +51 -0
- package/esm/orderly/useMarkets.d.ts +36 -0
- package/esm/orderly/useMarkets.d.ts.map +1 -0
- package/esm/orderly/useMarkets.js +240 -0
- package/esm/orderly/useMarketsStream.d.ts +5 -0
- package/esm/orderly/useMarketsStream.d.ts.map +1 -0
- package/esm/orderly/useMarketsStream.js +57 -0
- package/esm/orderly/useMaxQty.d.ts +3 -0
- package/esm/orderly/useMaxQty.d.ts.map +1 -0
- package/esm/orderly/useMaxQty.js +114 -0
- package/esm/orderly/useOpenInterest.d.ts +2 -0
- package/esm/orderly/useOpenInterest.d.ts.map +1 -0
- package/esm/orderly/useOpenInterest.js +15 -0
- package/esm/orderly/useOrderEntry.d.ts +63 -0
- package/esm/orderly/useOrderEntry.d.ts.map +1 -0
- package/esm/orderly/useOrderEntry.js +504 -0
- package/esm/orderly/useOrderStream.d.ts +38 -0
- package/esm/orderly/useOrderStream.d.ts.map +1 -0
- package/esm/orderly/useOrderStream.js +180 -0
- package/esm/orderly/useOrderbookStream.d.ts +53 -0
- package/esm/orderly/useOrderbookStream.d.ts.map +1 -0
- package/esm/orderly/useOrderbookStream.js +309 -0
- package/esm/orderly/usePositionStream.d.ts +25 -0
- package/esm/orderly/usePositionStream.d.ts.map +1 -0
- package/esm/orderly/usePositionStream.js +232 -0
- package/esm/orderly/usePrivateDataObserver.d.ts +5 -0
- package/esm/orderly/usePrivateDataObserver.d.ts.map +1 -0
- package/esm/orderly/usePrivateDataObserver.js +126 -0
- package/esm/orderly/useSettleSubscription.d.ts +4 -0
- package/esm/orderly/useSettleSubscription.d.ts.map +1 -0
- package/esm/orderly/useSettleSubscription.js +20 -0
- package/esm/orderly/useSymbolPriceRange.d.ts +13 -0
- package/esm/orderly/useSymbolPriceRange.d.ts.map +1 -0
- package/esm/orderly/useSymbolPriceRange.js +39 -0
- package/esm/orderly/useSymbolsInfo.d.ts +2 -0
- package/esm/orderly/useSymbolsInfo.d.ts.map +1 -0
- package/esm/orderly/useSymbolsInfo.js +33 -0
- package/esm/orderly/useTickerStream.d.ts +3 -0
- package/esm/orderly/useTickerStream.d.ts.map +1 -0
- package/esm/orderly/useTickerStream.js +86 -0
- package/esm/orderly/useWalletSubscription.d.ts +4 -0
- package/esm/orderly/useWalletSubscription.d.ts.map +1 -0
- package/esm/orderly/useWalletSubscription.js +20 -0
- package/esm/orderly/useWithdraw.d.ts +14 -0
- package/esm/orderly/useWithdraw.d.ts.map +1 -0
- package/esm/orderly/useWithdraw.js +64 -0
- package/esm/orderlyContext.d.ts +17 -0
- package/esm/orderlyContext.d.ts.map +1 -0
- package/esm/orderlyContext.js +5 -0
- package/esm/services/dataCenter.d.ts +2 -0
- package/esm/services/dataCenter.d.ts.map +1 -0
- package/esm/services/dataCenter.js +13 -0
- package/esm/services/painter/backgroundPaint.d.ts +9 -0
- package/esm/services/painter/backgroundPaint.d.ts.map +1 -0
- package/esm/services/painter/backgroundPaint.js +41 -0
- package/esm/services/painter/basePaint.d.ts +90 -0
- package/esm/services/painter/basePaint.d.ts.map +1 -0
- package/esm/services/painter/basePaint.js +6 -0
- package/esm/services/painter/dataPaint.d.ts +16 -0
- package/esm/services/painter/dataPaint.d.ts.map +1 -0
- package/esm/services/painter/dataPaint.js +195 -0
- package/esm/services/painter/layout.config.d.ts +3 -0
- package/esm/services/painter/layout.config.d.ts.map +1 -0
- package/esm/services/painter/layout.config.js +52 -0
- package/esm/services/painter/painter.d.ts +12 -0
- package/esm/services/painter/painter.d.ts.map +1 -0
- package/esm/services/painter/painter.js +37 -0
- package/esm/services/painter/resource.d.ts +7 -0
- package/esm/services/painter/resource.d.ts.map +1 -0
- package/esm/services/painter/resource.js +15 -0
- package/esm/statusProvider.d.ts +8 -0
- package/esm/statusProvider.d.ts.map +1 -0
- package/esm/statusProvider.js +8 -0
- package/esm/unuse/apiPrefixMiddleware.d.ts +3 -0
- package/esm/unuse/apiPrefixMiddleware.d.ts.map +1 -0
- package/esm/unuse/apiPrefixMiddleware.js +29 -0
- package/esm/unuse/fn.d.ts +2 -0
- package/esm/unuse/fn.d.ts.map +1 -0
- package/esm/unuse/fn.js +6 -0
- package/esm/unuse/useBalance.d.ts +2 -0
- package/esm/unuse/useBalance.d.ts.map +1 -0
- package/esm/unuse/useBalance.js +12 -0
- package/esm/unuse/useFetures.d.ts +11 -0
- package/esm/unuse/useFetures.d.ts.map +1 -0
- package/esm/unuse/useFetures.js +39 -0
- package/esm/unuse/useRunOnce.d.ts +7 -0
- package/esm/unuse/useRunOnce.d.ts.map +1 -0
- package/esm/unuse/useRunOnce.js +17 -0
- package/esm/unuse/useSyncEnd.d.ts +2 -0
- package/esm/unuse/useSyncEnd.d.ts.map +1 -0
- package/esm/unuse/useSyncEnd.js +10 -0
- package/esm/unuse/useTokenInfo.d.ts +2 -0
- package/esm/unuse/useTokenInfo.d.ts.map +1 -0
- package/esm/unuse/useTokenInfo.js +20 -0
- package/esm/unuse/useUnsettlementPnL.d.ts +2 -0
- package/esm/unuse/useUnsettlementPnL.d.ts.map +1 -0
- package/esm/unuse/useUnsettlementPnL.js +20 -0
- package/esm/useAccount.d.ts +8 -0
- package/esm/useAccount.d.ts.map +1 -0
- package/esm/useAccount.js +59 -0
- package/esm/useAccountInstance.d.ts +3 -0
- package/esm/useAccountInstance.d.ts.map +1 -0
- package/esm/useAccountInstance.js +23 -0
- package/esm/useBoolean.d.ts +6 -0
- package/esm/useBoolean.d.ts.map +1 -0
- package/esm/useBoolean.js +8 -0
- package/esm/useConfig.d.ts +3 -0
- package/esm/useConfig.d.ts.map +1 -0
- package/esm/useConfig.js +12 -0
- package/esm/useEventEmitter.d.ts +3 -0
- package/esm/useEventEmitter.d.ts.map +1 -0
- package/esm/useEventEmitter.js +12 -0
- package/esm/useLazyQuery.d.ts +13 -0
- package/esm/useLazyQuery.d.ts.map +1 -0
- package/esm/useLazyQuery.js +35 -0
- package/esm/useLocalStorage.d.ts +2 -0
- package/esm/useLocalStorage.d.ts.map +1 -0
- package/esm/useLocalStorage.js +74 -0
- package/esm/useMediaQuery.d.ts +2 -0
- package/esm/useMediaQuery.d.ts.map +1 -0
- package/esm/useMediaQuery.js +36 -0
- package/esm/useMutation.d.ts +10 -0
- package/esm/useMutation.d.ts.map +1 -0
- package/esm/useMutation.js +64 -0
- package/esm/useObserve.d.ts +6 -0
- package/esm/useObserve.d.ts.map +1 -0
- package/esm/useObserve.js +8 -0
- package/esm/useParamsCheck.d.ts +4 -0
- package/esm/useParamsCheck.d.ts.map +1 -0
- package/esm/useParamsCheck.js +14 -0
- package/esm/usePoster.d.ts +14 -0
- package/esm/usePoster.d.ts.map +1 -0
- package/esm/usePoster.js +52 -0
- package/esm/usePreloadData.d.ts +5 -0
- package/esm/usePreloadData.d.ts.map +1 -0
- package/esm/usePreloadData.js +14 -0
- package/esm/usePrivateInfiniteQuery.d.ts +5 -0
- package/esm/usePrivateInfiniteQuery.d.ts.map +1 -0
- package/esm/usePrivateInfiniteQuery.js +25 -0
- package/esm/usePrivateQuery.d.ts +10 -0
- package/esm/usePrivateQuery.d.ts.map +1 -0
- package/esm/usePrivateQuery.js +26 -0
- package/esm/useQuery.d.ts +10 -0
- package/esm/useQuery.d.ts.map +1 -0
- package/esm/useQuery.js +20 -0
- package/esm/useSessionStorage.d.ts +2 -0
- package/esm/useSessionStorage.d.ts.map +1 -0
- package/esm/useSessionStorage.js +60 -0
- package/esm/useWS.d.ts +3 -0
- package/esm/useWS.d.ts.map +1 -0
- package/esm/useWS.js +51 -0
- package/esm/useWsStatus.d.ts +7 -0
- package/esm/useWsStatus.d.ts.map +1 -0
- package/esm/useWsStatus.js +41 -0
- package/esm/utils/createGetter.d.ts +4 -0
- package/esm/utils/createGetter.d.ts.map +1 -0
- package/esm/utils/createGetter.js +21 -0
- package/esm/utils/createOrder.d.ts +56 -0
- package/esm/utils/createOrder.d.ts.map +1 -0
- package/esm/utils/createOrder.js +324 -0
- package/esm/utils/fetcher.d.ts +6 -0
- package/esm/utils/fetcher.d.ts.map +1 -0
- package/esm/utils/fetcher.js +2 -0
- package/esm/utils/json.d.ts +2 -0
- package/esm/utils/json.d.ts.map +1 -0
- package/esm/utils/json.js +8 -0
- package/esm/utils/orderEntryHelper.d.ts +25 -0
- package/esm/utils/orderEntryHelper.d.ts.map +1 -0
- package/esm/utils/orderEntryHelper.js +242 -0
- package/esm/utils/parseHolding.d.ts +9 -0
- package/esm/utils/parseHolding.d.ts.map +1 -0
- package/esm/utils/parseHolding.js +21 -0
- package/esm/version.d.ts +10 -0
- package/esm/version.d.ts.map +1 -0
- package/esm/version.js +6 -0
- package/esm/walletConnectorContext.d.ts +30 -0
- package/esm/walletConnectorContext.d.ts.map +1 -0
- package/esm/walletConnectorContext.js +5 -0
- package/lib/configProvider.d.ts +17 -0
- package/lib/configProvider.d.ts.map +1 -0
- package/lib/configProvider.js +82 -0
- package/lib/dataProvider.d.ts +10 -0
- package/lib/dataProvider.d.ts.map +1 -0
- package/lib/dataProvider.js +34 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +88 -0
- package/lib/middleware/signatureMiddleware.d.ts +3 -0
- package/lib/middleware/signatureMiddleware.d.ts.map +1 -0
- package/lib/middleware/signatureMiddleware.js +36 -0
- package/lib/orderly/orderlyHooks.d.ts +30 -0
- package/lib/orderly/orderlyHooks.d.ts.map +1 -0
- package/lib/orderly/orderlyHooks.js +58 -0
- package/lib/orderly/useAccountInfo.d.ts +3 -0
- package/lib/orderly/useAccountInfo.d.ts.map +1 -0
- package/lib/orderly/useAccountInfo.js +8 -0
- package/lib/orderly/useChain.d.ts +6 -0
- package/lib/orderly/useChain.d.ts.map +1 -0
- package/lib/orderly/useChain.js +26 -0
- package/lib/orderly/useChains.d.ts +34 -0
- package/lib/orderly/useChains.d.ts.map +1 -0
- package/lib/orderly/useChains.js +166 -0
- package/lib/orderly/useCollateral.d.ts +16 -0
- package/lib/orderly/useCollateral.d.ts.map +1 -0
- package/lib/orderly/useCollateral.js +76 -0
- package/lib/orderly/useDeposit.d.ts +38 -0
- package/lib/orderly/useDeposit.d.ts.map +1 -0
- package/lib/orderly/useDeposit.js +274 -0
- package/lib/orderly/useFundingRate.d.ts +11 -0
- package/lib/orderly/useFundingRate.d.ts.map +1 -0
- package/lib/orderly/useFundingRate.js +44 -0
- package/lib/orderly/useFundingRates.d.ts +2 -0
- package/lib/orderly/useFundingRates.d.ts.map +1 -0
- package/lib/orderly/useFundingRates.js +25 -0
- package/lib/orderly/useHoldingStream.d.ts +7 -0
- package/lib/orderly/useHoldingStream.d.ts.map +1 -0
- package/lib/orderly/useHoldingStream.js +54 -0
- package/lib/orderly/useIndexPrice.d.ts +2 -0
- package/lib/orderly/useIndexPrice.d.ts.map +1 -0
- package/lib/orderly/useIndexPrice.js +24 -0
- package/lib/orderly/useLeverage.d.ts +2 -0
- package/lib/orderly/useLeverage.d.ts.map +1 -0
- package/lib/orderly/useLeverage.js +38 -0
- package/lib/orderly/useMarginRatio.d.ts +7 -0
- package/lib/orderly/useMarginRatio.d.ts.map +1 -0
- package/lib/orderly/useMarginRatio.js +45 -0
- package/lib/orderly/useMarkPrice.d.ts +4 -0
- package/lib/orderly/useMarkPrice.d.ts.map +1 -0
- package/lib/orderly/useMarkPrice.js +33 -0
- package/lib/orderly/useMarkPricesStream.d.ts +2 -0
- package/lib/orderly/useMarkPricesStream.d.ts.map +1 -0
- package/lib/orderly/useMarkPricesStream.js +33 -0
- package/lib/orderly/useMarketTradeStream.d.ts +9 -0
- package/lib/orderly/useMarketTradeStream.d.ts.map +1 -0
- package/lib/orderly/useMarketTradeStream.js +55 -0
- package/lib/orderly/useMarkets.d.ts +36 -0
- package/lib/orderly/useMarkets.d.ts.map +1 -0
- package/lib/orderly/useMarkets.js +244 -0
- package/lib/orderly/useMarketsStream.d.ts +5 -0
- package/lib/orderly/useMarketsStream.d.ts.map +1 -0
- package/lib/orderly/useMarketsStream.js +64 -0
- package/lib/orderly/useMaxQty.d.ts +3 -0
- package/lib/orderly/useMaxQty.d.ts.map +1 -0
- package/lib/orderly/useMaxQty.js +118 -0
- package/lib/orderly/useOpenInterest.d.ts +2 -0
- package/lib/orderly/useOpenInterest.d.ts.map +1 -0
- package/lib/orderly/useOpenInterest.js +22 -0
- package/lib/orderly/useOrderEntry.d.ts +63 -0
- package/lib/orderly/useOrderEntry.d.ts.map +1 -0
- package/lib/orderly/useOrderEntry.js +508 -0
- package/lib/orderly/useOrderStream.d.ts +38 -0
- package/lib/orderly/useOrderStream.d.ts.map +1 -0
- package/lib/orderly/useOrderStream.js +187 -0
- package/lib/orderly/useOrderbookStream.d.ts +53 -0
- package/lib/orderly/useOrderbookStream.d.ts.map +1 -0
- package/lib/orderly/useOrderbookStream.js +315 -0
- package/lib/orderly/usePositionStream.d.ts +25 -0
- package/lib/orderly/usePositionStream.d.ts.map +1 -0
- package/lib/orderly/usePositionStream.js +236 -0
- package/lib/orderly/usePrivateDataObserver.d.ts +5 -0
- package/lib/orderly/usePrivateDataObserver.d.ts.map +1 -0
- package/lib/orderly/usePrivateDataObserver.js +130 -0
- package/lib/orderly/useSettleSubscription.d.ts +4 -0
- package/lib/orderly/useSettleSubscription.d.ts.map +1 -0
- package/lib/orderly/useSettleSubscription.js +27 -0
- package/lib/orderly/useSymbolPriceRange.d.ts +13 -0
- package/lib/orderly/useSymbolPriceRange.d.ts.map +1 -0
- package/lib/orderly/useSymbolPriceRange.js +43 -0
- package/lib/orderly/useSymbolsInfo.d.ts +2 -0
- package/lib/orderly/useSymbolsInfo.d.ts.map +1 -0
- package/lib/orderly/useSymbolsInfo.js +37 -0
- package/lib/orderly/useTickerStream.d.ts +3 -0
- package/lib/orderly/useTickerStream.d.ts.map +1 -0
- package/lib/orderly/useTickerStream.js +90 -0
- package/lib/orderly/useWalletSubscription.d.ts +4 -0
- package/lib/orderly/useWalletSubscription.d.ts.map +1 -0
- package/lib/orderly/useWalletSubscription.js +27 -0
- package/lib/orderly/useWithdraw.d.ts +14 -0
- package/lib/orderly/useWithdraw.d.ts.map +1 -0
- package/lib/orderly/useWithdraw.js +68 -0
- package/lib/orderlyContext.d.ts +17 -0
- package/lib/orderlyContext.d.ts.map +1 -0
- package/lib/orderlyContext.js +8 -0
- package/lib/services/dataCenter.d.ts +2 -0
- package/lib/services/dataCenter.d.ts.map +1 -0
- package/lib/services/dataCenter.js +15 -0
- package/lib/services/painter/backgroundPaint.d.ts +9 -0
- package/lib/services/painter/backgroundPaint.d.ts.map +1 -0
- package/lib/services/painter/backgroundPaint.js +45 -0
- package/lib/services/painter/basePaint.d.ts +90 -0
- package/lib/services/painter/basePaint.d.ts.map +1 -0
- package/lib/services/painter/basePaint.js +10 -0
- package/lib/services/painter/dataPaint.d.ts +16 -0
- package/lib/services/painter/dataPaint.d.ts.map +1 -0
- package/lib/services/painter/dataPaint.js +199 -0
- package/lib/services/painter/layout.config.d.ts +3 -0
- package/lib/services/painter/layout.config.d.ts.map +1 -0
- package/lib/services/painter/layout.config.js +55 -0
- package/lib/services/painter/painter.d.ts +12 -0
- package/lib/services/painter/painter.d.ts.map +1 -0
- package/lib/services/painter/painter.js +41 -0
- package/lib/services/painter/resource.d.ts +7 -0
- package/lib/services/painter/resource.d.ts.map +1 -0
- package/lib/services/painter/resource.js +19 -0
- package/lib/statusProvider.d.ts +8 -0
- package/lib/statusProvider.d.ts.map +1 -0
- package/lib/statusProvider.js +12 -0
- package/lib/unuse/apiPrefixMiddleware.d.ts +3 -0
- package/lib/unuse/apiPrefixMiddleware.d.ts.map +1 -0
- package/lib/unuse/apiPrefixMiddleware.js +33 -0
- package/lib/unuse/fn.d.ts +2 -0
- package/lib/unuse/fn.d.ts.map +1 -0
- package/lib/unuse/fn.js +9 -0
- package/lib/unuse/useBalance.d.ts +2 -0
- package/lib/unuse/useBalance.d.ts.map +1 -0
- package/lib/unuse/useBalance.js +19 -0
- package/lib/unuse/useFetures.d.ts +11 -0
- package/lib/unuse/useFetures.d.ts.map +1 -0
- package/lib/unuse/useFetures.js +43 -0
- package/lib/unuse/useRunOnce.d.ts +7 -0
- package/lib/unuse/useRunOnce.d.ts.map +1 -0
- package/lib/unuse/useRunOnce.js +21 -0
- package/lib/unuse/useSyncEnd.d.ts +2 -0
- package/lib/unuse/useSyncEnd.d.ts.map +1 -0
- package/lib/unuse/useSyncEnd.js +14 -0
- package/lib/unuse/useTokenInfo.d.ts +2 -0
- package/lib/unuse/useTokenInfo.d.ts.map +1 -0
- package/lib/unuse/useTokenInfo.js +24 -0
- package/lib/unuse/useUnsettlementPnL.d.ts +2 -0
- package/lib/unuse/useUnsettlementPnL.d.ts.map +1 -0
- package/lib/unuse/useUnsettlementPnL.js +24 -0
- package/lib/useAccount.d.ts +8 -0
- package/lib/useAccount.d.ts.map +1 -0
- package/lib/useAccount.js +63 -0
- package/lib/useAccountInstance.d.ts +3 -0
- package/lib/useAccountInstance.d.ts.map +1 -0
- package/lib/useAccountInstance.js +30 -0
- package/lib/useBoolean.d.ts +6 -0
- package/lib/useBoolean.d.ts.map +1 -0
- package/lib/useBoolean.js +12 -0
- package/lib/useConfig.d.ts +3 -0
- package/lib/useConfig.d.ts.map +1 -0
- package/lib/useConfig.js +16 -0
- package/lib/useEventEmitter.d.ts +3 -0
- package/lib/useEventEmitter.d.ts.map +1 -0
- package/lib/useEventEmitter.js +19 -0
- package/lib/useLazyQuery.d.ts +13 -0
- package/lib/useLazyQuery.d.ts.map +1 -0
- package/lib/useLazyQuery.js +42 -0
- package/lib/useLocalStorage.d.ts +2 -0
- package/lib/useLocalStorage.d.ts.map +1 -0
- package/lib/useLocalStorage.js +78 -0
- package/lib/useMediaQuery.d.ts +2 -0
- package/lib/useMediaQuery.d.ts.map +1 -0
- package/lib/useMediaQuery.js +40 -0
- package/lib/useMutation.d.ts +10 -0
- package/lib/useMutation.d.ts.map +1 -0
- package/lib/useMutation.js +71 -0
- package/lib/useObserve.d.ts +6 -0
- package/lib/useObserve.d.ts.map +1 -0
- package/lib/useObserve.js +12 -0
- package/lib/useParamsCheck.d.ts +4 -0
- package/lib/useParamsCheck.d.ts.map +1 -0
- package/lib/useParamsCheck.js +18 -0
- package/lib/usePoster.d.ts +14 -0
- package/lib/usePoster.d.ts.map +1 -0
- package/lib/usePoster.js +56 -0
- package/lib/usePreloadData.d.ts +5 -0
- package/lib/usePreloadData.d.ts.map +1 -0
- package/lib/usePreloadData.js +18 -0
- package/lib/usePrivateInfiniteQuery.d.ts +5 -0
- package/lib/usePrivateInfiniteQuery.d.ts.map +1 -0
- package/lib/usePrivateInfiniteQuery.js +32 -0
- package/lib/usePrivateQuery.d.ts +10 -0
- package/lib/usePrivateQuery.d.ts.map +1 -0
- package/lib/usePrivateQuery.js +33 -0
- package/lib/useQuery.d.ts +10 -0
- package/lib/useQuery.d.ts.map +1 -0
- package/lib/useQuery.js +27 -0
- package/lib/useSessionStorage.d.ts +2 -0
- package/lib/useSessionStorage.d.ts.map +1 -0
- package/lib/useSessionStorage.js +64 -0
- package/lib/useWS.d.ts +3 -0
- package/lib/useWS.d.ts.map +1 -0
- package/lib/useWS.js +58 -0
- package/lib/useWsStatus.d.ts +7 -0
- package/lib/useWsStatus.d.ts.map +1 -0
- package/lib/useWsStatus.js +45 -0
- package/lib/utils/createGetter.d.ts +4 -0
- package/lib/utils/createGetter.d.ts.map +1 -0
- package/lib/utils/createGetter.js +25 -0
- package/lib/utils/createOrder.d.ts +56 -0
- package/lib/utils/createOrder.d.ts.map +1 -0
- package/lib/utils/createOrder.js +337 -0
- package/lib/utils/fetcher.d.ts +6 -0
- package/lib/utils/fetcher.d.ts.map +1 -0
- package/lib/utils/fetcher.js +6 -0
- package/lib/utils/json.d.ts +2 -0
- package/lib/utils/json.d.ts.map +1 -0
- package/lib/utils/json.js +12 -0
- package/lib/utils/orderEntryHelper.d.ts +25 -0
- package/lib/utils/orderEntryHelper.d.ts.map +1 -0
- package/lib/utils/orderEntryHelper.js +250 -0
- package/lib/utils/parseHolding.d.ts +9 -0
- package/lib/utils/parseHolding.d.ts.map +1 -0
- package/lib/utils/parseHolding.js +25 -0
- package/lib/version.d.ts +10 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +8 -0
- package/lib/walletConnectorContext.d.ts +30 -0
- package/lib/walletConnectorContext.d.ts.map +1 -0
- package/lib/walletConnectorContext.js +9 -0
- package/package.json +18 -13
- package/dist/index.d.mts +0 -548
- package/dist/index.d.ts +0 -548
- package/dist/index.js +0 -5412
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -5329
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { usePrivateQuery } from "../usePrivateQuery";
|
|
3
|
+
import { account, positions } from "@orderly.network/perp";
|
|
4
|
+
import { createGetter } from "../utils/createGetter";
|
|
5
|
+
import { useFundingRates } from "./useFundingRates";
|
|
6
|
+
import { useSymbolsInfo } from "./useSymbolsInfo";
|
|
7
|
+
import { useMarkPricesStream } from "./useMarkPricesStream";
|
|
8
|
+
import { pathOr, propOr } from "ramda";
|
|
9
|
+
import { parseHolding } from "../utils/parseHolding";
|
|
10
|
+
import { zero } from "@orderly.network/utils";
|
|
11
|
+
import { useMarketsStream } from "./useMarketsStream";
|
|
12
|
+
export const usePositionStream = (
|
|
13
|
+
/**
|
|
14
|
+
* If symbol is passed, only the position of that symbol will be returned.
|
|
15
|
+
*/
|
|
16
|
+
symbol, options) => {
|
|
17
|
+
const symbolInfo = useSymbolsInfo();
|
|
18
|
+
const { data: accountInfo } = usePrivateQuery("/v1/client/info");
|
|
19
|
+
const { data: holding } = usePrivateQuery("/v1/client/holding", {
|
|
20
|
+
formatter: (data) => {
|
|
21
|
+
return data.holding;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const fundingRates = useFundingRates();
|
|
25
|
+
const { data, error, mutate: refreshPositions, } = usePrivateQuery(`/v1/positions`, {
|
|
26
|
+
// revalidateOnFocus: false,
|
|
27
|
+
// revalidateOnReconnect: false,
|
|
28
|
+
// dedupingInterval: 200,
|
|
29
|
+
// keepPreviousData: false,
|
|
30
|
+
// revalidateIfStale: true,
|
|
31
|
+
...options,
|
|
32
|
+
formatter: (data) => data,
|
|
33
|
+
onError: (err) => { },
|
|
34
|
+
});
|
|
35
|
+
const { data: markPrices } = useMarkPricesStream();
|
|
36
|
+
const [priceMode, setPriceMode] = useState(options?.calcMode || "markPrice");
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (options?.calcMode && priceMode !== options?.calcMode) {
|
|
39
|
+
setPriceMode(options?.calcMode);
|
|
40
|
+
}
|
|
41
|
+
}, [options?.calcMode]);
|
|
42
|
+
const { data: tickers } = useMarketsStream();
|
|
43
|
+
// console.log("mark prices", markPrices);
|
|
44
|
+
// console.log("tickers", tickers);
|
|
45
|
+
const tickerPrices = useMemo(() => {
|
|
46
|
+
const data = Object.create(null);
|
|
47
|
+
tickers?.forEach((item) => {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
data[item.symbol] = item["24h_close"];
|
|
50
|
+
});
|
|
51
|
+
return data;
|
|
52
|
+
}, [tickers]);
|
|
53
|
+
const formatedPositions = useMemo(() => {
|
|
54
|
+
if (!data?.rows || !symbolInfo || !accountInfo)
|
|
55
|
+
return null;
|
|
56
|
+
const filteredData = typeof symbol === "undefined" || symbol === ""
|
|
57
|
+
? data.rows
|
|
58
|
+
: data.rows.filter((item) => {
|
|
59
|
+
return item.symbol === symbol;
|
|
60
|
+
});
|
|
61
|
+
let unrealPnL_total = zero, notional_total = zero, unsettlementPnL_total = zero;
|
|
62
|
+
const formatted = filteredData.map((item) => {
|
|
63
|
+
// const price = (markPrices as any)[item.symbol] ?? item.mark_price;
|
|
64
|
+
const unRealizedPrice = propOr(item.mark_price, item.symbol, priceMode === "markPrice" ? markPrices : tickerPrices);
|
|
65
|
+
const price = propOr(item.mark_price, item.symbol, markPrices);
|
|
66
|
+
const info = symbolInfo?.[item.symbol];
|
|
67
|
+
//
|
|
68
|
+
const notional = positions.notional(item.position_qty, price);
|
|
69
|
+
const unrealPnl = positions.unrealizedPnL({
|
|
70
|
+
qty: item.position_qty,
|
|
71
|
+
openPrice: item?.average_open_price,
|
|
72
|
+
markPrice: unRealizedPrice,
|
|
73
|
+
});
|
|
74
|
+
const imr = account.IMR({
|
|
75
|
+
maxLeverage: accountInfo.max_leverage,
|
|
76
|
+
baseIMR: info("base_imr"),
|
|
77
|
+
IMR_Factor: accountInfo.imr_factor[item.symbol],
|
|
78
|
+
positionNotional: notional,
|
|
79
|
+
ordersNotional: 0,
|
|
80
|
+
IMR_factor_power: 4 / 5,
|
|
81
|
+
});
|
|
82
|
+
const unrealPnlROI = positions.unrealizedPnLROI({
|
|
83
|
+
positionQty: item.position_qty,
|
|
84
|
+
openPrice: item.average_open_price,
|
|
85
|
+
IMR: imr,
|
|
86
|
+
unrealizedPnL: unrealPnl,
|
|
87
|
+
});
|
|
88
|
+
const unsettlementPnL = positions.unsettlementPnL({
|
|
89
|
+
positionQty: item.position_qty,
|
|
90
|
+
markPrice: price,
|
|
91
|
+
costPosition: item.cost_position,
|
|
92
|
+
sumUnitaryFunding: fundingRates[item.symbol]?.("sum_unitary_funding", 0),
|
|
93
|
+
lastSumUnitaryFunding: item.last_sum_unitary_funding,
|
|
94
|
+
});
|
|
95
|
+
unrealPnL_total = unrealPnL_total.add(unrealPnl);
|
|
96
|
+
notional_total = notional_total.add(notional);
|
|
97
|
+
unsettlementPnL_total = unsettlementPnL_total.add(unsettlementPnL);
|
|
98
|
+
return {
|
|
99
|
+
...item,
|
|
100
|
+
mark_price: price,
|
|
101
|
+
mm: 0,
|
|
102
|
+
notional,
|
|
103
|
+
unsettlement_pnl: unsettlementPnL,
|
|
104
|
+
unrealized_pnl: unrealPnl,
|
|
105
|
+
unsettled_pnl_ROI: unrealPnlROI,
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
return [
|
|
109
|
+
formatted,
|
|
110
|
+
{
|
|
111
|
+
unrealPnL: unrealPnL_total.toNumber(),
|
|
112
|
+
notional: notional_total.toNumber(),
|
|
113
|
+
unsettledPnL: unsettlementPnL_total.toNumber(),
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
}, [
|
|
117
|
+
data?.rows,
|
|
118
|
+
symbolInfo,
|
|
119
|
+
accountInfo,
|
|
120
|
+
markPrices,
|
|
121
|
+
priceMode,
|
|
122
|
+
tickerPrices,
|
|
123
|
+
symbol,
|
|
124
|
+
holding,
|
|
125
|
+
]);
|
|
126
|
+
// const showSymbol = useCallback((symbol: string) => {
|
|
127
|
+
// setVisibleSymbol(symbol);
|
|
128
|
+
// }, []);
|
|
129
|
+
const [totalCollateral, totalValue, totalUnrealizedROI] = useMemo(() => {
|
|
130
|
+
if (!holding || !markPrices) {
|
|
131
|
+
return [zero, zero, 0];
|
|
132
|
+
}
|
|
133
|
+
const unsettlemnedPnL = pathOr(0, [1, "unsettledPnL"])(formatedPositions);
|
|
134
|
+
const unrealizedPnL = pathOr(0, [1, "unrealPnL"])(formatedPositions);
|
|
135
|
+
const [USDC_holding, nonUSDC] = parseHolding(holding, markPrices);
|
|
136
|
+
const totalCollateral = account.totalCollateral({
|
|
137
|
+
USDCHolding: USDC_holding,
|
|
138
|
+
nonUSDCHolding: nonUSDC,
|
|
139
|
+
unsettlementPnL: unsettlemnedPnL,
|
|
140
|
+
});
|
|
141
|
+
const totalValue = account.totalValue({
|
|
142
|
+
totalUnsettlementPnL: unsettlemnedPnL,
|
|
143
|
+
USDCHolding: USDC_holding,
|
|
144
|
+
nonUSDCHolding: nonUSDC,
|
|
145
|
+
});
|
|
146
|
+
const totalUnrealizedROI = account.totalUnrealizedROI({
|
|
147
|
+
totalUnrealizedPnL: unrealizedPnL,
|
|
148
|
+
totalValue: totalValue.toNumber(),
|
|
149
|
+
});
|
|
150
|
+
return [totalCollateral, totalValue, totalUnrealizedROI];
|
|
151
|
+
}, [holding, formatedPositions, markPrices]);
|
|
152
|
+
const positionsRows = useMemo(() => {
|
|
153
|
+
if (!formatedPositions)
|
|
154
|
+
return null;
|
|
155
|
+
if (!symbolInfo || !accountInfo)
|
|
156
|
+
return formatedPositions[0];
|
|
157
|
+
const total = totalCollateral.toNumber();
|
|
158
|
+
let rows = formatedPositions[0]
|
|
159
|
+
.filter((item) => item.position_qty !== 0)
|
|
160
|
+
.map((item) => {
|
|
161
|
+
const info = symbolInfo?.[item.symbol];
|
|
162
|
+
const MMR = positions.MMR({
|
|
163
|
+
baseMMR: info("base_mmr"),
|
|
164
|
+
baseIMR: info("base_imr"),
|
|
165
|
+
IMRFactor: accountInfo.imr_factor[item.symbol],
|
|
166
|
+
positionNotional: item.notional,
|
|
167
|
+
IMR_factor_power: 4 / 5,
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
...item,
|
|
171
|
+
mm: positions.maintenanceMargin({
|
|
172
|
+
positionQty: item.position_qty,
|
|
173
|
+
markPrice: item.mark_price,
|
|
174
|
+
MMR,
|
|
175
|
+
}),
|
|
176
|
+
// est_liq_price: positions.liqPrice({
|
|
177
|
+
// markPrice: item.mark_price,
|
|
178
|
+
// totalCollateral: total,
|
|
179
|
+
// positionQty: item.position_qty,
|
|
180
|
+
// MMR,
|
|
181
|
+
// }),
|
|
182
|
+
mmr: MMR,
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
// calculate est_liq_price
|
|
186
|
+
rows = rows.map((item) => {
|
|
187
|
+
const est_liq_price = positions.liqPrice({
|
|
188
|
+
markPrice: item.mark_price,
|
|
189
|
+
totalCollateral: total,
|
|
190
|
+
positionQty: item.position_qty,
|
|
191
|
+
positions: rows,
|
|
192
|
+
MMR: item.mmr,
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
...item,
|
|
196
|
+
est_liq_price,
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
return rows;
|
|
200
|
+
}, [formatedPositions, symbolInfo, accountInfo, totalCollateral]);
|
|
201
|
+
// useEffect(() => {
|
|
202
|
+
// ee.on("positions:changed", () => {
|
|
203
|
+
// updatePositions();
|
|
204
|
+
// });
|
|
205
|
+
// }, []);
|
|
206
|
+
return [
|
|
207
|
+
{
|
|
208
|
+
rows: positionsRows,
|
|
209
|
+
aggregated: {
|
|
210
|
+
...(formatedPositions?.[1] ?? {}),
|
|
211
|
+
unrealPnlROI: totalUnrealizedROI,
|
|
212
|
+
},
|
|
213
|
+
totalCollateral,
|
|
214
|
+
totalValue,
|
|
215
|
+
totalUnrealizedROI,
|
|
216
|
+
},
|
|
217
|
+
createGetter(data, 1),
|
|
218
|
+
{
|
|
219
|
+
// close: onClosePosition,
|
|
220
|
+
loading: false,
|
|
221
|
+
// showSymbol,
|
|
222
|
+
error,
|
|
223
|
+
// loadMore: () => {},
|
|
224
|
+
refresh: refreshPositions,
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
};
|
|
228
|
+
export const pathOr_unsettledPnLPathOr = pathOr(0, [
|
|
229
|
+
0,
|
|
230
|
+
"aggregated",
|
|
231
|
+
"unsettledPnL",
|
|
232
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrivateDataObserver.d.ts","sourceRoot":"","sources":["../../src/orderly/usePrivateDataObserver.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,eAAO,MAAM,sBAAsB;uBAEd,MAAM,KAAK,IAAI,MAAM,EAAE,cAAc,CAAC;UAgI1D,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useWS } from "../useWS";
|
|
3
|
+
import { useSWRConfig } from "swr";
|
|
4
|
+
import { useAccount } from "../useAccount";
|
|
5
|
+
import { unstable_serialize } from "swr/infinite";
|
|
6
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
7
|
+
import { useEventEmitter } from "../useEventEmitter";
|
|
8
|
+
import { parseJSON } from "../utils/json";
|
|
9
|
+
export const usePrivateDataObserver = (options) => {
|
|
10
|
+
const ws = useWS();
|
|
11
|
+
const { mutate } = useSWRConfig();
|
|
12
|
+
const ee = useEventEmitter();
|
|
13
|
+
const { state } = useAccount();
|
|
14
|
+
const updateOrders = useDebouncedCallback((data) => {
|
|
15
|
+
const map = options.getKeysMap("orders");
|
|
16
|
+
const orderStatus = getSessionStorage("orderly_order_status", "positions");
|
|
17
|
+
map.forEach((getKey, key) => {
|
|
18
|
+
if ((orderStatus === "history" && key === "orders") ||
|
|
19
|
+
(orderStatus === "positions" && key === "orders:NEW") ||
|
|
20
|
+
key.includes("INCOMPLETE") || // always update pending list
|
|
21
|
+
key.includes(orderStatus)) {
|
|
22
|
+
mutate(unstable_serialize((index, prevData) => [
|
|
23
|
+
getKey(index, prevData),
|
|
24
|
+
state.accountId,
|
|
25
|
+
]));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// update the orders history list;
|
|
29
|
+
// ee.emit("orders:changed");
|
|
30
|
+
}, 500);
|
|
31
|
+
// orders
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!state.accountId)
|
|
34
|
+
return;
|
|
35
|
+
const unsubscribe = ws.privateSubscribe("executionreport", {
|
|
36
|
+
onMessage: (data) => {
|
|
37
|
+
updateOrders(data);
|
|
38
|
+
ee.emit("orders:changed", data);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return () => unsubscribe?.();
|
|
42
|
+
}, [state.accountId]);
|
|
43
|
+
// algo orders
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!state.accountId)
|
|
46
|
+
return;
|
|
47
|
+
const unsubscribe = ws.privateSubscribe("algoexecutionreport", {
|
|
48
|
+
onMessage: (data) => {
|
|
49
|
+
updateOrders(data);
|
|
50
|
+
if (Array.isArray(data)) {
|
|
51
|
+
data.forEach((item) => ee.emit("orders:changed", { ...item, status: item.algoStatus }));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
ee.emit("orders:changed", { ...data, status: data.algoStatus });
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
return () => unsubscribe?.();
|
|
59
|
+
}, [state.accountId]);
|
|
60
|
+
// positions
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!state.accountId)
|
|
63
|
+
return;
|
|
64
|
+
const key = ["/v1/positions", state.accountId];
|
|
65
|
+
const unsubscribe = ws.privateSubscribe("position", {
|
|
66
|
+
onMessage: (data) => {
|
|
67
|
+
const { positions: nextPostions } = data;
|
|
68
|
+
// console.log("ws----- positions data-----", data);
|
|
69
|
+
// updatePositions();
|
|
70
|
+
mutate(key, (prevPositions) => {
|
|
71
|
+
// return nextPostions;
|
|
72
|
+
if (!!prevPositions) {
|
|
73
|
+
return {
|
|
74
|
+
...prevPositions,
|
|
75
|
+
rows: prevPositions.rows.map((row) => {
|
|
76
|
+
const item = nextPostions.find((item) => item.symbol === row.symbol);
|
|
77
|
+
if (item) {
|
|
78
|
+
return {
|
|
79
|
+
symbol: item.symbol,
|
|
80
|
+
position_qty: item.positionQty,
|
|
81
|
+
cost_position: item.costPosition,
|
|
82
|
+
last_sum_unitary_funding: item.lastSumUnitaryFunding,
|
|
83
|
+
pending_long_qty: item.pendingLongQty,
|
|
84
|
+
pending_short_qty: item.pendingShortQty,
|
|
85
|
+
settle_price: item.settlePrice,
|
|
86
|
+
average_open_price: item.averageOpenPrice,
|
|
87
|
+
unsettled_pnl: item.unsettledPnl,
|
|
88
|
+
mark_price: item.markPrice,
|
|
89
|
+
est_liq_price: item.estLiqPrice,
|
|
90
|
+
timestamp: Date.now(),
|
|
91
|
+
imr: item.imr,
|
|
92
|
+
mmr: item.mmr,
|
|
93
|
+
IMR_withdraw_orders: item.imrwithOrders,
|
|
94
|
+
MMR_with_orders: item.mmrwithOrders,
|
|
95
|
+
pnl_24_h: item.pnl24H,
|
|
96
|
+
fee_24_h: item.fee24H,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return row;
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
revalidate: false,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
return () => {
|
|
109
|
+
unsubscribe?.();
|
|
110
|
+
};
|
|
111
|
+
}, [state.accountId]);
|
|
112
|
+
};
|
|
113
|
+
const getSessionStorage = (key, initialValue) => {
|
|
114
|
+
// Prevent build error "window is undefined" but keep keep working
|
|
115
|
+
if (typeof window === "undefined") {
|
|
116
|
+
return initialValue;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const item = window.sessionStorage.getItem(key);
|
|
120
|
+
return item ? parseJSON(item) : initialValue;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.warn(`Error reading sessionStorage key “${key}”:`, error);
|
|
124
|
+
return initialValue;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSettleSubscription.d.ts","sourceRoot":"","sources":["../../src/orderly/useSettleSubscription.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB;wBACb,GAAG,KAAK,IAAI;8EAuBhC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import useSWRSubscription from "swr/subscription";
|
|
2
|
+
import { useWS } from "../useWS";
|
|
3
|
+
export const useSettleSubscription = (options) => {
|
|
4
|
+
const ws = useWS();
|
|
5
|
+
return useSWRSubscription("settle", (_, { next }) => {
|
|
6
|
+
const unsubscribe = ws.privateSubscribe({
|
|
7
|
+
id: "settle",
|
|
8
|
+
event: "subscribe",
|
|
9
|
+
topic: "settle",
|
|
10
|
+
ts: Date.now(),
|
|
11
|
+
}, {
|
|
12
|
+
onMessage: (data) => {
|
|
13
|
+
//
|
|
14
|
+
options?.onMessage?.(data);
|
|
15
|
+
next(data);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return () => unsubscribe();
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PriceRange = {
|
|
2
|
+
min: number;
|
|
3
|
+
max: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Get the price range for the specified symbol with an optional price
|
|
7
|
+
*
|
|
8
|
+
* @param symbol - The symbol to get the price range for
|
|
9
|
+
* @param price - Optional parameter to set the price
|
|
10
|
+
* @returns PriceRange | undefined - Returns the PriceRange representing the price range or undefined
|
|
11
|
+
*/
|
|
12
|
+
export declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?: number) => PriceRange | undefined;
|
|
13
|
+
//# sourceMappingURL=useSymbolPriceRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSymbolPriceRange.d.ts","sourceRoot":"","sources":["../../src/orderly/useSymbolPriceRange.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,UAAU,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,WAAY,MAAM,QAAQ,KAAK,GAAG,MAAM,UAAU,MAAM,KAAG,UAAU,GAAG,SAiCvG,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Decimal } from "@orderly.network/utils";
|
|
2
|
+
import { useSymbolsInfo } from "./useSymbolsInfo";
|
|
3
|
+
import { useMarkPricesStream } from "./useMarkPricesStream";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* Get the price range for the specified symbol with an optional price
|
|
7
|
+
*
|
|
8
|
+
* @param symbol - The symbol to get the price range for
|
|
9
|
+
* @param price - Optional parameter to set the price
|
|
10
|
+
* @returns PriceRange | undefined - Returns the PriceRange representing the price range or undefined
|
|
11
|
+
*/
|
|
12
|
+
export const useSymbolPriceRange = (symbol, side, price) => {
|
|
13
|
+
const config = useSymbolsInfo();
|
|
14
|
+
const priceRange = config?.[symbol]("price_range");
|
|
15
|
+
const priceScrope = config?.[symbol]("price_scope");
|
|
16
|
+
const { data: prices } = useMarkPricesStream();
|
|
17
|
+
const markPrice = price || prices?.[symbol];
|
|
18
|
+
/// max mark_price_i * (1+price_range)
|
|
19
|
+
/// min mark_price_i * (1-price_range)
|
|
20
|
+
const range = useMemo(() => {
|
|
21
|
+
if (config === undefined || markPrice === undefined) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (priceRange === undefined || Number.isNaN(markPrice)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (side === "BUY") {
|
|
28
|
+
return {
|
|
29
|
+
max: new Decimal(markPrice).mul((1 + priceRange)).toNumber(),
|
|
30
|
+
min: new Decimal(markPrice).mul((1 - priceScrope)).toNumber(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
max: new Decimal(markPrice).mul((1 + priceScrope)).toNumber(),
|
|
35
|
+
min: new Decimal(markPrice).mul((1 - priceRange)).toNumber(),
|
|
36
|
+
};
|
|
37
|
+
}, [symbol, side, priceRange, markPrice]);
|
|
38
|
+
return range;
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSymbolsInfo.d.ts","sourceRoot":"","sources":["../../src/orderly/useSymbolsInfo.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,2BAoC1B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useQuery } from "../useQuery";
|
|
2
|
+
import { createGetter } from "../utils/createGetter";
|
|
3
|
+
import { getPrecisionByNumber } from "@orderly.network/utils";
|
|
4
|
+
export const useSymbolsInfo = () => {
|
|
5
|
+
const { data = {} } = useQuery(`/v1/public/info`, {
|
|
6
|
+
focusThrottleInterval: 1000 * 60 * 60 * 24,
|
|
7
|
+
dedupingInterval: 1000 * 60 * 60 * 24,
|
|
8
|
+
revalidateOnFocus: false,
|
|
9
|
+
formatter(data) {
|
|
10
|
+
if (!data?.rows || !data?.rows?.length) {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
const obj = Object.create(null);
|
|
14
|
+
for (let index = 0; index < data.rows.length; index++) {
|
|
15
|
+
const item = data.rows[index];
|
|
16
|
+
const arr = item.symbol.split("_");
|
|
17
|
+
const base_dp = getPrecisionByNumber(item.base_tick);
|
|
18
|
+
const quote_dp = getPrecisionByNumber(item.quote_tick);
|
|
19
|
+
obj[item.symbol] = {
|
|
20
|
+
...item,
|
|
21
|
+
base_dp,
|
|
22
|
+
quote_dp,
|
|
23
|
+
base: arr[1],
|
|
24
|
+
quote: arr[2],
|
|
25
|
+
type: arr[0],
|
|
26
|
+
name: `${arr[1]}-${arr[0]}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return createGetter(data);
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTickerStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useTickerStream.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAQ7C,eAAO,MAAM,eAAe,WAAY,MAAM,mBAgG7C,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useQuery } from "../useQuery";
|
|
3
|
+
import { Decimal } from "@orderly.network/utils";
|
|
4
|
+
import { useWS } from "../useWS";
|
|
5
|
+
import { useMarkPrice } from "./useMarkPrice";
|
|
6
|
+
import { useIndexPrice } from "./useIndexPrice";
|
|
7
|
+
import { useOpenInterest } from "./useOpenInterest";
|
|
8
|
+
import { useFetures } from "../unuse/useFetures";
|
|
9
|
+
export const useTickerStream = (symbol) => {
|
|
10
|
+
if (!symbol) {
|
|
11
|
+
throw new Error("useFuturesForSymbol requires a symbol");
|
|
12
|
+
}
|
|
13
|
+
const { data: info } = useQuery(`/v1/public/futures/${symbol}`, {
|
|
14
|
+
revalidateOnFocus: false,
|
|
15
|
+
});
|
|
16
|
+
const [ticker, setTicker] = useState();
|
|
17
|
+
const ws = useWS();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const unsubscribe = ws.subscribe(
|
|
20
|
+
// { event: "subscribe", topic: "markprices" },
|
|
21
|
+
`${symbol}@ticker`, {
|
|
22
|
+
onMessage: (message) => {
|
|
23
|
+
if (message.symbol !== symbol)
|
|
24
|
+
return;
|
|
25
|
+
setTicker(message);
|
|
26
|
+
},
|
|
27
|
+
// onUnsubscribe: () => {
|
|
28
|
+
// return "markprices";
|
|
29
|
+
// },
|
|
30
|
+
// onError: (error: any) => {
|
|
31
|
+
//
|
|
32
|
+
// },
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
setTicker(undefined);
|
|
36
|
+
unsubscribe?.();
|
|
37
|
+
};
|
|
38
|
+
}, [symbol]);
|
|
39
|
+
const { data: markPrice } = useMarkPrice(symbol);
|
|
40
|
+
const { data: indexPrice } = useIndexPrice(symbol);
|
|
41
|
+
const { data: openInterest } = useOpenInterest(symbol);
|
|
42
|
+
const { data: futures } = useFetures();
|
|
43
|
+
const value = useMemo(() => {
|
|
44
|
+
//
|
|
45
|
+
if (!info)
|
|
46
|
+
return null;
|
|
47
|
+
if (!ticker)
|
|
48
|
+
return info;
|
|
49
|
+
const futureIndex = futures?.findIndex((item) => item.symbol === symbol);
|
|
50
|
+
let _oi = openInterest;
|
|
51
|
+
if (!_oi && futureIndex !== -1 && futures) {
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
_oi = futures[futureIndex].open_interest;
|
|
54
|
+
}
|
|
55
|
+
const config = {
|
|
56
|
+
...info,
|
|
57
|
+
mark_price: markPrice,
|
|
58
|
+
index_price: indexPrice,
|
|
59
|
+
open_interest: _oi,
|
|
60
|
+
};
|
|
61
|
+
if (ticker.open !== undefined) {
|
|
62
|
+
config["24h_open"] = ticker.open;
|
|
63
|
+
}
|
|
64
|
+
if (ticker.close !== undefined) {
|
|
65
|
+
config["24h_close"] = ticker.close;
|
|
66
|
+
}
|
|
67
|
+
if (ticker.high !== undefined) {
|
|
68
|
+
config["24h_high"] = ticker.high;
|
|
69
|
+
}
|
|
70
|
+
if (ticker.low !== undefined) {
|
|
71
|
+
config["24h_low"] = ticker.low;
|
|
72
|
+
}
|
|
73
|
+
if (ticker.volume !== undefined) {
|
|
74
|
+
config["24h_volumn"] = ticker.volume;
|
|
75
|
+
}
|
|
76
|
+
if (ticker.close !== undefined && ticker.open !== undefined) {
|
|
77
|
+
config["change"] = new Decimal(ticker.close)
|
|
78
|
+
.minus(ticker.open)
|
|
79
|
+
.div(ticker.open)
|
|
80
|
+
.toNumber();
|
|
81
|
+
config["24h_change"] = new Decimal(ticker.close).minus(ticker.open);
|
|
82
|
+
}
|
|
83
|
+
return config;
|
|
84
|
+
}, [info, symbol, ticker, futures, openInterest]);
|
|
85
|
+
return value;
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWalletSubscription.d.ts","sourceRoot":"","sources":["../../src/orderly/useWalletSubscription.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB;wBACb,GAAG,KAAK,IAAI;8EAuBhC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import useSWRSubscription from "swr/subscription";
|
|
2
|
+
import { useWS } from "../useWS";
|
|
3
|
+
export const useWalletSubscription = (options) => {
|
|
4
|
+
const ws = useWS();
|
|
5
|
+
return useSWRSubscription("wallet", (_, { next }) => {
|
|
6
|
+
const unsubscribe = ws.privateSubscribe({
|
|
7
|
+
id: "wallet",
|
|
8
|
+
event: "subscribe",
|
|
9
|
+
topic: "wallet",
|
|
10
|
+
ts: Date.now(),
|
|
11
|
+
}, {
|
|
12
|
+
onMessage: (data) => {
|
|
13
|
+
//
|
|
14
|
+
options?.onMessage?.(data);
|
|
15
|
+
next(null, data);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return () => unsubscribe();
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const useWithdraw: () => {
|
|
2
|
+
withdraw: (inputs: {
|
|
3
|
+
chainId: number;
|
|
4
|
+
token: string;
|
|
5
|
+
amount: string;
|
|
6
|
+
allowCrossChainWithdraw: boolean;
|
|
7
|
+
}) => Promise<any>;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
maxAmount: number;
|
|
10
|
+
availableBalance: number;
|
|
11
|
+
availableWithdraw: number;
|
|
12
|
+
unsettledPnL: number;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useWithdraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../src/orderly/useWithdraw.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;uBAUX;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,uBAAuB,EAAE,OAAO,CAAC;KAClC,KAAG,QAAQ,GAAG,CAAC;;;;;;CAiEnB,CAAC"}
|