@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,64 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { useHoldingStream } from "./useHoldingStream";
|
|
3
|
+
import { useCollateral } from "./useCollateral";
|
|
4
|
+
import { useAccount } from "../useAccount";
|
|
5
|
+
export const useWithdraw = () => {
|
|
6
|
+
const { account, state } = useAccount();
|
|
7
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
+
const { unsettledPnL, availableBalance, freeCollateral } = useCollateral();
|
|
9
|
+
// const withdrawQueue = useRef<number[]>([]);
|
|
10
|
+
const withdraw = useCallback((inputs) => {
|
|
11
|
+
return account.assetsManager.withdraw(inputs).then((res) => {
|
|
12
|
+
// if (res.success) {
|
|
13
|
+
// withdrawQueue.current.push(res.data.withdraw_id);
|
|
14
|
+
// }
|
|
15
|
+
return res;
|
|
16
|
+
});
|
|
17
|
+
}, [state]);
|
|
18
|
+
const { usdc } = useHoldingStream();
|
|
19
|
+
// useEffect(() => {
|
|
20
|
+
// const unsubscribe = ws.privateSubscribe(
|
|
21
|
+
// {
|
|
22
|
+
// id: "wallet",
|
|
23
|
+
// event: "subscribe",
|
|
24
|
+
// topic: "wallet",
|
|
25
|
+
// ts: Date.now(),
|
|
26
|
+
// },
|
|
27
|
+
// {
|
|
28
|
+
// onMessage: (data: any) => {
|
|
29
|
+
// //
|
|
30
|
+
// const { id } = data;
|
|
31
|
+
// if (withdrawQueue.current.includes(id)) {
|
|
32
|
+
// withdrawQueue.current = withdrawQueue.current.filter(
|
|
33
|
+
// (item) => item !== id
|
|
34
|
+
// );
|
|
35
|
+
// ee.emit("withdraw:success", data);
|
|
36
|
+
// }
|
|
37
|
+
// },
|
|
38
|
+
// }
|
|
39
|
+
// );
|
|
40
|
+
// return () => unsubscribe();
|
|
41
|
+
// }, []);
|
|
42
|
+
const maxAmount = useMemo(() => {
|
|
43
|
+
// if (!usdc || !usdc.holding) return 0;
|
|
44
|
+
// if (unsettledPnL >= 0) return usdc?.holding ?? 0;
|
|
45
|
+
// return new Decimal(usdc.holding).add(unsettledPnL).toNumber();
|
|
46
|
+
return freeCollateral;
|
|
47
|
+
}, [freeCollateral]);
|
|
48
|
+
const availableWithdraw = useMemo(() => {
|
|
49
|
+
if (unsettledPnL < 0) {
|
|
50
|
+
return freeCollateral;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return freeCollateral - unsettledPnL;
|
|
54
|
+
}
|
|
55
|
+
}, [freeCollateral, unsettledPnL]);
|
|
56
|
+
return {
|
|
57
|
+
withdraw,
|
|
58
|
+
isLoading,
|
|
59
|
+
maxAmount,
|
|
60
|
+
availableBalance,
|
|
61
|
+
availableWithdraw,
|
|
62
|
+
unsettledPnL,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ConfigStore, type OrderlyKeyStore, type getWalletAdapterFunc } from "@orderly.network/core";
|
|
3
|
+
import { NetworkId } from "@orderly.network/types";
|
|
4
|
+
export interface OrderlyConfigContextState {
|
|
5
|
+
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
6
|
+
configStore: ConfigStore;
|
|
7
|
+
keyStore: OrderlyKeyStore;
|
|
8
|
+
getWalletAdapter: getWalletAdapterFunc;
|
|
9
|
+
networkId: NetworkId;
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
onlyTestnet?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const OrderlyContext: import("react").Context<OrderlyConfigContextState>;
|
|
16
|
+
export declare const OrderlyProvider: import("react").Provider<OrderlyConfigContextState>;
|
|
17
|
+
//# sourceMappingURL=orderlyContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderlyContext.d.ts","sourceRoot":"","sources":["../src/orderlyContext.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAE3D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,eAAe,CAAC;IAC1B,gBAAgB,EAAE,oBAAoB,CAAC;IAEvC,SAAS,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CAEvB;AAED,eAAO,MAAM,cAAc,oDAEI,CAAC;AAEhC,eAAO,MAAM,eAAe,qDAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataCenter.d.ts","sourceRoot":"","sources":["../../src/services/dataCenter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventEmitter } from "@orderly.network/core";
|
|
2
|
+
class DataCenter extends EventEmitter {
|
|
3
|
+
constructor() {
|
|
4
|
+
super();
|
|
5
|
+
this.observe = (key, callback) => {
|
|
6
|
+
// merge data
|
|
7
|
+
this.on(key, callback);
|
|
8
|
+
};
|
|
9
|
+
this.unobserve = (key, callback) => {
|
|
10
|
+
this.off(key, callback);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BasePaint, type drawOptions } from "./basePaint";
|
|
2
|
+
export declare class BackgroundPaint extends BasePaint {
|
|
3
|
+
private img;
|
|
4
|
+
draw(options: drawOptions): Promise<void>;
|
|
5
|
+
_drawColor(options: drawOptions): void;
|
|
6
|
+
_drawImage(options: drawOptions): Promise<void>;
|
|
7
|
+
private loadImg;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=backgroundPaint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backgroundPaint.d.ts","sourceRoot":"","sources":["../../../src/services/painter/backgroundPaint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,OAAO,CAAC,GAAG,CAAiC;IAEtC,IAAI,CAAC,OAAO,EAAE,WAAW;IAa/B,UAAU,CAAC,OAAO,EAAE,WAAW;IAWzB,UAAU,CAAC,OAAO,EAAE,WAAW;IAarC,OAAO,CAAC,OAAO;CAahB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BasePaint } from "./basePaint";
|
|
2
|
+
export class BackgroundPaint extends BasePaint {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.img = null;
|
|
6
|
+
}
|
|
7
|
+
async draw(options) {
|
|
8
|
+
console.log("BackgroundPaint draw: ", options.backgroundColor);
|
|
9
|
+
if (typeof options.backgroundImg !== "undefined" &&
|
|
10
|
+
options.backgroundImg !== "") {
|
|
11
|
+
return this._drawImage(options);
|
|
12
|
+
}
|
|
13
|
+
else if (typeof options.backgroundColor !== "undefined") {
|
|
14
|
+
return this._drawColor(options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
_drawColor(options) {
|
|
18
|
+
console.log("graw background color", options);
|
|
19
|
+
this.ctx.fillStyle = options.backgroundColor || "black";
|
|
20
|
+
this.ctx.fillRect(0, 0, this.painter.width * this.painter.ratio, this.painter.height * this.painter.ratio);
|
|
21
|
+
}
|
|
22
|
+
async _drawImage(options) {
|
|
23
|
+
return this.loadImg(options.backgroundImg).then((img) => {
|
|
24
|
+
this.img = img;
|
|
25
|
+
this.ctx.drawImage(this.img, 0, 0, this.painter.width * this.painter.ratio, this.painter.height * this.painter.ratio);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
loadImg(url) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const img = new Image();
|
|
31
|
+
img.crossOrigin = "anonymous";
|
|
32
|
+
img.onload = () => {
|
|
33
|
+
resolve(img);
|
|
34
|
+
};
|
|
35
|
+
img.onerror = (e) => {
|
|
36
|
+
reject(e);
|
|
37
|
+
};
|
|
38
|
+
img.src = url;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { PosterPainter } from "./painter";
|
|
2
|
+
export type posterDataSource = {
|
|
3
|
+
message?: string;
|
|
4
|
+
position: {
|
|
5
|
+
symbol: string;
|
|
6
|
+
side: "LONG" | "SHORT";
|
|
7
|
+
/**
|
|
8
|
+
* The leverage of the position
|
|
9
|
+
*/
|
|
10
|
+
leverage: number;
|
|
11
|
+
/**
|
|
12
|
+
* The unrealized PnL of the position
|
|
13
|
+
*/
|
|
14
|
+
pnl: number;
|
|
15
|
+
/**
|
|
16
|
+
* The return on investment of the position
|
|
17
|
+
*/
|
|
18
|
+
ROI: number;
|
|
19
|
+
/**
|
|
20
|
+
* The informations of the position, such as open price, opened at, mark price, quantity
|
|
21
|
+
*/
|
|
22
|
+
informations: {
|
|
23
|
+
title: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* The quote currency of the position
|
|
28
|
+
*/
|
|
29
|
+
currency: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The domain of the application
|
|
33
|
+
*/
|
|
34
|
+
domain: string;
|
|
35
|
+
/**
|
|
36
|
+
* The update time of the position
|
|
37
|
+
*/
|
|
38
|
+
updateTime: string;
|
|
39
|
+
};
|
|
40
|
+
export type layoutInfo = {
|
|
41
|
+
width?: number;
|
|
42
|
+
height?: number;
|
|
43
|
+
fontSize?: number;
|
|
44
|
+
color?: string;
|
|
45
|
+
textAlign?: CanvasTextAlign;
|
|
46
|
+
textBaseline?: CanvasTextBaseline;
|
|
47
|
+
position: Partial<{
|
|
48
|
+
left: number;
|
|
49
|
+
right: number;
|
|
50
|
+
top: number;
|
|
51
|
+
bottom: number;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
export type posterLayoutConfig = {
|
|
55
|
+
message?: layoutInfo;
|
|
56
|
+
domain?: layoutInfo;
|
|
57
|
+
position?: layoutInfo;
|
|
58
|
+
unrealizedPnl?: layoutInfo;
|
|
59
|
+
informations?: layoutInfo;
|
|
60
|
+
updateTime?: layoutInfo;
|
|
61
|
+
};
|
|
62
|
+
export type drawOptions = {
|
|
63
|
+
/**
|
|
64
|
+
* Color of common text
|
|
65
|
+
*/
|
|
66
|
+
color?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Lose color
|
|
69
|
+
*/
|
|
70
|
+
loseColor?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Profit color
|
|
73
|
+
*/
|
|
74
|
+
profitColor?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The brand color of the application
|
|
77
|
+
*/
|
|
78
|
+
brandColor?: string;
|
|
79
|
+
backgroundColor?: string;
|
|
80
|
+
backgroundImg?: string;
|
|
81
|
+
data?: posterDataSource;
|
|
82
|
+
layout?: posterLayoutConfig;
|
|
83
|
+
};
|
|
84
|
+
export declare abstract class BasePaint {
|
|
85
|
+
protected ctx: CanvasRenderingContext2D;
|
|
86
|
+
protected painter: PosterPainter;
|
|
87
|
+
constructor(ctx: CanvasRenderingContext2D, painter: PosterPainter);
|
|
88
|
+
abstract draw(options: drawOptions): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=basePaint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basePaint.d.ts","sourceRoot":"","sources":["../../../src/services/painter/basePaint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QAEf,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACvB;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB;;WAEG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;WAEG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;WAEG;QACH,YAAY,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACjD;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,UAAU,CAAC;IAErB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,aAAa,CAAC,EAAE,UAAU,CAAC;IAE3B,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,8BAAsB,SAAS;IAE3B,SAAS,CAAC,GAAG,EAAE,wBAAwB;IACvC,SAAS,CAAC,OAAO,EAAE,aAAa;gBADtB,GAAG,EAAE,wBAAwB,EAC7B,OAAO,EAAE,aAAa;IAElC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CACnD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BasePaint, drawOptions } from "./basePaint";
|
|
2
|
+
export declare class DataPaint extends BasePaint {
|
|
3
|
+
private positionInfoCellWidth;
|
|
4
|
+
private DEFAULT_PROFIT_COLOR;
|
|
5
|
+
private DEFAULT_LOSE_COLOR;
|
|
6
|
+
draw(options: drawOptions): Promise<void>;
|
|
7
|
+
private drawMessage;
|
|
8
|
+
private drawPosition;
|
|
9
|
+
private drawUnrealizedPnL;
|
|
10
|
+
private drawInformations;
|
|
11
|
+
private drawDomainUrl;
|
|
12
|
+
private drawPositionTime;
|
|
13
|
+
private _drawText;
|
|
14
|
+
private _ratio;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dataPaint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataPaint.d.ts","sourceRoot":"","sources":["../../../src/services/painter/dataPaint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAGjE,qBAAa,SAAU,SAAQ,SAAS;IACtC,OAAO,CAAC,qBAAqB,CAAO;IAEpC,OAAO,CAAC,oBAAoB,CAAoB;IAChD,OAAO,CAAC,kBAAkB,CAAsB;IAE1C,IAAI,CAAC,OAAO,EAAE,WAAW;IA0B/B,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,YAAY;IAoEpB,OAAO,CAAC,iBAAiB;IAoDzB,OAAO,CAAC,gBAAgB;IA6BxB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,SAAS;IAoCjB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { commify } from "@orderly.network/utils";
|
|
2
|
+
import { BasePaint } from "./basePaint";
|
|
3
|
+
import { path } from "ramda";
|
|
4
|
+
export class DataPaint extends BasePaint {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.positionInfoCellWidth = 100;
|
|
8
|
+
this.DEFAULT_PROFIT_COLOR = "rgb(0,181,159)";
|
|
9
|
+
this.DEFAULT_LOSE_COLOR = "rgb(255,103,194)";
|
|
10
|
+
}
|
|
11
|
+
async draw(options) {
|
|
12
|
+
console.log("DataPaint draw: ", options.data);
|
|
13
|
+
if (!!options.data?.message) {
|
|
14
|
+
this.drawMessage(options);
|
|
15
|
+
}
|
|
16
|
+
if (!!options.data?.position) {
|
|
17
|
+
this.drawPosition(options);
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(options.data?.position?.informations)) {
|
|
20
|
+
this.drawInformations(options);
|
|
21
|
+
}
|
|
22
|
+
this.drawUnrealizedPnL(options);
|
|
23
|
+
if (!!options.data?.domain) {
|
|
24
|
+
this.drawDomainUrl(options);
|
|
25
|
+
}
|
|
26
|
+
if (typeof options.data?.updateTime !== "undefined") {
|
|
27
|
+
this.drawPositionTime(options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
drawMessage(options) {
|
|
31
|
+
// console.log("draw message", options);
|
|
32
|
+
const layout = path(["layout", "message"], options);
|
|
33
|
+
const { position } = layout;
|
|
34
|
+
this._drawText(`"${options.data?.message}"`, {
|
|
35
|
+
color: layout.color,
|
|
36
|
+
fontSize: this._ratio(layout.fontSize),
|
|
37
|
+
top: this._ratio(position.top),
|
|
38
|
+
left: this._ratio(position.left),
|
|
39
|
+
textBaseline: "top",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
drawPosition(options) {
|
|
43
|
+
const layout = path(["layout", "position"], options);
|
|
44
|
+
const { position } = layout;
|
|
45
|
+
let left = this._ratio(position.left);
|
|
46
|
+
let prevElementBoundingBox = {};
|
|
47
|
+
// draw position side;
|
|
48
|
+
if (typeof options.data?.position.side !== "undefined") {
|
|
49
|
+
prevElementBoundingBox = this._drawText(options.data.position.side, {
|
|
50
|
+
color: options.data?.position.side === "LONG"
|
|
51
|
+
? this.DEFAULT_PROFIT_COLOR
|
|
52
|
+
: this.DEFAULT_LOSE_COLOR,
|
|
53
|
+
left,
|
|
54
|
+
top: this._ratio(70),
|
|
55
|
+
fontSize: this._ratio(14),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (typeof options.data?.position.symbol !== "undefined") {
|
|
59
|
+
left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
|
|
60
|
+
if (prevElementBoundingBox.width) {
|
|
61
|
+
prevElementBoundingBox = this._drawText("|", {
|
|
62
|
+
color: "rgba(255,255,255,0.2)",
|
|
63
|
+
left,
|
|
64
|
+
top: this._ratio(70),
|
|
65
|
+
fontSize: this._ratio(12),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
|
|
69
|
+
prevElementBoundingBox = this._drawText(options.data?.position.symbol, {
|
|
70
|
+
color: "rgba(255,255,255,0.98)",
|
|
71
|
+
left: left,
|
|
72
|
+
top: this._ratio(70),
|
|
73
|
+
fontSize: this._ratio(12),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (typeof options.data?.position.leverage !== "undefined") {
|
|
77
|
+
left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
|
|
78
|
+
if (prevElementBoundingBox.width) {
|
|
79
|
+
prevElementBoundingBox = this._drawText("|", {
|
|
80
|
+
color: "rgba(255,255,255,0.2)",
|
|
81
|
+
left,
|
|
82
|
+
top: this._ratio(70),
|
|
83
|
+
fontSize: this._ratio(12),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
|
|
87
|
+
prevElementBoundingBox = this._drawText(`${options.data?.position.leverage}X`, {
|
|
88
|
+
color: "rgba(255,255,255,0.98)",
|
|
89
|
+
left,
|
|
90
|
+
top: this._ratio(70),
|
|
91
|
+
fontSize: this._ratio(12),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
drawUnrealizedPnL(options) {
|
|
96
|
+
// reset left value;
|
|
97
|
+
const layout = path(["layout", "unrealizedPnl"], options);
|
|
98
|
+
const { position } = layout;
|
|
99
|
+
let left = this._ratio(position.left);
|
|
100
|
+
let prevElementBoundingBox = {};
|
|
101
|
+
// ROI
|
|
102
|
+
if (typeof options.data?.position.ROI !== "undefined") {
|
|
103
|
+
const prefix = options.data?.position.ROI > 0 ? "+" : "";
|
|
104
|
+
prevElementBoundingBox = this._drawText(`${prefix}${commify(options.data?.position.ROI)}%`, {
|
|
105
|
+
color: prefix === "+"
|
|
106
|
+
? options.profitColor || this.DEFAULT_PROFIT_COLOR
|
|
107
|
+
: options.loseColor || this.DEFAULT_LOSE_COLOR,
|
|
108
|
+
left,
|
|
109
|
+
top: this._ratio(position.top),
|
|
110
|
+
fontSize: this._ratio(layout.fontSize),
|
|
111
|
+
fontWeight: 700,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// unrelPnL
|
|
115
|
+
if (typeof options.data?.position.pnl !== "undefined") {
|
|
116
|
+
const prefix = options.data?.position.pnl > 0 ? "+" : "";
|
|
117
|
+
let text = `${prefix}${commify(options.data?.position.pnl)} ${options.data?.position.currency}`;
|
|
118
|
+
if (prevElementBoundingBox.width) {
|
|
119
|
+
left += (prevElementBoundingBox.width ?? 0) + this._ratio(8);
|
|
120
|
+
text = `(${text})`;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
left = this._ratio(position.left);
|
|
124
|
+
}
|
|
125
|
+
prevElementBoundingBox = this._drawText(text, {
|
|
126
|
+
color: "rgba(255,255,255,0.5)",
|
|
127
|
+
left,
|
|
128
|
+
top: this._ratio(position.top),
|
|
129
|
+
fontSize: this._ratio(layout.fontSize * 0.6),
|
|
130
|
+
fontWeight: 600,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
drawInformations(options) {
|
|
135
|
+
const layout = path(["layout", "informations"], options);
|
|
136
|
+
const { position } = layout;
|
|
137
|
+
options.data?.position.informations.forEach((info, index) => {
|
|
138
|
+
const left = position.left + this.positionInfoCellWidth * (index % 2);
|
|
139
|
+
const top = position.top + Math.floor(index / 2) * 40;
|
|
140
|
+
this._drawText(info.title, {
|
|
141
|
+
left: this._ratio(left),
|
|
142
|
+
top: this._ratio(top),
|
|
143
|
+
fontSize: this._ratio(10),
|
|
144
|
+
color: "rgba(255,255,255,0.2)",
|
|
145
|
+
});
|
|
146
|
+
this._drawText(info.value, {
|
|
147
|
+
left: this._ratio(position.left + this.positionInfoCellWidth * (index % 2)),
|
|
148
|
+
top: this._ratio(top + 17),
|
|
149
|
+
fontSize: this._ratio(layout.fontSize),
|
|
150
|
+
fontWeight: 500,
|
|
151
|
+
color: layout.color,
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
drawDomainUrl(options) {
|
|
156
|
+
const layout = path(["layout", "domain"], options);
|
|
157
|
+
const { position } = layout;
|
|
158
|
+
const top = this.painter.height - position.bottom;
|
|
159
|
+
this._drawText(options.data?.domain, {
|
|
160
|
+
left: this._ratio(position.left),
|
|
161
|
+
top: this._ratio(top),
|
|
162
|
+
fontSize: this._ratio(layout.fontSize),
|
|
163
|
+
color: options.brandColor ?? this.DEFAULT_PROFIT_COLOR,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
drawPositionTime(options) {
|
|
167
|
+
const layout = path(["layout", "updateTime"], options);
|
|
168
|
+
const { position } = layout;
|
|
169
|
+
const top = this.painter.height - position.bottom;
|
|
170
|
+
const left = this.painter.width - position.right;
|
|
171
|
+
this._drawText(options.data?.updateTime, {
|
|
172
|
+
left: this._ratio(left),
|
|
173
|
+
top: this._ratio(top),
|
|
174
|
+
fontSize: this._ratio(layout.fontSize),
|
|
175
|
+
color: layout.color,
|
|
176
|
+
textAlign: "end",
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
_drawText(str, options) {
|
|
180
|
+
let boundingBox;
|
|
181
|
+
const { left = 30, top = 30, fontSize = 13, fontWeight = 500, color = "black", textBaseline = "middle", textAlign = "start", } = options ?? {};
|
|
182
|
+
this.ctx.save();
|
|
183
|
+
this.ctx.font = `${fontWeight} ${fontSize}px Manrope`;
|
|
184
|
+
this.ctx.fillStyle = color;
|
|
185
|
+
this.ctx.textBaseline = textBaseline;
|
|
186
|
+
this.ctx.textAlign = textAlign;
|
|
187
|
+
boundingBox = this.ctx.measureText(str);
|
|
188
|
+
this.ctx.fillText(str, left, top);
|
|
189
|
+
this.ctx.restore();
|
|
190
|
+
return boundingBox;
|
|
191
|
+
}
|
|
192
|
+
_ratio(num) {
|
|
193
|
+
return num * this.painter.ratio;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.config.d.ts","sourceRoot":"","sources":["../../../src/services/painter/layout.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE7D,eAAO,MAAM,mBAAmB,EAAE,kBAoDjC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const defaultLayoutConfig = {
|
|
2
|
+
domain: {
|
|
3
|
+
fontSize: 13,
|
|
4
|
+
// color: undefined,
|
|
5
|
+
position: {
|
|
6
|
+
left: 20,
|
|
7
|
+
bottom: 37,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
message: {
|
|
11
|
+
fontSize: 20,
|
|
12
|
+
color: "white",
|
|
13
|
+
textBaseline: "top",
|
|
14
|
+
position: {
|
|
15
|
+
left: 20,
|
|
16
|
+
top: 16,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
position: {
|
|
20
|
+
fontSize: 20,
|
|
21
|
+
color: "white",
|
|
22
|
+
position: {
|
|
23
|
+
left: 20,
|
|
24
|
+
top: 70,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
unrealizedPnl: {
|
|
28
|
+
fontSize: 36,
|
|
29
|
+
color: "rgba(255,255,255,0.5)",
|
|
30
|
+
position: {
|
|
31
|
+
left: 20,
|
|
32
|
+
top: 110,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
informations: {
|
|
36
|
+
fontSize: 12,
|
|
37
|
+
color: "rgba(255,255,255,0.54)",
|
|
38
|
+
position: {
|
|
39
|
+
left: 20,
|
|
40
|
+
top: 150,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
updateTime: {
|
|
44
|
+
fontSize: 10,
|
|
45
|
+
color: "rgba(255,255,255,0.5)",
|
|
46
|
+
textAlign: "end",
|
|
47
|
+
position: {
|
|
48
|
+
right: 15,
|
|
49
|
+
bottom: 15,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { drawOptions } from "./basePaint";
|
|
2
|
+
export declare class PosterPainter {
|
|
3
|
+
private canvas;
|
|
4
|
+
private ctx;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
ratio: number;
|
|
8
|
+
constructor(canvas: HTMLCanvasElement);
|
|
9
|
+
draw(options: drawOptions): void;
|
|
10
|
+
_draw(options: drawOptions): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=painter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"painter.d.ts","sourceRoot":"","sources":["../../../src/services/painter/painter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,aAAa;IAMZ,OAAO,CAAC,MAAM;IAL1B,OAAO,CAAC,GAAG,CAA2B;IACtC,KAAK,EAAE,MAAM,CAAK;IAClB,MAAM,EAAE,MAAM,CAAK;IACnB,KAAK,EAAE,MAAM,CAAK;gBAEE,MAAM,EAAE,iBAAiB;IAqB7C,IAAI,CAAC,OAAO,EAAE,WAAW;IAInB,KAAK,CAAC,OAAO,EAAE,WAAW;CAUjC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BackgroundPaint } from "./backgroundPaint";
|
|
2
|
+
import { DataPaint } from "./dataPaint";
|
|
3
|
+
export class PosterPainter {
|
|
4
|
+
// resourceManager: Resource;
|
|
5
|
+
constructor(canvas) {
|
|
6
|
+
// console.log("PosterPainter constructor");
|
|
7
|
+
this.canvas = canvas;
|
|
8
|
+
this.width = 0;
|
|
9
|
+
this.height = 0;
|
|
10
|
+
this.ratio = 1;
|
|
11
|
+
this.ctx = this.canvas.getContext("2d");
|
|
12
|
+
this.width = this.canvas.width;
|
|
13
|
+
this.height = this.canvas.height;
|
|
14
|
+
this.ratio = Math.floor(window.devicePixelRatio) || 1;
|
|
15
|
+
console.log("this ratio", this.ratio);
|
|
16
|
+
// render to high resolution
|
|
17
|
+
this.canvas.width = this.width * this.ratio;
|
|
18
|
+
this.canvas.height = this.height * this.ratio;
|
|
19
|
+
this.canvas.style.width = this.width + "px";
|
|
20
|
+
this.canvas.style.height = this.height + "px";
|
|
21
|
+
//
|
|
22
|
+
}
|
|
23
|
+
draw(options) {
|
|
24
|
+
requestAnimationFrame(() => this._draw.bind(this)(options));
|
|
25
|
+
}
|
|
26
|
+
async _draw(options) {
|
|
27
|
+
if (this.ctx === null)
|
|
28
|
+
return;
|
|
29
|
+
console.log("============ DRAW ============");
|
|
30
|
+
// this.ctx.clearRect(0, 0, this.width * this.ratio, this.height * this.ratio);
|
|
31
|
+
// start draw
|
|
32
|
+
// background
|
|
33
|
+
await new BackgroundPaint(this.ctx, this).draw(options);
|
|
34
|
+
// data paint
|
|
35
|
+
await new DataPaint(this.ctx, this).draw(options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/services/painter/resource.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAa;;IAMrD,GAAG,CAAC,MAAM,EAAE,MAAM;IAIlB,IAAI,CAAC,MAAM,EAAE,MAAM;CAMpB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class Resource {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.sourceMap = new Map();
|
|
4
|
+
console.log("Resource constructor");
|
|
5
|
+
}
|
|
6
|
+
has(source) {
|
|
7
|
+
return this.sourceMap.has(source);
|
|
8
|
+
}
|
|
9
|
+
load(source) {
|
|
10
|
+
console.log("Resource load: ", source);
|
|
11
|
+
const img = new Image();
|
|
12
|
+
img.src = source;
|
|
13
|
+
this.sourceMap.set(source, img);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { type WsNetworkStatus } from "./useWsStatus";
|
|
3
|
+
export interface StatusContextState {
|
|
4
|
+
ws?: WsNetworkStatus;
|
|
5
|
+
}
|
|
6
|
+
export declare const StatusContext: import("react").Context<StatusContextState>;
|
|
7
|
+
export declare const StatusProvider: React.FC<PropsWithChildren>;
|
|
8
|
+
//# sourceMappingURL=statusProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusProvider.d.ts","sourceRoot":"","sources":["../src/statusProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AACzD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,eAAe,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,6CAA0C,CAAC;AAErE,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAQtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
import { useWsStatus } from "./useWsStatus";
|
|
4
|
+
export const StatusContext = createContext({});
|
|
5
|
+
export const StatusProvider = (props) => {
|
|
6
|
+
const wsStatus = useWsStatus();
|
|
7
|
+
return (_jsx(StatusContext.Provider, { value: { ws: wsStatus }, children: props.children }));
|
|
8
|
+
};
|