@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,38 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { API, NetworkId } from "@orderly.network/types";
|
|
3
|
+
export type useDepositOptions = {
|
|
4
|
+
address?: string;
|
|
5
|
+
decimals?: number;
|
|
6
|
+
networkId?: NetworkId;
|
|
7
|
+
srcChainId?: number;
|
|
8
|
+
srcToken?: string;
|
|
9
|
+
quantity?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const useDeposit: (options?: useDepositOptions) => {
|
|
12
|
+
/** orderly support chain dst */
|
|
13
|
+
dst: {
|
|
14
|
+
symbol: string;
|
|
15
|
+
address: string | undefined;
|
|
16
|
+
decimals: number | undefined;
|
|
17
|
+
chainId: number;
|
|
18
|
+
network: string;
|
|
19
|
+
};
|
|
20
|
+
balance: string;
|
|
21
|
+
allowance: string;
|
|
22
|
+
isNativeToken: boolean;
|
|
23
|
+
balanceRevalidating: boolean;
|
|
24
|
+
allowanceRevalidating: boolean;
|
|
25
|
+
/** input quantiy */
|
|
26
|
+
quantity: string;
|
|
27
|
+
/** orderly deposit fee, unit: wei */
|
|
28
|
+
depositFee: bigint;
|
|
29
|
+
/** enquiring depositFee status on chain */
|
|
30
|
+
depositFeeRevalidating: boolean;
|
|
31
|
+
approve: (amount?: string) => Promise<void | undefined>;
|
|
32
|
+
deposit: () => Promise<any>;
|
|
33
|
+
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
34
|
+
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
35
|
+
/** set input quantity */
|
|
36
|
+
setQuantity: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=useDeposit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeposit.d.ts","sourceRoot":"","sources":["../../src/orderly/useDeposit.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,GAAG,EAMH,SAAS,EAEV,MAAM,wBAAwB,CAAC;AAMhC,MAAM,MAAM,iBAAiB,GAAG;IAE9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,UAAU,aAAc,iBAAiB;IA4TlD,gCAAgC;;;;;;;;;;;;;IAOhC,oBAAoB;;IAEpB,qCAAqC;;IAErC,2CAA2C;;uBApI3B,MAAM;;4BAhGyB,IAAI,SAAS,EAAE;4BAvC9C,MAAM,aAAa,MAAM;IAiRzC,yBAAyB;;CAG5B,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useAccount } from "../useAccount";
|
|
3
|
+
import { ARBITRUM_MAINNET_CHAINID, ARBITRUM_TESTNET_CHAINID, AccountStatusEnum, DEPOSIT_FEE_RATE, isNativeTokenChecker, } from "@orderly.network/types";
|
|
4
|
+
import { Decimal } from "@orderly.network/utils";
|
|
5
|
+
import { useChains } from "./useChains";
|
|
6
|
+
import { useConfig } from "../useConfig";
|
|
7
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
8
|
+
export const useDeposit = (options) => {
|
|
9
|
+
const networkId = useConfig("networkId");
|
|
10
|
+
const [balanceRevalidating, setBalanceRevalidating] = useState(false);
|
|
11
|
+
const [allowanceRevalidating, setAllowanceRevalidating] = useState(false);
|
|
12
|
+
const [_, { findByChainId }] = useChains(undefined);
|
|
13
|
+
const [quantity, setQuantity] = useState("");
|
|
14
|
+
const [depositFee, setDepositFee] = useState(0n);
|
|
15
|
+
const [depositFeeRevalidating, setDepositFeeRevalidating] = useState(false);
|
|
16
|
+
const [balance, setBalance] = useState("0");
|
|
17
|
+
const [allowance, setAllowance] = useState("0");
|
|
18
|
+
const { account, state } = useAccount();
|
|
19
|
+
const prevAddress = useRef();
|
|
20
|
+
const getBalanceListener = useRef();
|
|
21
|
+
const targetChain = useMemo(() => {
|
|
22
|
+
let chain;
|
|
23
|
+
// Orderly testnet supported chain
|
|
24
|
+
if (networkId === "testnet") {
|
|
25
|
+
chain = findByChainId(ARBITRUM_TESTNET_CHAINID);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
chain = findByChainId(options?.srcChainId);
|
|
29
|
+
// if is orderly un-supported chain
|
|
30
|
+
if (!chain?.network_infos?.bridgeless) {
|
|
31
|
+
// Orderly mainnet supported chain
|
|
32
|
+
chain = findByChainId(ARBITRUM_MAINNET_CHAINID);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return chain;
|
|
36
|
+
}, [networkId, findByChainId, options?.srcChainId]);
|
|
37
|
+
const dst = useMemo(() => {
|
|
38
|
+
if (!targetChain) {
|
|
39
|
+
throw new Error("dst chain not found");
|
|
40
|
+
}
|
|
41
|
+
const USDC = targetChain?.token_infos.find((token) => token.symbol === "USDC");
|
|
42
|
+
return {
|
|
43
|
+
symbol: "USDC",
|
|
44
|
+
address: USDC?.address,
|
|
45
|
+
decimals: USDC?.decimals,
|
|
46
|
+
chainId: targetChain.network_infos.chain_id,
|
|
47
|
+
network: targetChain.network_infos.shortName,
|
|
48
|
+
};
|
|
49
|
+
}, [targetChain]);
|
|
50
|
+
const isNativeToken = useMemo(() => isNativeTokenChecker(options?.address || ""), [options?.address]);
|
|
51
|
+
const fetchBalanceHandler = useCallback(async (address, decimals) => {
|
|
52
|
+
let balance;
|
|
53
|
+
if (!!address && isNativeTokenChecker(address)) {
|
|
54
|
+
balance = await account.assetsManager.getNativeBalance({
|
|
55
|
+
decimals,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
balance = await account.assetsManager.getBalance(address, { decimals });
|
|
60
|
+
}
|
|
61
|
+
return balance;
|
|
62
|
+
}, []);
|
|
63
|
+
const fetchBalance = useCallback(async (
|
|
64
|
+
// token contract address
|
|
65
|
+
address,
|
|
66
|
+
// format decimals
|
|
67
|
+
decimals) => {
|
|
68
|
+
if (!address)
|
|
69
|
+
return;
|
|
70
|
+
try {
|
|
71
|
+
// if (balanceRevalidating) return;
|
|
72
|
+
const balance = await fetchBalanceHandler(address, decimals);
|
|
73
|
+
setBalance(() => balance);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.warn("----- refresh balance error -----", e);
|
|
77
|
+
setBalance(() => "0");
|
|
78
|
+
}
|
|
79
|
+
}, [state]);
|
|
80
|
+
const fetchBalances = useCallback(async (tokens) => {
|
|
81
|
+
const tasks = [];
|
|
82
|
+
for (const token of tokens) {
|
|
83
|
+
// native token skip
|
|
84
|
+
if (isNativeTokenChecker(token.address)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
tasks.push(account.assetsManager.getBalanceByAddress(token.address));
|
|
88
|
+
}
|
|
89
|
+
const balances = await Promise.all(tasks);
|
|
90
|
+
// const balances = await account.assetsManager.getBalances(tokens);
|
|
91
|
+
// setBalance(() => balances);
|
|
92
|
+
}, []);
|
|
93
|
+
const getAllowance = async (address, vaultAddress) => {
|
|
94
|
+
// if (!address || !vaultAddress) return;
|
|
95
|
+
const key = `${address}-${vaultAddress}`;
|
|
96
|
+
if (prevAddress.current === key)
|
|
97
|
+
return;
|
|
98
|
+
if (!address || !vaultAddress)
|
|
99
|
+
return;
|
|
100
|
+
if (address && isNativeTokenChecker(address))
|
|
101
|
+
return;
|
|
102
|
+
// if (allowanceRevalidating) return;
|
|
103
|
+
// setAllowanceRevalidating(true);
|
|
104
|
+
prevAddress.current = key;
|
|
105
|
+
const allowance = await account.assetsManager.getAllowance(address, vaultAddress);
|
|
106
|
+
setAllowance(() => allowance);
|
|
107
|
+
// setAllowanceRevalidating(false);
|
|
108
|
+
return allowance;
|
|
109
|
+
};
|
|
110
|
+
const getAllowanceByDefaultAddress = async (address) => {
|
|
111
|
+
if (prevAddress.current === address)
|
|
112
|
+
return;
|
|
113
|
+
if (!address || isNativeTokenChecker(address))
|
|
114
|
+
return;
|
|
115
|
+
prevAddress.current = address;
|
|
116
|
+
const allowance = await account.assetsManager.getAllowance(address);
|
|
117
|
+
setAllowance(() => allowance);
|
|
118
|
+
};
|
|
119
|
+
const queryBalance = useDebouncedCallback((tokenAddress, decimals) => {
|
|
120
|
+
fetchBalance(options?.address, options?.decimals).finally(() => {
|
|
121
|
+
setBalanceRevalidating(false);
|
|
122
|
+
});
|
|
123
|
+
}, 100);
|
|
124
|
+
const queryAllowance = useDebouncedCallback((tokenAddress, vaultAddress) => {
|
|
125
|
+
getAllowance(tokenAddress, vaultAddress);
|
|
126
|
+
}, 100);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (state.status < AccountStatusEnum.Connected)
|
|
129
|
+
return;
|
|
130
|
+
setBalanceRevalidating(true);
|
|
131
|
+
// fetchBalance(options?.address, options?.decimals).finally(() => {
|
|
132
|
+
// setBalanceRevalidating(false);
|
|
133
|
+
// });
|
|
134
|
+
queryBalance(options?.address, options?.decimals);
|
|
135
|
+
if (dst.chainId !== options?.srcChainId) {
|
|
136
|
+
queryAllowance(options?.address);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
if (dst.symbol !== options?.srcToken) {
|
|
140
|
+
queryAllowance(options?.address);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
getAllowanceByDefaultAddress(options?.address);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, [
|
|
147
|
+
state.status,
|
|
148
|
+
options?.address,
|
|
149
|
+
options?.srcChainId,
|
|
150
|
+
options?.srcToken,
|
|
151
|
+
account.address,
|
|
152
|
+
dst.chainId,
|
|
153
|
+
dst.symbol,
|
|
154
|
+
]);
|
|
155
|
+
const approve = useCallback(async (amount) => {
|
|
156
|
+
if (!options?.address) {
|
|
157
|
+
throw new Error("address is required");
|
|
158
|
+
}
|
|
159
|
+
return account.assetsManager
|
|
160
|
+
.approve(options.address, amount)
|
|
161
|
+
.then((result) => {
|
|
162
|
+
return account.walletClient
|
|
163
|
+
?.pollTransactionReceiptWithBackoff(result.hash)
|
|
164
|
+
.then((receipt) => {
|
|
165
|
+
if (receipt.status === 1) {
|
|
166
|
+
account.assetsManager
|
|
167
|
+
.getAllowance(options.address)
|
|
168
|
+
.then((allowance) => {
|
|
169
|
+
setAllowance(() => allowance);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}, [account, getAllowance, options, dst]);
|
|
175
|
+
const deposit = useCallback(async () => {
|
|
176
|
+
// only support orderly deposit
|
|
177
|
+
return account.assetsManager
|
|
178
|
+
.deposit(quantity, depositFee)
|
|
179
|
+
.then((res) => {
|
|
180
|
+
account.assetsManager
|
|
181
|
+
.getAllowance(options?.address)
|
|
182
|
+
.then((allowance) => {
|
|
183
|
+
setAllowance(() => allowance);
|
|
184
|
+
});
|
|
185
|
+
setBalance((value) => new Decimal(value).sub(quantity).toString());
|
|
186
|
+
return res;
|
|
187
|
+
});
|
|
188
|
+
}, [account, fetchBalance, quantity, depositFee]);
|
|
189
|
+
const loopGetBalance = async () => {
|
|
190
|
+
getBalanceListener.current && clearTimeout(getBalanceListener.current);
|
|
191
|
+
getBalanceListener.current = setTimeout(async () => {
|
|
192
|
+
try {
|
|
193
|
+
const balance = await fetchBalanceHandler(options?.address, options?.decimals);
|
|
194
|
+
setBalance(balance);
|
|
195
|
+
loopGetBalance();
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
console.log("fetchBalanceHandler error", err);
|
|
199
|
+
}
|
|
200
|
+
}, 3000);
|
|
201
|
+
};
|
|
202
|
+
const getDepositFee = useCallback(async (quantity) => {
|
|
203
|
+
return account.assetsManager.getDepositFee(quantity, targetChain?.network_infos);
|
|
204
|
+
}, [account, targetChain]);
|
|
205
|
+
const enquiryDepositFee = useCallback(() => {
|
|
206
|
+
if (isNaN(Number(quantity)) || !quantity) {
|
|
207
|
+
setDepositFee(0n);
|
|
208
|
+
setDepositFeeRevalidating(false);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
setDepositFeeRevalidating(true);
|
|
212
|
+
getDepositFee(quantity)
|
|
213
|
+
.then((res = 0n) => {
|
|
214
|
+
const fee = BigInt(new Decimal(res.toString())
|
|
215
|
+
.mul(DEPOSIT_FEE_RATE)
|
|
216
|
+
.toFixed(0, Decimal.ROUND_UP)
|
|
217
|
+
.toString());
|
|
218
|
+
setDepositFee(fee);
|
|
219
|
+
console.log("getDepositFee", fee);
|
|
220
|
+
})
|
|
221
|
+
.catch((error) => {
|
|
222
|
+
console.log("getDepositFee error", error);
|
|
223
|
+
})
|
|
224
|
+
.finally(() => {
|
|
225
|
+
setDepositFeeRevalidating(false);
|
|
226
|
+
});
|
|
227
|
+
}, [quantity]);
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
enquiryDepositFee();
|
|
230
|
+
}, [quantity]);
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
if (!options?.address) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
loopGetBalance();
|
|
236
|
+
return () => {
|
|
237
|
+
getBalanceListener.current && clearTimeout(getBalanceListener.current);
|
|
238
|
+
};
|
|
239
|
+
// account.walletClient.on(
|
|
240
|
+
// // {
|
|
241
|
+
// // address: options?.address,
|
|
242
|
+
// // },
|
|
243
|
+
// "block",
|
|
244
|
+
// (log: any, event: any) => {
|
|
245
|
+
// console.log("account.walletClient.on", log, event);
|
|
246
|
+
// }
|
|
247
|
+
// );
|
|
248
|
+
}, [options?.address, options?.decimals]);
|
|
249
|
+
return {
|
|
250
|
+
/** orderly support chain dst */
|
|
251
|
+
dst,
|
|
252
|
+
balance,
|
|
253
|
+
allowance,
|
|
254
|
+
isNativeToken,
|
|
255
|
+
balanceRevalidating,
|
|
256
|
+
allowanceRevalidating,
|
|
257
|
+
/** input quantiy */
|
|
258
|
+
quantity,
|
|
259
|
+
/** orderly deposit fee, unit: wei */
|
|
260
|
+
depositFee,
|
|
261
|
+
/** enquiring depositFee status on chain */
|
|
262
|
+
depositFeeRevalidating,
|
|
263
|
+
approve,
|
|
264
|
+
deposit,
|
|
265
|
+
fetchBalances,
|
|
266
|
+
fetchBalance: fetchBalanceHandler,
|
|
267
|
+
/** set input quantity */
|
|
268
|
+
setQuantity,
|
|
269
|
+
};
|
|
270
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const useFundingRate: (symbol: string) => {
|
|
2
|
+
est_funding_rate: string;
|
|
3
|
+
countDown: string;
|
|
4
|
+
symbol?: string | undefined;
|
|
5
|
+
est_funding_rate_timestamp?: number | undefined;
|
|
6
|
+
last_funding_rate?: number | undefined;
|
|
7
|
+
last_funding_rate_timestamp?: number | undefined;
|
|
8
|
+
next_funding_time?: number | undefined;
|
|
9
|
+
sum_unitary_funding?: number | undefined;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useFundingRate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFundingRate.d.ts","sourceRoot":"","sources":["../../src/orderly/useFundingRate.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,WAAY,MAAM;;;;;;;;;CA4C5C,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useQuery } from "../useQuery";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { timeConvertString } from "@orderly.network/utils";
|
|
4
|
+
export const useFundingRate = (symbol) => {
|
|
5
|
+
if (!symbol) {
|
|
6
|
+
throw new Error("useFuturesForSymbol requires a symbol");
|
|
7
|
+
}
|
|
8
|
+
const [countDown, setCountDown] = useState("00:00:00");
|
|
9
|
+
const { data } = useQuery(`/v1/public/funding_rate/${symbol}`, {
|
|
10
|
+
fallbackData: {
|
|
11
|
+
est_funding_rate: 0,
|
|
12
|
+
next_funing_time: 0,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!data)
|
|
17
|
+
return;
|
|
18
|
+
const { next_funding_time } = data;
|
|
19
|
+
if (!next_funding_time || next_funding_time <= 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const timer = setInterval(() => {
|
|
23
|
+
const diff = new Date(next_funding_time).getTime() - Date.now();
|
|
24
|
+
const result = timeConvertString(diff);
|
|
25
|
+
if (result.length === 3) {
|
|
26
|
+
setCountDown(`${result[0].toString().padStart(2, "0")}:${result[1]
|
|
27
|
+
.toString()
|
|
28
|
+
.padStart(2, "0")}:${result[2].toString().padStart(2, "0")}`);
|
|
29
|
+
}
|
|
30
|
+
}, 1000);
|
|
31
|
+
return () => {
|
|
32
|
+
clearInterval(timer);
|
|
33
|
+
};
|
|
34
|
+
}, [data]);
|
|
35
|
+
return {
|
|
36
|
+
...data,
|
|
37
|
+
est_funding_rate: (Number(data?.est_funding_rate ?? 0) * 100).toFixed(4),
|
|
38
|
+
countDown,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFundingRates.d.ts","sourceRoot":"","sources":["../../src/orderly/useFundingRates.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,WAwB3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useQuery } from "../useQuery";
|
|
2
|
+
import { createGetter } from "../utils/createGetter";
|
|
3
|
+
export const useFundingRates = () => {
|
|
4
|
+
const { data } = useQuery(`/v1/public/funding_rates`, {
|
|
5
|
+
focusThrottleInterval: 1000 * 60 * 60 * 24,
|
|
6
|
+
revalidateOnFocus: false,
|
|
7
|
+
formatter(data) {
|
|
8
|
+
if (!data?.rows || !data?.rows?.length) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
const obj = Object.create(null);
|
|
12
|
+
for (let index = 0; index < data.rows.length; index++) {
|
|
13
|
+
const item = data.rows[index];
|
|
14
|
+
obj[item.symbol] = item;
|
|
15
|
+
}
|
|
16
|
+
return obj;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
return createGetter(data);
|
|
21
|
+
};
|
|
@@ -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,47 @@
|
|
|
1
|
+
import { usePrivateQuery } from "../usePrivateQuery";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useWS } from "../useWS";
|
|
4
|
+
import useSWRSubscription from "swr/subscription";
|
|
5
|
+
export const useHoldingStream = () => {
|
|
6
|
+
const ws = useWS();
|
|
7
|
+
const { data, isLoading, mutate } = usePrivateQuery("/v1/client/holding", {
|
|
8
|
+
formatter: (data) => {
|
|
9
|
+
return data.holding;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const usdc = useMemo(() => {
|
|
13
|
+
const usdc = data?.find((item) => item.token === "USDC");
|
|
14
|
+
return usdc;
|
|
15
|
+
}, [data]);
|
|
16
|
+
useSWRSubscription("holding", (_, { next }) => {
|
|
17
|
+
const unsubscribe = ws.privateSubscribe({
|
|
18
|
+
id: "balance",
|
|
19
|
+
event: "subscribe",
|
|
20
|
+
topic: "balance",
|
|
21
|
+
ts: Date.now(),
|
|
22
|
+
}, {
|
|
23
|
+
onMessage: (data) => {
|
|
24
|
+
const holding = data?.balances ?? {};
|
|
25
|
+
if (holding) {
|
|
26
|
+
mutate((prevData) => {
|
|
27
|
+
return prevData?.map((item) => {
|
|
28
|
+
const token = holding[item.token];
|
|
29
|
+
return {
|
|
30
|
+
...item,
|
|
31
|
+
frozen: token.frozen,
|
|
32
|
+
holding: token.holding,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
next(holding);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return () => unsubscribe();
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
data,
|
|
44
|
+
usdc,
|
|
45
|
+
isLoading,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -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,17 @@
|
|
|
1
|
+
import { useWS } from "../useWS";
|
|
2
|
+
import useSWRSubscription from "swr/subscription";
|
|
3
|
+
export const useIndexPrice = (symbol) => {
|
|
4
|
+
// WARNING: force change perp to spot, because there is no perp now
|
|
5
|
+
symbol = symbol.replace("PERP", "SPOT");
|
|
6
|
+
const ws = useWS();
|
|
7
|
+
return useSWRSubscription(`${symbol}@indexprice`, (key, { next }) => {
|
|
8
|
+
const unsubscribe = ws.subscribe(`${symbol}@indexprice`, {
|
|
9
|
+
onMessage: (message) => {
|
|
10
|
+
next(null, message.price);
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
return () => {
|
|
14
|
+
unsubscribe?.();
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -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,34 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useMutation } from "../useMutation";
|
|
3
|
+
import { usePrivateQuery } from "../usePrivateQuery";
|
|
4
|
+
import { prop } from "ramda";
|
|
5
|
+
import { useQuery } from "../useQuery";
|
|
6
|
+
export const useLeverage = () => {
|
|
7
|
+
const { data, mutate } = usePrivateQuery("/v1/client/info");
|
|
8
|
+
const [update, { isMutating }] = useMutation("/v1/client/leverage");
|
|
9
|
+
const { data: config } = useQuery("/v1/public/config");
|
|
10
|
+
const updateLeverage = useCallback((data) => {
|
|
11
|
+
return update(data).then((res) => {
|
|
12
|
+
if (res.success) {
|
|
13
|
+
return mutate();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
throw new Error(res.message);
|
|
17
|
+
}
|
|
18
|
+
// return res
|
|
19
|
+
});
|
|
20
|
+
}, []);
|
|
21
|
+
return [
|
|
22
|
+
prop("max_leverage", data),
|
|
23
|
+
{
|
|
24
|
+
update: updateLeverage,
|
|
25
|
+
isMutating,
|
|
26
|
+
// config: [1, 2, 3, 4, 5, 10, 15, 20],
|
|
27
|
+
config: config
|
|
28
|
+
? config?.available_futures_leverage
|
|
29
|
+
?.split(",")
|
|
30
|
+
.map((item) => parseInt(item))
|
|
31
|
+
: [],
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
};
|
|
@@ -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,41 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { account } from "@orderly.network/perp";
|
|
3
|
+
import { usePositionStream } from "./usePositionStream";
|
|
4
|
+
import { useMarkPricesStream } from "./useMarkPricesStream";
|
|
5
|
+
import { useCollateral } from "./useCollateral";
|
|
6
|
+
import { zero } from "@orderly.network/utils";
|
|
7
|
+
export const useMarginRatio = () => {
|
|
8
|
+
const [{ rows, aggregated }] = usePositionStream();
|
|
9
|
+
const { data: markPrices } = useMarkPricesStream();
|
|
10
|
+
const { totalCollateral } = useCollateral();
|
|
11
|
+
const marginRatio = useMemo(() => {
|
|
12
|
+
if (!rows || !markPrices || !totalCollateral || rows.length === 0) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
const ratio = account.totalMarginRatio({
|
|
16
|
+
totalCollateral: totalCollateral,
|
|
17
|
+
markPrices: markPrices,
|
|
18
|
+
positions: rows ?? [],
|
|
19
|
+
});
|
|
20
|
+
return ratio;
|
|
21
|
+
}, [rows, markPrices, totalCollateral]);
|
|
22
|
+
const currentLeverage = useMemo(() => {
|
|
23
|
+
return account.currentLeverage(marginRatio);
|
|
24
|
+
}, [marginRatio]);
|
|
25
|
+
// MMR
|
|
26
|
+
const mmr = useMemo(() => {
|
|
27
|
+
if (!rows || rows.length <= 0)
|
|
28
|
+
return null;
|
|
29
|
+
let positionsMM = zero;
|
|
30
|
+
// const positionsNotional = positions.totalNotional(rows);
|
|
31
|
+
for (let index = 0; index < rows.length; index++) {
|
|
32
|
+
const item = rows[index];
|
|
33
|
+
positionsMM = positionsMM.add(item.mm);
|
|
34
|
+
}
|
|
35
|
+
return account.MMR({
|
|
36
|
+
positionsMMR: positionsMM.toNumber(),
|
|
37
|
+
positionsNotional: aggregated.notional,
|
|
38
|
+
});
|
|
39
|
+
}, [rows, aggregated]);
|
|
40
|
+
return { marginRatio, currentLeverage, mmr };
|
|
41
|
+
};
|
|
@@ -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,29 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useWS } from "../useWS";
|
|
3
|
+
// import useSWRSubscription from "swr/subscription";
|
|
4
|
+
export const useMarkPrice = (symbol) => {
|
|
5
|
+
const ws = useWS();
|
|
6
|
+
const [price, setPrice] = useState(0);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
|
|
9
|
+
onMessage: (message) => {
|
|
10
|
+
setPrice(message.price);
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
return () => {
|
|
14
|
+
unsubscribe?.();
|
|
15
|
+
};
|
|
16
|
+
}, [symbol]);
|
|
17
|
+
// return useSWRSubscription(`${symbol}@markprice`, (key, { next }) => {
|
|
18
|
+
// const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
|
|
19
|
+
// onMessage: (message: any) => {
|
|
20
|
+
// next(null, message.price);
|
|
21
|
+
// },
|
|
22
|
+
// });
|
|
23
|
+
// return () => {
|
|
24
|
+
// // console.log("_____________________ unsubscribe _________ ", symbol);
|
|
25
|
+
// unsubscribe?.();
|
|
26
|
+
// };
|
|
27
|
+
// });
|
|
28
|
+
return { data: price };
|
|
29
|
+
};
|
|
@@ -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,26 @@
|
|
|
1
|
+
import useSWRSubscription from "swr/subscription";
|
|
2
|
+
import { useWS } from "../useWS";
|
|
3
|
+
export const useMarkPricesStream = () => {
|
|
4
|
+
const ws = useWS();
|
|
5
|
+
return useSWRSubscription("markPrices", (key, { next }) => {
|
|
6
|
+
const unsubscribe = ws.subscribe(
|
|
7
|
+
// { event: "subscribe", topic: "markprices" },
|
|
8
|
+
"markprices", {
|
|
9
|
+
onMessage: (message) => {
|
|
10
|
+
const data = Object.create(null);
|
|
11
|
+
for (let index = 0; index < message.length; index++) {
|
|
12
|
+
const element = message[index];
|
|
13
|
+
data[element.symbol] = element.price;
|
|
14
|
+
}
|
|
15
|
+
next(null, data);
|
|
16
|
+
},
|
|
17
|
+
// onUnsubscribe: () => {
|
|
18
|
+
// return "markprices";
|
|
19
|
+
// },
|
|
20
|
+
onError: (error) => { },
|
|
21
|
+
});
|
|
22
|
+
return () => {
|
|
23
|
+
unsubscribe?.();
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -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
|