@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,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateTestnetInfo = exports.updateOrderlyChains = exports.fillChainsInfo = exports.useChains = void 0;
|
|
4
|
+
const types_1 = require("@orderly.network/types");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useQuery_1 = require("../useQuery");
|
|
7
|
+
const ramda_1 = require("ramda");
|
|
8
|
+
const utils_1 = require("@orderly.network/utils");
|
|
9
|
+
const types_2 = require("@orderly.network/types");
|
|
10
|
+
function useChains(networkId, options = {}) {
|
|
11
|
+
const { pick: pickField, ...swrOptions } = options;
|
|
12
|
+
const filterFun = (0, react_1.useRef)(options?.filter);
|
|
13
|
+
filterFun.current = options?.filter;
|
|
14
|
+
const chainsMap = (0, react_1.useRef)(new Map());
|
|
15
|
+
const commonSwrOpts = {
|
|
16
|
+
revalidateIfStale: false,
|
|
17
|
+
revalidateOnFocus: false,
|
|
18
|
+
revalidateOnReconnect: false,
|
|
19
|
+
// If false, undefined data gets cached against the key.
|
|
20
|
+
revalidateOnMount: true,
|
|
21
|
+
// dont duplicate a request w/ same key for 1hr
|
|
22
|
+
dedupingInterval: 3600000,
|
|
23
|
+
...swrOptions,
|
|
24
|
+
};
|
|
25
|
+
// only prod env return mainnet chains info
|
|
26
|
+
// TODO: remove https://api-evm.orderly.org api base
|
|
27
|
+
const { data: tokenChains, error: tokenError } = (0, useQuery_1.useQuery)("https://api-evm.orderly.org/v1/public/token", { ...commonSwrOpts });
|
|
28
|
+
// only prod env return mainnet chains info
|
|
29
|
+
const { data: chainInfos, error: chainInfoErr } = (0, useQuery_1.useQuery)("/v1/public/chain_info", { ...commonSwrOpts });
|
|
30
|
+
const chains = (0, react_1.useMemo)(() => {
|
|
31
|
+
const orderlyChainsArr = fillChainsInfo(tokenChains, filterFun.current);
|
|
32
|
+
let testnetArr = [...types_2.TestnetChains];
|
|
33
|
+
orderlyChainsArr?.forEach((item) => {
|
|
34
|
+
const chainId = item.network_infos?.chain_id;
|
|
35
|
+
chainsMap.current.set(chainId, item);
|
|
36
|
+
updateTestnetInfo(testnetArr, chainId, item);
|
|
37
|
+
});
|
|
38
|
+
testnetArr.forEach((chain) => {
|
|
39
|
+
chainsMap.current.set(chain.network_infos?.chain_id, chain);
|
|
40
|
+
});
|
|
41
|
+
let mainnetArr = [];
|
|
42
|
+
// TODO: /v1/public/chain_info api data is not match /v1/public/token api data, so it can effect is prod
|
|
43
|
+
mainnetArr = updateOrderlyChains(orderlyChainsArr, chainInfos, filterFun.current);
|
|
44
|
+
mainnetArr.forEach((item) => {
|
|
45
|
+
const chainId = item.network_infos?.chain_id;
|
|
46
|
+
chainsMap.current.set(chainId, item);
|
|
47
|
+
updateTestnetInfo(testnetArr, chainId, item);
|
|
48
|
+
});
|
|
49
|
+
mainnetArr.sort((a, b) => {
|
|
50
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
51
|
+
});
|
|
52
|
+
testnetArr.sort((a, b) => {
|
|
53
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
54
|
+
});
|
|
55
|
+
if (!!pickField) {
|
|
56
|
+
//@ts-ignore
|
|
57
|
+
testnetArr = testnetArr.map((item) => item[pickField]);
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
mainnetArr = mainnetArr.map((item) => item[pickField]);
|
|
60
|
+
}
|
|
61
|
+
if (networkId === "mainnet") {
|
|
62
|
+
return mainnetArr;
|
|
63
|
+
}
|
|
64
|
+
if (networkId === "testnet") {
|
|
65
|
+
return testnetArr;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
testnet: testnetArr,
|
|
69
|
+
mainnet: mainnetArr,
|
|
70
|
+
};
|
|
71
|
+
}, [networkId, tokenChains, chainInfos, pickField]);
|
|
72
|
+
const findByChainId = (0, react_1.useCallback)((chainId, field) => {
|
|
73
|
+
const chain = chainsMap.current.get(chainId);
|
|
74
|
+
if (chain) {
|
|
75
|
+
chain.nativeToken =
|
|
76
|
+
chain.token_infos?.find((item) => item.address === types_2.nativeTokenAddress) ||
|
|
77
|
+
{
|
|
78
|
+
symbol: chain.network_infos?.currency_symbol,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (typeof field === "string") {
|
|
82
|
+
return (0, ramda_1.prop)(field, chain);
|
|
83
|
+
}
|
|
84
|
+
return chain;
|
|
85
|
+
}, [chains, chainsMap]);
|
|
86
|
+
return [
|
|
87
|
+
chains,
|
|
88
|
+
{
|
|
89
|
+
findByChainId,
|
|
90
|
+
error: tokenError,
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
exports.useChains = useChains;
|
|
95
|
+
/** orderly chains array form (/v1/public/token) api */
|
|
96
|
+
function fillChainsInfo(chains, filter) {
|
|
97
|
+
let _chains = [];
|
|
98
|
+
chains?.forEach((item) => {
|
|
99
|
+
item.chain_details.forEach((chain) => {
|
|
100
|
+
const chainId = Number(chain.chain_id);
|
|
101
|
+
const chainInfo = types_1.chainsInfoMap.get(chainId);
|
|
102
|
+
const _chain = {
|
|
103
|
+
network_infos: {
|
|
104
|
+
name: chain.chain_name ?? chainInfo?.chainName ?? "--",
|
|
105
|
+
chain_id: chainId,
|
|
106
|
+
withdrawal_fee: chain.withdrawal_fee,
|
|
107
|
+
cross_chain_withdrawal_fee: chain.cross_chain_withdrawal_fee,
|
|
108
|
+
bridgeless: true,
|
|
109
|
+
},
|
|
110
|
+
token_infos: [
|
|
111
|
+
{
|
|
112
|
+
symbol: item.token,
|
|
113
|
+
address: chain.contract_address,
|
|
114
|
+
decimals: chain.decimals,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
if (typeof filter === "function") {
|
|
119
|
+
if (!filter(_chain))
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
_chains.push(_chain);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
return _chains;
|
|
126
|
+
}
|
|
127
|
+
exports.fillChainsInfo = fillChainsInfo;
|
|
128
|
+
/** update network_infos by chain_info api(v1/public/chain_info) */
|
|
129
|
+
function updateOrderlyChains(chains, chainInfos, filter) {
|
|
130
|
+
const _chains = [];
|
|
131
|
+
chains.forEach((chain) => {
|
|
132
|
+
let _chain = { ...chain };
|
|
133
|
+
const networkInfo = chainInfos?.find((item) => item.chain_id == chain.network_infos.chain_id);
|
|
134
|
+
if (networkInfo) {
|
|
135
|
+
const { name, public_rpc_url, currency_symbol, explorer_base_url } = networkInfo;
|
|
136
|
+
_chain.network_infos = {
|
|
137
|
+
..._chain.network_infos,
|
|
138
|
+
name,
|
|
139
|
+
shortName: name,
|
|
140
|
+
public_rpc_url,
|
|
141
|
+
currency_symbol,
|
|
142
|
+
bridge_enable: true,
|
|
143
|
+
mainnet: true,
|
|
144
|
+
explorer_base_url,
|
|
145
|
+
est_txn_mins: null,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (typeof filter === "function") {
|
|
149
|
+
if (!filter(_chain))
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
_chains.push(_chain);
|
|
153
|
+
});
|
|
154
|
+
return _chains;
|
|
155
|
+
}
|
|
156
|
+
exports.updateOrderlyChains = updateOrderlyChains;
|
|
157
|
+
/** if chain is testnet, update testnet network_infos */
|
|
158
|
+
function updateTestnetInfo(testnetArr, chainId, chain) {
|
|
159
|
+
if ((0, utils_1.isTestnet)(chainId)) {
|
|
160
|
+
const index = testnetArr?.findIndex((item) => item.network_infos.chain_id === chainId);
|
|
161
|
+
if (index > -1) {
|
|
162
|
+
testnetArr[index] = chain;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.updateTestnetInfo = updateTestnetInfo;
|
|
@@ -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,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCollateral = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const usePrivateQuery_1 = require("../usePrivateQuery");
|
|
6
|
+
const usePositionStream_1 = require("./usePositionStream");
|
|
7
|
+
const ramda_1 = require("ramda");
|
|
8
|
+
const perp_1 = require("@orderly.network/perp");
|
|
9
|
+
const types_1 = require("@orderly.network/types");
|
|
10
|
+
const useSymbolsInfo_1 = require("./useSymbolsInfo");
|
|
11
|
+
const utils_1 = require("@orderly.network/utils");
|
|
12
|
+
const useMarkPricesStream_1 = require("./useMarkPricesStream");
|
|
13
|
+
const useHoldingStream_1 = require("./useHoldingStream");
|
|
14
|
+
const useOrderStream_1 = require("./useOrderStream");
|
|
15
|
+
const positionsPath = (0, ramda_1.pathOr)([], [0, "rows"]);
|
|
16
|
+
const totalCollateralPath = (0, ramda_1.pathOr)(0, [0, "totalCollateral"]);
|
|
17
|
+
const useCollateral = (options = { dp: 6 }) => {
|
|
18
|
+
const { dp } = options;
|
|
19
|
+
const positions = (0, usePositionStream_1.usePositionStream)();
|
|
20
|
+
const [orders] = (0, useOrderStream_1.useOrderStream)({ status: types_1.OrderStatus.NEW });
|
|
21
|
+
const { data: accountInfo } = (0, usePrivateQuery_1.usePrivateQuery)("/v1/client/info");
|
|
22
|
+
const symbolInfo = (0, useSymbolsInfo_1.useSymbolsInfo)();
|
|
23
|
+
const { data: markPrices } = (0, useMarkPricesStream_1.useMarkPricesStream)();
|
|
24
|
+
const { usdc } = (0, useHoldingStream_1.useHoldingStream)();
|
|
25
|
+
const filterAlgoOrders = orders?.filter((item) => item.algo_order_id === undefined) ?? [];
|
|
26
|
+
// const { data: holding } = usePrivateQuery<API.Holding[]>(
|
|
27
|
+
// "/v1/client/holding",
|
|
28
|
+
// {
|
|
29
|
+
// formatter: (data) => {
|
|
30
|
+
// return data.holding;
|
|
31
|
+
// },
|
|
32
|
+
// }
|
|
33
|
+
// );
|
|
34
|
+
const [totalCollateral, totalValue] = (0, react_1.useMemo)(() => {
|
|
35
|
+
return [
|
|
36
|
+
(0, ramda_1.pathOr)(utils_1.zero, [0, "totalCollateral"], positions),
|
|
37
|
+
(0, ramda_1.pathOr)(utils_1.zero, [0, "totalValue"], positions),
|
|
38
|
+
];
|
|
39
|
+
}, [positions, markPrices]);
|
|
40
|
+
const totalInitialMarginWithOrders = (0, react_1.useMemo)(() => {
|
|
41
|
+
if (!accountInfo || !symbolInfo || !markPrices) {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
return perp_1.account.totalInitialMarginWithOrders({
|
|
45
|
+
positions: positionsPath(positions),
|
|
46
|
+
orders: filterAlgoOrders,
|
|
47
|
+
markPrices,
|
|
48
|
+
IMR_Factors: accountInfo.imr_factor,
|
|
49
|
+
maxLeverage: accountInfo.max_leverage,
|
|
50
|
+
symbolInfo,
|
|
51
|
+
});
|
|
52
|
+
}, [positions, filterAlgoOrders, markPrices, accountInfo, symbolInfo]);
|
|
53
|
+
const freeCollateral = (0, react_1.useMemo)(() => {
|
|
54
|
+
return perp_1.account.freeCollateral({
|
|
55
|
+
totalCollateral,
|
|
56
|
+
totalInitialMarginWithOrders,
|
|
57
|
+
});
|
|
58
|
+
}, [totalCollateral, totalInitialMarginWithOrders]);
|
|
59
|
+
const availableBalance = (0, react_1.useMemo)(() => {
|
|
60
|
+
return perp_1.account.availableBalance({
|
|
61
|
+
USDCHolding: usdc?.holding ?? 0,
|
|
62
|
+
unsettlementPnL: (0, usePositionStream_1.pathOr_unsettledPnLPathOr)(positions),
|
|
63
|
+
});
|
|
64
|
+
}, [usdc?.holding, (0, usePositionStream_1.pathOr_unsettledPnLPathOr)(positions)]);
|
|
65
|
+
return {
|
|
66
|
+
totalCollateral: totalCollateral.toDecimalPlaces(dp).toNumber(),
|
|
67
|
+
freeCollateral: freeCollateral.toDecimalPlaces(dp).toNumber(),
|
|
68
|
+
totalValue: totalValue.toDecimalPlaces(dp).toNumber(),
|
|
69
|
+
availableBalance,
|
|
70
|
+
unsettledPnL: (0, usePositionStream_1.pathOr_unsettledPnLPathOr)(positions),
|
|
71
|
+
accountInfo,
|
|
72
|
+
// @hidden
|
|
73
|
+
positions: positionsPath(positions),
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
exports.useCollateral = useCollateral;
|
|
@@ -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,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDeposit = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useAccount_1 = require("../useAccount");
|
|
6
|
+
const types_1 = require("@orderly.network/types");
|
|
7
|
+
const utils_1 = require("@orderly.network/utils");
|
|
8
|
+
const useChains_1 = require("./useChains");
|
|
9
|
+
const useConfig_1 = require("../useConfig");
|
|
10
|
+
const use_debounce_1 = require("use-debounce");
|
|
11
|
+
const useDeposit = (options) => {
|
|
12
|
+
const networkId = (0, useConfig_1.useConfig)("networkId");
|
|
13
|
+
const [balanceRevalidating, setBalanceRevalidating] = (0, react_1.useState)(false);
|
|
14
|
+
const [allowanceRevalidating, setAllowanceRevalidating] = (0, react_1.useState)(false);
|
|
15
|
+
const [_, { findByChainId }] = (0, useChains_1.useChains)(undefined);
|
|
16
|
+
const [quantity, setQuantity] = (0, react_1.useState)("");
|
|
17
|
+
const [depositFee, setDepositFee] = (0, react_1.useState)(0n);
|
|
18
|
+
const [depositFeeRevalidating, setDepositFeeRevalidating] = (0, react_1.useState)(false);
|
|
19
|
+
const [balance, setBalance] = (0, react_1.useState)("0");
|
|
20
|
+
const [allowance, setAllowance] = (0, react_1.useState)("0");
|
|
21
|
+
const { account, state } = (0, useAccount_1.useAccount)();
|
|
22
|
+
const prevAddress = (0, react_1.useRef)();
|
|
23
|
+
const getBalanceListener = (0, react_1.useRef)();
|
|
24
|
+
const targetChain = (0, react_1.useMemo)(() => {
|
|
25
|
+
let chain;
|
|
26
|
+
// Orderly testnet supported chain
|
|
27
|
+
if (networkId === "testnet") {
|
|
28
|
+
chain = findByChainId(types_1.ARBITRUM_TESTNET_CHAINID);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
chain = findByChainId(options?.srcChainId);
|
|
32
|
+
// if is orderly un-supported chain
|
|
33
|
+
if (!chain?.network_infos?.bridgeless) {
|
|
34
|
+
// Orderly mainnet supported chain
|
|
35
|
+
chain = findByChainId(types_1.ARBITRUM_MAINNET_CHAINID);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return chain;
|
|
39
|
+
}, [networkId, findByChainId, options?.srcChainId]);
|
|
40
|
+
const dst = (0, react_1.useMemo)(() => {
|
|
41
|
+
if (!targetChain) {
|
|
42
|
+
throw new Error("dst chain not found");
|
|
43
|
+
}
|
|
44
|
+
const USDC = targetChain?.token_infos.find((token) => token.symbol === "USDC");
|
|
45
|
+
return {
|
|
46
|
+
symbol: "USDC",
|
|
47
|
+
address: USDC?.address,
|
|
48
|
+
decimals: USDC?.decimals,
|
|
49
|
+
chainId: targetChain.network_infos.chain_id,
|
|
50
|
+
network: targetChain.network_infos.shortName,
|
|
51
|
+
};
|
|
52
|
+
}, [targetChain]);
|
|
53
|
+
const isNativeToken = (0, react_1.useMemo)(() => (0, types_1.isNativeTokenChecker)(options?.address || ""), [options?.address]);
|
|
54
|
+
const fetchBalanceHandler = (0, react_1.useCallback)(async (address, decimals) => {
|
|
55
|
+
let balance;
|
|
56
|
+
if (!!address && (0, types_1.isNativeTokenChecker)(address)) {
|
|
57
|
+
balance = await account.assetsManager.getNativeBalance({
|
|
58
|
+
decimals,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
balance = await account.assetsManager.getBalance(address, { decimals });
|
|
63
|
+
}
|
|
64
|
+
return balance;
|
|
65
|
+
}, []);
|
|
66
|
+
const fetchBalance = (0, react_1.useCallback)(async (
|
|
67
|
+
// token contract address
|
|
68
|
+
address,
|
|
69
|
+
// format decimals
|
|
70
|
+
decimals) => {
|
|
71
|
+
if (!address)
|
|
72
|
+
return;
|
|
73
|
+
try {
|
|
74
|
+
// if (balanceRevalidating) return;
|
|
75
|
+
const balance = await fetchBalanceHandler(address, decimals);
|
|
76
|
+
setBalance(() => balance);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
console.warn("----- refresh balance error -----", e);
|
|
80
|
+
setBalance(() => "0");
|
|
81
|
+
}
|
|
82
|
+
}, [state]);
|
|
83
|
+
const fetchBalances = (0, react_1.useCallback)(async (tokens) => {
|
|
84
|
+
const tasks = [];
|
|
85
|
+
for (const token of tokens) {
|
|
86
|
+
// native token skip
|
|
87
|
+
if ((0, types_1.isNativeTokenChecker)(token.address)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
tasks.push(account.assetsManager.getBalanceByAddress(token.address));
|
|
91
|
+
}
|
|
92
|
+
const balances = await Promise.all(tasks);
|
|
93
|
+
// const balances = await account.assetsManager.getBalances(tokens);
|
|
94
|
+
// setBalance(() => balances);
|
|
95
|
+
}, []);
|
|
96
|
+
const getAllowance = async (address, vaultAddress) => {
|
|
97
|
+
// if (!address || !vaultAddress) return;
|
|
98
|
+
const key = `${address}-${vaultAddress}`;
|
|
99
|
+
if (prevAddress.current === key)
|
|
100
|
+
return;
|
|
101
|
+
if (!address || !vaultAddress)
|
|
102
|
+
return;
|
|
103
|
+
if (address && (0, types_1.isNativeTokenChecker)(address))
|
|
104
|
+
return;
|
|
105
|
+
// if (allowanceRevalidating) return;
|
|
106
|
+
// setAllowanceRevalidating(true);
|
|
107
|
+
prevAddress.current = key;
|
|
108
|
+
const allowance = await account.assetsManager.getAllowance(address, vaultAddress);
|
|
109
|
+
setAllowance(() => allowance);
|
|
110
|
+
// setAllowanceRevalidating(false);
|
|
111
|
+
return allowance;
|
|
112
|
+
};
|
|
113
|
+
const getAllowanceByDefaultAddress = async (address) => {
|
|
114
|
+
if (prevAddress.current === address)
|
|
115
|
+
return;
|
|
116
|
+
if (!address || (0, types_1.isNativeTokenChecker)(address))
|
|
117
|
+
return;
|
|
118
|
+
prevAddress.current = address;
|
|
119
|
+
const allowance = await account.assetsManager.getAllowance(address);
|
|
120
|
+
setAllowance(() => allowance);
|
|
121
|
+
};
|
|
122
|
+
const queryBalance = (0, use_debounce_1.useDebouncedCallback)((tokenAddress, decimals) => {
|
|
123
|
+
fetchBalance(options?.address, options?.decimals).finally(() => {
|
|
124
|
+
setBalanceRevalidating(false);
|
|
125
|
+
});
|
|
126
|
+
}, 100);
|
|
127
|
+
const queryAllowance = (0, use_debounce_1.useDebouncedCallback)((tokenAddress, vaultAddress) => {
|
|
128
|
+
getAllowance(tokenAddress, vaultAddress);
|
|
129
|
+
}, 100);
|
|
130
|
+
(0, react_1.useEffect)(() => {
|
|
131
|
+
if (state.status < types_1.AccountStatusEnum.Connected)
|
|
132
|
+
return;
|
|
133
|
+
setBalanceRevalidating(true);
|
|
134
|
+
// fetchBalance(options?.address, options?.decimals).finally(() => {
|
|
135
|
+
// setBalanceRevalidating(false);
|
|
136
|
+
// });
|
|
137
|
+
queryBalance(options?.address, options?.decimals);
|
|
138
|
+
if (dst.chainId !== options?.srcChainId) {
|
|
139
|
+
queryAllowance(options?.address);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
if (dst.symbol !== options?.srcToken) {
|
|
143
|
+
queryAllowance(options?.address);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
getAllowanceByDefaultAddress(options?.address);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}, [
|
|
150
|
+
state.status,
|
|
151
|
+
options?.address,
|
|
152
|
+
options?.srcChainId,
|
|
153
|
+
options?.srcToken,
|
|
154
|
+
account.address,
|
|
155
|
+
dst.chainId,
|
|
156
|
+
dst.symbol,
|
|
157
|
+
]);
|
|
158
|
+
const approve = (0, react_1.useCallback)(async (amount) => {
|
|
159
|
+
if (!options?.address) {
|
|
160
|
+
throw new Error("address is required");
|
|
161
|
+
}
|
|
162
|
+
return account.assetsManager
|
|
163
|
+
.approve(options.address, amount)
|
|
164
|
+
.then((result) => {
|
|
165
|
+
return account.walletClient
|
|
166
|
+
?.pollTransactionReceiptWithBackoff(result.hash)
|
|
167
|
+
.then((receipt) => {
|
|
168
|
+
if (receipt.status === 1) {
|
|
169
|
+
account.assetsManager
|
|
170
|
+
.getAllowance(options.address)
|
|
171
|
+
.then((allowance) => {
|
|
172
|
+
setAllowance(() => allowance);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}, [account, getAllowance, options, dst]);
|
|
178
|
+
const deposit = (0, react_1.useCallback)(async () => {
|
|
179
|
+
// only support orderly deposit
|
|
180
|
+
return account.assetsManager
|
|
181
|
+
.deposit(quantity, depositFee)
|
|
182
|
+
.then((res) => {
|
|
183
|
+
account.assetsManager
|
|
184
|
+
.getAllowance(options?.address)
|
|
185
|
+
.then((allowance) => {
|
|
186
|
+
setAllowance(() => allowance);
|
|
187
|
+
});
|
|
188
|
+
setBalance((value) => new utils_1.Decimal(value).sub(quantity).toString());
|
|
189
|
+
return res;
|
|
190
|
+
});
|
|
191
|
+
}, [account, fetchBalance, quantity, depositFee]);
|
|
192
|
+
const loopGetBalance = async () => {
|
|
193
|
+
getBalanceListener.current && clearTimeout(getBalanceListener.current);
|
|
194
|
+
getBalanceListener.current = setTimeout(async () => {
|
|
195
|
+
try {
|
|
196
|
+
const balance = await fetchBalanceHandler(options?.address, options?.decimals);
|
|
197
|
+
setBalance(balance);
|
|
198
|
+
loopGetBalance();
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
console.log("fetchBalanceHandler error", err);
|
|
202
|
+
}
|
|
203
|
+
}, 3000);
|
|
204
|
+
};
|
|
205
|
+
const getDepositFee = (0, react_1.useCallback)(async (quantity) => {
|
|
206
|
+
return account.assetsManager.getDepositFee(quantity, targetChain?.network_infos);
|
|
207
|
+
}, [account, targetChain]);
|
|
208
|
+
const enquiryDepositFee = (0, react_1.useCallback)(() => {
|
|
209
|
+
if (isNaN(Number(quantity)) || !quantity) {
|
|
210
|
+
setDepositFee(0n);
|
|
211
|
+
setDepositFeeRevalidating(false);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
setDepositFeeRevalidating(true);
|
|
215
|
+
getDepositFee(quantity)
|
|
216
|
+
.then((res = 0n) => {
|
|
217
|
+
const fee = BigInt(new utils_1.Decimal(res.toString())
|
|
218
|
+
.mul(types_1.DEPOSIT_FEE_RATE)
|
|
219
|
+
.toFixed(0, utils_1.Decimal.ROUND_UP)
|
|
220
|
+
.toString());
|
|
221
|
+
setDepositFee(fee);
|
|
222
|
+
console.log("getDepositFee", fee);
|
|
223
|
+
})
|
|
224
|
+
.catch((error) => {
|
|
225
|
+
console.log("getDepositFee error", error);
|
|
226
|
+
})
|
|
227
|
+
.finally(() => {
|
|
228
|
+
setDepositFeeRevalidating(false);
|
|
229
|
+
});
|
|
230
|
+
}, [quantity]);
|
|
231
|
+
(0, react_1.useEffect)(() => {
|
|
232
|
+
enquiryDepositFee();
|
|
233
|
+
}, [quantity]);
|
|
234
|
+
(0, react_1.useEffect)(() => {
|
|
235
|
+
if (!options?.address) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
loopGetBalance();
|
|
239
|
+
return () => {
|
|
240
|
+
getBalanceListener.current && clearTimeout(getBalanceListener.current);
|
|
241
|
+
};
|
|
242
|
+
// account.walletClient.on(
|
|
243
|
+
// // {
|
|
244
|
+
// // address: options?.address,
|
|
245
|
+
// // },
|
|
246
|
+
// "block",
|
|
247
|
+
// (log: any, event: any) => {
|
|
248
|
+
// console.log("account.walletClient.on", log, event);
|
|
249
|
+
// }
|
|
250
|
+
// );
|
|
251
|
+
}, [options?.address, options?.decimals]);
|
|
252
|
+
return {
|
|
253
|
+
/** orderly support chain dst */
|
|
254
|
+
dst,
|
|
255
|
+
balance,
|
|
256
|
+
allowance,
|
|
257
|
+
isNativeToken,
|
|
258
|
+
balanceRevalidating,
|
|
259
|
+
allowanceRevalidating,
|
|
260
|
+
/** input quantiy */
|
|
261
|
+
quantity,
|
|
262
|
+
/** orderly deposit fee, unit: wei */
|
|
263
|
+
depositFee,
|
|
264
|
+
/** enquiring depositFee status on chain */
|
|
265
|
+
depositFeeRevalidating,
|
|
266
|
+
approve,
|
|
267
|
+
deposit,
|
|
268
|
+
fetchBalances,
|
|
269
|
+
fetchBalance: fetchBalanceHandler,
|
|
270
|
+
/** set input quantity */
|
|
271
|
+
setQuantity,
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
exports.useDeposit = useDeposit;
|
|
@@ -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,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFundingRate = void 0;
|
|
4
|
+
const useQuery_1 = require("../useQuery");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const utils_1 = require("@orderly.network/utils");
|
|
7
|
+
const useFundingRate = (symbol) => {
|
|
8
|
+
if (!symbol) {
|
|
9
|
+
throw new Error("useFuturesForSymbol requires a symbol");
|
|
10
|
+
}
|
|
11
|
+
const [countDown, setCountDown] = (0, react_1.useState)("00:00:00");
|
|
12
|
+
const { data } = (0, useQuery_1.useQuery)(`/v1/public/funding_rate/${symbol}`, {
|
|
13
|
+
fallbackData: {
|
|
14
|
+
est_funding_rate: 0,
|
|
15
|
+
next_funing_time: 0,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
if (!data)
|
|
20
|
+
return;
|
|
21
|
+
const { next_funding_time } = data;
|
|
22
|
+
if (!next_funding_time || next_funding_time <= 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const timer = setInterval(() => {
|
|
26
|
+
const diff = new Date(next_funding_time).getTime() - Date.now();
|
|
27
|
+
const result = (0, utils_1.timeConvertString)(diff);
|
|
28
|
+
if (result.length === 3) {
|
|
29
|
+
setCountDown(`${result[0].toString().padStart(2, "0")}:${result[1]
|
|
30
|
+
.toString()
|
|
31
|
+
.padStart(2, "0")}:${result[2].toString().padStart(2, "0")}`);
|
|
32
|
+
}
|
|
33
|
+
}, 1000);
|
|
34
|
+
return () => {
|
|
35
|
+
clearInterval(timer);
|
|
36
|
+
};
|
|
37
|
+
}, [data]);
|
|
38
|
+
return {
|
|
39
|
+
...data,
|
|
40
|
+
est_funding_rate: (Number(data?.est_funding_rate ?? 0) * 100).toFixed(4),
|
|
41
|
+
countDown,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.useFundingRate = useFundingRate;
|
|
@@ -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,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFundingRates = void 0;
|
|
4
|
+
const useQuery_1 = require("../useQuery");
|
|
5
|
+
const createGetter_1 = require("../utils/createGetter");
|
|
6
|
+
const useFundingRates = () => {
|
|
7
|
+
const { data } = (0, useQuery_1.useQuery)(`/v1/public/funding_rates`, {
|
|
8
|
+
focusThrottleInterval: 1000 * 60 * 60 * 24,
|
|
9
|
+
revalidateOnFocus: false,
|
|
10
|
+
formatter(data) {
|
|
11
|
+
if (!data?.rows || !data?.rows?.length) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
const obj = Object.create(null);
|
|
15
|
+
for (let index = 0; index < data.rows.length; index++) {
|
|
16
|
+
const item = data.rows[index];
|
|
17
|
+
obj[item.symbol] = item;
|
|
18
|
+
}
|
|
19
|
+
return obj;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
return (0, createGetter_1.createGetter)(data);
|
|
24
|
+
};
|
|
25
|
+
exports.useFundingRates = useFundingRates;
|