UNPKG

@orderly.network/ui-positions

Version:

291 lines (268 loc) 9.48 kB
import { OrderType, OrderSide, API } from '@orderly.network/types'; import React, { FC } from 'react'; import { PriceMode } from '@orderly.network/hooks'; import * as _orderly_network_ui from '@orderly.network/ui'; import { SortOrder, TableSort } from '@orderly.network/ui'; import { SharePnLConfig } from '@orderly.network/ui-share'; interface PositionsRowContextState { quantity: string; price: string; type: OrderType; side: OrderSide; position: API.PositionExt | API.PositionTPSLExt; updateQuantity: (value: string) => void; updatePriceChange: (value: string) => void; updateOrderType: (value: OrderType) => void; closeOrderData: any; onSubmit: () => Promise<any>; submitting: boolean; tpslOrder?: API.AlgoOrder; partialTPSLOrder?: API.AlgoOrder; quoteDp?: number; baseDp?: number; baseTick?: number; errors: any | undefined; } declare const usePositionsRowContext: () => PositionsRowContextState; declare const FundingFeeHistoryUI: FC<{ total: number; symbol: string; start_t: string; end_t: string; }>; declare const FundingFeeButton: FC<{ fee: number; symbol: string; start_t: string; end_t: string; }>; type SortType = { sortKey: string; sortOrder: SortOrder; }; type PositionsProps = { pnlNotionalDecimalPrecision?: number; sharePnLConfig?: SharePnLConfig; symbol?: string; calcMode?: PriceMode; includedPendingOrder?: boolean; selectedAccount?: string; onSymbolChange?: (symbol: API.Symbol) => void; enableSortingStorage?: boolean; }; declare const PositionsWidget: React.FC<PositionsProps>; declare const MobilePositionsWidget: React.FC<PositionsProps>; declare const CombinePositionsWidget: React.FC<PositionsProps>; declare enum PositionsTabName { Positions = "positions", PositionHistory = "positionHistory" } declare function useTabSort(options: { storageKey: string; }): { tabSort: Record<PositionsTabName, SortType>; onTabSort: (type: PositionsTabName) => (sort?: SortType) => void; }; declare function sortList(list: any[], sort?: SortType): any[]; declare function useSort(initialSort?: SortType, onSortChange?: (sort?: SortType) => void): { sort: SortType | undefined; onSort: (options?: TableSort) => void; getSortedList: (list: any[]) => any[]; }; type PositionHistoryProps$1 = { onSymbolChange?: (symbol: API.Symbol) => void; symbol?: string; pnlNotionalDecimalPrecision?: number; sharePnLConfig?: SharePnLConfig; enableSortingStorage?: boolean; }; declare const PositionHistoryWidget: React.FC<PositionHistoryProps$1>; declare const MobilePositionHistoryWidget: React.FC<PositionHistoryProps$1 & { classNames?: { root?: string; content?: string; cell?: string; }; }>; declare const usePositionHistoryScript: (props: PositionHistoryProps$1) => { dataSource: any[]; isLoading: boolean; onSymbolChange: ((symbol: API.Symbol) => void) | undefined; pagination: _orderly_network_ui.PaginationMeta; filterItems: any[]; onFilter: (filter: { name: string; value: any; }) => void; symbol: string | undefined; filterDays: 1 | 7 | 30 | 90 | null; updateFilterDays: (days: 1 | 7 | 30 | 90) => void; pnlNotionalDecimalPrecision: number | undefined; onSort: (options?: _orderly_network_ui.TableSort) => void; initialSort: SortType | undefined; }; type PositionHistoryState = ReturnType<typeof usePositionHistoryScript>; type PositionHistoryProps = PositionHistoryState & { sharePnLConfig?: SharePnLConfig; }; declare const PositionHistory: FC<PositionHistoryProps>; declare const MobilePositionHistory: FC<PositionHistoryState & { classNames?: { root?: string; content?: string; cell?: string; }; sharePnLConfig?: SharePnLConfig; }>; type LiquidationProps = { symbol?: string; enableLoadMore?: boolean; }; declare const LiquidationWidget: React.FC<LiquidationProps>; declare const MobileLiquidationWidget: React.FC<LiquidationProps & { classNames?: { root?: string; content?: string; cell?: string; }; }>; declare const useLiquidationScript: (props: LiquidationProps) => { dataSource: any[] | null | undefined; isLoading: boolean; loadMore: () => void; pagination: _orderly_network_ui.PaginationMeta; dateRange: { from?: Date; to?: Date; }; filterDays: 1 | 7 | 30 | 90 | null; updateFilterDays: (days: 1 | 7 | 30 | 90) => void; filterItems: any[]; onFilter: (filter: { name: string; value: any; }) => void; }; type LiquidationState = ReturnType<typeof useLiquidationScript>; declare const Liquidation: FC<LiquidationState>; declare const MobileLiquidation: FC<LiquidationState & { classNames?: { root?: string; content?: string; cell?: string; }; }>; interface UseCloseAllPositionsScriptOptions { symbol?: string; onSuccess?: () => void; } declare const useCloseAllPositionsScript: (options?: UseCloseAllPositionsScriptOptions) => { onCloseAll: () => void; hasOpenPositions: boolean; isClosing: boolean; openPositionsCount: number; symbol: string | undefined; }; type CloseAllPositionsState = ReturnType<typeof useCloseAllPositionsScript>; type CloseAllPositionsProps = CloseAllPositionsState & { className?: string; style?: React.CSSProperties; }; declare const CloseAllPositions: FC<CloseAllPositionsProps>; type CloseAllPositionsWidgetProps = Pick<CloseAllPositionsProps, "className" | "style"> & { symbol?: string; onSuccess?: () => void; }; declare const CloseAllPositionsWidget: React.FC<CloseAllPositionsWidgetProps>; interface UseReversePositionScriptOptions { position: API.PositionExt | API.PositionTPSLExt; onSuccess?: () => void; onError?: (error: any) => void; calcMode?: "markPrice" | "lastPrice"; } type ReversePositionValidationError = "belowMin" | null; /** * Hook for managing reverse position enabled state * Separates desktop and mobile preferences internally */ declare const useReversePositionEnabled: () => { isEnabled: any; setEnabled: (enabled: boolean) => void; }; declare const useReversePositionScript: (options?: UseReversePositionScriptOptions) => { isEnabled: any; setEnabled: (enabled: boolean) => void; reversePosition: () => Promise<boolean>; isReversing: boolean; displayInfo: { symbol: string; base: string; quote: string; baseDp: number; quoteDp: number; positionQty: string; reverseQty: string; markPrice: string; leverage: number; isLong: boolean; unrealizedPnL: number | undefined; pnlNotionalDecimalPrecision: any; } | null; positionQty: number; reverseQty: number; isLong: boolean; validationError: ReversePositionValidationError; splitOrders: { needsSplit: boolean; orders: { symbol: string; order_type: OrderType; side: OrderSide; order_quantity: string; reduce_only: boolean; }[]; }; }; type ReversePositionState = ReturnType<typeof useReversePositionScript>; type ReversePositionProps = ReversePositionState & { className?: string; style?: React.CSSProperties; onConfirm?: () => Promise<void>; onCancel?: () => void; }; declare const ReversePosition: FC<ReversePositionProps>; type ReversePositionWidgetProps = { position: API.PositionExt | API.PositionTPSLExt; close?: () => void; resolve?: (value?: any) => void; reject?: (reason?: any) => void; }; declare const ReversePositionWidget: React.FC<ReversePositionWidgetProps>; declare const ReversePositionDialogId = "ReversePositionDialogId"; interface OrderInfoCardProps { /** Order title */ title: string; /** Order side */ side: OrderSide; /** Leverage multiplier */ leverage: number; /** Quantity */ qty: string; /** Base decimal places */ baseDp: number; /** Price label, defaults to "Market" */ estLiqPrice?: React.ReactNode; /** Estimated PnL value */ estPnL?: string; /** PnL decimal precision */ pnlNotionalDecimalPrecision?: number; /** Custom class name */ className?: string; } /** * Order info card component * Displays detailed order information including title, side, leverage, quantity, and price */ declare const OrderInfoCard: FC<OrderInfoCardProps>; declare const MarketCloseConfirmID = "MarketCloseConfirmID"; export { CloseAllPositions, type CloseAllPositionsProps, type CloseAllPositionsState, CloseAllPositionsWidget, CombinePositionsWidget, FundingFeeButton, FundingFeeHistoryUI, Liquidation, LiquidationWidget, MarketCloseConfirmID, MobileLiquidation, MobileLiquidationWidget, MobilePositionHistory, MobilePositionHistoryWidget, MobilePositionsWidget, OrderInfoCard, type OrderInfoCardProps, PositionHistory, PositionHistoryWidget, type PositionsProps, PositionsTabName, PositionsWidget, ReversePosition, ReversePositionDialogId, type ReversePositionProps, type ReversePositionState, ReversePositionWidget, type ReversePositionWidgetProps, type SortType, sortList, useCloseAllPositionsScript, useLiquidationScript, usePositionHistoryScript, usePositionsRowContext, useReversePositionEnabled, useReversePositionScript, useSort, useTabSort };