@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,17 @@
|
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
2
|
+
import { ConfigStore, OrderlyKeyStore, getWalletAdapterFunc, IContract } from "@orderly.network/core";
|
|
3
|
+
import { NetworkId } from "@orderly.network/types";
|
|
4
|
+
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
5
|
+
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
6
|
+
}[R];
|
|
7
|
+
export interface ConfigProviderProps {
|
|
8
|
+
configStore?: ConfigStore;
|
|
9
|
+
keyStore?: OrderlyKeyStore;
|
|
10
|
+
contracts?: IContract;
|
|
11
|
+
getWalletAdapter?: getWalletAdapterFunc;
|
|
12
|
+
brokerId: string;
|
|
13
|
+
networkId: NetworkId;
|
|
14
|
+
}
|
|
15
|
+
export declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=configProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configProvider.d.ts","sourceRoot":"","sources":["../src/configProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAM,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGnD,OAAO,EACL,WAAW,EAGX,eAAe,EACf,oBAAoB,EAMpB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAYnD,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACjE;KACG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACnE,CAAC,CAAC,CAAC,CAAC;AAEP,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,UACzB,kBACL,kBAAkB,mBAAmB,EAAE,UAAU,GAAG,aAAa,CAAC,CACnE,mDA+EF,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
|
+
import { OrderlyProvider } from "./orderlyContext";
|
|
4
|
+
import {
|
|
5
|
+
// MemoryConfigStore,
|
|
6
|
+
DefaultConfigStore, LocalStorageStore, EtherAdapter, SimpleDI, Account, } from "@orderly.network/core";
|
|
7
|
+
import useConstant from "use-constant";
|
|
8
|
+
// import { usePreLoadData } from "./usePreloadData";
|
|
9
|
+
import { DataCenterProvider } from "./dataProvider";
|
|
10
|
+
import { StatusProvider } from "./statusProvider";
|
|
11
|
+
import { SDKError } from "@orderly.network/types";
|
|
12
|
+
export const OrderlyConfigProvider = (props) => {
|
|
13
|
+
const [account, setAccount] = React.useState(null);
|
|
14
|
+
const { configStore, keyStore, getWalletAdapter, brokerId, networkId, contracts, } = props;
|
|
15
|
+
if (!brokerId && typeof configStore === "undefined") {
|
|
16
|
+
console.error("[OrderlyConfigProvider]: brokerId is required");
|
|
17
|
+
}
|
|
18
|
+
if (typeof configStore !== "undefined" && !configStore.get("brokerId")) {
|
|
19
|
+
// console.error("[OrderlyConfigProvider]: brokerId is required");
|
|
20
|
+
throw new SDKError("if configStore is provided, brokerId is required in configStore");
|
|
21
|
+
}
|
|
22
|
+
const innerConfigStore = useConstant(() => {
|
|
23
|
+
return configStore || new DefaultConfigStore({ brokerId, networkId });
|
|
24
|
+
});
|
|
25
|
+
const innerKeyStore = useConstant(() => {
|
|
26
|
+
return keyStore || new LocalStorageStore(networkId);
|
|
27
|
+
});
|
|
28
|
+
const innerGetWalletAdapter = useConstant(() => {
|
|
29
|
+
return (getWalletAdapter ||
|
|
30
|
+
((options) => new EtherAdapter(options)));
|
|
31
|
+
});
|
|
32
|
+
// check params, if has mismatch, throw warning message to console
|
|
33
|
+
// useParamsCheck({ brokerId: innerConfigStore.get("brokerId") });
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
let account = SimpleDI.get(Account.instanceName);
|
|
36
|
+
if (!account) {
|
|
37
|
+
account = new Account(innerConfigStore, innerKeyStore, innerGetWalletAdapter, {
|
|
38
|
+
contracts,
|
|
39
|
+
});
|
|
40
|
+
SimpleDI.registerByName(Account.instanceName, account);
|
|
41
|
+
}
|
|
42
|
+
setAccount(account);
|
|
43
|
+
}, []);
|
|
44
|
+
if (!account) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (_jsx(OrderlyProvider, { value: {
|
|
48
|
+
configStore: innerConfigStore,
|
|
49
|
+
keyStore: innerKeyStore,
|
|
50
|
+
getWalletAdapter: innerGetWalletAdapter,
|
|
51
|
+
networkId: networkId,
|
|
52
|
+
// apiBaseUrl,
|
|
53
|
+
}, children: _jsx(StatusProvider, { children: _jsx(DataCenterProvider, { children: props.children }) }) }));
|
|
54
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export type getKeyFunction = (index: number, prevData: any) => string | null;
|
|
3
|
+
interface DataCenterContextValue {
|
|
4
|
+
regesterKeyHandler: (key: string, handler: getKeyFunction) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const DataCenterContext: import("react").Context<DataCenterContextValue>;
|
|
7
|
+
export declare const useDataCenterContext: () => DataCenterContextValue;
|
|
8
|
+
export declare const DataCenterProvider: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=dataProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataProvider.d.ts","sourceRoot":"","sources":["../src/dataProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AAI7E,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;AAE7E,UAAU,sBAAsB;IAK9B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;CACpE;AAED,eAAO,MAAM,iBAAiB,iDAE7B,CAAC;AAEF,eAAO,MAAM,oBAAoB,8BAAsC,CAAC;AAExE,eAAO,MAAM,kBAAkB,iBAAkB,iBAAiB,mDAgCjE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from "react";
|
|
3
|
+
import { usePrivateDataObserver } from "./orderly/usePrivateDataObserver";
|
|
4
|
+
import { usePreLoadData } from "./usePreloadData";
|
|
5
|
+
export const DataCenterContext = createContext({});
|
|
6
|
+
export const useDataCenterContext = () => useContext(DataCenterContext);
|
|
7
|
+
export const DataCenterProvider = ({ children }) => {
|
|
8
|
+
/**
|
|
9
|
+
* preload the required data for the app
|
|
10
|
+
* hidden view while the required data is not ready
|
|
11
|
+
*/
|
|
12
|
+
const { error, done } = usePreLoadData();
|
|
13
|
+
const getKeyHandlerMapRef = useRef(new Map());
|
|
14
|
+
usePrivateDataObserver({
|
|
15
|
+
getKeysMap(type) {
|
|
16
|
+
return getKeyHandlerMapRef.current;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
if (error) {
|
|
20
|
+
return _jsx("div", { children: "Data load failed" });
|
|
21
|
+
}
|
|
22
|
+
if (!done)
|
|
23
|
+
return null;
|
|
24
|
+
return (_jsx(DataCenterContext.Provider, { value: {
|
|
25
|
+
regesterKeyHandler: (key, fun) => {
|
|
26
|
+
getKeyHandlerMapRef.current.set(key, fun);
|
|
27
|
+
},
|
|
28
|
+
}, children: children }));
|
|
29
|
+
};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { default as version } from "./version";
|
|
2
|
+
export { useQuery } from "./useQuery";
|
|
3
|
+
export { useLazyQuery } from "./useLazyQuery";
|
|
4
|
+
export { useMutation } from "./useMutation";
|
|
5
|
+
export { usePrivateQuery } from "./usePrivateQuery";
|
|
6
|
+
export { usePrivateInfiniteQuery } from "./usePrivateInfiniteQuery";
|
|
7
|
+
export { useBoolean } from "./useBoolean";
|
|
8
|
+
export { useAccount } from "./useAccount";
|
|
9
|
+
export { useAccountInstance } from "./useAccountInstance";
|
|
10
|
+
export { usePreLoadData } from "./usePreloadData";
|
|
11
|
+
export { useEventEmitter } from "./useEventEmitter";
|
|
12
|
+
export { useSessionStorage } from "./useSessionStorage";
|
|
13
|
+
export { useLocalStorage } from "./useLocalStorage";
|
|
14
|
+
export { parseJSON } from "./utils/json";
|
|
15
|
+
export { default as useConstant } from "use-constant";
|
|
16
|
+
export { useWS } from "./useWS";
|
|
17
|
+
export { useConfig } from "./useConfig";
|
|
18
|
+
export * from "./orderlyContext";
|
|
19
|
+
export * from "./statusProvider";
|
|
20
|
+
export { useWsStatus, WsNetworkStatus } from "./useWsStatus";
|
|
21
|
+
export type { ConfigProviderProps } from "./configProvider";
|
|
22
|
+
export { OrderlyConfigProvider } from "./configProvider";
|
|
23
|
+
export { WalletConnectorContext, useWalletConnector, } from "./walletConnectorContext";
|
|
24
|
+
export * from "./orderly/orderlyHooks";
|
|
25
|
+
import useSWR, { type SWRConfiguration, SWRConfig } from "swr";
|
|
26
|
+
export { useSWR, SWRConfig, type SWRConfiguration };
|
|
27
|
+
export * from "use-debounce";
|
|
28
|
+
export { useMediaQuery } from "./useMediaQuery";
|
|
29
|
+
export { usePoster, type drawOptions } from "./usePoster";
|
|
30
|
+
export * from "./orderly/orderlyHooks";
|
|
31
|
+
export { cleanStringStyle } from "./utils/orderEntryHelper";
|
|
32
|
+
export type { WalletAdapter } from "@orderly.network/core";
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,cAAc,wBAAwB,CAAC;AAGvC,OAAO,MAAM,EAAE,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAEpD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { default as version } from "./version";
|
|
2
|
+
export { useQuery } from "./useQuery";
|
|
3
|
+
export { useLazyQuery } from "./useLazyQuery";
|
|
4
|
+
export { useMutation } from "./useMutation";
|
|
5
|
+
export { usePrivateQuery } from "./usePrivateQuery";
|
|
6
|
+
export { usePrivateInfiniteQuery } from "./usePrivateInfiniteQuery";
|
|
7
|
+
export { useBoolean } from "./useBoolean";
|
|
8
|
+
export { useAccount } from "./useAccount";
|
|
9
|
+
export { useAccountInstance } from "./useAccountInstance";
|
|
10
|
+
export { usePreLoadData } from "./usePreloadData";
|
|
11
|
+
export { useEventEmitter } from "./useEventEmitter";
|
|
12
|
+
export { useSessionStorage } from "./useSessionStorage";
|
|
13
|
+
export { useLocalStorage } from "./useLocalStorage";
|
|
14
|
+
export { parseJSON } from "./utils/json";
|
|
15
|
+
export { default as useConstant } from "use-constant";
|
|
16
|
+
export { useWS } from "./useWS";
|
|
17
|
+
export { useConfig } from "./useConfig";
|
|
18
|
+
export * from "./orderlyContext";
|
|
19
|
+
export * from "./statusProvider";
|
|
20
|
+
export { useWsStatus, WsNetworkStatus } from "./useWsStatus";
|
|
21
|
+
export { OrderlyConfigProvider } from "./configProvider";
|
|
22
|
+
export { WalletConnectorContext, useWalletConnector, } from "./walletConnectorContext";
|
|
23
|
+
export * from "./orderly/orderlyHooks";
|
|
24
|
+
import useSWR, { SWRConfig } from "swr";
|
|
25
|
+
export { useSWR, SWRConfig };
|
|
26
|
+
export * from "use-debounce";
|
|
27
|
+
export { useMediaQuery } from "./useMediaQuery";
|
|
28
|
+
export { usePoster } from "./usePoster";
|
|
29
|
+
export * from "./orderly/orderlyHooks";
|
|
30
|
+
export { cleanStringStyle } from "./utils/orderEntryHelper";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureMiddleware.d.ts","sourceRoot":"","sources":["../../src/middleware/signatureMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,KAAK,CAAC;AAI1C,eAAO,MAAM,mBAAmB,EAAE,UAiCjC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SimpleDI } from "@orderly.network/core";
|
|
2
|
+
import { useConfig } from "../useConfig";
|
|
3
|
+
export const signatureMiddleware = (useSWRNext) => {
|
|
4
|
+
const apiBaseUrl = useConfig("apiBaseUrl");
|
|
5
|
+
return (key, fetcher, config) => {
|
|
6
|
+
try {
|
|
7
|
+
const extendedFetcher = async (args) => {
|
|
8
|
+
let url = Array.isArray(args) ? args[0] : args;
|
|
9
|
+
let account = SimpleDI.get("account");
|
|
10
|
+
let fullUrl = `${apiBaseUrl}${url}`;
|
|
11
|
+
const signer = account.signer;
|
|
12
|
+
const payload = {
|
|
13
|
+
method: "GET",
|
|
14
|
+
url,
|
|
15
|
+
};
|
|
16
|
+
const signature = await signer.sign(payload);
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
return fetcher(fullUrl, {
|
|
19
|
+
headers: {
|
|
20
|
+
...signature,
|
|
21
|
+
"orderly-account-id": account.accountId,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
return useSWRNext(key, extendedFetcher, config);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.error("signature error:", e);
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { useOrderbookStream } from "./useOrderbookStream";
|
|
2
|
+
export { useOrderEntry } from "./useOrderEntry";
|
|
3
|
+
export type { UseOrderEntryMetaState, OrderParams } from "./useOrderEntry";
|
|
4
|
+
export { useSymbolsInfo } from "./useSymbolsInfo";
|
|
5
|
+
export { useAccountInfo } from "./useAccountInfo";
|
|
6
|
+
export { useMarketsStream } from "./useMarketsStream";
|
|
7
|
+
export { useMarkets, MarketsType } from "./useMarkets";
|
|
8
|
+
export type { FavoriteTab, Favorite, Recent } from "./useMarkets";
|
|
9
|
+
export { useMarkPricesStream } from "./useMarkPricesStream";
|
|
10
|
+
export { useMarkPrice } from "./useMarkPrice";
|
|
11
|
+
export { useIndexPrice } from "./useIndexPrice";
|
|
12
|
+
export { useLeverage } from "./useLeverage";
|
|
13
|
+
export { useTickerStream } from "./useTickerStream";
|
|
14
|
+
export { useFundingRate } from "./useFundingRate";
|
|
15
|
+
export { usePositionStream } from "./usePositionStream";
|
|
16
|
+
export { useOrderStream } from "./useOrderStream";
|
|
17
|
+
export { useMarketTradeStream } from "./useMarketTradeStream";
|
|
18
|
+
export { useCollateral } from "./useCollateral";
|
|
19
|
+
export { useMaxQty } from "./useMaxQty";
|
|
20
|
+
export { useMarginRatio } from "./useMarginRatio";
|
|
21
|
+
export { useChains } from "./useChains";
|
|
22
|
+
export { useChain } from "./useChain";
|
|
23
|
+
export { useWithdraw } from "./useWithdraw";
|
|
24
|
+
export { useDeposit } from "./useDeposit";
|
|
25
|
+
export { useHoldingStream } from "./useHoldingStream";
|
|
26
|
+
export { useWalletSubscription } from "./useWalletSubscription";
|
|
27
|
+
export { useSettleSubscription } from "./useSettleSubscription";
|
|
28
|
+
export { usePrivateDataObserver } from "./usePrivateDataObserver";
|
|
29
|
+
export { useSymbolPriceRange } from "./useSymbolPriceRange";
|
|
30
|
+
//# sourceMappingURL=orderlyHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderlyHooks.d.ts","sourceRoot":"","sources":["../../src/orderly/orderlyHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { useOrderbookStream } from "./useOrderbookStream";
|
|
2
|
+
export { useOrderEntry } from "./useOrderEntry";
|
|
3
|
+
export { useSymbolsInfo } from "./useSymbolsInfo";
|
|
4
|
+
export { useAccountInfo } from "./useAccountInfo";
|
|
5
|
+
export { useMarketsStream } from "./useMarketsStream";
|
|
6
|
+
export { useMarkets, MarketsType } from "./useMarkets";
|
|
7
|
+
export { useMarkPricesStream } from "./useMarkPricesStream";
|
|
8
|
+
export { useMarkPrice } from "./useMarkPrice";
|
|
9
|
+
export { useIndexPrice } from "./useIndexPrice";
|
|
10
|
+
export { useLeverage } from "./useLeverage";
|
|
11
|
+
export { useTickerStream } from "./useTickerStream";
|
|
12
|
+
export { useFundingRate } from "./useFundingRate";
|
|
13
|
+
export { usePositionStream } from "./usePositionStream";
|
|
14
|
+
export { useOrderStream } from "./useOrderStream";
|
|
15
|
+
export { useMarketTradeStream } from "./useMarketTradeStream";
|
|
16
|
+
export { useCollateral } from "./useCollateral";
|
|
17
|
+
export { useMaxQty } from "./useMaxQty";
|
|
18
|
+
export { useMarginRatio } from "./useMarginRatio";
|
|
19
|
+
export { useChains } from "./useChains";
|
|
20
|
+
export { useChain } from "./useChain";
|
|
21
|
+
export { useWithdraw } from "./useWithdraw";
|
|
22
|
+
export { useDeposit } from "./useDeposit";
|
|
23
|
+
export { useHoldingStream } from "./useHoldingStream";
|
|
24
|
+
export { useWalletSubscription } from "./useWalletSubscription";
|
|
25
|
+
export { useSettleSubscription } from "./useSettleSubscription";
|
|
26
|
+
export { usePrivateDataObserver } from "./usePrivateDataObserver";
|
|
27
|
+
export { useSymbolPriceRange } from "./useSymbolPriceRange";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountInfo.d.ts","sourceRoot":"","sources":["../../src/orderly/useAccountInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAG7C,eAAO,MAAM,cAAc,sEAE1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChain.d.ts","sourceRoot":"","sources":["../../src/orderly/useChain.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAiB,MAAM,wBAAwB,CAAC;AAE5D,eAAO,MAAM,QAAQ,UAAW,MAAM;;;CAsBrC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useQuery } from "../useQuery";
|
|
3
|
+
import { chainsInfoMap } from "@orderly.network/types";
|
|
4
|
+
export const useChain = (token) => {
|
|
5
|
+
const { data, isLoading } = useQuery("/v1/public/token");
|
|
6
|
+
const chains = useMemo(() => {
|
|
7
|
+
if (!data)
|
|
8
|
+
return null;
|
|
9
|
+
let item = data.find((chain) => chain.token === token);
|
|
10
|
+
if (item) {
|
|
11
|
+
item.chain_details = item.chain_details.map((d) => {
|
|
12
|
+
const chain = chainsInfoMap.get(Number(d.chain_id));
|
|
13
|
+
return {
|
|
14
|
+
...d,
|
|
15
|
+
chain_name: chain?.chainName ?? "--",
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return item || null;
|
|
20
|
+
}, [data, token]);
|
|
21
|
+
return { chains, isLoading };
|
|
22
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NetworkId, type API } from "@orderly.network/types";
|
|
2
|
+
import { SWRConfiguration } from "swr";
|
|
3
|
+
type InputOptions = {
|
|
4
|
+
filter?: (item: API.Chain) => boolean;
|
|
5
|
+
pick?: "dexs" | "network_infos" | "token_infos";
|
|
6
|
+
};
|
|
7
|
+
export type Chain = API.Chain & {
|
|
8
|
+
nativeToken?: API.TokenInfo;
|
|
9
|
+
};
|
|
10
|
+
export type Chains<T extends NetworkId | undefined = undefined, K extends keyof API.Chain | undefined = undefined> = T extends NetworkId ? K extends keyof API.Chain ? API.Chain[K][] : API.Chain[] : K extends keyof API.Chain ? {
|
|
11
|
+
testnet: API.Chain[K][];
|
|
12
|
+
mainnet: API.Chain[K][];
|
|
13
|
+
} : {
|
|
14
|
+
testnet: API.Chain[];
|
|
15
|
+
mainnet: API.Chain[];
|
|
16
|
+
};
|
|
17
|
+
export type Options = InputOptions & SWRConfiguration;
|
|
18
|
+
export type ReturnObject = {
|
|
19
|
+
findByChainId: (chainId: number, field?: string) => Chain | undefined;
|
|
20
|
+
error: any;
|
|
21
|
+
};
|
|
22
|
+
export declare function useChains(networkId?: undefined, options?: undefined): [Chains<undefined, undefined>, ReturnObject];
|
|
23
|
+
export declare function useChains<T extends NetworkId | undefined, K extends Options | undefined>(networkId?: T, options?: K): [
|
|
24
|
+
Chains<T, K extends Options ? K["pick"] extends keyof API.Chain ? K["pick"] : undefined : undefined>,
|
|
25
|
+
ReturnObject
|
|
26
|
+
];
|
|
27
|
+
/** orderly chains array form (/v1/public/token) api */
|
|
28
|
+
export declare function fillChainsInfo(chains?: API.Chain[], filter?: (chain: any) => boolean): API.Chain[];
|
|
29
|
+
/** update network_infos by chain_info api(v1/public/chain_info) */
|
|
30
|
+
export declare function updateOrderlyChains(chains: API.Chain[], chainInfos: any, filter?: (chain: any) => boolean): API.Chain[];
|
|
31
|
+
/** if chain is testnet, update testnet network_infos */
|
|
32
|
+
export declare function updateTestnetInfo(testnetArr: API.Chain[], chainId: number, chain: API.Chain): void;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=useChains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChains.d.ts","sourceRoot":"","sources":["../../src/orderly/useChains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,GAAG,EAAiB,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAMvC,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,KAAK,OAAO,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,aAAa,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,GAAG;IAC9B,WAAW,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,MAAM,CAChB,CAAC,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS,EAC3C,CAAC,SAAS,MAAM,GAAG,CAAC,KAAK,GAAG,SAAS,GAAG,SAAS,IAC/C,CAAC,SAAS,SAAS,GACnB,CAAC,SAAS,MAAM,GAAG,CAAC,KAAK,GACvB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GACd,GAAG,CAAC,KAAK,EAAE,GACb,CAAC,SAAS,MAAM,GAAG,CAAC,KAAK,GACzB;IACE,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;CACzB,GACD;IACE,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;CACtB,CAAC;AAEN,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,KAAK,GAAG,SAAS,CAAC;IACtE,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,wBAAgB,SAAS,CACvB,SAAS,CAAC,EAAE,SAAS,EACrB,OAAO,CAAC,EAAE,SAAS,GAClB,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC;AAEhD,wBAAgB,SAAS,CACvB,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,SAAS,OAAO,GAAG,SAAS,EAE7B,SAAS,CAAC,EAAE,CAAC,EACb,OAAO,CAAC,EAAE,CAAC,GACV;IACD,MAAM,CACJ,CAAC,EACD,CAAC,SAAS,OAAO,GACb,CAAC,CAAC,MAAM,CAAC,SAAS,MAAM,GAAG,CAAC,KAAK,GAC/B,CAAC,CAAC,MAAM,CAAC,GACT,SAAS,GACX,SAAS,CACd;IACD,YAAY;CACb,CAAC;AA6HF,uDAAuD;AACvD,wBAAgB,cAAc,CAC5B,MAAM,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,EACpB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,eAmCjC;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,EACnB,UAAU,EAAE,GAAG,EACf,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,eAkCjC;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,GAAG,CAAC,KAAK,QAUjB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { chainsInfoMap } from "@orderly.network/types";
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { useQuery } from "../useQuery";
|
|
4
|
+
import { prop } from "ramda";
|
|
5
|
+
import { isTestnet } from "@orderly.network/utils";
|
|
6
|
+
import { TestnetChains, nativeTokenAddress } from "@orderly.network/types";
|
|
7
|
+
export function useChains(networkId, options = {}) {
|
|
8
|
+
const { pick: pickField, ...swrOptions } = options;
|
|
9
|
+
const filterFun = useRef(options?.filter);
|
|
10
|
+
filterFun.current = options?.filter;
|
|
11
|
+
const chainsMap = useRef(new Map());
|
|
12
|
+
const commonSwrOpts = {
|
|
13
|
+
revalidateIfStale: false,
|
|
14
|
+
revalidateOnFocus: false,
|
|
15
|
+
revalidateOnReconnect: false,
|
|
16
|
+
// If false, undefined data gets cached against the key.
|
|
17
|
+
revalidateOnMount: true,
|
|
18
|
+
// dont duplicate a request w/ same key for 1hr
|
|
19
|
+
dedupingInterval: 3600000,
|
|
20
|
+
...swrOptions,
|
|
21
|
+
};
|
|
22
|
+
// only prod env return mainnet chains info
|
|
23
|
+
// TODO: remove https://api-evm.orderly.org api base
|
|
24
|
+
const { data: tokenChains, error: tokenError } = useQuery("https://api-evm.orderly.org/v1/public/token", { ...commonSwrOpts });
|
|
25
|
+
// only prod env return mainnet chains info
|
|
26
|
+
const { data: chainInfos, error: chainInfoErr } = useQuery("/v1/public/chain_info", { ...commonSwrOpts });
|
|
27
|
+
const chains = useMemo(() => {
|
|
28
|
+
const orderlyChainsArr = fillChainsInfo(tokenChains, filterFun.current);
|
|
29
|
+
let testnetArr = [...TestnetChains];
|
|
30
|
+
orderlyChainsArr?.forEach((item) => {
|
|
31
|
+
const chainId = item.network_infos?.chain_id;
|
|
32
|
+
chainsMap.current.set(chainId, item);
|
|
33
|
+
updateTestnetInfo(testnetArr, chainId, item);
|
|
34
|
+
});
|
|
35
|
+
testnetArr.forEach((chain) => {
|
|
36
|
+
chainsMap.current.set(chain.network_infos?.chain_id, chain);
|
|
37
|
+
});
|
|
38
|
+
let mainnetArr = [];
|
|
39
|
+
// TODO: /v1/public/chain_info api data is not match /v1/public/token api data, so it can effect is prod
|
|
40
|
+
mainnetArr = updateOrderlyChains(orderlyChainsArr, chainInfos, filterFun.current);
|
|
41
|
+
mainnetArr.forEach((item) => {
|
|
42
|
+
const chainId = item.network_infos?.chain_id;
|
|
43
|
+
chainsMap.current.set(chainId, item);
|
|
44
|
+
updateTestnetInfo(testnetArr, chainId, item);
|
|
45
|
+
});
|
|
46
|
+
mainnetArr.sort((a, b) => {
|
|
47
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
48
|
+
});
|
|
49
|
+
testnetArr.sort((a, b) => {
|
|
50
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
51
|
+
});
|
|
52
|
+
if (!!pickField) {
|
|
53
|
+
//@ts-ignore
|
|
54
|
+
testnetArr = testnetArr.map((item) => item[pickField]);
|
|
55
|
+
//@ts-ignore
|
|
56
|
+
mainnetArr = mainnetArr.map((item) => item[pickField]);
|
|
57
|
+
}
|
|
58
|
+
if (networkId === "mainnet") {
|
|
59
|
+
return mainnetArr;
|
|
60
|
+
}
|
|
61
|
+
if (networkId === "testnet") {
|
|
62
|
+
return testnetArr;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
testnet: testnetArr,
|
|
66
|
+
mainnet: mainnetArr,
|
|
67
|
+
};
|
|
68
|
+
}, [networkId, tokenChains, chainInfos, pickField]);
|
|
69
|
+
const findByChainId = useCallback((chainId, field) => {
|
|
70
|
+
const chain = chainsMap.current.get(chainId);
|
|
71
|
+
if (chain) {
|
|
72
|
+
chain.nativeToken =
|
|
73
|
+
chain.token_infos?.find((item) => item.address === nativeTokenAddress) ||
|
|
74
|
+
{
|
|
75
|
+
symbol: chain.network_infos?.currency_symbol,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (typeof field === "string") {
|
|
79
|
+
return prop(field, chain);
|
|
80
|
+
}
|
|
81
|
+
return chain;
|
|
82
|
+
}, [chains, chainsMap]);
|
|
83
|
+
return [
|
|
84
|
+
chains,
|
|
85
|
+
{
|
|
86
|
+
findByChainId,
|
|
87
|
+
error: tokenError,
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
/** orderly chains array form (/v1/public/token) api */
|
|
92
|
+
export function fillChainsInfo(chains, filter) {
|
|
93
|
+
let _chains = [];
|
|
94
|
+
chains?.forEach((item) => {
|
|
95
|
+
item.chain_details.forEach((chain) => {
|
|
96
|
+
const chainId = Number(chain.chain_id);
|
|
97
|
+
const chainInfo = chainsInfoMap.get(chainId);
|
|
98
|
+
const _chain = {
|
|
99
|
+
network_infos: {
|
|
100
|
+
name: chain.chain_name ?? chainInfo?.chainName ?? "--",
|
|
101
|
+
chain_id: chainId,
|
|
102
|
+
withdrawal_fee: chain.withdrawal_fee,
|
|
103
|
+
cross_chain_withdrawal_fee: chain.cross_chain_withdrawal_fee,
|
|
104
|
+
bridgeless: true,
|
|
105
|
+
},
|
|
106
|
+
token_infos: [
|
|
107
|
+
{
|
|
108
|
+
symbol: item.token,
|
|
109
|
+
address: chain.contract_address,
|
|
110
|
+
decimals: chain.decimals,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
if (typeof filter === "function") {
|
|
115
|
+
if (!filter(_chain))
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
_chains.push(_chain);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return _chains;
|
|
122
|
+
}
|
|
123
|
+
/** update network_infos by chain_info api(v1/public/chain_info) */
|
|
124
|
+
export function updateOrderlyChains(chains, chainInfos, filter) {
|
|
125
|
+
const _chains = [];
|
|
126
|
+
chains.forEach((chain) => {
|
|
127
|
+
let _chain = { ...chain };
|
|
128
|
+
const networkInfo = chainInfos?.find((item) => item.chain_id == chain.network_infos.chain_id);
|
|
129
|
+
if (networkInfo) {
|
|
130
|
+
const { name, public_rpc_url, currency_symbol, explorer_base_url } = networkInfo;
|
|
131
|
+
_chain.network_infos = {
|
|
132
|
+
..._chain.network_infos,
|
|
133
|
+
name,
|
|
134
|
+
shortName: name,
|
|
135
|
+
public_rpc_url,
|
|
136
|
+
currency_symbol,
|
|
137
|
+
bridge_enable: true,
|
|
138
|
+
mainnet: true,
|
|
139
|
+
explorer_base_url,
|
|
140
|
+
est_txn_mins: null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (typeof filter === "function") {
|
|
144
|
+
if (!filter(_chain))
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
_chains.push(_chain);
|
|
148
|
+
});
|
|
149
|
+
return _chains;
|
|
150
|
+
}
|
|
151
|
+
/** if chain is testnet, update testnet network_infos */
|
|
152
|
+
export function updateTestnetInfo(testnetArr, chainId, chain) {
|
|
153
|
+
if (isTestnet(chainId)) {
|
|
154
|
+
const index = testnetArr?.findIndex((item) => item.network_infos.chain_id === chainId);
|
|
155
|
+
if (index > -1) {
|
|
156
|
+
testnetArr[index] = chain;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type API } from "@orderly.network/types";
|
|
2
|
+
export type CollateralOutputs = {
|
|
3
|
+
totalCollateral: number;
|
|
4
|
+
freeCollateral: number;
|
|
5
|
+
totalValue: number;
|
|
6
|
+
availableBalance: number;
|
|
7
|
+
unsettledPnL: number;
|
|
8
|
+
positions: API.Position[];
|
|
9
|
+
accountInfo?: API.AccountInfo;
|
|
10
|
+
};
|
|
11
|
+
type Options = {
|
|
12
|
+
dp: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const useCollateral: (options?: Options) => CollateralOutputs;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useCollateral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCollateral.d.ts","sourceRoot":"","sources":["../../src/orderly/useCollateral.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,wBAAwB,CAAC;AAO/D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC;CAC/B,CAAC;AAKF,KAAK,OAAO,GAAG;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,aAAa,aACf,OAAO,KACf,iBA0EF,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { usePrivateQuery } from "../usePrivateQuery";
|
|
3
|
+
import { pathOr_unsettledPnLPathOr, usePositionStream, } from "./usePositionStream";
|
|
4
|
+
import { pathOr } from "ramda";
|
|
5
|
+
import { account } from "@orderly.network/perp";
|
|
6
|
+
import { OrderStatus } from "@orderly.network/types";
|
|
7
|
+
import { useSymbolsInfo } from "./useSymbolsInfo";
|
|
8
|
+
import { zero } from "@orderly.network/utils";
|
|
9
|
+
import { useMarkPricesStream } from "./useMarkPricesStream";
|
|
10
|
+
import { useHoldingStream } from "./useHoldingStream";
|
|
11
|
+
import { useOrderStream } from "./useOrderStream";
|
|
12
|
+
const positionsPath = pathOr([], [0, "rows"]);
|
|
13
|
+
const totalCollateralPath = pathOr(0, [0, "totalCollateral"]);
|
|
14
|
+
export const useCollateral = (options = { dp: 6 }) => {
|
|
15
|
+
const { dp } = options;
|
|
16
|
+
const positions = usePositionStream();
|
|
17
|
+
const [orders] = useOrderStream({ status: OrderStatus.NEW });
|
|
18
|
+
const { data: accountInfo } = usePrivateQuery("/v1/client/info");
|
|
19
|
+
const symbolInfo = useSymbolsInfo();
|
|
20
|
+
const { data: markPrices } = useMarkPricesStream();
|
|
21
|
+
const { usdc } = useHoldingStream();
|
|
22
|
+
const filterAlgoOrders = orders?.filter((item) => item.algo_order_id === undefined) ?? [];
|
|
23
|
+
// const { data: holding } = usePrivateQuery<API.Holding[]>(
|
|
24
|
+
// "/v1/client/holding",
|
|
25
|
+
// {
|
|
26
|
+
// formatter: (data) => {
|
|
27
|
+
// return data.holding;
|
|
28
|
+
// },
|
|
29
|
+
// }
|
|
30
|
+
// );
|
|
31
|
+
const [totalCollateral, totalValue] = useMemo(() => {
|
|
32
|
+
return [
|
|
33
|
+
pathOr(zero, [0, "totalCollateral"], positions),
|
|
34
|
+
pathOr(zero, [0, "totalValue"], positions),
|
|
35
|
+
];
|
|
36
|
+
}, [positions, markPrices]);
|
|
37
|
+
const totalInitialMarginWithOrders = useMemo(() => {
|
|
38
|
+
if (!accountInfo || !symbolInfo || !markPrices) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
return account.totalInitialMarginWithOrders({
|
|
42
|
+
positions: positionsPath(positions),
|
|
43
|
+
orders: filterAlgoOrders,
|
|
44
|
+
markPrices,
|
|
45
|
+
IMR_Factors: accountInfo.imr_factor,
|
|
46
|
+
maxLeverage: accountInfo.max_leverage,
|
|
47
|
+
symbolInfo,
|
|
48
|
+
});
|
|
49
|
+
}, [positions, filterAlgoOrders, markPrices, accountInfo, symbolInfo]);
|
|
50
|
+
const freeCollateral = useMemo(() => {
|
|
51
|
+
return account.freeCollateral({
|
|
52
|
+
totalCollateral,
|
|
53
|
+
totalInitialMarginWithOrders,
|
|
54
|
+
});
|
|
55
|
+
}, [totalCollateral, totalInitialMarginWithOrders]);
|
|
56
|
+
const availableBalance = useMemo(() => {
|
|
57
|
+
return account.availableBalance({
|
|
58
|
+
USDCHolding: usdc?.holding ?? 0,
|
|
59
|
+
unsettlementPnL: pathOr_unsettledPnLPathOr(positions),
|
|
60
|
+
});
|
|
61
|
+
}, [usdc?.holding, pathOr_unsettledPnLPathOr(positions)]);
|
|
62
|
+
return {
|
|
63
|
+
totalCollateral: totalCollateral.toDecimalPlaces(dp).toNumber(),
|
|
64
|
+
freeCollateral: freeCollateral.toDecimalPlaces(dp).toNumber(),
|
|
65
|
+
totalValue: totalValue.toDecimalPlaces(dp).toNumber(),
|
|
66
|
+
availableBalance,
|
|
67
|
+
unsettledPnL: pathOr_unsettledPnLPathOr(positions),
|
|
68
|
+
accountInfo,
|
|
69
|
+
// @hidden
|
|
70
|
+
positions: positionsPath(positions),
|
|
71
|
+
};
|
|
72
|
+
};
|