@orderly.network/hooks 1.1.4-rc.8 → 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 -559
- package/dist/index.d.ts +0 -559
- package/dist/index.js +0 -5449
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -5365
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHoldingStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useHoldingStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAM7C,eAAO,MAAM,gBAAgB;;;;CAuD5B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useHoldingStream = void 0;
|
|
7
|
+
const usePrivateQuery_1 = require("../usePrivateQuery");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const useWS_1 = require("../useWS");
|
|
10
|
+
const subscription_1 = __importDefault(require("swr/subscription"));
|
|
11
|
+
const useHoldingStream = () => {
|
|
12
|
+
const ws = (0, useWS_1.useWS)();
|
|
13
|
+
const { data, isLoading, mutate } = (0, usePrivateQuery_1.usePrivateQuery)("/v1/client/holding", {
|
|
14
|
+
formatter: (data) => {
|
|
15
|
+
return data.holding;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const usdc = (0, react_1.useMemo)(() => {
|
|
19
|
+
const usdc = data?.find((item) => item.token === "USDC");
|
|
20
|
+
return usdc;
|
|
21
|
+
}, [data]);
|
|
22
|
+
(0, subscription_1.default)("holding", (_, { next }) => {
|
|
23
|
+
const unsubscribe = ws.privateSubscribe({
|
|
24
|
+
id: "balance",
|
|
25
|
+
event: "subscribe",
|
|
26
|
+
topic: "balance",
|
|
27
|
+
ts: Date.now(),
|
|
28
|
+
}, {
|
|
29
|
+
onMessage: (data) => {
|
|
30
|
+
const holding = data?.balances ?? {};
|
|
31
|
+
if (holding) {
|
|
32
|
+
mutate((prevData) => {
|
|
33
|
+
return prevData?.map((item) => {
|
|
34
|
+
const token = holding[item.token];
|
|
35
|
+
return {
|
|
36
|
+
...item,
|
|
37
|
+
frozen: token.frozen,
|
|
38
|
+
holding: token.holding,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
next(holding);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return () => unsubscribe();
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
data,
|
|
50
|
+
usdc,
|
|
51
|
+
isLoading,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.useHoldingStream = useHoldingStream;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIndexPrice.d.ts","sourceRoot":"","sources":["../../src/orderly/useIndexPrice.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,WAAY,MAAM,iEAe3C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useIndexPrice = void 0;
|
|
7
|
+
const useWS_1 = require("../useWS");
|
|
8
|
+
const subscription_1 = __importDefault(require("swr/subscription"));
|
|
9
|
+
const useIndexPrice = (symbol) => {
|
|
10
|
+
// WARNING: force change perp to spot, because there is no perp now
|
|
11
|
+
symbol = symbol.replace("PERP", "SPOT");
|
|
12
|
+
const ws = (0, useWS_1.useWS)();
|
|
13
|
+
return (0, subscription_1.default)(`${symbol}@indexprice`, (key, { next }) => {
|
|
14
|
+
const unsubscribe = ws.subscribe(`${symbol}@indexprice`, {
|
|
15
|
+
onMessage: (message) => {
|
|
16
|
+
next(null, message.price);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
return () => {
|
|
20
|
+
unsubscribe?.();
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
exports.useIndexPrice = useIndexPrice;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLeverage.d.ts","sourceRoot":"","sources":["../../src/orderly/useLeverage.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,QAAO,GA8B9B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLeverage = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useMutation_1 = require("../useMutation");
|
|
6
|
+
const usePrivateQuery_1 = require("../usePrivateQuery");
|
|
7
|
+
const ramda_1 = require("ramda");
|
|
8
|
+
const useQuery_1 = require("../useQuery");
|
|
9
|
+
const useLeverage = () => {
|
|
10
|
+
const { data, mutate } = (0, usePrivateQuery_1.usePrivateQuery)("/v1/client/info");
|
|
11
|
+
const [update, { isMutating }] = (0, useMutation_1.useMutation)("/v1/client/leverage");
|
|
12
|
+
const { data: config } = (0, useQuery_1.useQuery)("/v1/public/config");
|
|
13
|
+
const updateLeverage = (0, react_1.useCallback)((data) => {
|
|
14
|
+
return update(data).then((res) => {
|
|
15
|
+
if (res.success) {
|
|
16
|
+
return mutate();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
throw new Error(res.message);
|
|
20
|
+
}
|
|
21
|
+
// return res
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
return [
|
|
25
|
+
(0, ramda_1.prop)("max_leverage", data),
|
|
26
|
+
{
|
|
27
|
+
update: updateLeverage,
|
|
28
|
+
isMutating,
|
|
29
|
+
// config: [1, 2, 3, 4, 5, 10, 15, 20],
|
|
30
|
+
config: config
|
|
31
|
+
? config?.available_futures_leverage
|
|
32
|
+
?.split(",")
|
|
33
|
+
.map((item) => parseInt(item))
|
|
34
|
+
: [],
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
};
|
|
38
|
+
exports.useLeverage = useLeverage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarginRatio.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarginRatio.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,iBAAiB,GAAG;IAE9B,WAAW,EAAE,MAAM,CAAC;IAEpB,eAAe,EAAE,MAAM,CAAC;IAExB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,iBAwCjC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMarginRatio = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const perp_1 = require("@orderly.network/perp");
|
|
6
|
+
const usePositionStream_1 = require("./usePositionStream");
|
|
7
|
+
const useMarkPricesStream_1 = require("./useMarkPricesStream");
|
|
8
|
+
const useCollateral_1 = require("./useCollateral");
|
|
9
|
+
const utils_1 = require("@orderly.network/utils");
|
|
10
|
+
const useMarginRatio = () => {
|
|
11
|
+
const [{ rows, aggregated }] = (0, usePositionStream_1.usePositionStream)();
|
|
12
|
+
const { data: markPrices } = (0, useMarkPricesStream_1.useMarkPricesStream)();
|
|
13
|
+
const { totalCollateral } = (0, useCollateral_1.useCollateral)();
|
|
14
|
+
const marginRatio = (0, react_1.useMemo)(() => {
|
|
15
|
+
if (!rows || !markPrices || !totalCollateral || rows.length === 0) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
const ratio = perp_1.account.totalMarginRatio({
|
|
19
|
+
totalCollateral: totalCollateral,
|
|
20
|
+
markPrices: markPrices,
|
|
21
|
+
positions: rows ?? [],
|
|
22
|
+
});
|
|
23
|
+
return ratio;
|
|
24
|
+
}, [rows, markPrices, totalCollateral]);
|
|
25
|
+
const currentLeverage = (0, react_1.useMemo)(() => {
|
|
26
|
+
return perp_1.account.currentLeverage(marginRatio);
|
|
27
|
+
}, [marginRatio]);
|
|
28
|
+
// MMR
|
|
29
|
+
const mmr = (0, react_1.useMemo)(() => {
|
|
30
|
+
if (!rows || rows.length <= 0)
|
|
31
|
+
return null;
|
|
32
|
+
let positionsMM = utils_1.zero;
|
|
33
|
+
// const positionsNotional = positions.totalNotional(rows);
|
|
34
|
+
for (let index = 0; index < rows.length; index++) {
|
|
35
|
+
const item = rows[index];
|
|
36
|
+
positionsMM = positionsMM.add(item.mm);
|
|
37
|
+
}
|
|
38
|
+
return perp_1.account.MMR({
|
|
39
|
+
positionsMMR: positionsMM.toNumber(),
|
|
40
|
+
positionsNotional: aggregated.notional,
|
|
41
|
+
});
|
|
42
|
+
}, [rows, aggregated]);
|
|
43
|
+
return { marginRatio, currentLeverage, mmr };
|
|
44
|
+
};
|
|
45
|
+
exports.useMarginRatio = useMarginRatio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarkPrice.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarkPrice.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,WAAY,MAAM;;CA8B1C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMarkPrice = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useWS_1 = require("../useWS");
|
|
6
|
+
// import useSWRSubscription from "swr/subscription";
|
|
7
|
+
const useMarkPrice = (symbol) => {
|
|
8
|
+
const ws = (0, useWS_1.useWS)();
|
|
9
|
+
const [price, setPrice] = (0, react_1.useState)(0);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
|
|
12
|
+
onMessage: (message) => {
|
|
13
|
+
setPrice(message.price);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return () => {
|
|
17
|
+
unsubscribe?.();
|
|
18
|
+
};
|
|
19
|
+
}, [symbol]);
|
|
20
|
+
// return useSWRSubscription(`${symbol}@markprice`, (key, { next }) => {
|
|
21
|
+
// const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
|
|
22
|
+
// onMessage: (message: any) => {
|
|
23
|
+
// next(null, message.price);
|
|
24
|
+
// },
|
|
25
|
+
// });
|
|
26
|
+
// return () => {
|
|
27
|
+
// // console.log("_____________________ unsubscribe _________ ", symbol);
|
|
28
|
+
// unsubscribe?.();
|
|
29
|
+
// };
|
|
30
|
+
// });
|
|
31
|
+
return { data: price };
|
|
32
|
+
};
|
|
33
|
+
exports.useMarkPrice = useMarkPrice;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarkPricesStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarkPricesStream.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,oEA4B/B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useMarkPricesStream = void 0;
|
|
7
|
+
const subscription_1 = __importDefault(require("swr/subscription"));
|
|
8
|
+
const useWS_1 = require("../useWS");
|
|
9
|
+
const useMarkPricesStream = () => {
|
|
10
|
+
const ws = (0, useWS_1.useWS)();
|
|
11
|
+
return (0, subscription_1.default)("markPrices", (key, { next }) => {
|
|
12
|
+
const unsubscribe = ws.subscribe(
|
|
13
|
+
// { event: "subscribe", topic: "markprices" },
|
|
14
|
+
"markprices", {
|
|
15
|
+
onMessage: (message) => {
|
|
16
|
+
const data = Object.create(null);
|
|
17
|
+
for (let index = 0; index < message.length; index++) {
|
|
18
|
+
const element = message[index];
|
|
19
|
+
data[element.symbol] = element.price;
|
|
20
|
+
}
|
|
21
|
+
next(null, data);
|
|
22
|
+
},
|
|
23
|
+
// onUnsubscribe: () => {
|
|
24
|
+
// return "markprices";
|
|
25
|
+
// },
|
|
26
|
+
onError: (error) => { },
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
unsubscribe?.();
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.useMarkPricesStream = useMarkPricesStream;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { API } from "@orderly.network/types";
|
|
2
|
+
export interface MarketTradeStreamOptions {
|
|
3
|
+
limit?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const useMarketTradeStream: (symbol: string, options?: MarketTradeStreamOptions) => {
|
|
6
|
+
data: API.Trade[];
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useMarketTradeStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarketTradeStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarketTradeStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI7C,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,oBAAoB,WACvB,MAAM,YACL,wBAAwB;;;CA8DlC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMarketTradeStream = void 0;
|
|
4
|
+
const useWS_1 = require("../useWS");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useMarketTradeStream = (symbol, options = {}) => {
|
|
7
|
+
if (!symbol) {
|
|
8
|
+
throw new Error("useTradeStream: symbol is required");
|
|
9
|
+
}
|
|
10
|
+
const [trades, setTrades] = (0, react_1.useState)([]);
|
|
11
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
12
|
+
const { limit = 50 } = options;
|
|
13
|
+
const ws = (0, useWS_1.useWS)();
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
setIsLoading(true);
|
|
16
|
+
setTrades(() => []);
|
|
17
|
+
ws.onceSubscribe({
|
|
18
|
+
id: `${symbol}@trade`,
|
|
19
|
+
event: "request",
|
|
20
|
+
params: {
|
|
21
|
+
type: "trade",
|
|
22
|
+
symbol: symbol,
|
|
23
|
+
limit,
|
|
24
|
+
},
|
|
25
|
+
}, {
|
|
26
|
+
onMessage: (data) => {
|
|
27
|
+
setIsLoading(false);
|
|
28
|
+
setTrades(() => data);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}, [symbol]);
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
const unsubscript = ws.subscribe({
|
|
34
|
+
id: `${symbol}@trade`,
|
|
35
|
+
event: "subscribe",
|
|
36
|
+
topic: `${symbol}@trade`,
|
|
37
|
+
ts: Date.now(),
|
|
38
|
+
}, {
|
|
39
|
+
onMessage: (data) => {
|
|
40
|
+
setTrades((prev) => {
|
|
41
|
+
const arr = [{ ...data, ts: Date.now() }, ...prev];
|
|
42
|
+
if (arr.length > limit) {
|
|
43
|
+
arr.pop();
|
|
44
|
+
}
|
|
45
|
+
return arr;
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
unsubscript?.();
|
|
51
|
+
};
|
|
52
|
+
}, [symbol]);
|
|
53
|
+
return { data: trades, isLoading };
|
|
54
|
+
};
|
|
55
|
+
exports.useMarketTradeStream = useMarketTradeStream;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { API } from "@orderly.network/types";
|
|
2
|
+
export declare enum MarketsType {
|
|
3
|
+
FAVORITES = 0,
|
|
4
|
+
RECENT = 1,
|
|
5
|
+
ALL = 2
|
|
6
|
+
}
|
|
7
|
+
export interface FavoriteTab {
|
|
8
|
+
name: string;
|
|
9
|
+
id: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Favorite {
|
|
12
|
+
name: string;
|
|
13
|
+
tabs: FavoriteTab[];
|
|
14
|
+
}
|
|
15
|
+
export interface Recent {
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const useMarkets: (type: MarketsType) => readonly [import("@orderly.network/types").WSMessage.Ticker[], {
|
|
19
|
+
readonly favoriteTabs: FavoriteTab[];
|
|
20
|
+
readonly favorites: {
|
|
21
|
+
tabs: FavoriteTab[];
|
|
22
|
+
name: string;
|
|
23
|
+
}[];
|
|
24
|
+
readonly recent: Recent[];
|
|
25
|
+
readonly addToHistory: (symbol: API.MarketInfoExt) => void;
|
|
26
|
+
readonly updateFavoriteTabs: (tab: FavoriteTab | FavoriteTab[], operator?: {
|
|
27
|
+
add?: boolean;
|
|
28
|
+
update?: boolean;
|
|
29
|
+
delete?: boolean;
|
|
30
|
+
}) => void;
|
|
31
|
+
readonly updateSymbolFavoriteState: (symbol: API.MarketInfoExt, tab: FavoriteTab | FavoriteTab[], del?: boolean) => void;
|
|
32
|
+
readonly pinToTop: (symbol: API.MarketInfoExt) => void;
|
|
33
|
+
readonly getLastSelFavTab: () => FavoriteTab;
|
|
34
|
+
readonly updateSelectedFavoriteTab: (tab: FavoriteTab) => void;
|
|
35
|
+
}];
|
|
36
|
+
//# sourceMappingURL=useMarkets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarkets.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarkets.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI7C,oBAAY,WAAW;IACnB,SAAS,IAAA;IACT,MAAM,IAAA;IACN,GAAG,IAAA;CACN;AAuBD,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,UAAU,SAAU,WAAW;;;;cARlC,MAAM;;;oCAuNkB,IAAI,aAAa;uCAhJd,WAAW,GAAG,WAAW,EAAE,aAAa;QACrE,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,OAAO,CAAC;KACpB;iDAgJ0C,IAAI,aAAa,OAAO,WAAW,GAAG,WAAW,EAAE,QAAO,OAAO;gCAMlF,IAAI,aAAa;;8CA6BH,WAAW;EAsBtD,CAAA"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMarkets = exports.MarketsType = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useMarketsStream_1 = require("./useMarketsStream");
|
|
6
|
+
const orderlyContext_1 = require("../orderlyContext");
|
|
7
|
+
const useSymbolsInfo_1 = require("./useSymbolsInfo");
|
|
8
|
+
var MarketsType;
|
|
9
|
+
(function (MarketsType) {
|
|
10
|
+
MarketsType[MarketsType["FAVORITES"] = 0] = "FAVORITES";
|
|
11
|
+
MarketsType[MarketsType["RECENT"] = 1] = "RECENT";
|
|
12
|
+
MarketsType[MarketsType["ALL"] = 2] = "ALL";
|
|
13
|
+
})(MarketsType || (exports.MarketsType = MarketsType = {}));
|
|
14
|
+
const useMarkets = (type) => {
|
|
15
|
+
const marketsKey = "markets";
|
|
16
|
+
const { data } = (0, useMarketsStream_1.useMarketsStream)();
|
|
17
|
+
const { configStore } = (0, react_1.useContext)(orderlyContext_1.OrderlyContext);
|
|
18
|
+
// {"PERP_ETH_USDC": {}, ...}
|
|
19
|
+
const publicInfo = (0, useSymbolsInfo_1.useSymbolsInfo)();
|
|
20
|
+
if (!configStore.get(marketsKey)) {
|
|
21
|
+
const jsonStr = localStorage.getItem(marketsKey);
|
|
22
|
+
if (jsonStr) {
|
|
23
|
+
configStore.set(marketsKey, JSON.parse(jsonStr));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const defaultTab = { name: "Popular", id: 1 };
|
|
27
|
+
configStore.set(marketsKey, {
|
|
28
|
+
recent: [],
|
|
29
|
+
favorites: [
|
|
30
|
+
{ name: "PERP_ETH_USDC", tabs: [{ ...defaultTab }] },
|
|
31
|
+
{ name: "PERP_BTC_USDC", tabs: [{ ...defaultTab }] },
|
|
32
|
+
],
|
|
33
|
+
favoriteTabs: [{ ...defaultTab }],
|
|
34
|
+
lastSelectFavoriteTab: { ...defaultTab }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const getFavoriteTabs = (0, react_1.useMemo)(() => {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
const tabs = configStore.get(marketsKey)["favoriteTabs"];
|
|
41
|
+
return (tabs || [{ name: "Popular", id: 1 }]);
|
|
42
|
+
}, []);
|
|
43
|
+
const getFavorites = (0, react_1.useMemo)(() => {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
const curData = (configStore.get(marketsKey)["favorites"] || []);
|
|
46
|
+
const tabs = getFavoriteTabs;
|
|
47
|
+
const result = [];
|
|
48
|
+
for (let index = 0; index < curData.length; index++) {
|
|
49
|
+
const favData = curData[index];
|
|
50
|
+
var favTabs = favData.tabs.filter((tab) => tabs.findIndex((item) => tab.id === item.id) !== -1);
|
|
51
|
+
if (favTabs.length > 0) {
|
|
52
|
+
result.push({ ...favData, tabs: favTabs });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
configStore.set(marketsKey, { ...configStore.getOr(marketsKey, {}), favorites: result });
|
|
56
|
+
// localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
|
|
57
|
+
return result;
|
|
58
|
+
}, [configStore]);
|
|
59
|
+
const getRecent = (0, react_1.useMemo)(() => {
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
const curData = configStore.get(marketsKey)["recent"];
|
|
62
|
+
return (curData || []).filter((e) => e);
|
|
63
|
+
}, []);
|
|
64
|
+
const [favoriteTabs, setFavoriteTabs] = (0, react_1.useState)(getFavoriteTabs);
|
|
65
|
+
const [favorites, setFavorites] = (0, react_1.useState)(getFavorites);
|
|
66
|
+
const [recent, setRecent] = (0, react_1.useState)(getRecent);
|
|
67
|
+
const updateFavoriteTabs = (tab, operator) => {
|
|
68
|
+
const saveTabs = (tabs) => {
|
|
69
|
+
setFavoriteTabs(tabs);
|
|
70
|
+
configStore.set(marketsKey, {
|
|
71
|
+
...configStore.getOr(marketsKey, {}),
|
|
72
|
+
"favoriteTabs": tabs
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
if (Array.isArray(tab)) {
|
|
76
|
+
saveTabs(tab);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var tabs = [...favoriteTabs];
|
|
80
|
+
const index = tabs.findIndex((item) => item.id === tab.id);
|
|
81
|
+
if (operator?.add) {
|
|
82
|
+
tabs.push(tab);
|
|
83
|
+
}
|
|
84
|
+
else if (operator?.update) {
|
|
85
|
+
if (index !== -1) {
|
|
86
|
+
tabs[index] = tab;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (operator?.delete) {
|
|
90
|
+
if (index !== -1) {
|
|
91
|
+
tabs.splice(index, 1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
saveTabs(tabs);
|
|
95
|
+
};
|
|
96
|
+
const setRecentData = (symbol) => {
|
|
97
|
+
const curData = [...recent];
|
|
98
|
+
const index = curData.findIndex((item) => item.name == symbol.symbol);
|
|
99
|
+
if (index !== -1) {
|
|
100
|
+
curData.splice(index, 1);
|
|
101
|
+
}
|
|
102
|
+
curData.unshift({ name: symbol.symbol });
|
|
103
|
+
configStore.set(marketsKey, {
|
|
104
|
+
...configStore.getOr(marketsKey, {}),
|
|
105
|
+
"recent": curData
|
|
106
|
+
});
|
|
107
|
+
setRecent(curData);
|
|
108
|
+
};
|
|
109
|
+
const setFavoritesData = (symbol, tab, remove = false) => {
|
|
110
|
+
const curData = [...favorites];
|
|
111
|
+
const index = curData.findIndex((item) => item.name == symbol.symbol);
|
|
112
|
+
if (index === -1) { // can not find
|
|
113
|
+
if (Array.isArray(tab)) {
|
|
114
|
+
if (tab.length > 0) {
|
|
115
|
+
curData.unshift({ name: symbol.symbol, tabs: tab });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if (!remove) {
|
|
120
|
+
// insert
|
|
121
|
+
curData.unshift({ name: symbol.symbol, tabs: [tab] });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const favorite = curData[index];
|
|
127
|
+
if (Array.isArray(tab)) {
|
|
128
|
+
if (tab.length === 0) {
|
|
129
|
+
// remove
|
|
130
|
+
curData.splice(index, 1);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// overrides
|
|
134
|
+
curData[index] = { ...favorite, tabs: tab };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
if (remove) {
|
|
139
|
+
const tabs = favorite.tabs.filter((tab) => tab.id != tab.id);
|
|
140
|
+
if (tabs.length === 0) { // del favorite
|
|
141
|
+
curData.splice(index, 1);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
curData[index] = { ...favorite, tabs };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else { // insert
|
|
148
|
+
const tabs = favorite.tabs;
|
|
149
|
+
tabs.push(tab);
|
|
150
|
+
curData[index] = { ...favorite, tabs };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
configStore.set(marketsKey, {
|
|
155
|
+
...configStore.getOr(marketsKey, {}),
|
|
156
|
+
"favorites": curData
|
|
157
|
+
});
|
|
158
|
+
setFavorites(() => curData);
|
|
159
|
+
};
|
|
160
|
+
const getData = (type) => {
|
|
161
|
+
// get data
|
|
162
|
+
const localData = type === MarketsType.FAVORITES ? [...favorites] : [...recent];
|
|
163
|
+
// filter
|
|
164
|
+
const keys = localData.map((item) => item.name);
|
|
165
|
+
const filter = type == MarketsType.ALL ?
|
|
166
|
+
data :
|
|
167
|
+
data?.filter((item) => keys.includes(item.symbol));
|
|
168
|
+
const favoritesData = [...favorites];
|
|
169
|
+
const favoriteKeys = favoritesData.map((item) => item.name);
|
|
170
|
+
if (filter) {
|
|
171
|
+
for (let index = 0; index < filter.length; index++) {
|
|
172
|
+
const element = filter[index];
|
|
173
|
+
const isFavorite = type == MarketsType.FAVORITES ?
|
|
174
|
+
true :
|
|
175
|
+
(favoriteKeys.includes(element.symbol));
|
|
176
|
+
const fIndex = favoritesData.findIndex((item) => item.name === element.symbol);
|
|
177
|
+
const tabs = fIndex === -1 ? [] : favoritesData[fIndex].tabs;
|
|
178
|
+
let imr = undefined;
|
|
179
|
+
if (publicInfo) {
|
|
180
|
+
imr = publicInfo?.[element.symbol]("base_imr");
|
|
181
|
+
}
|
|
182
|
+
filter[index] = {
|
|
183
|
+
...filter[index],
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
isFavorite,
|
|
186
|
+
tabs,
|
|
187
|
+
leverage: imr ? 1 / imr : undefined
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return filter;
|
|
192
|
+
};
|
|
193
|
+
const addToHistory = (symbol) => {
|
|
194
|
+
setRecentData(symbol);
|
|
195
|
+
};
|
|
196
|
+
const updateSymbolFavoriteState = (symbol, tab, del = false) => {
|
|
197
|
+
setFavoritesData(symbol, tab, del);
|
|
198
|
+
};
|
|
199
|
+
const markets = getData(type);
|
|
200
|
+
const pinToTop = (symbol) => {
|
|
201
|
+
const index = favorites.findIndex((item) => item.name === symbol.symbol);
|
|
202
|
+
if (index !== -1) {
|
|
203
|
+
const element = favorites[index];
|
|
204
|
+
const list = [...favorites];
|
|
205
|
+
list.splice(index, 1);
|
|
206
|
+
list.unshift(element);
|
|
207
|
+
configStore.set(marketsKey, {
|
|
208
|
+
...configStore.getOr(marketsKey, {}),
|
|
209
|
+
"favorites": list
|
|
210
|
+
});
|
|
211
|
+
setFavorites(list);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const tabs = (0, react_1.useMemo)(() => {
|
|
215
|
+
return favoriteTabs;
|
|
216
|
+
}, [favoriteTabs]);
|
|
217
|
+
const getLastSelFavTab = () => {
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
const curData = configStore.get(marketsKey)["lastSelectedFavoriteTab"];
|
|
220
|
+
return (curData || { name: "Popular", id: 1 });
|
|
221
|
+
};
|
|
222
|
+
const updateSelectedFavoriteTab = (tab) => {
|
|
223
|
+
configStore.set(marketsKey, {
|
|
224
|
+
...configStore.getOr(marketsKey, {}),
|
|
225
|
+
lastSelectedFavoriteTab: tab
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
return [
|
|
229
|
+
markets || [],
|
|
230
|
+
{
|
|
231
|
+
favoriteTabs: tabs,
|
|
232
|
+
favorites,
|
|
233
|
+
recent,
|
|
234
|
+
addToHistory,
|
|
235
|
+
// updateFavoriteTabs("tab", operator: {add/update/delete})
|
|
236
|
+
updateFavoriteTabs,
|
|
237
|
+
updateSymbolFavoriteState,
|
|
238
|
+
pinToTop,
|
|
239
|
+
getLastSelFavTab,
|
|
240
|
+
updateSelectedFavoriteTab,
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
};
|
|
244
|
+
exports.useMarkets = useMarkets;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarketsStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarketsStream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,eAAO,MAAM,gBAAgB;;CA4D5B,CAAC"}
|