@kodiak-finance/orderly-ui-orders 2.8.18 → 2.8.19-rc.0
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5924 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5928 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/orders.script.ts","../src/utils/util.ts","../src/components/provider/symbolContext.tsx","../src/components/provider/symbolProvider.tsx","../src/components/shareButton/shareButton.ui.tsx","../src/components/shareButton/shareButton.script.tsx","../src/components/shareButton/shareButton.widget.tsx","../src/components/shareButton/index.ts","../src/components/orderList/desktop/avgPrice.tsx","../src/components/orderList/desktop/bracketOrderPrice.tsx","../src/components/orderList/orderListContext.tsx","../src/components/orderList/desktop/cancelBtn.tsx","../src/type.ts","../src/components/orderList/desktop/editOrder/confirmContent.tsx","../src/components/orderList/desktop/hooks/usePopoverState.ts","../src/components/orderList/desktop/hooks/useValidateField.ts","../src/components/orderList/desktop/components/editableCellInput.tsx","../src/components/orderList/desktop/components/previewCell.tsx","../src/components/orderList/desktop/components/activedPriceCell.tsx","../src/components/orderList/desktop/components/priceCell.tsx","../src/components/orderList/tpslOrderRowContext.tsx","../src/components/orderList/desktop/editOrder/innerInput.tsx","../src/components/orderList/desktop/components/quantityCell.tsx","../src/components/orderList/desktop/components/trailingCallbackCell.tsx","../src/components/orderList/desktop/components/triggerPriceCell.tsx","../src/components/orderList/desktop/renew.tsx","../src/components/orderList/desktop/tpslEdit.tsx","../src/components/orderList/desktop/tpslPrice.tsx","../src/components/orderList/desktop/tpslTriggerPrice.tsx","../src/components/orderList/desktop/useColumn.tsx","../src/components/orderList/mobile/items.tsx","../src/components/orderList/mobile/bracketOrderPrice/bracketOrderPrice.ui.tsx","../src/components/orderList/mobile/bracketOrderPrice/bracketOrderPrice.script.tsx","../src/components/orderList/mobile/bracketOrderPrice/bracketOrderPrice.widget.tsx","../src/components/orderList/mobile/bracketOrderPrice/index.ts","../src/components/orderList/mobile/cancelBtn/cancelBtn.ui.tsx","../src/components/orderList/mobile/cancelBtn/cancelBtn.script.tsx","../src/components/orderList/mobile/cancelBtn/cancelBtn.widget.tsx","../src/components/orderList/mobile/cancelBtn/index.ts","../src/components/orderList/mobile/editBtn/editBtn.ui.tsx","../src/components/orderList/mobile/editSheet/components/editSheetContext.ts","../src/components/orderList/mobile/editSheet/components/activitedPriceInput.tsx","../src/components/orderList/mobile/editSheet/components/editDialogContent.tsx","../src/components/orderList/mobile/editSheet/components/editSheetHeader.tsx","../src/components/orderList/mobile/editSheet/components/priceInput.tsx","../src/components/orderList/mobile/editSheet/components/quantityInput.tsx","../src/components/orderList/mobile/editSheet/components/quantitySlider.tsx","../src/components/orderList/mobile/editSheet/components/trailingCallbackInput.tsx","../src/components/orderList/mobile/editSheet/components/triggerPriceInput.tsx","../src/components/orderList/mobile/editSheet/editSheet.ui.tsx","../src/components/orderList/mobile/editSheet/hooks/useEditOrderEntry.ts","../src/components/orderList/mobile/editSheet/hooks/useEditOrderMaxQty.ts","../src/components/orderList/mobile/editSheet/editSheet.script.tsx","../src/components/orderList/mobile/editSheet/editSheet.widget.tsx","../src/components/orderList/mobile/editSheet/index.ts","../src/components/orderList/mobile/editBtn/editBtn.script.tsx","../src/components/orderList/mobile/editBtn/editBtn.widget.tsx","../src/components/orderList/mobile/editBtn/index.ts","../src/components/orderList/mobile/orderCell.ui.tsx","../src/components/orderList/mobile/orderCell.script.tsx","../src/components/orderList/mobile/orderCell.widget.tsx","../src/components/orderList/mobile/index.ts","../src/components/orderList/orderListProvider.tsx","../src/components/orderList/orderList.ui.tsx","../src/components/orderList/useFormatOrderHistory.ts","../src/components/orderList/orderList.script.tsx","../src/components/orderList/orderList.widget.tsx","../src/components/orderList/index.ts","../src/components/orders.ui.tsx","../src/components/orders.widget.tsx","../src/index.ts"],"names":["useImperativeHandle","useRef","useOrdersScript","init_orders_script","__esmMin","props","current","pnlNotionalDecimalPrecision","sharePnLConfig","orderListRef","utils","i18n","OrderSide","AlgoOrderRootType","AlgoOrderType","OrderStatus","OrderType","Decimal","parseBadgesFor","record","orderType","algoType","list","types","type","upperCaseFirstLetter","tpOrder","order","slOrder","grayCell","getOrderStatus","isGrayCell","status","findBracketTPSLOrder","innerOrder","item","calcBracketRoiAndPnL","defaultCallback","quantity","tpPnL","slPnL","tpRoi","slRoi","areDatesEqual","date1","date2","isTrailingStopOrder","getNotional","dp","convertApiOrderTypeToOrderEntryType","init_util","str","createContext","useContext","SymbolContext","useSymbolContext","init_symbolContext","useMemo","useSymbolsInfo","jsx","SymbolProvider","init_symbolProvider","symbol","children","symbolInfo","memoizedValue","ShareIcon","ShareButton","init_shareButton_ui","e","useReferralInfo","useLeverageBySymbol","useTranslation","modal","useShareButtonScript","init_shareButton_script","iconSize","t","getFirstRefCode","refCode","leverage","ShareButtonWidget","init_shareButton_widget","state","init_shareButton","memo","Text","AvgPrice","init_avgPrice","info","Flex","Tooltip","cn","EditIcon","Fragment","jsxs","BracketOrderPrice","EditBracketOrder","Price","init_bracketOrderPrice","quote_dp","base_dp","sl_trigger_price","tp_trigger_price","pnl","roi","onEdit","value","OrderListContext","useOrderListContext","init_orderListContext","useState","ThrottledButton","toast","CancelButton","init_cancelBtn","onCancelOrder","isLoading","setIsLoading","event","res","error","init_type","Trans","Button","CloseIcon","commify","ConfirmContent","init_confirmContent","base","cancelPopover","isSubmitting","onConfirm","common","useCallback","useEffect","usePopoverState","originValue","setValue","open","setOpen","editing","setEditing","containerRef","closePopover","onClick","handleClickOutside","init_usePopoverState","useOrderEntity","useOrderEntryFormErrorMsg","useValidateField","field","fieldValues","changeFields","errors","validate","clearErrors","getErrorMsg","init_useValidateField","EMPTY_LIST","inputFormatter","Input","CheckIcon","EditableCellInput","init_editableCellInput","inputRef","handleKeyDown","input","length","commifyOptional","PreviewCell","init_previewCell","disabled","Popover","ActivedPriceCell","init_activedPriceCell","submitting","setSubmitting","editAlgoOrder","data","result","err","renderContent","PriceCell","init_priceCell","isAlgoOrder","editOrder","order_id","future","unstable_serialize","useAccount","useMemoizedFn","useMutation","useSWRConfig","findTPSLOrderPriceFromOrder","findTPSLFromOrder","calcTPSLPnL","position","isTPSLOrder","sl_order_price","tp_order_price","avgOpenPrice","TPSLOrderRowContext","useTPSLOrderRowContext","TPSLOrderRowProvider","init_tpslOrderRowContext","setPosition","doDeleteOrder","doUpdateOrder","config","positionKey","onUpdateOrder","params","getRelatedPosition","p","InnerInput","init_innerInput","onClose","onFocus","onBlur","hintInfo","useMaxQty","Slider","PopoverTrigger","PopoverRoot","PopoverContent","QuantityCell","EditState","Buttons","init_quantityCell","reduce_only","setError","checkMinNotional","onUpdateTPSLOrder","base_tick","setQuantity","qty","maxQty","positionQty","setIsSubmitting","clickHandler","price","notionalText","order_price","rest","componentRef","quantitySliderRef","executed","confirmOpen","maxBuyQty","sliderValue","setSliderValue","formatQuantity","_qty","values","index","TrailingCallbackCell","init_trailingCallbackCell","callback_value","callback_rate","isCallbackValue","isCallbackRate","suffix","formatters","TriggerPriceCell","init_triggerPriceCell","useConfig","Renew","init_renew","doCreateOrder","reset","isMutating","brokerId","onSubmit","PositionTPSLPopover","TP_SLEditButton","init_tpslEdit","useTPSLOrderPrice","tpTriggerPrice","slTriggerPrice","TPSLOrderPrice","TPSLOrderPriceItem","init_tpslPrice","quoteDP","OrderTriggerPrice","TPSLTriggerPrice","TriggerPriceItem","init_tpslTriggerPrice","direction","msgs","child","content","entryPrice","orderSide","label","format","Badge","SharePnLDialogId","getTrailingStopPrice","instrument","option","r1","r2","badges","displayBadges","showGray","side","sortOrder","clsName","fillAndQuantity","a","b","aQuantity","bQuantity","compareNumbers","tpslPrice","callback","avgPrice","triggerPrice","isPending","checkOrderType","isBracketOrder","tpslTriggerPrice","bracketOrderPrice","getTPSLTriggerPrice","estTotal","aTotal","bTotal","estTotalValue","realizedPnL","_value","formatValue","reduceOnly","hidden","orderTime","date","fee","tpslNotional","statusMap","avgOpen","cancelBtn","_","pendingTabCancelBtn","tpslAction","trailingCallback","useOrderColumn","init_useColumn","init_orders_widget","_type","onSymbolChange","symbolsInfo","Statistic","SharePnLBottomSheetId","SymbolToken","OrderTypeView","OrderTime","OrderState","Qty","Filled","EstTotal","TriggerPrice","MarkPrice","LimitPrice","TPTrigger","SLTrigger","TPPrice","SLPrice","TPSLQuantity","OrderPrice","RealizedPnL","MobileTooltip","Fee","TrailingCallback","TrailingPrice","init_items","isBuy","isEntirePosition","rendrerContent","isTrailingStop","isStopMarket","renderOrderPrice","classNames","init_bracketOrderPrice_ui","useBracketOrderPriceScript","init_bracketOrderPrice_script","BracketOrderPriceWidget","init_bracketOrderPrice_widget","CancelBtn","init_cancelBtn_ui","useCancelBtnScript","init_cancelBtn_script","CancelBtnWidget","init_cancelBtn_widget","EditBtn","init_editBtn_ui","useEditSheetContext","EditSheetContext","init_editSheetContext","ActivitedPriceInput","init_activitedPriceInput","activated_price","setOrderValue","quote","val","Checkbox","Divider","ConfirmDialogContent","init_editDialogContent","formattedOrder","showTriggerPrice","showPrice","showActivatedPrice","showTrailingCallback","header","triggerPriceItem","priceItem","activatedPriceItem","trailingCallbackItem","quantityItem","orderConfirmCheckbox","EditSheetHeader","init_editSheetHeader","PriceInput","init_priceInput","focus","setFocus","QuantityInput","init_quantityInput","formatQty","useThrottledCallback","QuantitySlider","init_quantitySlider","sliderToQuantity","newQty","percentages","TrailingCallbackInput","init_trailingCallbackInput","TriggerPriceInput","init_triggerPriceInput","SimpleDialog","EditSheet","init_editSheet_ui","lastPrice","triggerPriceInput","renderPriceInput","trailingCallbackInput","quantityInput","quantitySlider","buttons","ctxValue","useEditOrderEntry","init_useEditOrderEntry","setFormattedOrder","markPrice","key","oldValue","order_quantity","trigger_price","isChanged","useEditOrderMaxQty","init_useEditOrderMaxQty","useLocalStorage","useModal","useEditSheetScript","init_editSheet_script","dialogOpen","setDialogOpen","orderConfirm","setOrderConfirm","onCloseDialog","isHidden","EditSheetWidget","init_editSheet_widget","init_editSheet","PositionTPSLSheet","useEditBtnScript","init_editBtn_script","onShowEditSheet","EditBtnWidget","init_editBtn_widget","init_editBtn","Grid","itemsWithType","OrderCell","Header","Body","Btns","init_orderCell_ui","useOrderCellScript","init_orderCell_script","OrderCellWidget","init_orderCell_widget","className","init_mobile","getMinNotional","OrderListProvider","init_orderListProvider","cancelOrder","cancelAlgoOrder","min_notional","minNotional","ListView","Picker","DataFilter","TableFeatures","AuthGuardDataTable","DesktopOrderList","MobileOrderList","CancelAll","init_orderList_ui","columns","table","useFormatOrderHistory","init_useFormatOrderHistory","_data","element","j","differenceInDays","setHours","subDays","useOrderStream","useDataTap","usePagination","offsetStartOfDay","newDate","offsetEndOfDay","useOrderListScript","useFilter","formatDatePickerRange","init_orderList_script","ordersStatus","enableLoadMore","filterConfig","manualPagination","defaultPageSize","page","pageSize","setPage","pagination","parsePagination","orderStatus","ordersSide","dateRange","filterItems","onFilter","filterDays","updateFilterDays","includes","excludes","tableInstance","loadMore","updateOrder","updateAlgoOrder","cancelAllOrders","cancelAllTPSLOrders","meta","refresh","localPageSizeKey","typePageSize","setTypePageSize","onCancelAll","isTPSL","title","getContent","baseMessage","messageWithSymbol","formattedData","dataSource","_pagination","setOrderStatus","setOrdersSide","setFilterDays","defaultRange","setDateRange","days","filter","newDateRange","diffDays","sideFilter","dateRangeFilter","statusFilter","React","forwardRef","DesktopOrderListWidget","MobileOrderListWidget","init_orderList_widget","ref","testIds","orderList_exports","__export","init_orderList","TabPanel","Tabs","LazyDesktopOrderListWidget","Orders","init_orders_ui","mod","commonProps","TabType","OrdersWidget"],"mappings":"gIAAA,OAAuB,uBAAAA,GAAqB,UAAAC,OAAc,QAA1D,IAYaC,GAZbC,GAAAC,EAAA,kBAYaF,GAAmBG,GAAkC,CAChE,GAAM,CAAE,QAAAC,EAAS,4BAAAC,EAA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CACF,IC3BAwQ,KAIAxV,KAGA2kB","sourcesContent":["import { ForwardedRef, useImperativeHandle, useRef } from \"react\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { OrderListInstance } from \"./orderList/orderList.script\";\nimport { TabType } from \"./orders.widget\";\n\ntype UseOrdersScriptOptions = {\n current?: TabType;\n pnlNotionalDecimalPrecision?: number;\n ref: ForwardedRef<OrderListInstance>;\n sharePnLConfig?: SharePnLConfig;\n};\n\nexport const useOrdersScript = (props: UseOrdersScriptOptions) => {\n const { current, pnlNotionalDecimalPrecision, sharePnLConfig } = props;\n\n const orderListRef = useRef<OrderListInstance>(null);\n\n useImperativeHandle(props.ref, () => ({}));\n\n return {\n current,\n pnlNotionalDecimalPrecision,\n orderListRef,\n sharePnLConfig,\n };\n};\n\nexport type OrdersBuilderState = ReturnType<typeof useOrdersScript>;\n","import { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { i18n } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport {\n AlgoOrderRootType,\n AlgoOrderType,\n API,\n OrderStatus,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\n\nexport const upperCaseFirstLetter = (str: string) => {\n if (str === undefined) return str;\n if (str.length === 0) return str;\n if (str.length === 1) return str.charAt(0).toUpperCase();\n return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1);\n};\n\n/**\n * order_type: LIMIT、MARKET、CLOSE_POSITION\n * algo_type: STOP、TPSL、positional_TPSL、BRACKET\n */\nexport function parseBadgesFor(record: any): undefined | string[] {\n const orderType = record.type;\n const algoType = record.algo_type;\n if (typeof orderType !== \"undefined\") {\n const list: string[] = [];\n\n if (!!record.parent_algo_type) {\n if (algoType === AlgoOrderType.STOP_LOSS) {\n const types =\n orderType === OrderType.CLOSE_POSITION\n ? [i18n.t(\"common.position\"), i18n.t(\"tpsl.sl\")]\n : [i18n.t(\"tpsl.sl\")];\n list.push(...types);\n }\n\n if (algoType === AlgoOrderType.TAKE_PROFIT) {\n const types =\n orderType === OrderType.CLOSE_POSITION\n ? [i18n.t(\"common.position\"), i18n.t(\"tpsl.tp\")]\n : [i18n.t(\"tpsl.tp\")];\n list.push(...types);\n }\n\n return list;\n }\n\n const type =\n typeof orderType === \"string\" ? orderType.replace(\"_ORDER\", \"\") : \"\";\n\n // bbo(ask, bid) order as a limit type\n if ([OrderType.ASK, OrderType.BID].includes(orderType)) {\n return [i18n.t(\"orderEntry.orderType.limit\")];\n }\n\n if (\n record.algo_order_id === undefined ||\n (record.algo_order_id && algoType === \"BRACKET\")\n ) {\n const typeMap = {\n [OrderType.LIMIT]: i18n.t(\"orderEntry.orderType.limit\"),\n [OrderType.MARKET]: i18n.t(\"orderEntry.orderType.market\"),\n [OrderType.POST_ONLY]: i18n.t(\"orderEntry.orderType.postOnly\"),\n [OrderType.IOC]: i18n.t(\"orderEntry.orderType.ioc\"),\n [OrderType.FOK]: i18n.t(\"orderEntry.orderType.fok\"),\n };\n\n return [\n typeMap[type as keyof typeof typeMap] || upperCaseFirstLetter(type),\n ];\n }\n\n if (algoType === AlgoOrderRootType.TRAILING_STOP) {\n return [i18n.t(\"orderEntry.orderType.trailingStop\")];\n }\n\n // stop limit, stop market\n if (type) {\n const typeMap = {\n [OrderType.LIMIT]: i18n.t(\"orderEntry.orderType.stopLimit\"),\n [OrderType.MARKET]: i18n.t(\"orderEntry.orderType.stopMarket\"),\n };\n return [typeMap[type as keyof typeof typeMap] || type];\n }\n }\n\n if (typeof algoType !== \"undefined\") {\n const list: string[] = [];\n\n if (algoType === AlgoOrderRootType.POSITIONAL_TP_SL) {\n list.push(i18n.t(\"common.position\"));\n }\n\n const tpOrder = record?.child_orders?.find(\n (order: any) =>\n order.algo_type === AlgoOrderType.TAKE_PROFIT && !!order.trigger_price,\n );\n\n const slOrder = record?.child_orders?.find(\n (order: any) =>\n order.algo_type === AlgoOrderType.STOP_LOSS && !!order.trigger_price,\n );\n\n if (tpOrder || slOrder) {\n list.push(\n tpOrder && slOrder\n ? i18n.t(\"common.tpsl\")\n : tpOrder\n ? i18n.t(\"tpsl.tp\")\n : i18n.t(\"tpsl.sl\"),\n );\n }\n\n return list;\n }\n\n return undefined;\n}\n\nexport function grayCell(record: any): boolean {\n return (\n (record as API.Order).status === OrderStatus.CANCELLED ||\n (record as API.AlgoOrder).algo_status === OrderStatus.CANCELLED\n );\n}\n\nexport function getOrderStatus(record: any) {\n return (record as API.Order).status || (record as API.AlgoOrder).algo_status;\n}\n\nexport function isGrayCell(status?: string): boolean {\n return status === OrderStatus.CANCELLED;\n}\n\nfunction findBracketTPSLOrder(order: API.AlgoOrderExt) {\n if (order.algo_type !== AlgoOrderRootType.BRACKET) {\n return {\n tpOrder: undefined,\n slOrder: undefined,\n };\n }\n\n const innerOrder = order.child_orders?.[0];\n if (!innerOrder)\n return {\n tpOrder: undefined,\n slOrder: undefined,\n };\n\n const tpOrder = innerOrder?.child_orders?.find(\n (item) => item.algo_type === AlgoOrderType.TAKE_PROFIT,\n );\n\n const slOrder = innerOrder?.child_orders?.find(\n (item) => item.algo_type === AlgoOrderType.STOP_LOSS,\n );\n\n return {\n tpOrder,\n slOrder,\n };\n}\n\nexport function calcBracketRoiAndPnL(order: API.AlgoOrderExt) {\n const defaultCallback = {\n pnl: {\n tpPnL: undefined,\n slPnL: undefined,\n },\n roi: {\n tpRoi: undefined,\n slRoi: undefined,\n },\n };\n const { tpOrder, slOrder } = findBracketTPSLOrder(order);\n if (!tpOrder && !slOrder) return defaultCallback;\n\n if (typeof order.price === undefined || !order.price) return defaultCallback;\n\n const quantity =\n order.side === OrderSide.BUY ? order.quantity : order.quantity * -1;\n\n const tpPnL =\n tpOrder?.trigger_price &&\n utils.priceToPnl({\n qty: quantity,\n price: tpOrder?.trigger_price,\n entryPrice: order.price,\n // @ts-ignore\n orderSide: order.side,\n // @ts-ignore\n orderType: tpOrder.algo_type,\n });\n const slPnL =\n slOrder?.trigger_price &&\n utils.priceToPnl({\n qty: quantity,\n // trigger price\n price: slOrder?.trigger_price,\n //\n entryPrice: order.price,\n // @ts-ignore\n orderSide: order.side,\n // @ts-ignore\n orderType: slOrder.algo_type,\n });\n\n const tpRoi = tpPnL\n ? utils.calcTPSL_ROI({\n pnl: tpPnL,\n qty: order.quantity,\n price: order.price,\n })\n : undefined;\n const slRoi = slPnL\n ? utils.calcTPSL_ROI({\n pnl: slPnL,\n qty: order.quantity,\n price: order.price,\n })\n : undefined;\n\n return {\n pnl: {\n tpPnL,\n slPnL,\n },\n roi: {\n tpRoi,\n slRoi,\n },\n };\n}\n\nexport function areDatesEqual(date1?: Date, date2?: Date): boolean {\n if (!date1 || !date2) return false;\n return (\n date1.getFullYear() === date2.getFullYear() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getDate() === date2.getDate()\n );\n}\n\nexport function isTrailingStopOrder(order: API.AlgoOrderExt) {\n return order.algo_type === OrderType.TRAILING_STOP;\n}\n\nexport function getNotional(order: API.AlgoOrderExt, dp = 2) {\n if (order.price && order.quantity) {\n return new Decimal(order.price)\n .mul(order.quantity)\n .toFixed(dp, Decimal.ROUND_DOWN);\n }\n\n return 0;\n}\n/**\n * api order type ==> orderEntry type\n */\nexport function convertApiOrderTypeToOrderEntryType(order: API.AlgoOrderExt) {\n if (order.algo_type === OrderType.TRAILING_STOP) {\n return order.algo_type;\n }\n\n const isAlgoOrder = order.algo_order_id !== undefined;\n\n if (isAlgoOrder && order.algo_type !== AlgoOrderRootType.BRACKET) {\n return `STOP_${order.type}` as OrderType;\n }\n\n return order.type;\n}\n","import { createContext, useContext } from \"react\";\nimport type { API } from \"@kodiak-finance/orderly-types\";\n\nexport interface SymbolContextState {\n base_dp: number;\n quote_dp: number;\n base_tick: number;\n quote_tick: number;\n base: string;\n quote: string;\n symbol: string;\n origin: API.SymbolExt;\n quote_min: number;\n quote_max: number;\n}\n\nexport const SymbolContext = createContext<SymbolContextState>(\n {} as SymbolContextState,\n);\n\nexport const useSymbolContext = () => {\n return useContext<SymbolContextState>(SymbolContext);\n};\n","import { FC, PropsWithChildren, useMemo } from \"react\";\nimport { useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { SymbolContext, SymbolContextState } from \"./symbolContext\";\n\ninterface FormatterProviderProps {\n symbol: string;\n}\n\nexport const SymbolProvider: FC<PropsWithChildren<FormatterProviderProps>> = (\n props,\n) => {\n const { symbol, children } = props;\n const symbolInfo = useSymbolsInfo()[symbol];\n const memoizedValue = useMemo<SymbolContextState>(() => {\n return {\n symbol: symbol,\n base_dp: symbolInfo(\"base_dp\"),\n quote_dp: symbolInfo(\"quote_dp\"),\n base_tick: symbolInfo(\"base_tick\"),\n quote_tick: symbolInfo(\"quote_tick\"),\n base: symbolInfo(\"base\"),\n quote: symbolInfo(\"quote\"),\n origin: symbolInfo(),\n quote_max: symbolInfo(\"quote_max\"),\n quote_min: symbolInfo(\"quote_min\"),\n };\n }, [symbol, symbolInfo]);\n return (\n <SymbolContext.Provider value={memoizedValue}>\n {children}\n </SymbolContext.Provider>\n );\n};\n","import { FC } from \"react\";\nimport { ShareIcon } from \"@kodiak-finance/orderly-ui\";\nimport { ShareButtonScriptReturn } from \"./shareButton.script\";\n\nexport const ShareButton: FC<ShareButtonScriptReturn> = (props) => {\n if (props.sharePnLConfig == null) {\n return null;\n }\n\n return (\n <button\n type=\"button\"\n onClick={(e: any) => {\n e.stopPropagation();\n props.showModal();\n }}\n >\n <ShareIcon color=\"white\" opacity={0.54} size={props.iconSize ?? 16} />\n </button>\n );\n};\n","import { useMemo } from \"react\";\nimport { useReferralInfo, useLeverageBySymbol } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { modal } from \"@kodiak-finance/orderly-ui\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\n\nexport type ShareButtonScriptReturn = ReturnType<typeof useShareButtonScript>;\n\nexport const useShareButtonScript = (props: {\n order: any;\n sharePnLConfig?: SharePnLConfig;\n modalId: string;\n iconSize?: number;\n}) => {\n const { sharePnLConfig, order, iconSize } = props;\n const { t } = useTranslation();\n const { getFirstRefCode } = useReferralInfo();\n const refCode = useMemo(() => {\n return getFirstRefCode()?.code;\n }, [getFirstRefCode]);\n const leverage = useLeverageBySymbol(order.symbol);\n\n const showModal = () => {\n modal.show(props.modalId, {\n pnl: {\n entity: {\n symbol: order.symbol,\n pnl: order.realized_pnl,\n side:\n order.side == \"BUY\"\n ? t(\"share.pnl.share.long\")\n : t(\"share.pnl.share.short\"),\n openPrice: order.average_executed_price,\n openTime: order.updated_time,\n quantity: order.quantity,\n },\n refCode,\n leverage,\n ...sharePnLConfig,\n },\n });\n };\n\n return {\n iconSize,\n sharePnLConfig,\n showModal,\n };\n};\n","import React from \"react\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { useShareButtonScript } from \"./shareButton.script\";\nimport { ShareButton } from \"./shareButton.ui\";\n\nexport const ShareButtonWidget: React.FC<{\n order: any;\n sharePnLConfig?: SharePnLConfig;\n modalId: string;\n iconSize?: number;\n}> = (props) => {\n const state = useShareButtonScript(props);\n return <ShareButton {...state} />;\n};\n","export { ShareButton } from \"./shareButton.ui\";\nexport { ShareButtonWidget } from \"./shareButton.widget\";\n","import { memo } from \"react\";\nimport { useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { Text } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\n\ntype AvgPriceProps = {\n symbol: string;\n value: string;\n};\n\nexport const AvgPrice = memo((props: AvgPriceProps) => {\n const symbolsInfo = useSymbolsInfo();\n\n const info = symbolsInfo[props.symbol];\n\n if (!props.value) {\n return \"--\";\n }\n\n return (\n <Text.numeral\n padding={false}\n dp={info(\"quote_dp\", 2)}\n rm={Decimal.ROUND_UP}\n >\n {props.value}\n </Text.numeral>\n );\n});\n","import { useMemo } from \"react\";\nimport { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport {\n Flex,\n Tooltip,\n Text,\n cn,\n EditIcon,\n useModal,\n modal,\n} from \"@kodiak-finance/orderly-ui\";\nimport { calcBracketRoiAndPnL } from \"../../../utils/util\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\n\nexport const BracketOrderPrice = (props: { order: API.AlgoOrderExt }) => {\n const { order } = props;\n const { quote_dp, base_dp } = useSymbolContext();\n const { t } = useTranslation();\n\n const { sl_trigger_price, tp_trigger_price } = useMemo(() => {\n if (!(\"algo_type\" in order) || !Array.isArray(order.child_orders)) {\n return {};\n }\n return utils.findTPSLFromOrder(props.order.child_orders[0]);\n }, [props.order]);\n\n const { pnl, roi } = calcBracketRoiAndPnL(order);\n\n if (!tp_trigger_price && !sl_trigger_price) {\n return \"--\";\n }\n\n return (\n <Tooltip\n // @ts-ignore\n content={\n <Flex direction={\"column\"} itemAlign={\"start\"} gap={1}>\n {typeof pnl.tpPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.tpPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={quote_dp}\n color=\"buy\"\n showIdentifier\n >\n {pnl.tpPnL}\n </Text.numeral>\n )}\n {typeof pnl.slPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.slPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={quote_dp}\n color=\"sell\"\n >\n {pnl.slPnL}\n </Text.numeral>\n )}\n </Flex>\n }\n className=\"oui-bg-base-6\"\n >\n <Flex itemAlign={\"center\"} justify={\"start\"} gap={2}>\n <Flex direction={\"column\"} justify={\"start\"} itemAlign={\"start\"}>\n <Price type=\"TP\" value={tp_trigger_price} quote_dp={quote_dp} />\n <Price type=\"SL\" value={sl_trigger_price} quote_dp={quote_dp} />\n </Flex>\n <EditBracketOrder order={order} />\n </Flex>\n </Tooltip>\n );\n};\n\nconst EditBracketOrder = (props: { order: API.AlgoOrderExt }) => {\n const { order } = props;\n\n const onEdit = () => {\n modal.show(\"EditBracketOrderDialogId\", {\n order,\n });\n };\n\n return (\n <EditIcon\n size={16}\n className=\"oui-text-base-contrast oui-cursor-pointer\"\n onClick={() => {\n onEdit();\n }}\n />\n );\n};\n\nconst Price = (props: {\n type: \"TP\" | \"SL\";\n value?: number | string;\n quote_dp: number;\n}) => {\n const { type, value, quote_dp } = props;\n const { t } = useTranslation();\n\n return value ? (\n <Text.numeral\n className={cn(\n \"oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12\",\n type === \"TP\" ? \"oui-text-trade-profit\" : \"oui-text-trade-loss\",\n )}\n key={\"tp\"}\n rule=\"price\"\n dp={quote_dp}\n // @ts-ignore\n prefix={\n <span className={\"oui-text-base-contrast-54\"}>\n {type === \"TP\" ? `${t(\"tpsl.tp\")} -` : `${t(\"tpsl.sl\")} -`}\n \n </span>\n }\n >\n {value}\n </Text.numeral>\n ) : (\n <></>\n );\n};\n","import { createContext, useContext } from \"react\";\nimport { API, OrderEntity } from \"@kodiak-finance/orderly-types\";\n\nexport interface OrderListContextState {\n onCancelOrder: (order: API.Order | API.AlgoOrder) => Promise<any>;\n editOrder: (id: string, order: OrderEntity) => Promise<any>;\n editAlgoOrder: (id: string, order: OrderEntity) => Promise<any>;\n checkMinNotional: (\n symbol: string,\n price?: string | number,\n qty?: string | number,\n ) => string | undefined;\n}\n\nexport const OrderListContext = createContext<OrderListContextState>(\n {} as OrderListContextState,\n);\n\nexport const useOrderListContext = () => {\n return useContext(OrderListContext);\n};\n\nexport interface OrderListProviderProps {\n cancelOrder: (orderId: number, symbol: string) => Promise<any>;\n editOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n cancelAlgoOrder: (orderId: number, symbol: string) => Promise<any>;\n editAlgoOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n}\n","import { FC, useState } from \"react\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { ThrottledButton, toast } from \"@kodiak-finance/orderly-ui\";\nimport { useOrderListContext } from \"../orderListContext\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\n\nexport const CancelButton: FC<{\n order: API.Order;\n}> = (props) => {\n const { order } = props;\n const { t } = useTranslation();\n\n const { onCancelOrder } = useOrderListContext();\n const [isLoading, setIsLoading] = useState(false);\n\n return (\n <ThrottledButton\n size=\"sm\"\n variant={\"outlined\"}\n color={\"secondary\"}\n onClick={(event) => {\n if (!onCancelOrder) return;\n event.preventDefault();\n event.stopPropagation();\n setIsLoading(true);\n onCancelOrder(order)\n .then(\n (res: any) => res,\n (error: any) => {\n toast.error(error.message);\n }\n )\n .finally(() => {\n setIsLoading(false);\n });\n }}\n loading={isLoading}\n >\n {t(\"common.cancel\")}\n </ThrottledButton>\n );\n};\n","export enum EditType {\n quantity,\n price,\n triggerPrice,\n callbackValue,\n callbackRate,\n}\n","import { memo } from \"react\";\nimport { useTranslation, Trans } from \"@kodiak-finance/orderly-i18n\";\nimport { Button, CloseIcon, ThrottledButton } from \"@kodiak-finance/orderly-ui\";\nimport { commify } from \"@kodiak-finance/orderly-utils\";\nimport { EditType } from \"../../../../type\";\n\ntype ConfirmContentProps = {\n type: EditType;\n base: string;\n value: string;\n cancelPopover: () => void;\n isSubmitting: boolean;\n onConfirm: (e: any) => void;\n};\n\nexport const ConfirmContent = memo((props: ConfirmContentProps) => {\n const { type, base, value, cancelPopover, isSubmitting, onConfirm } = props;\n const { t } = useTranslation();\n\n const renderLabel = () => {\n const common = {\n values: { base, value: commify(value) },\n components: [<span key=\"0\" className=\"oui-text-warning-darken\" />],\n };\n\n switch (type) {\n case EditType.quantity:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.quantity\" {...common} />\n );\n case EditType.price:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.price\" {...common} />\n );\n case EditType.triggerPrice:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.triggerPrice\" {...common} />\n );\n case EditType.callbackValue:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.callbackValue\" {...common} />\n );\n case EditType.callbackRate:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.callbackRate\" {...common} />\n );\n }\n };\n\n return (\n <div className=\"oui-relative oui-pt-5\">\n <div className=\"desktop:oui-text-sm oui-text-2xs oui-text-base-contrast-54\">\n {renderLabel()}\n </div>\n <div className=\"oui-mt-5 oui-grid oui-grid-cols-2 oui-gap-2\">\n <Button\n color=\"secondary\"\n size={\"md\"}\n onClick={cancelPopover}\n disabled={isSubmitting}\n >\n {t(\"common.cancel\")}\n </Button>\n <ThrottledButton size={\"md\"} loading={isSubmitting} onClick={onConfirm}>\n {t(\"common.confirm\")}\n </ThrottledButton>\n </div>\n <button\n className=\"oui-absolute oui-right-0 oui-top-0 oui-text-base-contrast-54\"\n onClick={cancelPopover}\n >\n <CloseIcon size={16} color=\"white\" opacity={1} />\n </button>\n </div>\n );\n});\n\nConfirmContent.displayName = \"ConfirmContent\";\n","import { useCallback, useEffect, useRef, useState, MouseEvent } from \"react\";\n\ntype PopoverStateProps = {\n originValue: string;\n value: string;\n setValue: (value: string) => void;\n};\n\nexport function usePopoverState(props: PopoverStateProps) {\n const { originValue, value, setValue } = props;\n\n const [open, setOpen] = useState(false);\n const [editing, setEditing] = useState(false);\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const closePopover = useCallback(() => {\n setOpen(false);\n setEditing(false);\n }, []);\n\n const cancelPopover = useCallback(() => {\n closePopover();\n setValue(originValue);\n }, [originValue]);\n\n const onClick = useCallback(\n async (event: MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\n // if value is not changed, then don't open popover\n if (value === originValue) {\n setEditing(false);\n return;\n }\n\n setOpen(true);\n },\n [value, originValue],\n );\n\n useEffect(() => {\n const handleClickOutside = (event: any) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node) &&\n !open\n ) {\n cancelPopover();\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [open, cancelPopover]);\n\n return {\n value,\n setValue,\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n };\n}\n","import { useEffect, useMemo } from \"react\";\nimport { OrderValidationResult, useOrderEntity } from \"@kodiak-finance/orderly-hooks\";\nimport { useOrderEntryFormErrorMsg } from \"@kodiak-finance/orderly-react-app\";\nimport { API, OrderlyOrder, OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { convertApiOrderTypeToOrderEntryType } from \"../../../../utils/util\";\n\nexport function useValidateField(props: {\n order: API.OrderExt | API.AlgoOrderExt;\n originValue?: string;\n value: string;\n field: keyof OrderValidationResult;\n fieldValues?: Partial<OrderlyOrder>;\n}) {\n const { order, field, originValue, value, fieldValues } = props;\n const changeFields = fieldValues || { [field]: value };\n\n const orderType = useMemo(\n () => convertApiOrderTypeToOrderEntryType(order as API.AlgoOrderExt),\n [order],\n );\n\n const { errors, validate, clearErrors } = useOrderEntity({\n symbol: order.symbol,\n order_type: orderType,\n side: order.side as OrderSide,\n ...(changeFields as any),\n });\n const { getErrorMsg } = useOrderEntryFormErrorMsg(errors);\n\n const error = useMemo(\n () => (field ? getErrorMsg(field) : undefined),\n [getErrorMsg, field],\n );\n\n useEffect(() => {\n // if value is not changed, then don't validate\n if (value === originValue) {\n clearErrors();\n return;\n }\n validate()\n .then((order) => {\n console.log(\"order\", order);\n })\n .catch((errors) => {\n console.error(`${field} validate error:`, errors);\n });\n }, [value, originValue]);\n\n return { error, errors, getErrorMsg };\n}\n","import { FC, useCallback, useEffect, useRef, MouseEvent } from \"react\";\nimport { EMPTY_LIST } from \"@kodiak-finance/orderly-types\";\nimport {\n inputFormatter,\n Input,\n InputProps,\n CheckIcon,\n cn,\n Flex,\n} from \"@kodiak-finance/orderly-ui\";\n\nexport type EditableCellInputProps = {\n id?: string;\n name?: string;\n placeholder?: string;\n suffix?: React.ReactNode;\n value?: InputProps[\"value\"];\n onChange?: (value: string) => void;\n error?: string;\n formatters?: InputProps[\"formatters\"];\n overrideFormatters?: InputProps[\"formatters\"];\n classNames?: InputProps[\"classNames\"];\n readonly?: boolean;\n onClick: (e: MouseEvent) => void;\n onFocus?: (e: any) => void;\n onBlur?: (e: any) => void;\n handleKeyDown?: (e: any) => void;\n};\n\nexport const EditableCellInput: FC<EditableCellInputProps> = (props) => {\n const { onClick } = props;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleKeyDown = useCallback(\n (event: any) => {\n if (event.key === \"Enter\") {\n onClick(event);\n }\n },\n [onClick],\n );\n\n useEffect(() => {\n const input = inputRef.current;\n if (input) {\n const length = input.value.length;\n input.setSelectionRange(length, length);\n }\n }, [props.value]);\n\n return (\n <Input.tooltip\n ref={inputRef}\n tooltip={props.error}\n autoComplete=\"off\"\n autoFocus\n type=\"text\"\n size=\"sm\"\n placeholder={props.readonly ? \"\" : props.placeholder || \"\"}\n id={props.id}\n name={props.name}\n color={props.error ? \"danger\" : undefined}\n value={props.readonly ? \"\" : props.value || \"\"}\n onValueChange={props.onChange}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n onFocus={props.onFocus}\n onBlur={props.onBlur}\n onKeyDown={props.handleKeyDown || handleKeyDown}\n inputMode=\"decimal\"\n formatters={\n props.overrideFormatters || [\n ...(props.formatters ?? EMPTY_LIST),\n inputFormatter.numberFormatter,\n inputFormatter.decimalPointFormatter,\n ]\n }\n classNames={{\n root: \"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded\",\n input: \"oui-pr-2\",\n }}\n readOnly={props.readonly}\n suffix={\n <Flex gapX={1}>\n {props.suffix}\n <button onClick={onClick} disabled={!!props.error}>\n <CheckIcon\n size={18}\n color=\"white\"\n opacity={1}\n className={cn(\n \"oui-opacity-50\",\n props.error\n ? \"oui-cursor-not-allowed\"\n : \"oui-cursor-pointer hover:oui-opacity-100\",\n )}\n />\n </button>\n </Flex>\n }\n />\n );\n};\n","import { memo } from \"react\";\nimport { cn, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { commifyOptional } from \"@kodiak-finance/orderly-utils\";\nimport { isGrayCell } from \"../../../../utils/util\";\n\ntype PreviewCellProps = {\n status?: string;\n value: string;\n setEditing: (isEditing: boolean) => void;\n disabled?: boolean;\n suffix?: string;\n className?: string;\n};\n\nexport const PreviewCell = memo((props: PreviewCellProps) => {\n const { status, value, disabled } = props;\n\n return (\n <div\n className={cn(\n \"oui-flex oui-items-center oui-justify-start\",\n \"oui-relative oui-max-w-[110px] oui-gap-1 oui-font-semibold\",\n isGrayCell(status) && \"oui-text-base-contrast-20\",\n props.className,\n )}\n onClick={(e) => {\n if (!disabled) {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }\n }}\n >\n <Flex\n r=\"base\"\n className={cn(\n \"oui-h-[28px] oui-min-w-[70px]\",\n !disabled && \"oui-border oui-border-line-12 oui-bg-base-7 oui-px-2\",\n )}\n >\n <Text size=\"2xs\">\n {commifyOptional(value)}\n {props.suffix}\n </Text>\n </Flex>\n </div>\n );\n});\n","import { useCallback, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderType } from \"@kodiak-finance/orderly-types\";\nimport { inputFormatter, Popover, toast } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const ActivedPriceCell = (props: {\n order: API.AlgoOrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { t } = useTranslation();\n // the value before editing, initial value\n const originValue = order.activated_price?.toString() ?? \"\";\n\n const [value, setValue] = useState<string>(originValue);\n const [submitting, setSubmitting] = useState(false);\n const disabled = props.disabled || order.is_activated || order.is_triggered;\n\n const { editAlgoOrder } = useOrderListContext();\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error } = useValidateField({\n order,\n field: \"activated_price\",\n originValue,\n value,\n });\n\n const onConfirm = useCallback(() => {\n setSubmitting(true);\n\n const data: any = {\n algo_order_id: order.algo_order_id,\n activated_price: value,\n };\n\n editAlgoOrder(order.algo_order_id.toString(), data)\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setSubmitting(false));\n }, [order.algo_order_id, value, cancelPopover]);\n\n if (!order.activated_price && order.type === OrderType.MARKET) {\n return <span>{t(\"common.marketPrice\")}</span>;\n }\n\n const renderContent = () => {\n if (!editing || disabled) {\n return (\n <PreviewCell\n value={value}\n status={getOrderStatus(order)}\n setEditing={setEditing}\n disabled={disabled}\n />\n );\n }\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n // when editing, value should not be empty\n error={value ? error : t(\"orderEntry.triggerPrice.error.required\")}\n formatters={[inputFormatter.dpFormatter(quote_dp)]}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.triggerPrice}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={submitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import { useMemo, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { OrderType } from \"@kodiak-finance/orderly-types\";\nimport { inputFormatter, Popover, toast } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const PriceCell = (props: {\n order: API.OrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { t } = useTranslation();\n\n const originValue = useMemo(() => {\n if (order.type === OrderType.MARKET && !order.price) {\n return \"Market\";\n }\n return order.price?.toString() ?? \"Market\";\n }, [order.price, order.type]);\n\n const [value, setValue] = useState<string>(originValue);\n\n const isAlgoOrder = order?.algo_order_id !== undefined;\n\n const [submitting, setSubmitting] = useState(false);\n\n const { editOrder, editAlgoOrder } = useOrderListContext();\n\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error, getErrorMsg } = useValidateField({\n order,\n field: \"order_price\",\n originValue,\n value,\n fieldValues: {\n order_price: value,\n // add order quantity to validate total\n order_quantity: order.quantity?.toString(),\n // need to pass trigger_price to validate order_price, because order_price is depend on trigger_price when type is stop limit\n trigger_price: order.trigger_price?.toString(),\n },\n });\n\n const onConfirm = () => {\n setSubmitting(true);\n\n let order_id = order.order_id;\n // if reduce only is true, edit order must add symbol, order_type, side, order_price, order_quantity, reduce_only\n let data: any = {\n symbol: order.symbol,\n order_type: order.type,\n side: order.side,\n order_quantity: order.quantity,\n order_price: value,\n };\n\n if (order.reduce_only) {\n data.reduce_only = order.reduce_only;\n }\n\n if (order.order_tag) {\n data.order_tag = order.order_tag;\n }\n\n if (order.client_order_id) {\n data.client_order_id = order.client_order_id;\n }\n\n if (isAlgoOrder) {\n order_id = order.algo_order_id as number;\n data = {\n ...data,\n order_id,\n price: value,\n algo_order_id: order_id,\n };\n }\n\n // edit order don't need to set visible quantity again\n // if (order?.visible_quantity === 0) {\n // data[\"visible_quantity\"] = 0;\n // }\n\n // TODO: remove this, because order not have this field\n // @ts-ignore\n if (order.tag !== undefined) {\n // @ts-ignore\n data[\"order_tag\"] = order.tag;\n }\n\n let future;\n if (order.algo_order_id !== undefined) {\n future = editAlgoOrder(order.algo_order_id.toString(), data);\n } else {\n future = editOrder(order.order_id.toString(), data);\n }\n\n future\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setSubmitting(false));\n };\n\n const isAlgoMarketOrder = order.algo_order_id && order.type == \"MARKET\";\n\n if (isAlgoMarketOrder || value === \"Market\") {\n return <span>{t(\"common.marketPrice\")}</span>;\n }\n\n const renderContent = () => {\n if (!editing || props.disabled) {\n return (\n <PreviewCell\n value={value}\n status={getOrderStatus(order)}\n setEditing={setEditing}\n disabled={props.disabled}\n />\n );\n }\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n error={error || getErrorMsg(\"total\")}\n formatters={[inputFormatter.dpFormatter(quote_dp)]}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.price}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={submitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport {\n unstable_serialize,\n useAccount,\n useMemoizedFn,\n useMutation,\n useSWRConfig,\n utils,\n} from \"@kodiak-finance/orderly-hooks\";\nimport {\n findTPSLOrderPriceFromOrder,\n findTPSLFromOrder,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { API, OrderType } from \"@kodiak-finance/orderly-types\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { AlgoOrderType } from \"@kodiak-finance/orderly-types\";\nimport { useSymbolContext } from \"../provider/symbolContext\";\n\nexport type TPSLOrderRowContextState = {\n order: API.AlgoOrderExt;\n tp_trigger_price?: number;\n sl_trigger_price?: number;\n sl_order_price?: number | OrderType;\n tp_order_price?: number | OrderType;\n tpPnL?: number;\n slPnL?: number;\n\n onCancelOrder: (order: API.AlgoOrderExt) => Promise<void>;\n onUpdateOrder: (order: API.AlgoOrderExt, params: any) => Promise<void>;\n\n getRelatedPosition: (symbol: string) => API.PositionTPSLExt | undefined;\n\n position?: API.PositionTPSLExt;\n};\n\nexport const TPSLOrderRowContext = createContext<TPSLOrderRowContextState>(\n {} as TPSLOrderRowContextState,\n);\n\nexport const useTPSLOrderRowContext = () => {\n return useContext(TPSLOrderRowContext);\n};\n\nexport const TPSLOrderRowProvider: FC<\n PropsWithChildren<{ order: API.AlgoOrderExt }>\n> = (props) => {\n const { order, children } = props;\n const { quote_dp } = useSymbolContext();\n const [position, setPosition] = useState<API.PositionTPSLExt>();\n\n const [doDeleteOrder] = useMutation(\"/v1/algo/order\", \"DELETE\");\n const [doUpdateOrder] = useMutation(\"/v1/algo/order\", \"PUT\");\n\n const config = useSWRConfig();\n const { state } = useAccount();\n\n const positionKey = useMemo(() => {\n return unstable_serialize(() => [\"/v1/positions\", state.accountId]);\n }, [state.accountId]);\n\n const onCancelOrder = useMemoizedFn(async (order: API.AlgoOrderExt) => {\n return doDeleteOrder(null, {\n order_id: order.algo_order_id,\n symbol: order.symbol,\n });\n });\n\n const onUpdateOrder = useMemoizedFn(\n async (order: API.AlgoOrderExt, params: any) => {\n return doUpdateOrder({\n order_id: order.algo_order_id,\n child_orders: order.child_orders.map((order) => ({\n order_id: order.algo_order_id,\n quantity: params.order_quantity,\n })),\n });\n },\n );\n\n const getRelatedPosition = useMemoizedFn(\n (symbol: string): API.PositionTPSLExt => {\n const positions = config.cache.get(positionKey);\n return positions?.data?.rows?.find(\n (p: API.PositionTPSLExt) => p.symbol === symbol,\n );\n },\n );\n\n const {\n sl_trigger_price,\n tp_trigger_price,\n tpPnL,\n slPnL,\n sl_order_price,\n tp_order_price,\n } = calcTPSLPnL({\n order: order,\n position,\n quote_dp,\n });\n\n useEffect(() => {\n if (\"algo_type\" in order || ((order as any)?.reduce_only ?? false)) {\n const position = getRelatedPosition(order.symbol);\n if (position) {\n setPosition(position);\n }\n }\n }, [order.symbol]);\n\n const memoizedValue = useMemo<TPSLOrderRowContextState>(() => {\n return {\n order: order,\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n tpPnL,\n slPnL,\n position,\n onCancelOrder,\n onUpdateOrder,\n getRelatedPosition,\n };\n }, [\n order,\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n tpPnL,\n slPnL,\n position,\n onCancelOrder,\n onUpdateOrder,\n getRelatedPosition,\n ]);\n\n return (\n <TPSLOrderRowContext.Provider value={memoizedValue}>\n {children}\n </TPSLOrderRowContext.Provider>\n );\n};\n\nfunction calcTPSLPnL(props: {\n order: API.AlgoOrderExt;\n position?: API.PositionTPSLExt;\n quote_dp: number;\n}) {\n const { order, position, quote_dp } = props;\n\n if (!position)\n return {\n sl_trigger_price: undefined,\n tp_trigger_price: undefined,\n slPnL: undefined,\n tpPnL: undefined,\n };\n\n const isTPSLOrder = \"algo_type\" in order && Array.isArray(order.child_orders);\n\n const { sl_trigger_price, tp_trigger_price } = isTPSLOrder\n ? findTPSLFromOrder(order)\n : {\n sl_trigger_price: undefined,\n tp_trigger_price: undefined,\n };\n const { sl_order_price, tp_order_price } = isTPSLOrder\n ? findTPSLOrderPriceFromOrder(order)\n : {\n sl_order_price: undefined,\n tp_order_price: undefined,\n };\n\n let quantity = order.quantity;\n\n if (quantity === 0) {\n if (order.child_orders?.[0].type === \"CLOSE_POSITION\") {\n quantity = position.position_qty;\n }\n }\n\n const avgOpenPrice = position.average_open_price;\n const tpPnL =\n typeof quantity === \"number\" &&\n typeof tp_trigger_price === \"number\" &&\n typeof avgOpenPrice === \"number\"\n ? utils.priceToPnl(\n {\n qty: quantity,\n price: tp_trigger_price,\n entryPrice: position.average_open_price,\n orderSide: order.side as OrderSide,\n orderType: AlgoOrderType.TAKE_PROFIT,\n },\n { symbol: { quote_dp } },\n )\n : undefined;\n\n const slPnL =\n typeof quantity === \"number\" &&\n typeof sl_trigger_price === \"number\" &&\n typeof avgOpenPrice === \"number\"\n ? utils.priceToPnl(\n {\n qty: quantity,\n price: sl_trigger_price,\n entryPrice: position.average_open_price,\n orderSide: order.side as OrderSide,\n orderType: AlgoOrderType.STOP_LOSS,\n },\n { symbol: { quote_dp } },\n )\n : undefined;\n\n return {\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n slPnL,\n tpPnL,\n };\n}\n","import { FC, useEffect } from \"react\";\nimport { CheckIcon, Input, inputFormatter, Tooltip } from \"@kodiak-finance/orderly-ui\";\n\nexport const InnerInput: FC<{\n inputRef: any;\n value: string;\n setValue: any;\n setEditing: any;\n error?: string;\n handleKeyDown: (e: any) => void;\n onClick: (e: any) => void;\n onClose: (e: any) => void;\n onFocus?: (e: any) => void;\n onBlur?: (e: any) => void;\n dp: number;\n hintInfo?: string;\n}> = (props) => {\n const {\n inputRef,\n dp,\n value,\n setValue,\n setEditing,\n error,\n handleKeyDown,\n onClick,\n onClose,\n onFocus,\n onBlur,\n hintInfo,\n } = props;\n\n useEffect(() => {\n const input = inputRef.current;\n if (input) {\n const length = input.value.length;\n input.setSelectionRange(length, length);\n }\n setEditing(true);\n }, []);\n const open = (hintInfo?.length || 0) > 0;\n return (\n <Tooltip content={hintInfo} open={open}>\n <Input\n ref={inputRef}\n type=\"text\"\n size=\"sm\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(dp),\n inputFormatter.currencyFormatter,\n ]}\n value={value}\n onValueChange={(e) => setValue(e)}\n helpText={error}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n autoComplete=\"off\"\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={handleKeyDown}\n autoFocus\n color={open ? \"danger\" : undefined}\n classNames={{\n root: \"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded\",\n input: \"oui-pr-2\",\n }}\n // prefix={\n // <CloseIcon\n // size={14}\n // color=\"white\"\n // opacity={1}\n // className=\"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100\"\n // onClick={(e) => {\n // e.stopPropagation();\n // e.preventDefault();\n // onClose(e);\n // }}\n // />\n // }\n suffix={\n <button onClick={onClick}>\n <CheckIcon\n size={18}\n color=\"white\"\n opacity={1}\n className=\"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100\"\n />\n </button>\n }\n />\n </Tooltip>\n );\n};\n","import { FC, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useMaxQty, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { AlgoOrderRootType } from \"@kodiak-finance/orderly-types\";\nimport {\n cn,\n Flex,\n Popover,\n toast,\n Text,\n Slider,\n Button,\n PopoverTrigger,\n PopoverRoot,\n PopoverContent,\n} from \"@kodiak-finance/orderly-ui\";\nimport { commifyOptional, Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { EditType } from \"../../../../type\";\nimport { grayCell } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { useTPSLOrderRowContext } from \"../../tpslOrderRowContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { InnerInput } from \"../editOrder/innerInput\";\n\nexport const QuantityCell = (props: {\n order: API.OrderExt | API.AlgoOrder;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { reduce_only } = order;\n const originValue = order.quantity.toString();\n const [value, setValue] = useState(originValue);\n\n const [editing, setEditing] = useState(false);\n\n const { t } = useTranslation();\n\n const [open, setOpen] = useState(false);\n const [error, setError] = useState<string>();\n\n const { editOrder, editAlgoOrder, checkMinNotional } = useOrderListContext();\n const { onUpdateOrder: onUpdateTPSLOrder, position } =\n useTPSLOrderRowContext();\n\n const { base_dp, base, base_tick } = useSymbolContext();\n\n const setQuantity = async (qty: string, maxQty?: number): Promise<void> => {\n setValue(qty);\n const positionQty = Math.abs(position?.position_qty || 0);\n\n if (position && reduce_only && Number(qty) > positionQty) {\n setError(\n t(\"orders.quantity.lessThanPosition\", {\n quantity: positionQty,\n }),\n );\n } else {\n const quantity = Number(qty);\n if (maxQty && quantity > maxQty) {\n setError(\n t(\"orders.quantity.lessThan\", {\n quantity: commifyOptional(maxQty, {\n fix: base_dp,\n }),\n }),\n );\n } else {\n setError(undefined);\n }\n }\n return Promise.resolve();\n };\n\n useEffect(() => {\n setQuantity(order.quantity.toString());\n }, [props.order.quantity]);\n\n const closePopover = () => {\n setOpen(false);\n setEditing(false);\n };\n const cancelPopover = () => {\n setOpen(false);\n setQuantity(order.quantity.toString());\n setEditing(false);\n };\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const clickHandler = () => {\n if (!!error) {\n return;\n }\n\n if (Number(value) === Number(order.quantity)) {\n setEditing(false);\n return;\n }\n\n const price =\n order.algo_order_id !== undefined ? order.trigger_price : order.price;\n if (price !== null && order.reduce_only !== true) {\n const notionalText = checkMinNotional(order.symbol, price, value);\n if (notionalText) {\n toast.error(notionalText);\n setIsSubmitting(false);\n cancelPopover();\n return;\n }\n }\n\n setOpen(true);\n };\n\n const onClick = (event: any) => {\n event?.stopPropagation();\n event?.preventDefault();\n\n clickHandler();\n };\n\n const handleKeyDown = (event: any) => {\n if (event.key === \"Enter\") {\n event?.stopPropagation();\n event?.preventDefault();\n clickHandler();\n }\n };\n\n const onConfirm = useCallback(() => {\n setIsSubmitting(true);\n\n let params: any = {\n symbol: order.symbol,\n order_type: order.type,\n side: order.side,\n order_price: order.price,\n order_quantity: value,\n // reduce_only: Boolean(order.reduce_only),\n algo_order_id: order.algo_order_id,\n };\n\n if (\n typeof params.algo_order_id !== \"undefined\" &&\n params.order_type === \"MARKET\"\n ) {\n // stop market order\n const { order_price, ...rest } = params;\n params = rest;\n }\n\n if (typeof order.reduce_only !== \"undefined\") {\n params.reduce_only = order.reduce_only;\n }\n\n if (order.order_tag) {\n params.order_tag = order.order_tag;\n }\n\n if (order.client_order_id) {\n params.client_order_id = order.client_order_id;\n }\n\n if (order?.visible_quantity === 0) {\n params[\"visible_quantity\"] = 0;\n }\n\n // @ts-ignore\n if (order?.tag !== undefined) {\n // @ts-ignore\n params[\"order_tag\"] = order.tag;\n }\n\n let future;\n\n if (\"algo_type\" in order && order.algo_type === AlgoOrderRootType.TP_SL) {\n future = onUpdateTPSLOrder(order as API.AlgoOrderExt, params);\n } else {\n if (order.algo_order_id !== undefined) {\n future = editAlgoOrder(order.algo_order_id.toString(), params);\n } else {\n future = editOrder((order as API.OrderExt).order_id.toString(), params);\n }\n }\n\n future\n .then(\n (result: any) => {\n closePopover();\n setQuantity(value.toString());\n },\n (err: any) => {\n toast.error(err.message);\n setQuantity(order.quantity.toString());\n cancelPopover();\n },\n )\n .finally(() => setIsSubmitting(false));\n }, [value]);\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n const quantitySliderRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n quantitySliderRef.current &&\n !componentRef.current.contains(event.target as Node) &&\n !quantitySliderRef.current.contains(event.target as Node) &&\n !open\n ) {\n cancelPopover();\n }\n };\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [open, order.quantity]);\n\n const renderContent = () => {\n if (!editing || props.disabled) {\n return (\n <PreviewCell\n order={order}\n value={value}\n setEditing={setEditing}\n disable={props.disabled}\n />\n );\n }\n\n return (\n <EditState\n inputRef={inputRef}\n quantitySliderRef={quantitySliderRef}\n base_dp={base_dp}\n base_tick={base_tick}\n quantity={value}\n setQuantity={setQuantity}\n editing={editing}\n setEditing={setEditing}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\n symbol={order.symbol}\n reduce_only={reduce_only}\n positionQty={position?.position_qty}\n error={error}\n confirmOpen={open}\n side={order.side}\n order={order}\n setError={setError}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.quantity}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n contentProps={{\n onOpenAutoFocus: (e) => {\n // e.preventDefault();\n // e.stopPropagation();\n },\n }}\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={componentRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n\nconst PreviewCell: FC<{\n order: API.AlgoOrder | API.OrderExt;\n value: string;\n setEditing: any;\n disable?: boolean;\n}> = (props) => {\n const { order, value } = props;\n\n const executed = (order as API.OrderExt).total_executed_quantity;\n\n return (\n <Flex\n direction=\"row\"\n justify={\"start\"}\n gap={1}\n className={cn(\n \"oui-relative oui-max-w-[110px]\",\n order.side === OrderSide.BUY && \"oui-text-trade-profit\",\n order.side === OrderSide.SELL && \"oui-text-trade-loss\",\n grayCell(order) && \"oui-text-base-contrast-20\",\n )}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }}\n >\n {\"algo_type\" in order &&\n order.algo_type === AlgoOrderRootType.TP_SL ? null : (\n <>\n <span>{executed}</span>\n <span>/</span>\n </>\n )}\n\n <Flex\n r=\"base\"\n className={cn(\n \"oui-h-[28px] oui-min-w-[70px]\",\n !props.disable &&\n \"oui-border oui-border-line-12 oui-bg-base-7 oui-px-2\",\n )}\n >\n <Text size=\"2xs\">{value}</Text>\n </Flex>\n </Flex>\n );\n};\n\nconst EditState: FC<{\n inputRef: any;\n quantitySliderRef: any;\n base_dp: number;\n base_tick: number;\n quantity: string;\n setQuantity: (quantity: string, maxQty: number) => Promise<void>;\n editing: boolean;\n confirmOpen: boolean;\n setEditing: (value: boolean) => void;\n handleKeyDown: (e: any) => void;\n onClick: (e: any) => void;\n onClose: () => void;\n error?: string;\n symbol: string;\n reduce_only: boolean;\n positionQty?: number;\n side?: string;\n order: any;\n setError: (err: string) => void;\n}> = (props) => {\n const {\n inputRef,\n quantitySliderRef,\n base_dp,\n base_tick,\n quantity,\n setQuantity,\n setEditing,\n handleKeyDown,\n onClick,\n onClose,\n error,\n symbol,\n reduce_only,\n positionQty,\n confirmOpen,\n order,\n } = props;\n\n const maxBuyQty = useMaxQty(symbol, order.side, order.reduce_only);\n\n const maxQty = useMemo(() => {\n if (reduce_only) {\n return Math.abs(positionQty ?? 0);\n }\n return order.quantity + Math.abs(maxBuyQty);\n }, [order.quantity, maxBuyQty, reduce_only, positionQty]);\n\n const [sliderValue, setSliderValue] = useState<number | undefined>(undefined);\n\n useEffect(() => {\n if (sliderValue === undefined) {\n const sliderValue = new Decimal(quantity)\n .div(maxQty)\n .abs()\n .mul(100)\n .toNumber();\n setSliderValue(sliderValue);\n }\n }, [sliderValue, maxQty, quantity]);\n\n const formatQuantity = async (_qty: string | number): Promise<void> => {\n if (base_tick > 0) {\n _qty = utils.formatNumber(_qty, base_tick) ?? _qty;\n }\n return setQuantity(`${_qty}`, maxQty);\n };\n\n return (\n <PopoverRoot open={!confirmOpen}>\n <PopoverTrigger>\n <InnerInput\n inputRef={inputRef}\n dp={base_dp}\n value={quantity}\n setValue={(e: string) => {\n const quantity = Math.abs(Math.min(Number(e), maxQty)).toString();\n setQuantity(e, maxQty);\n if (e.endsWith(\".\")) return;\n if (Number(quantity) === 0) {\n setSliderValue(0);\n return;\n }\n const sliderValue = new Decimal(e)\n .div(maxQty)\n .mul(100)\n .toDecimalPlaces(2, Decimal.ROUND_DOWN)\n .toNumber();\n setSliderValue(Math.min(100, sliderValue));\n }}\n setEditing={setEditing}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={onClose}\n onBlur={(e) => {\n formatQuantity(e.target.value);\n }}\n hintInfo={error}\n />\n </PopoverTrigger>\n <PopoverContent\n className=\"oui-w-[360px] oui-rounded-xl\"\n align=\"start\"\n side=\"bottom\"\n onOpenAutoFocus={(event) => {\n // event.stopPropagation();\n event.preventDefault();\n }}\n >\n <Flex\n p={1}\n gap={2}\n width={\"100%\"}\n itemAlign={\"start\"}\n ref={quantitySliderRef}\n >\n <Text.numeral\n size=\"xs\"\n intensity={98}\n className=\"oui-min-w-[30px] \"\n dp={2}\n padding={false}\n unit=\"%\"\n rm={Decimal.ROUND_DOWN}\n >\n {`${sliderValue}`}\n </Text.numeral>\n <Flex\n direction={\"column\"}\n width={\"100%\"}\n gap={2}\n className=\"oui-mt-[6px]\"\n >\n <Slider\n markCount={4}\n value={[sliderValue ?? 0]}\n onValueChange={(e) => {\n const values = Array.from(e.values());\n setSliderValue(values[0]);\n const quantity = new Decimal(values[0])\n .div(100)\n .mul(maxQty)\n .abs()\n .toFixed(base_dp, Decimal.ROUND_DOWN);\n setQuantity(quantity, maxQty);\n }}\n onValueCommit={(values) => {\n const quantity = new Decimal(values[0])\n .div(100)\n .mul(maxQty)\n .abs()\n .toFixed(base_dp, Decimal.ROUND_DOWN);\n formatQuantity(quantity).finally(() => {\n inputRef.current.focus();\n });\n }}\n />\n <Buttons\n onClick={(value) => {\n setSliderValue(value * 100);\n let quantity = new Decimal(value)\n .mul(maxQty)\n .abs()\n .toFixed(base_dp, Decimal.ROUND_DOWN);\n quantity = utils.formatNumber(quantity, base_tick) ?? quantity;\n\n setQuantity(quantity, maxQty);\n setTimeout(() => {\n inputRef.current.focus();\n inputRef.current.setSelectionRange(\n quantity.length,\n quantity.length,\n );\n }, 100);\n }}\n />\n </Flex>\n </Flex>\n </PopoverContent>\n </PopoverRoot>\n );\n};\n\nconst Buttons = (props: { onClick: (value: number) => void }) => {\n const { t } = useTranslation();\n const list = [\n {\n label: \"0%\",\n value: 0,\n },\n {\n label: \"25%\",\n value: 0.25,\n },\n {\n label: \"50%\",\n value: 0.5,\n },\n {\n label: \"75%\",\n value: 0.75,\n },\n {\n label: t(\"common.max\"),\n value: 1,\n },\n ];\n\n return (\n <Flex gap={2} width={\"100%\"}>\n {list.map((item, index) => {\n return (\n <Button\n key={index}\n variant=\"outlined\"\n color=\"secondary\"\n size=\"xs\"\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick(item.value);\n }}\n className=\"oui-w-1/5\"\n >\n {item.label}\n </Button>\n );\n })}\n </Flex>\n );\n};\n","import { useCallback, useMemo, useState } from \"react\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { Popover, toast, inputFormatter } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const TrailingCallbackCell = (props: {\n order: API.AlgoOrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { callback_value, callback_rate } = order;\n\n const isCallbackValue = !!callback_value;\n const isCallbackRate = !!callback_rate;\n\n const originValue = useMemo(() => {\n return callback_rate\n ? (callback_rate * 100).toString()\n : callback_value?.toString()!;\n }, [callback_value, callback_rate]);\n\n const [value, setValue] = useState<string>(originValue!);\n const [submitting, setSubmitting] = useState(false);\n\n const disabled = props.disabled || order.is_triggered;\n\n const { editAlgoOrder } = useOrderListContext();\n\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error } = useValidateField({\n order,\n originValue,\n value,\n field: isCallbackValue ? \"callback_value\" : \"callback_rate\",\n fieldValues: {\n callback_value: isCallbackValue ? value : undefined,\n callback_rate: isCallbackRate ? value : undefined,\n },\n });\n\n const onConfirm = useCallback(() => {\n setSubmitting(true);\n\n const data: any = {\n algo_order_id: order.algo_order_id,\n callback_value: isCallbackValue ? value : undefined,\n callback_rate: isCallbackRate ? `${Number(value) / 100}` : undefined,\n };\n\n editAlgoOrder(order.algo_order_id.toString(), data)\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setSubmitting(false));\n }, [order.algo_order_id, value, cancelPopover]);\n\n const renderContent = () => {\n const suffix = isCallbackRate ? \"%\" : undefined;\n\n if (!editing || disabled) {\n return (\n <PreviewCell\n status={getOrderStatus(order)}\n value={value}\n setEditing={setEditing}\n disabled={disabled}\n suffix={suffix}\n />\n );\n }\n\n const formatters = isCallbackRate\n ? [inputFormatter.dpFormatter(1)]\n : [\n inputFormatter.currencyFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ];\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n error={error}\n suffix={suffix}\n formatters={formatters}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={isCallbackRate ? EditType.callbackRate : EditType.callbackValue}\n base={base}\n value={isCallbackRate ? `${value}%` : value}\n cancelPopover={cancelPopover}\n isSubmitting={submitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import { useCallback, useState } from \"react\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { Popover, toast, inputFormatter } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const TriggerPriceCell = (props: {\n order: API.AlgoOrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const originValue = order.trigger_price?.toString();\n\n const [value, setValue] = useState<string>(originValue);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const disabled = props.disabled || order.is_triggered;\n\n const { editAlgoOrder } = useOrderListContext();\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error } = useValidateField({\n order,\n field: \"trigger_price\",\n originValue,\n value,\n });\n\n const onConfirm = useCallback(() => {\n setIsSubmitting(true);\n\n const data: any = {\n trigger_price: value,\n algo_order_id: order.algo_order_id,\n };\n\n editAlgoOrder(`${order.algo_order_id}`, data)\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setIsSubmitting(false));\n }, [order.algo_order_id, value, cancelPopover]);\n\n const renderContent = () => {\n if (!editing || disabled) {\n return (\n <PreviewCell\n value={value}\n status={getOrderStatus(order)}\n setEditing={setEditing}\n disabled={disabled}\n />\n );\n }\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n error={error}\n formatters={[inputFormatter.dpFormatter(quote_dp)]}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.triggerPrice}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import { FC, useCallback, useState } from \"react\";\nimport { useConfig, useMutation } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderEntity } from \"@kodiak-finance/orderly-types\";\nimport { Button } from \"@kodiak-finance/orderly-ui\";\n\nexport const Renew: FC<{ record: any }> = (props) => {\n const { record } = props;\n const [open, setOpen] = useState(false);\n const [doCreateOrder, { data, error, reset, isMutating }] = useMutation<\n OrderEntity,\n any\n >(\"/v1/order\");\n\n const { t } = useTranslation();\n\n const brokerId = useConfig(\"brokerId\");\n const onSubmit = useCallback(() => {\n setOpen(false);\n const data: OrderEntity = {\n symbol: record.symbol,\n order_type: record.type,\n order_price: record.price,\n order_quantity: record.quantity,\n order_amount: record.amount,\n side: record.side,\n broker_id: brokerId,\n };\n\n if (Number(record.visible_quantity) < Number(record.quantity)) {\n data.visible_quantity = 0;\n }\n\n if (typeof record.reduce_only !== \"undefined\") {\n data.reduce_only = record.reduce_only;\n }\n\n if (record.order_tag) {\n data.order_tag = record.order_tag;\n }\n\n if (record.client_order_id) {\n data.client_order_id = record.client_order_id;\n }\n\n doCreateOrder(data);\n }, []);\n\n return (\n <Button\n size={\"sm\"}\n variant={\"outlined\"}\n color={\"secondary\"}\n loading={isMutating}\n disabled={isMutating}\n onClick={(event) => {\n if (isMutating) return;\n event.preventDefault();\n event.stopPropagation();\n onSubmit();\n }}\n >\n {t(\"orders.history.renew\")}\n </Button>\n );\n};\n","import { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { PositionTPSLPopover } from \"@kodiak-finance/orderly-ui-tpsl\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\n\nexport const TP_SLEditButton = (props: { order: API.Order }) => {\n const { position, order } = useTPSLOrderRowContext();\n const { quote_dp, base_dp } = useSymbolContext();\n const { t } = useTranslation();\n\n return (\n <PositionTPSLPopover\n quoteDP={quote_dp}\n baseDP={base_dp}\n position={position!}\n order={order}\n label={t(\"common.edit\")}\n isEditing\n />\n );\n};\n","import {\n findTPSLOrderPriceFromOrder,\n findTPSLFromOrder,\n useSymbolsInfo,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { i18n, useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderType } from \"@kodiak-finance/orderly-types\";\nimport { Text } from \"@kodiak-finance/orderly-ui\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\n\nexport const TPSLOrderPrice = () => {\n const {\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n order,\n } = useTPSLOrderRowContext();\n const { t } = useTranslation();\n const symbolInfo = useSymbolsInfo()[order.symbol]();\n return (\n <div>\n {!!tp_trigger_price ? (\n <div className={\"oui-text-base-contrast-80 oui-td-bg-transparent\"}>\n <Text intensity={54}>{`${t(\"tpsl.tp\")} -`} </Text>\n <TPSLOrderPriceItem\n price={tp_order_price}\n quoteDP={symbolInfo.quote_dp}\n />\n </div>\n ) : null}\n {!!sl_trigger_price ? (\n <div className={\"oui-text-base-contrast-80 oui-td-bg-transparent\"}>\n <span className={\"oui-text-base-contrast-54\"}>\n {`${t(\"tpsl.sl\")} -`} \n </span>\n <TPSLOrderPriceItem\n price={sl_order_price}\n quoteDP={symbolInfo.quote_dp}\n />\n </div>\n ) : null}\n </div>\n );\n};\n\nconst TPSLOrderPriceItem = ({\n price,\n quoteDP,\n}: {\n price?: number | OrderType;\n quoteDP: number;\n}) => {\n const { t } = useTranslation();\n if (!price) {\n return null;\n }\n if (price === OrderType.MARKET) {\n return <span>{t(\"common.marketPrice\")}</span>;\n }\n\n return (\n <Text.numeral\n className=\"oui-text-base-contrast-80\"\n rule={\"price\"}\n dp={quoteDP}\n >\n {price}\n </Text.numeral>\n );\n};\n\nexport function useTPSLOrderPrice(order: any) {\n // @ts-ignore\n const { sl_trigger_price, tp_trigger_price } =\n !(\"algo_type\" in order) || !Array.isArray(order.child_orders)\n ? {}\n : findTPSLFromOrder(order);\n\n const tpTriggerPrice = tp_trigger_price\n ? `${i18n.t(\"tpsl.tp\")} - ${i18n.t(\"common.marketPrice\")}`\n : undefined;\n const slTriggerPrice = sl_trigger_price\n ? `${i18n.t(\"tpsl.sl\")} - ${i18n.t(\"common.marketPrice\")}`\n : undefined;\n\n return { tpTriggerPrice, slTriggerPrice };\n}\n","import { FC, useMemo } from \"react\";\nimport { useSymbolsInfo, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { API, AlgoOrderType } from \"@kodiak-finance/orderly-types\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { cn, Text, Tooltip } from \"@kodiak-finance/orderly-ui\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nexport const OrderTriggerPrice = () => {\n const { sl_trigger_price, tp_trigger_price, order, position } =\n useTPSLOrderRowContext();\n\n return (\n <TPSLTriggerPrice\n stopLossPrice={sl_trigger_price}\n takeProfitPrice={tp_trigger_price}\n direction={\"column\"}\n order={order}\n position={position}\n tooltip\n />\n );\n};\n\nexport const TPSLTriggerPrice: FC<{\n takeProfitPrice: number | undefined;\n stopLossPrice: number | undefined;\n className?: string;\n direction?: \"row\" | \"column\";\n tooltip?: boolean;\n order?: API.AlgoOrder;\n position?: API.PositionTPSLExt;\n}> = (props) => {\n const { direction = \"row\", order, position } = props;\n // const symbolInfo = useSymbolsInfo()[position?.symbol ?? \"\"]();\n const symbolInfo = useSymbolsInfo();\n const { t } = useTranslation();\n\n const pnl = useMemo(() => {\n const msgs = [];\n\n if (!props.tooltip || !order || !position) return;\n\n let quantity = order.quantity;\n\n if (quantity === 0) {\n if (order.child_orders?.[0].type === \"CLOSE_POSITION\") {\n quantity = position.position_qty;\n }\n }\n\n if (!!props.takeProfitPrice) {\n msgs.push(\n <TriggerPriceItem\n key={\"tp\"}\n qty={quantity}\n price={props.takeProfitPrice}\n entryPrice={position.average_open_price}\n orderSide={order.side as OrderSide}\n orderType={AlgoOrderType.TAKE_PROFIT}\n symbolInfo={symbolInfo[order.symbol]()}\n />\n );\n }\n\n if (!!props.stopLossPrice) {\n msgs.push(\n <TriggerPriceItem\n key={\"sl\"}\n qty={quantity}\n price={props.stopLossPrice}\n entryPrice={position.average_open_price}\n orderSide={order.side as OrderSide}\n orderType={AlgoOrderType.STOP_LOSS}\n symbolInfo={symbolInfo[order.symbol]()}\n />\n );\n }\n\n return <div>{msgs}</div>;\n }, [\n props.takeProfitPrice,\n props.stopLossPrice,\n position?.average_open_price,\n order?.side,\n order?.quantity,\n order?.algo_type,\n ]);\n\n const child = useMemo(() => {\n const children = [];\n\n if (!order?.symbol) return <span>-</span>;\n if (props.takeProfitPrice) {\n children.push(\n <Text.numeral\n className={cn(\n \"oui-text-trade-profit oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12\"\n )}\n key={\"tp\"}\n rule=\"price\"\n dp={symbolInfo[order!.symbol](\"quote_dp\", 2)}\n children={props.takeProfitPrice}\n // @ts-ignore\n prefix={\n !props.stopLossPrice || direction === \"column\" ? (\n <span className={\"oui-text-base-contrast-54\"}>\n {`${t(\"tpsl.tp\")} -`} \n </span>\n ) : (\n \"\"\n )\n }\n />\n );\n }\n if (props.stopLossPrice) {\n children.push(\n <Text.numeral\n key={\"sl\"}\n className={cn(\n \"oui-text-trade-loss oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12\"\n )}\n rule={\"price\"}\n dp={symbolInfo[order!.symbol](\"quote_dp\", 2)}\n children={props.stopLossPrice}\n // @ts-ignore\n prefix={\n !props.takeProfitPrice || direction === \"column\" ? (\n <span className={\"oui-text-base-contrast-54\"}>\n {`${t(\"tpsl.sl\")} -`} \n </span>\n ) : (\n \"\"\n )\n }\n />\n );\n }\n\n if (children.length === 0) return <span>-</span>;\n\n if (children.length === 2 && direction === \"row\") {\n children.splice(1, 0, <span key={\"split\"}>/</span>);\n }\n\n return children;\n }, [props.takeProfitPrice, props.stopLossPrice, order?.symbol, t]);\n\n const content = (\n <div\n className={cn(\n \"oui-inline-flex oui-text-base-contrast-36\",\n props.direction === \"column\"\n ? \"oui-flex-col\"\n : \"oui-flex-row oui-gap-1\",\n props.className\n )}\n >\n {child}\n </div>\n );\n\n if (props.tooltip) {\n // @ts-ignore\n return (\n <Tooltip\n // @ts-ignore\n content={pnl}\n className=\"oui-bg-base-5\"\n arrow={{ className: \"oui-fill-base-5\" }}\n >\n {content}\n </Tooltip>\n );\n }\n\n return content;\n};\n\nconst TriggerPriceItem: FC<{\n qty: number;\n price: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n symbolInfo: API.SymbolExt;\n}> = (props) => {\n const { qty, price, entryPrice, orderSide, orderType, symbolInfo } = props;\n const { t } = useTranslation();\n\n const pnl = utils.priceToPnl(\n {\n qty,\n price,\n entryPrice,\n orderSide,\n orderType,\n },\n {\n symbol: symbolInfo,\n }\n );\n\n const type = orderType === AlgoOrderType.TAKE_PROFIT ? \"TP\" : \"SL\";\n const label = type === \"TP\" ? `${t(\"tpsl.tpPnl\")}:` : `${t(\"tpsl.slPnl\")}:`;\n\n // console.log(\"trigger price item\", \"dp\", symbolInfo.quote_dp);\n\n return (\n <div className=\"oui-flex oui-items-center\">\n <span className=\"oui-text-base-contrast-54 oui-mr-1\">{label}</span>\n <Text.numeral\n rule=\"price\"\n dp={symbolInfo.quote_dp}\n padding={false}\n className={\n pnl === 0\n ? \"oui-text-base-contrast-36\"\n : pnl > 0\n ? \"oui-text-trade-profit oui-gap-0\"\n : \"oui-text-trade-loss oui-gap-0\"\n }\n // @ts-ignore\n prefix={\n // @ts-ignore\n <span>{pnl === 0 ? \"\" : pnl > 0 ? \"+\" : \"-\"}</span>\n }\n suffix={\n <span className=\"oui-text-base-contrast-36 oui-ml-1\">USDC</span>\n }\n >{`${Math.abs(pnl)}`}</Text.numeral>\n </div>\n );\n};\n","import { useMemo } from \"react\";\nimport { format } from \"date-fns\";\nimport { SymbolsInfo, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation, i18n } from \"@kodiak-finance/orderly-i18n\";\nimport {\n AlgoOrderRootType,\n AlgoOrderType,\n API,\n OrderSide,\n OrderStatus,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\nimport { cn, Column, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { Badge } from \"@kodiak-finance/orderly-ui\";\nimport {\n SharePnLConfig,\n SharePnLDialogId,\n} from \"@kodiak-finance/orderly-ui-share\";\nimport {\n commifyOptional,\n Decimal,\n getTrailingStopPrice,\n} from \"@kodiak-finance/orderly-utils\";\nimport {\n grayCell,\n parseBadgesFor,\n upperCaseFirstLetter,\n isTrailingStopOrder,\n getNotional,\n} from \"../../../utils/util\";\nimport { TabType } from \"../../orders.widget\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\nimport { ShareButtonWidget } from \"../../shareButton\";\nimport { AvgPrice } from \"./avgPrice\";\nimport { BracketOrderPrice } from \"./bracketOrderPrice\";\nimport { CancelButton } from \"./cancelBtn\";\nimport { ActivedPriceCell } from \"./components/activedPriceCell\";\nimport { PriceCell } from \"./components/priceCell\";\nimport { QuantityCell } from \"./components/quantityCell\";\nimport { TrailingCallbackCell } from \"./components/trailingCallbackCell\";\nimport { TriggerPriceCell } from \"./components/triggerPriceCell\";\nimport { Renew } from \"./renew\";\nimport { TP_SLEditButton } from \"./tpslEdit\";\nimport { TPSLOrderPrice, useTPSLOrderPrice } from \"./tpslPrice\";\nimport { OrderTriggerPrice } from \"./tpslTriggerPrice\";\n\nexport const useOrderColumn = (props: {\n _type: TabType;\n onSymbolChange?: (symbol: API.Symbol) => void;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n symbolsInfo?: SymbolsInfo;\n}) => {\n const {\n _type,\n onSymbolChange,\n pnlNotionalDecimalPrecision,\n sharePnLConfig,\n symbolsInfo,\n } = props;\n const { t } = useTranslation();\n\n const columns = useMemo(() => {\n switch (_type) {\n case TabType.all:\n return [\n instrument({\n width: 130,\n showType: true,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n side({ width: 130 }),\n fillAndQuantity({\n width: 130,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n enableSort: false,\n }),\n price({\n width: 130,\n title: t(\"common.orderPrice\"),\n disableEdit: true,\n enableSort: false,\n }),\n avgOpen({ width: 130, enableSort: false, symbolsInfo }),\n tpslTriggerPrice({ width: 130, symbolsInfo: props.symbolsInfo }),\n realizedPnL({\n width: 124,\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n sharePnLConfig: sharePnLConfig,\n symbolsInfo: props.symbolsInfo,\n }),\n estTotal({ width: 130, enableSort: false }),\n fee({ width: 130 }),\n status({ width: 130 }),\n reduceOnly({ width: 130 }),\n hidden({ width: 130 }),\n cancelBtn({ width: 130 }),\n orderTime({ width: 160, enableSort: false }),\n ];\n case TabType.pending:\n return [\n instrument({\n width: 172,\n showType: true,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n // side({ width: 162 }),\n fillAndQuantity({\n width: 162,\n className: \"oui-pr-0\",\n enableSort: false,\n }),\n price({ width: 162, className: \"oui-pr-0\", enableSort: false }),\n trailingCallback({ width: 162 }),\n triggerPrice({ width: 162, className: \"oui-pr-0\", isPending: true }),\n bracketOrderPrice({ width: 130 }),\n estTotal({ width: 162, isPending: true }),\n reduceOnly({ width: 162 }),\n hidden({ width: 162 }),\n orderTime({ width: 162, enableSort: false }),\n pendingTabCancelBtn({ width: 80 }),\n ];\n case TabType.tp_sl:\n return [\n instrument({\n width: 176,\n showType: true,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n // side({ width: 176 }),\n quantity({ width: 176 }),\n tpslTriggerPrice({ width: 176, symbolsInfo }),\n tpslPrice({ width: 176, disableEdit: true }),\n tpslNotional({ width: 176 }),\n reduceOnly({ width: 176 }),\n orderTime({ width: 176, enableSort: false }),\n tpslAction({ width: 176 }),\n ];\n case TabType.filled:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n }),\n // type({ width: 124 }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 124,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n }),\n price({\n width: 124,\n title: t(\"common.orderPrice\"),\n disableEdit: true,\n }),\n avgPrice({ width: 124 }),\n triggerPrice({ width: 124, disableEdit: true }),\n realizedPnL({\n width: 124,\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n sharePnLConfig: sharePnLConfig,\n symbolsInfo,\n hideShare: true,\n }),\n estTotal({ width: 124 }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n orderTime({ width: 176 }),\n ];\n case TabType.cancelled:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 124,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n enableSort: false,\n }),\n price({ width: 124, disableEdit: true, enableSort: false }),\n avgOpen({ width: 124, enableSort: false }),\n triggerPrice({ width: 124, disableEdit: true }),\n estTotal({ width: 124 }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n ];\n case TabType.rejected:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 124,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n }),\n price({ width: 124, disableEdit: true }),\n avgOpen({ width: 124 }),\n triggerPrice({ width: 124, disableEdit: true }),\n estTotal({ width: 124 }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n orderTime({ width: 176 }),\n ];\n case TabType.orderHistory:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n }),\n fillAndQuantity({\n width: 150,\n disableEdit: true,\n className: \"oui-pl-6 oui-pr-0\",\n }),\n price({\n width: 124,\n disableEdit: true,\n tabType: TabType.orderHistory,\n }),\n avgOpen({ width: 124 }),\n triggerPrice({ width: 124, disableEdit: true }),\n realizedPnL({\n width: 124,\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n sharePnLConfig: sharePnLConfig,\n symbolsInfo: props.symbolsInfo,\n }),\n estTotal({ width: 124 }),\n trailingCallback({ width: 124, disableEdit: true }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n orderTime({ width: 150 }),\n cancelBtn({ width: 80 }),\n ];\n }\n }, [_type, pnlNotionalDecimalPrecision, sharePnLConfig, t]);\n\n return columns as Column[];\n\n // return columns();\n};\n\nfunction instrument(option?: {\n showType?: boolean;\n enableSort?: boolean;\n width?: number;\n onSymbolChange?: (symbol: API.Symbol) => void;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.symbol\"),\n dataIndex: \"symbol\",\n fixed: \"left\",\n // className: \"oui-h-[48px]\",\n width: option?.width,\n onSort: option?.enableSort\n ? (r1, r2) => {\n return r1.symbol.localeCompare(r2.symbol);\n // if (sortOrder === \"asc\") {\n // return r1.symbol.localeCompare(r2.symbol);\n // }\n // return r2.symbol.localeCompare(r1.symbol);\n }\n : undefined,\n renderPlantText: (value: string, record) => {\n const badges = parseBadgesFor(record)?.join(\",\");\n const displayBadges = badges?.length ? ` (${badges})` : \"\";\n return `${value.split(\"_\")[1]}-PERP${displayBadges}`;\n },\n render: (value: string, record) => {\n const showGray = grayCell(record);\n\n return (\n <Flex gap={2}>\n <div\n className={cn(\n \"oui-h-7 oui-w-1 oui-shrink-0 oui-rounded-[1px]\",\n record.side === OrderSide.BUY\n ? \"oui-bg-trade-profit\"\n : \"oui-bg-trade-loss\",\n )}\n />\n <Flex direction=\"column\" itemAlign={\"start\"}>\n <Text.formatted\n // rule={\"symbol\"}\n size=\"xs\"\n className=\"oui-cursor-pointer oui-text-xs\"\n onClick={(e) => {\n option?.onSymbolChange?.({ symbol: value } as API.Symbol);\n e.stopPropagation();\n e.preventDefault();\n }}\n >\n {`${value.split(\"_\")[1]}-PERP`}\n </Text.formatted>\n\n {option?.showType && (\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(record)?.map((e, index) => (\n <Badge\n key={index}\n color={\n e.toLocaleLowerCase() === \"position\"\n ? showGray\n ? \"neutral\"\n : \"primary\"\n : \"neutral\"\n }\n size=\"xs\"\n className=\"oui-whitespace-nowrap oui-break-normal\"\n >\n {e}\n </Badge>\n ))}\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n },\n };\n}\n\nfunction side(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.side\"),\n dataIndex: \"side\",\n width: option?.width,\n // className: \"oui-h-[48px]\",\n onSort: option?.enableSort\n ? (r1, r2, sortOrder) => {\n return r2.side.localeCompare(r1.side);\n // if (sortOrder === \"asc\") {\n // return r2.side.localeCompare(r1.side);\n // }\n // return r1.side.localeCompare(r2.side);\n }\n : undefined,\n renderPlantText: (value: string, record) => upperCaseFirstLetter(value),\n render: (value: string, record) => {\n const clsName = grayCell(record)\n ? \"oui-text-base-contrast-20\"\n : value === OrderSide.BUY\n ? \"oui-text-trade-profit\"\n : \"oui-text-trade-loss\";\n return (\n <span className={cn(\"oui-font-semibold\", clsName)}>\n {upperCaseFirstLetter(value)}\n </span>\n );\n },\n };\n}\n\nfunction type(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.type\"),\n dataIndex: \"type\",\n width: option?.width,\n className: option?.className,\n formatter: (value: string, record: any) => {\n if (!!record.parent_algo_type) {\n if (record.algo_type === AlgoOrderType.STOP_LOSS) {\n return record.type === OrderType.CLOSE_POSITION\n ? `Position SL`\n : \"SL\";\n }\n\n if (record.algo_type === AlgoOrderType.TAKE_PROFIT) {\n return record.type === OrderType.CLOSE_POSITION\n ? `Position TP`\n : \"TP\";\n }\n }\n\n if (record.algo_order_id) {\n return `Stop ` + `${record.type}`.toLowerCase();\n }\n return upperCaseFirstLetter(value);\n },\n };\n}\n\nfunction fillAndQuantity(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.AlgoOrderExt> {\n return {\n title: i18n.t(\"orders.column.fill&Quantity\"),\n plantTextTitle: \"Filled\",\n dataIndex: \"fill_quantity\",\n className: option?.className,\n width: option?.width,\n exportable: false,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b) => {\n const aQuantity =\n (a.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : a.quantity) ?? 0;\n const bQuantity =\n (b.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : b.quantity) ?? 0;\n\n return compareNumbers(aQuantity, bQuantity);\n\n // if (type == \"asc\") {\n // return compareNumbers(aQuantity, bQuantity);\n // }\n // return compareNumbers(bQuantity, aQuantity);\n }\n : undefined,\n\n renderPlantText: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n const executed = (record as API.OrderExt).total_executed_quantity;\n const first =\n \"algo_type\" in record && record.algo_type === AlgoOrderRootType.TP_SL\n ? \"\"\n : `${executed} / `;\n return first + `${record.quantity}`;\n },\n render: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n return <QuantityCell order={record} disabled={option?.disableEdit} />;\n // return value;\n },\n };\n}\n\nfunction quantity(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.AlgoOrderExt> {\n return {\n title: i18n.t(\"common.quantity\"),\n className: option?.className,\n dataIndex: \"quantity\",\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b) => {\n const aQuantity =\n (a.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : a.quantity) ?? 0;\n const bQuantity =\n (b.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : b.quantity) ?? 0;\n return compareNumbers(aQuantity, bQuantity);\n // if (type == \"asc\") {\n // return compareNumbers(aQuantity, bQuantity);\n // }\n // return compareNumbers(bQuantity, aQuantity);\n }\n : undefined,\n renderPlantText: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n const executed = (record as API.OrderExt).total_executed_quantity;\n const first =\n \"algo_type\" in record && record.algo_type === AlgoOrderRootType.TP_SL\n ? \"\"\n : `${executed} / `;\n return first + `${record.quantity}`;\n },\n render: (value: string, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n return <QuantityCell order={record} />;\n // return value;\n },\n };\n}\n\nfunction price(option?: {\n title?: string;\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n tabType?: TabType;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"common.price\"),\n dataIndex: \"price\",\n className: option?.className,\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b, type) => {\n return compareNumbers(a.price ?? 0, b.price ?? 0);\n }\n : undefined,\n renderPlantText: (value: string, record: any) => {\n const isTrailingStop = isTrailingStopOrder(record);\n if (isTrailingStop) {\n // TODO: fix precision\n return option?.tabType === TabType.orderHistory\n ? i18n.t(\"common.marketPrice\")\n : getTrailingStopPrice(record) || \"--\";\n }\n return commifyOptional(record.price, {\n fallback: i18n.t(\"common.marketPrice\"),\n });\n },\n render: (value: string, record: any) => {\n const isTrailingStop = isTrailingStopOrder(record);\n if (isTrailingStop) {\n // TODO: fix precision\n return option?.tabType === TabType.orderHistory\n ? i18n.t(\"common.marketPrice\")\n : getTrailingStopPrice(record) || \"--\";\n }\n\n return <PriceCell order={record} disabled={option?.disableEdit} />;\n },\n };\n}\n\nfunction tpslPrice(option?: {\n title?: string;\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"common.price\"),\n dataIndex: \"price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n const { tpTriggerPrice, slTriggerPrice } = useTPSLOrderPrice(record);\n const callback = `${tpTriggerPrice || \"\"}${\n slTriggerPrice ? `${tpTriggerPrice ? \"\\n\" : \"\"}${slTriggerPrice}` : \"\"\n }`;\n\n return callback.length > 0 ? callback : \"--\";\n },\n render: (value: string, record: any) => {\n return <TPSLOrderPrice />;\n },\n };\n}\n\nfunction avgPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n symbolsInfo?: SymbolsInfo;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.avgPrice\"),\n dataIndex: \"average_executed_price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n return commifyOptional(value);\n },\n render: (value: string, record: any) => {\n return <AvgPrice symbol={record.symbol} value={value} />;\n },\n };\n}\n\nfunction triggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n isPending?: boolean;\n}): Column<API.Order> {\n const { isPending } = option || {};\n const checkOrderType = (record: any) => {\n const isAlgoOrder = record?.algo_order_id !== undefined;\n const isBracketOrder = record?.algo_type === \"BRACKET\";\n return isAlgoOrder && !isBracketOrder;\n };\n\n return {\n title: i18n.t(\"common.trigger\"),\n className: option?.className,\n dataIndex: \"trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n if (!checkOrderType(record)) {\n return \"--\";\n }\n if (isTrailingStopOrder(record) && isPending) {\n return record.activated_price\n ? commifyOptional(record.activated_price)\n : \"--\";\n }\n return commifyOptional(value);\n },\n render: (value: string, record: any) => {\n if (!checkOrderType(record)) {\n return \"--\";\n }\n\n if (isTrailingStopOrder(record) && isPending) {\n return (\n <ActivedPriceCell order={record} disabled={option?.disableEdit} />\n );\n }\n return <TriggerPriceCell order={record} disabled={option?.disableEdit} />;\n },\n };\n}\n\nfunction tpslTriggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n title?: string;\n symbolsInfo?: SymbolsInfo;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"common.trigger\"),\n className: option?.className,\n dataIndex: \"tpsl_trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n const info = option?.symbolsInfo?.[record.symbol];\n const quote_dp = info?.(\"quote_dp\");\n // @ts-ignore\n const { sl_trigger_price, tp_trigger_price } =\n !(\"algo_type\" in record) || !Array.isArray(record.child_orders)\n ? {}\n : utils.findTPSLFromOrder(record);\n\n const callback =\n (tp_trigger_price != null\n ? `${i18n.t(\"tpsl.tp\")}: ${commifyOptional(tp_trigger_price, {\n fix: quote_dp,\n padEnd: true,\n })}`\n : \"\") +\n (sl_trigger_price != null\n ? `${tp_trigger_price ? \"\\n\" : \"\"}${i18n.t(\n \"tpsl.sl\",\n )}: ${commifyOptional(sl_trigger_price, {\n fix: quote_dp,\n padEnd: true,\n })}`\n : \"\");\n return callback.length > 0 ? callback : \"--\";\n },\n render: (value: string, record: any) => <OrderTriggerPrice />,\n };\n}\n\nfunction bracketOrderPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}) {\n return {\n title: i18n.t(\"common.tpsl\"),\n className: option?.className,\n dataIndex: \"bracketOrderPrice\",\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n const getTPSLTriggerPrice = (): {\n sl_trigger_price?: number;\n tp_trigger_price?: number;\n } => {\n if (!(\"algo_type\" in record) || !Array.isArray(record.child_orders)) {\n return {};\n }\n return utils.findTPSLFromOrder(record.child_orders[0]);\n };\n\n const { sl_trigger_price, tp_trigger_price } = getTPSLTriggerPrice();\n\n const callback =\n (tp_trigger_price != null\n ? `${i18n.t(\"tpsl.tp\")}: ${tp_trigger_price}`\n : \"\") +\n (sl_trigger_price != null\n ? `${tp_trigger_price ? \"\\n\" : \"\"}${i18n.t(\n \"tpsl.sl\",\n )}: ${sl_trigger_price}`\n : \"\");\n return callback.length > 0 ? callback : \"--\";\n },\n render: (value: string, record: any) => (\n <BracketOrderPrice order={record} />\n ),\n };\n}\n\nfunction estTotal(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n isPending?: boolean;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.notional\"),\n dataIndex: \"executed\",\n width: option?.width,\n className: option?.className,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b, type) => {\n const aTotal =\n a.type === OrderType.CLOSE_POSITION &&\n a.status !== OrderStatus.FILLED\n ? 0\n : a.total_executed_quantity === 0 ||\n Number.isNaN(a.average_executed_price) ||\n a.average_executed_price === null\n ? 0\n : a.total_executed_quantity * a.average_executed_price;\n const bTotal =\n b.type === OrderType.CLOSE_POSITION &&\n b.status !== OrderStatus.FILLED\n ? 0\n : b.total_executed_quantity === 0 ||\n Number.isNaN(b.average_executed_price) ||\n b.average_executed_price === null\n ? 0\n : b.total_executed_quantity * b.average_executed_price;\n return compareNumbers(aTotal, bTotal);\n // if (type === \"asc\") {\n // return compareNumbers(aTotal, bTotal);\n // }\n // return compareNumbers(bTotal, aTotal);\n }\n : undefined,\n renderPlantText: (value: string, record: any) => {\n const estTotal = estTotalValue(record, option?.isPending ?? false);\n\n if (estTotal === \"Entire position\") {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return commifyOptional(\n estTotalValue(record, option?.isPending ?? false),\n { fix: 2 },\n );\n },\n render: (value: string, record: any) => {\n const estTotal = estTotalValue(record, option?.isPending ?? false);\n\n if (estTotal === \"Entire position\") {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return (\n <Text.numeral rm={Decimal.ROUND_DOWN} dp={2}>\n {estTotal}\n </Text.numeral>\n );\n },\n };\n}\n\nfunction realizedPnL(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n symbolsInfo?: SymbolsInfo;\n hideShare?: boolean;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.realizedPnl\"),\n dataIndex: \"realized_pnl\",\n width: option?.width,\n className: option?.className,\n renderPlantText: (_value: string, record: any) => {\n const info = option?.symbolsInfo?.[record.symbol];\n const quote_dp = info?.(\"quote_dp\");\n const dp = option?.pnlNotionalDecimalPrecision ?? quote_dp;\n const value = new Decimal(_value ?? 0)\n .toDecimalPlaces(dp, Decimal.ROUND_DOWN)\n .toNumber();\n\n const formatValue = commifyOptional(value);\n\n return value > 0 ? `+${formatValue}` : formatValue;\n },\n render: (_value: number | undefined, record: any) => {\n const { quote_dp } = useSymbolContext();\n const dp = option?.pnlNotionalDecimalPrecision ?? quote_dp;\n const value = new Decimal(_value ?? 0)\n .toDecimalPlaces(dp, Decimal.ROUND_DOWN)\n .toNumber();\n // wraper flex\n return (\n <Flex gap={1}>\n <Text.numeral\n dp={dp}\n rm={Decimal.ROUND_DOWN}\n padding={false}\n intensity={(value ?? 0) == 0 ? 80 : undefined}\n showIdentifier={(value ?? 0) > 0}\n coloring={(value ?? 0) != 0}\n >\n {value ?? \"--\"}\n </Text.numeral>\n {!option?.hideShare && (\n <ShareButtonWidget\n order={record}\n sharePnLConfig={option?.sharePnLConfig}\n modalId={SharePnLDialogId}\n />\n )}\n </Flex>\n );\n },\n };\n}\n\nfunction reduceOnly(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"orderEntry.reduceOnly\"),\n dataIndex: \"reduce_only\",\n width: option?.width,\n className: option?.className,\n renderPlantText: (value: string, record: any) => {\n return value ? i18n.t(\"common.yes\") : i18n.t(\"common.no\");\n },\n render: (value: boolean) => {\n return <Text>{value ? i18n.t(\"common.yes\") : i18n.t(\"common.no\")}</Text>;\n },\n };\n}\n\nfunction hidden(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"orders.column.hidden\"),\n dataIndex: \"visible\",\n width: option?.width,\n className: option?.className,\n renderPlantText: (value: number, record: any) => {\n return value !== 0 ? i18n.t(\"common.no\") : i18n.t(\"common.yes\");\n },\n render: (value: number, record) => {\n return (\n <Text>\n {record.visible_quantity !== 0\n ? i18n.t(\"common.no\")\n : i18n.t(\"common.yes\")}\n </Text>\n );\n },\n };\n}\n\nfunction orderTime(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n formatString?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"orders.column.orderTime\"),\n dataIndex: \"created_time\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: string, record: any) => {\n const date = new Date(value);\n const formattedDate = format(date, \"yyyy-MM-dd HH:mm:ss\");\n return formattedDate;\n },\n render: (value: string) => (\n <Text.formatted\n rule={\"date\"}\n formatString={option?.formatString || \"yyyy-MM-dd HH:mm:ss\"}\n className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\"\n >\n {value}\n </Text.formatted>\n ),\n };\n}\n\nfunction fee(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.fee\"),\n dataIndex: \"total_fee\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n };\n}\n\nfunction notional(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.notional\"),\n dataIndex: \"notional\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: number, record: any) => {\n return commifyOptional(value, { fix: 2 });\n },\n render: (value?: string) => (\n <Text.numeral className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {value ?? \"--\"}\n </Text.numeral>\n ),\n };\n}\n\nfunction tpslNotional(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.notional\"),\n dataIndex: \"executed\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: any, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n return commifyOptional(\n record.quantity === 0\n ? \"--\"\n : `${new Decimal(record.mark_price)\n .mul(record.quantity)\n .todp(2)\n .toNumber()}`,\n );\n },\n render: (value: any, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return (\n <Text.numeral className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {record.quantity === 0\n ? \"--\"\n : `${new Decimal(record.mark_price)\n .mul(record.quantity)\n .todp(2)\n .toNumber()}`}\n </Text.numeral>\n );\n },\n };\n}\n\nfunction status(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n const statusMap = {\n [OrderStatus.NEW]: i18n.t(\"orders.status.pending\"),\n [OrderStatus.FILLED]: i18n.t(\"orders.status.filled\"),\n [OrderStatus.PARTIAL_FILLED]: i18n.t(\"orders.status.partialFilled\"),\n [OrderStatus.CANCELLED]: i18n.t(\"orders.status.canceled\"),\n [OrderStatus.REJECTED]: i18n.t(\"orders.status.rejected\"),\n [OrderStatus.INCOMPLETE]: i18n.t(\"orders.status.incomplete\"),\n [OrderStatus.COMPLETED]: i18n.t(\"orders.status.completed\"),\n };\n return {\n title: i18n.t(\"common.status\"),\n dataIndex: \"status\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: string, record: any) => {\n const status = value || record.algo_status;\n return (\n statusMap[status as keyof typeof statusMap] ||\n upperCaseFirstLetter(status)\n );\n },\n render: (value: string, record: any) => {\n const status = value || record.algo_status;\n return (\n statusMap[status as keyof typeof statusMap] ||\n upperCaseFirstLetter(status)\n );\n },\n };\n}\n\nfunction avgOpen(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n symbolsInfo?: SymbolsInfo;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.avgPrice\"),\n dataIndex: \"average_executed_price\",\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b) => {\n return compareNumbers(\n a.average_executed_price ?? 0,\n b.average_executed_price ?? 0,\n );\n }\n : undefined,\n className: option?.className,\n render: (value: string, record) => {\n if (record.type === OrderType.MARKET && !value) {\n return \"--\";\n }\n\n return <AvgPrice symbol={record.symbol} value={value} />;\n },\n renderPlantText: (value: string, record: any) => {\n return value ? commifyOptional(value) : \"--\";\n },\n };\n}\n\nfunction cancelBtn(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n type: \"action\",\n dataIndex: \"action\",\n width: option?.width,\n className: option?.className,\n align: \"right\",\n fixed: \"right\",\n render: (_: string, record: any) => {\n if (record.status === OrderStatus.CANCELLED) {\n return <Renew record={record} />;\n }\n\n if (\n record.status === OrderStatus.NEW ||\n record.algo_status === OrderStatus.NEW\n ) {\n return <CancelButton order={record} />;\n }\n\n return null;\n },\n };\n}\n\nfunction pendingTabCancelBtn(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n type: \"action\",\n dataIndex: \"action\",\n width: option?.width,\n className: option?.className,\n align: \"right\",\n fixed: \"right\",\n render: (_: string, record: any) => {\n return <CancelButton order={record} />;\n },\n };\n}\n\nfunction tpslAction(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n type: \"action\",\n dataIndex: \"action\",\n width: option?.width,\n className: option?.className,\n align: \"right\",\n fixed: \"right\",\n render: (_: string, record: any) => {\n return (\n <Flex gap={3}>\n <TP_SLEditButton order={record} />\n <CancelButton order={record} />\n </Flex>\n );\n },\n };\n}\n\nfunction compareNumbers(a: number, b: number): number {\n if (a > b) return 1;\n if (a < b) return -1;\n return 0;\n}\n\n// estTotal\nfunction estTotalValue(record: any, isPending: boolean): string {\n if (isPending) {\n return getNotional(record) || \"--\";\n }\n\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return record.total_executed_quantity === 0 ||\n Number.isNaN(record.average_executed_price) ||\n record.average_executed_price === null\n ? \"--\"\n : `${record.total_executed_quantity * record.average_executed_price}`;\n}\n\nfunction trailingCallback(option?: {\n title?: string;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"orderEntry.trailing\"),\n dataIndex: \"callback_value\",\n className: option?.className,\n width: option?.width,\n renderPlantText: (value: string, record: any) => {\n const { callback_value, callback_rate } = record;\n const val =\n callback_value || (callback_rate ? `${callback_rate * 100}%` : \"--\");\n return val?.toString();\n },\n render: (value: string, record: any) => {\n if (isTrailingStopOrder(record)) {\n return (\n <TrailingCallbackCell order={record} disabled={option?.disableEdit} />\n );\n }\n\n return \"--\";\n },\n };\n}\n","import {\n FC,\n PropsWithChildren,\n ReactNode,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport {\n AlgoOrderRootType,\n API,\n OrderStatus,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { Badge, Flex, Statistic, Text, Tooltip } from \"@kodiak-finance/orderly-ui\";\nimport { SharePnLBottomSheetId } from \"@kodiak-finance/orderly-ui-share\";\nimport { Decimal, getTrailingStopPrice } from \"@kodiak-finance/orderly-utils\";\nimport {\n getNotional,\n parseBadgesFor,\n upperCaseFirstLetter,\n} from \"../../../utils/util\";\nimport { ShareButtonWidget } from \"../../shareButton\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\nimport { OrderCellState } from \"./orderCell.script\";\n\nexport const SymbolToken: FC<OrderCellState> = (props) => {\n const { item } = props;\n const isBuy = item.side === OrderSide.BUY;\n const { t } = useTranslation();\n\n return (\n <Text.formatted\n intensity={80}\n rule=\"symbol\"\n formatString=\"base-type\"\n size=\"sm\"\n // @ts-ignore\n prefix={\n <Badge color={isBuy ? \"success\" : \"danger\"} size=\"xs\">\n {isBuy ? t(\"common.buy\") : t(\"common.sell\")}\n </Badge>\n }\n onClick={() => {\n props.onSymbolChange?.({ symbol: item.symbol } as API.Symbol);\n }}\n // showIcon\n >\n {item.symbol}\n </Text.formatted>\n );\n};\n\nexport const OrderTypeView: FC<OrderCellState> = (props) => {\n const { item } = props;\n\n const orderType = useCallback(() => {\n const type =\n typeof item.type === \"string\"\n ? item.type.replace(\"_ORDER\", \"\").toLowerCase()\n : item.type;\n const isAlgoOrder =\n item.algo_order_id && item.algo_type !== AlgoOrderRootType.BRACKET;\n if (isAlgoOrder) {\n return `Stop ${type}`;\n }\n return upperCaseFirstLetter(item.type);\n }, [item]);\n\n return (\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(props.item)?.map((e, index) => (\n <Badge\n key={index}\n color={e.toLocaleLowerCase() === \"position\" ? \"primary\" : \"neutral\"}\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n </Flex>\n );\n};\n\nexport const OrderTime: FC<OrderCellState> = (props) => {\n const { item } = props;\n\n return (\n <Text.formatted\n rule={\"date\"}\n formatString=\"yyyy-MM-dd HH:mm:ss\"\n intensity={36}\n size=\"2xs\"\n >\n {item.created_time}\n </Text.formatted>\n );\n};\n\nexport const OrderState: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n // @ts-ignore\n const status = item.status || item.algo_status;\n\n const statusMap = useMemo(() => {\n return {\n [OrderStatus.NEW]: t(\"orders.status.pending\"),\n [OrderStatus.FILLED]: t(\"orders.status.filled\"),\n [OrderStatus.PARTIAL_FILLED]: t(\"orders.status.partialFilled\"),\n [OrderStatus.CANCELLED]: t(\"orders.status.canceled\"),\n [OrderStatus.REJECTED]: t(\"orders.status.rejected\"),\n [OrderStatus.INCOMPLETE]: t(\"orders.status.incomplete\"),\n [OrderStatus.COMPLETED]: t(\"orders.status.completed\"),\n };\n }, [t]);\n\n return (\n <Text.formatted intensity={80} size=\"2xs\">\n {statusMap[status as keyof typeof statusMap] ||\n upperCaseFirstLetter(status)}\n </Text.formatted>\n );\n};\n\nexport const Qty: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n const isEntirePosition =\n item.type === OrderType.CLOSE_POSITION &&\n // @ts-ignore\n item?.status !== OrderStatus.FILLED;\n\n return (\n <Statistic\n label={t(\"common.qty\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.base_dp}\n padding={false}\n coloring\n placeholder={t(\"tpsl.entirePosition\")}\n intensity={80}\n >\n {isEntirePosition ? t(\"tpsl.entirePosition\") : item.quantity}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const Filled: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={<Text>{t(\"orders.status.filled\")}</Text>}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.base_dp}\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {/* {item.algo_order_id\n ? item.total_executed_quantity\n : (item as unknown as API.OrderExt).executed} */}\n {item.total_executed_quantity}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const Notional: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Statistic\n align=\"end\"\n label={\n <Text>\n {t(\"common.notional\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n coloring\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {(item as any).notional ?? \"--\"}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const EstTotal: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const value = useMemo(() => getNotional(item), [item.price, item.quantity]);\n\n const rendrerContent = () => {\n if (value) {\n return (\n <Text.numeral\n dp={props.quote_dp}\n coloring\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {value}\n </Text.numeral>\n );\n }\n\n return \"--\";\n };\n\n return (\n <Statistic\n align=\"end\"\n label={\n <Text>\n {t(\"common.notional\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {rendrerContent()}\n </Statistic>\n );\n};\n\nexport const TriggerPrice: FC<\n OrderCellState & {\n align?: \"start\" | \"end\";\n isPending?: boolean;\n }\n> = (props) => {\n const { item, isPending } = props;\n const { t } = useTranslation();\n\n const isTrailingStop = item?.algo_type === AlgoOrderRootType.TRAILING_STOP;\n\n const rendrerContent = () => {\n if (isTrailingStop && isPending && item.activated_price) {\n return (\n <Text.numeral\n dp={props.quote_dp}\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {item.activated_price}\n </Text.numeral>\n );\n }\n\n if (item.trigger_price) {\n return (\n <Text.numeral\n dp={props.quote_dp}\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {item.trigger_price}\n </Text.numeral>\n );\n }\n\n return \"--\";\n };\n\n return (\n <Statistic\n label={isTrailingStop ? t(\"common.trigger\") : t(\"common.triggerPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n align={props.align}\n >\n {rendrerContent()}\n </Statistic>\n );\n};\n\nexport const MarkPrice: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={t(\"common.markPrice\")}\n align=\"end\"\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {item.mark_price}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const LimitPrice: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const isAlgoOrder = item?.algo_order_id !== undefined;\n const isTrailingStop = item?.algo_type === AlgoOrderRootType.TRAILING_STOP;\n const isStopMarket = item?.type === \"MARKET\" && isAlgoOrder;\n\n const rendrerContent = () => {\n if (isTrailingStop) {\n return \"--\";\n }\n if (isStopMarket) {\n return <Text>{t(\"common.marketPrice\")}</Text>;\n }\n\n return (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {item.price ?? \"--\"}\n </Text.numeral>\n );\n };\n\n return (\n <Statistic\n label={t(\"common.limitPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {rendrerContent()}\n </Statistic>\n );\n};\n\nexport const TPTrigger: FC<OrderCellState> = (props) => {\n const { tp_trigger_price, tpPnL } = useTPSLOrderRowContext();\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={t(\"tpsl.tpTrigger\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <MobileTooltip\n content={\n tpPnL && (\n <Text.numeral\n size=\"2xs\"\n showIdentifier\n // @ts-ignore\n prefix={<Text intensity={54}>{`${t(\"tpsl.tpPnl\")}:`} </Text>}\n suffix={<Text intensity={20}> USDC</Text>}\n coloring\n >\n {tpPnL}\n </Text.numeral>\n )\n }\n classNames={{\n content: \"oui-bg-base-6 oui-ml-2\",\n arrow: \"oui-fill-base-6\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n color=\"buy\"\n padding={false}\n className={\n tp_trigger_price\n ? \"oui-border-b oui-border-dashed oui-border-base-contrast-12\"\n : undefined\n }\n >\n {tp_trigger_price ?? \"--\"}\n </Text.numeral>\n </MobileTooltip>\n </Statistic>\n );\n};\n\nexport const SLTrigger: FC<OrderCellState> = (props) => {\n const { sl_trigger_price, slPnL } = useTPSLOrderRowContext();\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={t(\"tpsl.slTrigger\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <MobileTooltip\n content={\n slPnL && (\n <Text.numeral\n size=\"2xs\"\n // @ts-ignore\n prefix={\n <Text intensity={54}>{`${t(\"tpsl.slPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}> USDC</Text>}\n coloring\n >\n {slPnL}\n </Text.numeral>\n )\n }\n classNames={{\n content: \"oui-bg-base-6 oui-ml-2\",\n arrow: \"oui-fill-base-6\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n color=\"sell\"\n padding={false}\n className={\n sl_trigger_price\n ? \"oui-border-b oui-border-dashed oui-border-base-contrast-12\"\n : undefined\n }\n >\n {sl_trigger_price ?? \"--\"}\n </Text.numeral>\n </MobileTooltip>\n </Statistic>\n );\n};\n\nexport const TPPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n const { tp_order_price } = useTPSLOrderRowContext();\n\n const renderOrderPrice = useMemo(() => {\n if (tp_order_price === undefined) {\n return <Text>--</Text>;\n }\n if (tp_order_price === OrderType.MARKET) {\n return <Text>{t(\"common.marketPrice\")}</Text>;\n }\n return (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {tp_order_price}\n </Text.numeral>\n );\n }, [tp_order_price]);\n\n return (\n <Statistic\n label={t(\"tpsl.tpPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {renderOrderPrice}\n </Statistic>\n );\n};\nexport const SLPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n const { sl_order_price } = useTPSLOrderRowContext();\n\n const renderOrderPrice = useMemo(() => {\n if (sl_order_price === undefined) {\n return <Text>--</Text>;\n }\n if (sl_order_price === OrderType.MARKET) {\n return <Text>{t(\"common.marketPrice\")}</Text>;\n }\n return (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {sl_order_price}\n </Text.numeral>\n );\n }, [sl_order_price]);\n\n return (\n <Statistic\n label={t(\"tpsl.slPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {renderOrderPrice}\n </Statistic>\n );\n};\n\nexport const TPSLQuantity: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const quantity = useMemo(() => {\n if (item.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return (\n <span className=\"oui-text-base-contrast-80\">\n {t(\"tpsl.entirePosition\")}\n </span>\n );\n }\n\n return (\n <Text.numeral\n dp={props.base_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {item.quantity}\n </Text.numeral>\n );\n }, [item, t]);\n\n return (\n <Statistic\n label={t(\"common.quantity\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n align=\"end\"\n >\n {quantity}\n </Statistic>\n );\n};\n\nexport const AvgPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n return (\n <Statistic\n label={\n <Text>\n {t(\"common.avgPrice\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {/* @ts-ignore */}\n {props.item?.average_executed_price ?? \"--\"}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const OrderPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n return (\n <Statistic\n label={\n <Text>\n {t(\"common.orderPrice\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n placeholder={t(\"common.marketPrice\")}\n >\n {/* @ts-ignore */}\n {props.item?.price ?? \"--\"}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const RealizedPnL: FC<OrderCellState> = (props) => {\n // @ts-ignore\n const value = props?.item?.realized_pnl;\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={\n <Text>\n {t(\"common.realizedPnl\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n align=\"end\"\n >\n <Flex gap={1}>\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n padding={false}\n intensity={(value ?? 0) == 0 ? 80 : undefined}\n showIdentifier={(value ?? 0) > 0}\n coloring={(value ?? 0) != 0}\n >\n {value ?? \"--\"}\n </Text.numeral>\n <ShareButtonWidget\n order={props.item}\n sharePnLConfig={props.sharePnLConfig}\n modalId={SharePnLBottomSheetId}\n iconSize={12}\n />\n </Flex>\n </Statistic>\n );\n};\n\nexport const MobileTooltip: FC<\n PropsWithChildren<{\n content?: string | ReactNode;\n classNames?: {\n content?: string;\n arrow?: string;\n };\n }>\n> = (props) => {\n const { classNames, content } = props;\n const [open, setOpen] = useState(false);\n if (typeof content === \"undefined\") return props.children;\n return (\n <Tooltip\n // @ts-ignore\n content={content}\n className={classNames?.content}\n open={open}\n onOpenChange={setOpen}\n arrow={{ className: classNames?.arrow }}\n >\n <div onClick={() => setOpen((e) => !e)}>{props.children}</div>\n </Tooltip>\n );\n};\n\nexport const Fee: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n return (\n <Flex justify=\"end\" gapX={1} mt={1}>\n <Text size=\"2xs\" intensity={36}>\n {t(\"common.fee\")}:\n </Text>\n <Text size=\"2xs\" intensity={80}>\n {props.item?.total_fee ?? \"--\"}\n </Text>\n </Flex>\n );\n};\n\nexport const TrailingCallback: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const { callback_value, callback_rate } = item;\n\n return (\n <Statistic\n label={t(\"orderEntry.trailing\")}\n align=\"end\"\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {callback_rate ? (\n <Text intensity={80}>{`${callback_rate * 100}%`}</Text>\n ) : (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {callback_value ?? \"--\"}\n </Text.numeral>\n )}\n </Statistic>\n );\n};\n\nexport const TrailingPrice: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const value = useMemo(() => {\n return getTrailingStopPrice(item);\n }, [item]);\n\n return (\n <Statistic\n label={t(\"common.price\")}\n align=\"start\"\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {value ? (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {value}\n </Text.numeral>\n ) : (\n \"--\"\n )}\n </Statistic>\n );\n};\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, EditIcon, Flex, Text, modal } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { MobileTooltip } from \"../items\";\nimport { BracketOrderPriceState } from \"./bracketOrderPrice.script\";\n\nexport const BracketOrderPrice: FC<BracketOrderPriceState> = (props) => {\n const { t } = useTranslation();\n\n const onEdit = () => {\n modal.show(\"EditBracketOrderSheetId\", {\n order: props.order,\n });\n };\n\n if (!props.sl_trigger_price && !props.tp_trigger_price) return <></>;\n\n return (\n <Flex gap={1} itemAlign={\"center\"} justify={\"start\"}>\n <MobileTooltip\n classNames={{\n content: \"oui-bg-base-6 oui-ml-2\",\n arrow: \"oui-fill-base-6\",\n }}\n content={\n <Flex direction={\"column\"} itemAlign={\"start\"} gap={1}>\n {typeof props.pnl?.tpPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.tpPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={props.quote_dp}\n color=\"buy\"\n showIdentifier\n >\n {props.pnl?.tpPnL}\n </Text.numeral>\n )}\n {typeof props.pnl?.slPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.slPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={props.quote_dp}\n color=\"sell\"\n >\n {props.pnl?.slPnL}\n </Text.numeral>\n )}\n </Flex>\n }\n >\n <button\n onClick={() => {\n props.setOpen(!props.open);\n }}\n >\n <Flex gap={1} width={\"1\"}>\n {props.tp_trigger_price && (\n <Price\n type=\"TP\"\n value={props.tp_trigger_price}\n quote_dp={props.quote_dp}\n />\n )}\n {props.sl_trigger_price && (\n <Price\n type=\"SL\"\n value={props.sl_trigger_price}\n quote_dp={props.quote_dp}\n />\n )}\n </Flex>\n </button>\n </MobileTooltip>\n <EditIcon\n onClick={onEdit}\n opacity={1}\n className=\"oui-cursor-pointer oui-text-base-contrast-54\"\n size={16}\n />\n </Flex>\n );\n};\n\nconst Price = (props: {\n type: \"TP\" | \"SL\";\n value?: number | string;\n quote_dp: number;\n}) => {\n const { type, value, quote_dp } = props;\n\n return value ? (\n <Text.numeral\n size=\"2xs\"\n className={cn(\n \"oui-border-b oui-border-dashed oui-border-base-contrast-12\",\n type === \"TP\" ? \"oui-text-trade-profit\" : \"oui-text-trade-loss\",\n )}\n key={\"tp\"}\n rule=\"price\"\n dp={quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n // @ts-ignore\n prefix={\n <span className={\"oui-text-base-contrast-36\"}>\n {`${type} `}: \n </span>\n }\n >\n {value}\n </Text.numeral>\n ) : (\n <></>\n );\n};\n","import { useMemo, useState } from \"react\";\nimport { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { calcBracketRoiAndPnL } from \"../../../../utils/util\";\nimport { OrderCellState } from \"../orderCell.script\";\n\nexport const useBracketOrderPriceScript = (props: OrderCellState) => {\n const { item: order, quote_dp, base_dp } = props;\n\n const [open, setOpen] = useState(false);\n\n const { sl_trigger_price, tp_trigger_price } = useMemo(() => {\n if (!(\"algo_type\" in order) || !Array.isArray(order.child_orders)) {\n return {};\n }\n return utils.findTPSLFromOrder(order.child_orders[0]);\n }, [order]);\n\n const { pnl, roi } = calcBracketRoiAndPnL(order);\n\n return {\n sl_trigger_price,\n order,\n tp_trigger_price,\n pnl,\n roi,\n quote_dp,\n open,\n setOpen,\n };\n};\n\nexport type BracketOrderPriceState = ReturnType<\n typeof useBracketOrderPriceScript\n>;\n","import { FC } from \"react\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useBracketOrderPriceScript } from \"./bracketOrderPrice.script\";\nimport { BracketOrderPrice } from \"./bracketOrderPrice.ui\";\n\nexport const BracketOrderPriceWidget: FC<OrderCellState> = (props) => {\n const state = useBracketOrderPriceScript(props);\n return (<BracketOrderPrice {...state} />);\n};\n","export { BracketOrderPrice } from \"./bracketOrderPrice.ui\";\nexport { BracketOrderPriceWidget } from \"./bracketOrderPrice.widget\";\nexport { useBracketOrderPriceScript } from \"./bracketOrderPrice.script\";\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Button, SimpleDialog, Text } from \"@kodiak-finance/orderly-ui\";\nimport { CancelBtnState } from \"./cancelBtn.script\";\n\nexport const CancelBtn: FC<CancelBtnState> = (props) => {\n const { t } = useTranslation();\n\n return (\n <Button\n variant=\"outlined\"\n fullWidth\n color=\"secondary\"\n size=\"sm\"\n className=\"oui-border-base-contrast-36\"\n onClick={(e) => props.onCancel(e)}\n >\n {t(\"common.cancel\")}\n </Button>\n );\n};\n","import { FC, useState } from \"react\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { toast } from \"@kodiak-finance/orderly-ui\";\n\nexport const useCancelBtnScript = (props: { state: OrderCellState }) => {\n const { state } = props;\n const [open, setOpen] = useState(false);\n\n const { onCancelOrder } = useOrderListContext();\n const [isLoading, setIsLoading] = useState(false);\n\n const onCancel = (event?: any) => {\n if (!onCancelOrder) return Promise.resolve();\n event?.preventDefault();\n event?.stopPropagation();\n setIsLoading(true);\n return onCancelOrder(state.item)\n .then(\n (res: any) => {\n setOpen(false);\n },\n (error: any) => {\n toast.error(error.message);\n }\n ).finally(() => {\n setIsLoading(false);\n });\n };\n\n const onClose = () => {\n setOpen(false);\n };\n\n return {\n ...state,\n\n open,\n setOpen,\n onCancel,\n onClose,\n isLoading,\n };\n};\n\nexport type CancelBtnState = ReturnType<typeof useCancelBtnScript>;\n","import { FC } from \"react\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useCancelBtnScript } from \"./cancelBtn.script\";\nimport { CancelBtn } from \"./cancelBtn.ui\";\n\nexport const CancelBtnWidget = (props: { state: OrderCellState }) => {\n const state = useCancelBtnScript(props);\n return <CancelBtn {...state} />;\n};\n","export { CancelBtn } from \"./cancelBtn.ui\";\nexport { CancelBtnWidget } from \"./cancelBtn.widget\";\nexport { useCancelBtnScript } from \"./cancelBtn.script\";\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Button } from \"@kodiak-finance/orderly-ui\";\nimport { EditBtnState } from \"./editBtn.script\";\n\nexport const EditBtn: FC<EditBtnState> = (props) => {\n const { t } = useTranslation();\n\n return (\n <>\n <Button\n variant=\"outlined\"\n fullWidth\n color=\"secondary\"\n size=\"sm\"\n className=\"oui-border-base-contrast-36\"\n onClick={() => {\n props.onShowEditSheet();\n }}\n >\n {t(\"common.edit\")}\n </Button>\n </>\n );\n};\n","import { createContext, useContext } from \"react\";\nimport { OrderValidationResult } from \"@kodiak-finance/orderly-hooks\";\nimport { OrderlyOrder } from \"@kodiak-finance/orderly-types\";\nimport { SymbolContextState } from \"../../../../provider/symbolContext\";\n\nexport type EditSheetContextState = {\n symbolInfo: SymbolContextState;\n getErrorMsg: (\n key: keyof OrderValidationResult,\n customValue?: string,\n ) => string;\n setOrderValue: (key: keyof OrderlyOrder, value: any) => void;\n};\n\nexport const EditSheetContext = createContext({} as EditSheetContextState);\n\nexport function useEditSheetContext() {\n return useContext(EditSheetContext);\n}\n","import { memo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype ActivitedPriceInputProps = {\n activated_price?: string | number;\n disabled?: boolean;\n};\n\nexport const ActivitedPriceInput = memo((props: ActivitedPriceInputProps) => {\n const { activated_price } = props;\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const error = activated_price\n ? getErrorMsg(\"activated_price\")\n : t(\"orderEntry.triggerPrice.error.required\");\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.trigger\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]}\n value={activated_price}\n onValueChange={(val) => setOrderValue(\"activated_price\", val)}\n disabled={props.disabled}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-5 oui-max-w-[360px]\",\n },\n arrow: {\n className: \"oui-fill-base-5\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nActivitedPriceInput.displayName = \"ActivitedPriceInput\";\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { Badge, Checkbox, Divider, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { parseBadgesFor } from \"../../../../../utils/util\";\nimport { EditSheetState } from \"../editSheet.script\";\n\nexport const ConfirmDialogContent: FC<EditSheetState> = (props) => {\n const { item } = props;\n const {\n formattedOrder,\n symbolInfo,\n isStopMarket,\n showTriggerPrice,\n isTrailingStop,\n } = props;\n const { t } = useTranslation();\n\n const showPrice = !isTrailingStop;\n const showActivatedPrice = isTrailingStop && formattedOrder.activated_price;\n const showTrailingCallback = isTrailingStop;\n\n const header = (\n <>\n <Text\n intensity={80}\n >{`You agree to edit your ${props.base}-PERP order.`}</Text>\n <Flex gap={2} mb={3} mt={2} justify={\"between\"}>\n <Text.formatted\n rule=\"symbol\"\n formatString=\"base-type\"\n size=\"base\"\n showIcon\n >\n {item.symbol}\n </Text.formatted>\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(item)?.map((e, index) => (\n <Badge\n key={index}\n color={\n e.toLocaleLowerCase() === \"position\" ? \"primary\" : \"neutral\"\n }\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n {item.side === OrderSide.BUY ? (\n <Badge color=\"success\" size=\"xs\">\n {t(\"common.buy\")}\n </Badge>\n ) : (\n <Badge color=\"danger\" size=\"xs\">\n {t(\"common.sell\")}\n </Badge>\n )}\n </Flex>\n </Flex>\n </>\n );\n\n const triggerPriceItem = showTriggerPrice && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.triggerPrice\")}</Text>\n <Text.numeral\n intensity={80}\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n suffix={<Text intensity={54}>{\" USDC\"}</Text>}\n >\n {formattedOrder.trigger_price ?? \"--\"}\n </Text.numeral>\n </Flex>\n );\n\n const priceItem = showPrice && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.price\")}</Text>\n <Text.numeral\n intensity={80}\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n suffix={<Text intensity={54}>{\" USDC\"}</Text>}\n placeholder={isStopMarket ? t(\"common.marketPrice\") : \"--\"}\n >\n {isStopMarket\n ? t(\"common.marketPrice\")\n : (formattedOrder.order_price ?? \"--\")}\n </Text.numeral>\n </Flex>\n );\n\n const activatedPriceItem = showActivatedPrice && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.triggerPrice\")}</Text>\n {formattedOrder.activated_price ? (\n <Text.numeral\n intensity={80}\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n suffix={<Text intensity={54}>{\" USDC\"}</Text>}\n >\n {formattedOrder.activated_price}\n </Text.numeral>\n ) : (\n t(\"common.marketPrice\")\n )}\n </Flex>\n );\n\n const trailingCallbackItem = showTrailingCallback && (\n <>\n {formattedOrder.callback_value && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"orderEntry.trailingValue\")}</Text>\n <Text.numeral\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {formattedOrder.callback_value}\n </Text.numeral>\n </Flex>\n )}\n {formattedOrder.callback_rate && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"orderEntry.trailingRate\")}</Text>\n <Text className=\"oui-text-base-contrast\">\n {formattedOrder.callback_rate}%\n </Text>\n </Flex>\n )}\n </>\n );\n\n const quantityItem = (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.qty\")}</Text>\n <Text.numeral\n color={item.side === OrderSide.BUY ? \"buy\" : \"sell\"}\n dp={symbolInfo.base_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {formattedOrder.order_quantity}\n </Text.numeral>\n </Flex>\n );\n\n const orderConfirmCheckbox = (\n <Flex className=\"oui-gap-[2px]\">\n <Checkbox\n color=\"white\"\n id=\"oui-checkbox-disableOrderConfirmation\"\n checked={!props.orderConfirm}\n onCheckedChange={(e: boolean) => {\n props.setOrderConfirm(!e);\n }}\n />\n <label\n className=\"oui-text-2xs oui-text-base-contrast-54\"\n htmlFor=\"oui-checkbox-disableOrderConfirmation\"\n >\n {t(\"orderEntry.disableOrderConfirm\")}\n </label>\n </Flex>\n );\n\n return (\n <div className=\"oui-pt-2\">\n {header}\n <Divider />\n <Flex\n direction={\"column\"}\n gap={1}\n width={\"100%\"}\n className=\"oui-text-sm oui-text-base-contrast-54\"\n py={3}\n >\n {triggerPriceItem}\n {priceItem}\n {quantityItem}\n {activatedPriceItem}\n {trailingCallbackItem}\n </Flex>\n\n {orderConfirmCheckbox}\n </div>\n );\n};\n","import { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { Badge, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { parseBadgesFor } from \"../../../../../utils/util\";\n\ntype EditSheetHeaderProps = {\n item: API.AlgoOrderExt;\n};\n\nexport const EditSheetHeader = (props: EditSheetHeaderProps) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Flex width={\"100%\"} justify={\"between\"}>\n <Text.formatted rule={\"symbol\"} showIcon intensity={80}>\n {item.symbol}\n </Text.formatted>\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(props.item)?.map((e, index) => (\n <Badge\n key={index}\n color={e.toLocaleLowerCase() === \"position\" ? \"primary\" : \"neutral\"}\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n {item.side === OrderSide.BUY ? (\n <Badge color=\"success\" size=\"xs\">\n {t(\"common.buy\")}\n </Badge>\n ) : (\n <Badge color=\"danger\" size=\"xs\">\n {t(\"common.sell\")}\n </Badge>\n )}\n </Flex>\n </Flex>\n );\n};\n","import { memo, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype PriceInputProps = {\n order_price?: string | number;\n disabled?: boolean;\n};\n\nexport const PriceInput = memo((props: PriceInputProps) => {\n const [focus, setFocus] = useState(false);\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const error =\n getErrorMsg(\"order_price\") || (focus ? getErrorMsg(\"total\") : \"\");\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.price\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]}\n disabled={props.disabled}\n value={props.order_price}\n onValueChange={(val) => setOrderValue(\"order_price\", val)}\n onBlur={() => {\n setFocus(false);\n }}\n onFocus={() => {\n setFocus(true);\n }}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-5\",\n },\n arrow: {\n className: \"oui-fill-base-5\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nPriceInput.displayName = \"PriceInput\";\n","import { memo, useState } from \"react\";\nimport { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype QuantityInputProps = {\n value: string | number;\n};\n\nexport const QuantityInput = memo((props: QuantityInputProps) => {\n const [focus, setFocus] = useState(false);\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n\n const { base_dp, base_tick, base } = symbolInfo;\n\n const error =\n getErrorMsg(\"order_quantity\") || (focus ? getErrorMsg(\"total\") : \"\");\n\n const setQuantity = (val: string) => {\n setOrderValue(\"order_quantity\", val);\n };\n\n const onBlur = (value: string) => {\n if (base_tick && base_tick > 0) {\n const formatQty = utils.formatNumber(value, base_tick) ?? value;\n setQuantity(formatQty);\n }\n };\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.quantity\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {base}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(base_dp),\n // inputFormatter.rangeFormatter({ max: props.maxQty }),\n ]}\n value={props.value}\n onValueChange={setQuantity}\n onBlur={(event) => {\n onBlur(event.target.value);\n setFocus(false);\n }}\n onFocus={() => {\n setFocus(true);\n }}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-6\",\n },\n arrow: {\n className: \"oui-fill-base-6\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nQuantityInput.displayName = \"QuantityInput\";\n","import { memo, useMemo } from \"react\";\nimport { useThrottledCallback, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Flex, Slider, Text } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype QuantitySliderProps = {\n maxQty: number;\n quantity: string | number;\n};\n\nexport const QuantitySlider = memo((props: QuantitySliderProps) => {\n const { quantity, maxQty } = props;\n const { t } = useTranslation();\n\n const { symbolInfo, setOrderValue } = useEditSheetContext();\n const { base_dp, base_tick } = symbolInfo;\n\n const sliderValue = useMemo(() => {\n if (quantity && Number(quantity) !== 0 && maxQty !== 0) {\n const value = new Decimal(quantity)\n .div(maxQty)\n .mul(100)\n .toDecimalPlaces(2, Decimal.ROUND_DOWN)\n .toNumber();\n return value;\n }\n return 0;\n }, [quantity, maxQty]);\n\n const sliderToQuantity = useThrottledCallback(\n (value: number) => {\n const newQty = new Decimal(value)\n .div(100)\n .mul(maxQty)\n .toDecimalPlaces(base_dp, Decimal.ROUND_DOWN)\n .toNumber();\n\n setOrderValue(\"order_quantity\", utils.formatNumber(newQty, base_tick));\n },\n 50,\n {},\n );\n\n const percentages =\n props.quantity && props.maxQty\n ? Math.min(Number(props.quantity) / props.maxQty, 1)\n : undefined;\n\n return (\n <>\n <Slider\n markCount={4}\n value={[sliderValue]}\n onValueChange={(e) => {\n sliderToQuantity(e[0]);\n }}\n color=\"primary\"\n />\n <Flex width={\"100%\"} justify={\"between\"}>\n <Text.numeral\n color=\"primary\"\n size=\"2xs\"\n dp={2}\n padding={false}\n rule=\"percentages\"\n >{`${percentages ?? 0}`}</Text.numeral>\n <Flex\n gap={1}\n onClick={() => {\n setOrderValue(\"order_quantity\", maxQty.toString());\n }}\n >\n <Text size=\"2xs\" color=\"primary\">\n {t(\"common.max\")}\n </Text>\n <Text.numeral intensity={54} size=\"2xs\" dp={base_dp}>\n {props.maxQty}\n </Text.numeral>\n </Flex>\n </Flex>\n </>\n );\n});\n\nQuantitySlider.displayName = \"QuantitySlider\";\n","import { memo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype TrailingCallbackInputProps = {\n isCallbackValue?: boolean;\n callback_value?: number;\n callback_rate?: number;\n};\n\nexport const TrailingCallbackInput = memo(\n (props: TrailingCallbackInputProps) => {\n const { isCallbackValue, callback_value, callback_rate } = props;\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const label = isCallbackValue\n ? t(\"orderEntry.trailingValue\")\n : t(\"orderEntry.trailingRate\");\n\n const field = isCallbackValue ? \"callback_value\" : \"callback_rate\";\n\n const suffix = isCallbackValue ? (\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n ) : (\n \"%\"\n );\n\n const error = getErrorMsg(field);\n\n const formatters = [\n inputFormatter.numberFormatter,\n inputFormatter.decimalPointFormatter,\n ];\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {label}\n </Text>\n }\n suffix={suffix}\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={\n isCallbackValue\n ? [\n ...formatters,\n inputFormatter.currencyFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]\n : [...formatters, inputFormatter.dpFormatter(1)]\n }\n value={isCallbackValue ? callback_value : callback_rate}\n onValueChange={(val) => setOrderValue(field, val)}\n tooltip={error}\n tooltipProps={{\n content: {\n // mobile max width\n className: \"oui-bg-base-5 oui-max-w-[360px]\",\n },\n arrow: {\n className: \"oui-fill-base-5\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n },\n);\n\nTrailingCallbackInput.displayName = \"TrailingCallbackInput\";\n","import { memo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype TriggerPriceInputProps = {\n trigger_price?: string | number;\n disabled?: boolean;\n};\n\nexport const TriggerPriceInput = memo((props: TriggerPriceInputProps) => {\n const { t } = useTranslation();\n\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const error = getErrorMsg(\"trigger_price\");\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.triggerPrice\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]}\n value={props.trigger_price}\n onValueChange={(val) => setOrderValue(\"trigger_price\", val)}\n disabled={props.disabled}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-6 oui-text-base-contrast-80\",\n },\n arrow: {\n className: \"oui-fill-base-6\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast oui-w-full\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nTriggerPriceInput.displayName = \"TriggerPriceInput\";\n","import { FC, useMemo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { useOrderEntryFormErrorMsg } from \"@kodiak-finance/orderly-react-app\";\nimport {\n Button,\n Divider,\n Flex,\n SimpleDialog,\n Text,\n ThrottledButton,\n} from \"@kodiak-finance/orderly-ui\";\nimport { ActivitedPriceInput } from \"./components/activitedPriceInput\";\nimport { ConfirmDialogContent } from \"./components/editDialogContent\";\nimport { EditSheetContext } from \"./components/editSheetContext\";\nimport { EditSheetHeader } from \"./components/editSheetHeader\";\nimport { PriceInput } from \"./components/priceInput\";\nimport { QuantityInput } from \"./components/quantityInput\";\nimport { QuantitySlider } from \"./components/quantitySlider\";\nimport { TrailingCallbackInput } from \"./components/trailingCallbackInput\";\nimport { TriggerPriceInput } from \"./components/triggerPriceInput\";\nimport { EditSheetState } from \"./editSheet.script\";\n\nexport const EditSheet: FC<EditSheetState> = (props) => {\n const {\n item,\n symbolInfo,\n formattedOrder,\n isStopMarket,\n isTrailingStop,\n setOrderValue,\n errors,\n } = props;\n const { t } = useTranslation();\n\n const { getErrorMsg } = useOrderEntryFormErrorMsg(errors!);\n\n const disabled =\n !props.isChanged ||\n Object.keys(errors!).length > 0 ||\n // when activated price is not empty, the activated price input should not be empty\n (item.activated_price && !formattedOrder.activated_price);\n\n const header = <EditSheetHeader item={item} />;\n\n const lastPrice = (\n <Flex width={\"100%\"} justify={\"between\"}>\n <Text>{t(\"common.lastPrice\")}</Text>\n <Text.numeral dp={symbolInfo.quote_dp}>\n {props.markPrice ?? \"--\"}\n </Text.numeral>\n </Flex>\n );\n\n const triggerPriceInput = props.showTriggerPrice && (\n <TriggerPriceInput\n trigger_price={formattedOrder.trigger_price}\n disabled={!!item.is_triggered}\n />\n );\n\n const renderPriceInput = () => {\n if (isTrailingStop) {\n return (\n item.activated_price && (\n <ActivitedPriceInput\n activated_price={formattedOrder.activated_price}\n disabled={item.is_activated}\n />\n )\n );\n }\n\n return (\n <PriceInput\n order_price={\n isStopMarket\n ? t(\"orderEntry.orderType.market\")\n : formattedOrder.order_price\n }\n disabled={isStopMarket}\n />\n );\n };\n\n const trailingCallbackInput = isTrailingStop && (\n <TrailingCallbackInput\n isCallbackValue={!!item.callback_value}\n callback_value={formattedOrder.callback_value}\n callback_rate={formattedOrder.callback_rate}\n />\n );\n\n const quantityInput = <QuantityInput value={formattedOrder.order_quantity} />;\n\n const quantitySlider = (\n <QuantitySlider\n maxQty={props.maxQty}\n quantity={formattedOrder.order_quantity}\n />\n );\n\n const buttons = (\n <Flex width={\"100%\"} gap={3} mt={2}>\n <Button\n fullWidth\n color=\"secondary\"\n onClick={(e) => {\n props.onClose();\n }}\n >\n {t(\"common.cancel\")}\n </Button>\n <ThrottledButton\n fullWidth\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onSheetConfirm();\n }}\n loading={props.submitting}\n disabled={disabled}\n >\n {t(\"common.confirm\")}\n </ThrottledButton>\n </Flex>\n );\n\n const ctxValue = useMemo(() => {\n return {\n symbolInfo,\n getErrorMsg,\n setOrderValue,\n };\n }, [symbolInfo, getErrorMsg, setOrderValue]);\n\n return (\n <EditSheetContext.Provider value={ctxValue}>\n <Flex\n direction={\"column\"}\n gap={3}\n width={\"100%\"}\n itemAlign={\"start\"}\n className=\"oui-text-sm\"\n >\n {header}\n <Divider intensity={8} className=\"oui-w-full\" />\n {lastPrice}\n <Flex width={\"100%\"} direction={\"column\"} itemAlign={\"stretch\"} gap={2}>\n {triggerPriceInput}\n {renderPriceInput()}\n {trailingCallbackInput}\n {quantityInput}\n {quantitySlider}\n </Flex>\n {buttons}\n </Flex>\n\n <SimpleDialog\n open={props.dialogOpen}\n onOpenChange={props.setDialogOpen}\n title={t(\"orders.editOrder\")}\n size=\"xs\"\n actions={{\n primary: {\n label: t(\"common.confirm\"),\n onClick: props.onDialogConfirm,\n loading: props.submitting,\n fullWidth: true,\n },\n secondary: {\n label: t(\"common.cancel\"),\n onClick: props.onCloseDialog,\n fullWidth: true,\n },\n }}\n classNames={{\n content: \"oui-pb-4\",\n body: \"oui-p-0\",\n footer: \"oui-pt-3 oui-pb-0\",\n }}\n >\n <ConfirmDialogContent {...props} />\n </SimpleDialog>\n </EditSheetContext.Provider>\n );\n};\n","import { useCallback, useEffect, useState } from \"react\";\nimport { useOrderEntity } from \"@kodiak-finance/orderly-hooks\";\nimport {\n API,\n OrderlyOrder,\n OrderSide,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\n\nexport const useEditOrderEntry = (props: {\n order: API.AlgoOrderExt;\n orderType: OrderType;\n maxQty: number;\n}) => {\n const { order, orderType, maxQty } = props;\n\n const [formattedOrder, setFormattedOrder] = useState({\n symbol: order.symbol,\n side: order.side as OrderSide,\n reduce_only: order.reduce_only,\n order_type: orderType,\n // TODO: trailing stop order edit price twice, order.price will be 0\n order_price: order.price || undefined,\n order_quantity: order.quantity,\n trigger_price: order.trigger_price,\n activated_price: order.activated_price,\n callback_value: order.callback_value,\n callback_rate: order.callback_rate ? order.callback_rate * 100 : undefined,\n });\n\n const { markPrice, errors, validate, clearErrors } = useOrderEntity(\n formattedOrder,\n {\n maxQty,\n },\n );\n\n const setOrderValue = useCallback((key: keyof OrderlyOrder, value: any) => {\n setFormattedOrder((oldValue) => ({\n ...oldValue,\n [key]: value,\n }));\n }, []);\n\n const {\n order_price,\n order_quantity,\n trigger_price,\n activated_price,\n callback_value,\n callback_rate,\n } = formattedOrder;\n\n const isChanged =\n (order.price && order.price != order_price) ||\n (order.quantity && order.quantity != order_quantity) ||\n (order.trigger_price && order.trigger_price != trigger_price) ||\n // trailing stop fields\n (order.activated_price && order.activated_price != activated_price) ||\n (order.callback_value && order.callback_value != callback_value) ||\n (order.callback_rate && order.callback_rate * 100 != callback_rate);\n\n useEffect(() => {\n if (isChanged) {\n validate()\n .then((order) => {\n console.log(\"validate success\", order);\n })\n .catch((err) => {\n console.log(\"validate error\", err);\n });\n } else {\n clearErrors();\n }\n }, [\n isChanged,\n order_price,\n order_quantity,\n trigger_price,\n activated_price,\n callback_value,\n callback_rate,\n ]);\n\n return {\n markPrice,\n errors,\n validate,\n setOrderValue,\n formattedOrder,\n isChanged,\n };\n};\n","import { useMemo } from \"react\";\nimport { useMaxQty } from \"@kodiak-finance/orderly-hooks\";\nimport { API, OrderSide } from \"@kodiak-finance/orderly-types\";\n\nexport function useEditOrderMaxQty(\n order: API.AlgoOrderExt,\n positionQty?: number,\n) {\n const { reduce_only } = order;\n\n const maxQty = useMaxQty(order.symbol, order.side as OrderSide, reduce_only);\n\n return useMemo(() => {\n if (reduce_only) {\n return Math.abs(positionQty ?? 0);\n }\n return order.quantity + Math.abs(maxQty);\n }, [order.quantity, maxQty, reduce_only, positionQty]);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useLocalStorage } from \"@kodiak-finance/orderly-hooks\";\nimport { API, OrderEntity, OrderType } from \"@kodiak-finance/orderly-types\";\nimport { AlgoOrderRootType } from \"@kodiak-finance/orderly-types\";\nimport { toast, useModal } from \"@kodiak-finance/orderly-ui\";\nimport { convertApiOrderTypeToOrderEntryType } from \"../../../../utils/util\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useEditOrderEntry } from \"./hooks/useEditOrderEntry\";\nimport { useEditOrderMaxQty } from \"./hooks/useEditOrderMaxQty\";\n\nexport const useEditSheetScript = (props: {\n state: OrderCellState;\n position?: API.PositionTPSLExt;\n editAlgoOrder: (id: string, order: OrderEntity) => Promise<any>;\n editOrder: (id: string, order: OrderEntity) => Promise<any>;\n}) => {\n const { state, editAlgoOrder, editOrder, position } = props;\n const { item: order } = state;\n const { hide: onClose } = useModal();\n const [dialogOpen, setDialogOpen] = useState(false);\n const [submitting, setSubmitting] = useState(false);\n\n const isAlgoOrder =\n order.algo_order_id !== undefined &&\n order.algo_type !== AlgoOrderRootType.BRACKET;\n\n const isStopMarket = order?.type === \"MARKET\" && isAlgoOrder;\n const isTrailingStop = order.algo_type === OrderType.TRAILING_STOP;\n\n const showTriggerPrice = isAlgoOrder && !isTrailingStop;\n\n const orderType = useMemo(\n () => convertApiOrderTypeToOrderEntryType(order),\n [order],\n );\n\n const [orderConfirm, setOrderConfirm] = useLocalStorage(\n \"orderly_order_confirm\",\n true,\n );\n\n const maxQty = useEditOrderMaxQty(order, position?.position_qty);\n\n const {\n formattedOrder,\n setOrderValue,\n markPrice,\n errors,\n validate,\n isChanged,\n } = useEditOrderEntry({\n order,\n orderType,\n maxQty,\n });\n\n useEffect(() => {}, [order.price, formattedOrder.order_price]);\n\n const onCloseDialog = useCallback(() => {\n setDialogOpen(false);\n }, []);\n\n const onSubmit = useCallback(\n async (values: OrderEntity) => {\n let future;\n const isHidden =\n order.visible_quantity !== undefined\n ? order.visible_quantity === 0\n : (order as any).visible !== undefined\n ? (order as any).visible === 0\n : false;\n\n if (order.order_tag) {\n values.order_tag = order.order_tag;\n }\n\n if (order.client_order_id) {\n values.client_order_id = order.client_order_id;\n }\n\n if (order.algo_order_id !== undefined) {\n if (isTrailingStop) {\n if (values.callback_rate) {\n values = {\n ...values,\n callback_rate: (Number(values.callback_rate) / 100).toString(),\n };\n } else if (isStopMarket && \"order_price\" in values) {\n const { order_price, ...rest } = values;\n values = rest;\n }\n }\n\n future = editAlgoOrder(order.algo_order_id.toString(), {\n ...values,\n });\n } else {\n future = editOrder((order as any).order_id.toString(), {\n ...values,\n ...(isHidden ? { visible_quantity: 0 } : {}),\n });\n }\n try {\n setSubmitting(true);\n\n const res = await future;\n onClose();\n } catch (err: any) {\n toast.error(err?.message ?? `${err}`);\n } finally {\n setSubmitting(false);\n }\n },\n [editAlgoOrder, editOrder, isTrailingStop],\n );\n\n const onDialogConfirm = () => {\n if (formattedOrder) {\n return onSubmit(formattedOrder as any);\n }\n return Promise.reject();\n };\n\n const onSheetConfirm = () => {\n validate()\n .then(\n (result) => {\n if (orderConfirm) {\n setDialogOpen(true);\n } else {\n // @ts-ignore\n onSubmit(formattedOrder);\n }\n },\n (error) => {\n // rejected\n if (error?.total?.message) {\n toast.error(error?.total.message);\n }\n },\n )\n .catch((err) => {});\n };\n\n return {\n ...state,\n markPrice,\n isStopMarket,\n isTrailingStop,\n showTriggerPrice,\n formattedOrder,\n setOrderValue,\n maxQty,\n onClose,\n onSheetConfirm,\n errors,\n isChanged,\n dialogOpen,\n setDialogOpen,\n onDialogConfirm,\n onCloseDialog,\n submitting,\n\n orderConfirm,\n setOrderConfirm,\n };\n};\n\nexport type EditSheetState = ReturnType<typeof useEditSheetScript>;\n","import { API, OrderEntity } from \"@kodiak-finance/orderly-types\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useEditSheetScript } from \"./editSheet.script\";\nimport { EditSheet } from \"./editSheet.ui\";\n\ntype EditSheetWidgetProps = {\n state: OrderCellState;\n editAlgoOrder: (id: string, order: OrderEntity) => Promise<any>;\n editOrder: (id: string, order: OrderEntity) => Promise<any>;\n position?: API.PositionTPSLExt;\n};\n\nexport const EditSheetWidget = (props: EditSheetWidgetProps) => {\n const state = useEditSheetScript(props);\n return <EditSheet {...state} />;\n};\n","export { EditSheet } from \"./editSheet.ui\";\nexport { EditSheetWidget } from \"./editSheet.widget\";\nexport { useEditSheetScript } from \"./editSheet.script\";\n","import { useCallback } from \"react\";\nimport { useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { modal } from \"@kodiak-finance/orderly-ui\";\nimport { PositionTPSLSheet } from \"@kodiak-finance/orderly-ui-tpsl\";\nimport { TabType } from \"../../../orders.widget\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { useTPSLOrderRowContext } from \"../../tpslOrderRowContext\";\nimport { EditSheetWidget } from \"../editSheet\";\nimport { OrderCellState } from \"../orderCell.script\";\n\nexport const useEditBtnScript = (props: { state: OrderCellState }) => {\n const { state } = props;\n const { t } = useTranslation();\n const symbolInfo = useSymbolsInfo()[props.state.item.symbol]();\n\n const { editAlgoOrder, editOrder } = useOrderListContext();\n const { position } = useTPSLOrderRowContext();\n\n const onShowEditSheet = useCallback(() => {\n if (props.state.type === TabType.tp_sl) {\n modal\n .sheet({\n content: (\n <PositionTPSLSheet\n symbol={props.state.item.symbol}\n symbolInfo={symbolInfo}\n isEditing\n order={props.state.item}\n />\n ),\n })\n .catch((error) => {\n console.log(error);\n });\n } else {\n modal\n .sheet({\n title: t(\"orders.editOrder\"),\n // size: \"xs\",\n classNames: {\n content: \"oui-bg-base-8\",\n },\n content: (\n <EditSheetWidget\n state={state}\n position={position}\n editAlgoOrder={editAlgoOrder}\n editOrder={editOrder}\n />\n ),\n })\n .catch((error) => {\n console.log(error);\n });\n }\n }, [state]);\n\n return {\n ...state,\n onShowEditSheet,\n };\n};\n\nexport type EditBtnState = ReturnType<typeof useEditBtnScript>;\n","import { OrderCellState } from \"../orderCell.script\";\nimport { useEditBtnScript } from \"./editBtn.script\";\nimport { EditBtn } from \"./editBtn.ui\";\n\nexport const EditBtnWidget = (props: { state: OrderCellState }) => {\n const state = useEditBtnScript(props);\n return <EditBtn {...state} />;\n};\n","export { EditBtn } from \"./editBtn.ui\";\nexport { EditBtnWidget } from \"./editBtn.widget\";\nexport { useEditBtnScript } from \"./editBtn.script\";\n","import React, { FC } from \"react\";\nimport { AlgoOrderRootType } from \"@kodiak-finance/orderly-types\";\nimport { Divider, Flex, Grid, Text } from \"@kodiak-finance/orderly-ui\";\nimport { TabType } from \"../../orders.widget\";\nimport { BracketOrderPriceWidget } from \"./bracketOrderPrice\";\nimport { CancelBtnWidget } from \"./cancelBtn\";\nimport { EditBtnWidget } from \"./editBtn\";\nimport {\n OrderTime,\n SymbolToken,\n OrderTypeView,\n Qty,\n Filled,\n EstTotal,\n TriggerPrice,\n LimitPrice,\n MarkPrice,\n TPTrigger,\n TPPrice,\n TPSLQuantity,\n SLTrigger,\n SLPrice,\n AvgPrice,\n OrderPrice,\n RealizedPnL,\n OrderState,\n Fee,\n TrailingCallback,\n TrailingPrice,\n} from \"./items\";\nimport { OrderCellState } from \"./orderCell.script\";\n\nexport const OrderCell: FC<\n OrderCellState & {\n className?: string;\n }\n> = (props) => {\n return (\n <Flex\n direction={\"column\"}\n width={\"100%\"}\n gap={2}\n itemAlign={\"start\"}\n className={props.className}\n >\n <Header {...props} />\n <Divider intensity={6} className=\"oui-w-full\" />\n <Body {...props} />\n {props.type === TabType.pending && <BracketOrderPriceWidget {...props} />}\n {props.type !== TabType.orderHistory && <Btns {...props} />}\n </Flex>\n );\n};\n\nexport const Header: FC<OrderCellState> = (props) => {\n return (\n <Flex direction={\"column\"} gap={1} width={\"100%\"}>\n <Flex justify={\"between\"} width={\"100%\"}>\n <SymbolToken {...props} />\n <OrderTime {...props} />\n </Flex>\n <Flex width={\"100%\"} justify={\"between\"}>\n <OrderTypeView {...props} />\n {props.type === TabType.orderHistory && <OrderState {...props} />}\n </Flex>\n </Flex>\n );\n};\n\nexport const Body: FC<OrderCellState> = (props) => {\n return (\n <Grid cols={3} rows={2} width={\"100%\"} gap={1}>\n {itemsWithType(props)}\n </Grid>\n );\n};\n\nexport const Btns: FC<OrderCellState> = (props) => {\n return (\n <Grid cols={3} rows={1} width={\"100%\"} gap={2}>\n <div></div>\n <EditBtnWidget state={props} />\n <CancelBtnWidget state={props} />\n </Grid>\n );\n};\n\nfunction itemsWithType(props: OrderCellState) {\n switch (props.type) {\n case TabType.all:\n return <></>;\n case TabType.pending:\n const isTrailingStop =\n props.item?.algo_type === AlgoOrderRootType.TRAILING_STOP;\n\n if (isTrailingStop) {\n return (\n <>\n <Qty {...props} />\n <Filled {...props} />\n <EstTotal {...props} />\n <TriggerPrice {...props} isPending={true} />\n <TrailingPrice {...props} />\n <TrailingCallback {...props} />\n </>\n );\n }\n\n return (\n <>\n <Qty {...props} />\n <Filled {...props} />\n <EstTotal {...props} />\n <TriggerPrice {...props} isPending={true} />\n <LimitPrice {...props} />\n <MarkPrice {...props} />\n </>\n );\n\n case TabType.tp_sl:\n return (\n <>\n <TPTrigger {...props} />\n <TPPrice {...props} />\n <TPSLQuantity {...props} />\n <SLTrigger {...props} />\n <SLPrice {...props} />\n </>\n );\n case TabType.filled:\n return <></>;\n case TabType.cancelled:\n return <></>;\n case TabType.rejected:\n return <></>;\n case TabType.orderHistory:\n return (\n <>\n <Qty {...props} />\n <Filled {...props} />\n <TriggerPrice {...props} align=\"end\" />\n <AvgPrice {...props} />\n <OrderPrice {...props} />\n <RealizedPnL {...props} />\n {/* placeholder */}\n <div></div>\n {/* placeholder */}\n <div></div>\n <Fee {...props} />\n </>\n );\n }\n}\n","import { API } from \"@kodiak-finance/orderly-types\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { TabType } from \"../../orders.widget\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\n\nexport const useOrderCellScript = (props: {\n item: API.AlgoOrderExt;\n index: number;\n type: TabType;\n sharePnLConfig?: SharePnLConfig;\n onSymbolChange?: (symbol: API.Symbol) => void;\n}) => {\n const symbolInfo = useSymbolContext();\n return {\n ...props,\n ...symbolInfo,\n // use symbolInfo replace ...symbolInfo\n symbolInfo,\n };\n};\n\nexport type OrderCellState = ReturnType<typeof useOrderCellScript>;\n","import { API } from \"@kodiak-finance/orderly-types\";\nimport { useOrderCellScript } from \"./orderCell.script\";\nimport { OrderCell } from \"./orderCell.ui\";\nimport { TabType } from \"../../orders.widget\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\n\nexport const OrderCellWidget = (props: {\n item: API.AlgoOrderExt;\n index: number;\n className?: string;\n type: TabType;\n sharePnLConfig?: SharePnLConfig;\n onSymbolChange?: (symbol: API.Symbol) => void;\n}) => {\n const { className, ...rest } = props;\n\n const state = useOrderCellScript(rest);\n return <OrderCell {...state} className={className} />;\n};\n","export { OrderCell } from \"./orderCell.ui\";\nexport { OrderCellWidget } from \"./orderCell.widget\";\nexport { useOrderCellScript } from \"./orderCell.script\";\n","import { FC, PropsWithChildren, useMemo } from \"react\";\nimport { getMinNotional, useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { useMemoizedFn } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderEntity } from \"@kodiak-finance/orderly-types\";\nimport { OrderListContext, OrderListContextState } from \"./orderListContext\";\n\nexport interface OrderListProviderProps {\n cancelOrder: (orderId: number, symbol: string) => Promise<any>;\n editOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n cancelAlgoOrder: (orderId: number, symbol: string) => Promise<any>;\n editAlgoOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n}\n\nexport const OrderListProvider: FC<\n PropsWithChildren<OrderListProviderProps>\n> = (props) => {\n const { cancelOrder, editOrder, cancelAlgoOrder, editAlgoOrder } = props;\n const { t } = useTranslation();\n const symbolsInfo = useSymbolsInfo();\n\n const onCancelOrder = useMemoizedFn(\n async (order: API.Order | API.AlgoOrder) => {\n if (order.algo_order_id !== undefined) {\n if (\n \"root_algo_order_id\" in order &&\n order.root_algo_order_id !== order.algo_order_id\n ) {\n return cancelAlgoOrder(order.root_algo_order_id, order.symbol);\n }\n\n return cancelAlgoOrder(order.algo_order_id, order.symbol).then(\n () => {},\n );\n }\n // @ts-ignore\n return cancelOrder(order.order_id, order.symbol).then(() => {\n // toast.success(\"Order canceled successfully\");\n });\n },\n );\n\n const checkMinNotional = useMemoizedFn(\n (symbol: string, price?: string | number, qty?: string | number) => {\n const { min_notional } = symbolsInfo[symbol]();\n const minNotional = getMinNotional({ price, qty, min_notional });\n if (minNotional !== undefined) {\n return t(\"orderEntry.total.error.min\", { value: minNotional });\n }\n },\n );\n\n const memoizedValue = useMemo<OrderListContextState>(() => {\n return {\n onCancelOrder,\n editOrder,\n editAlgoOrder,\n checkMinNotional,\n };\n }, [onCancelOrder, editOrder, editAlgoOrder, checkMinNotional]);\n\n return (\n <OrderListContext.Provider value={memoizedValue}>\n {props.children}\n </OrderListContext.Provider>\n );\n};\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport {\n Flex,\n ListView,\n Button,\n Grid,\n Picker,\n DataFilter,\n cn,\n TableFeatures,\n} from \"@kodiak-finance/orderly-ui\";\nimport { AuthGuardDataTable } from \"@kodiak-finance/orderly-ui-connector\";\nimport { grayCell } from \"../../utils/util\";\nimport { TabType } from \"../orders.widget\";\nimport { SymbolProvider } from \"../provider/symbolProvider\";\nimport { useOrderColumn } from \"./desktop/useColumn\";\nimport { OrderCellWidget } from \"./mobile\";\nimport { OrdersBuilderState } from \"./orderList.script\";\nimport { OrderListProvider } from \"./orderListProvider\";\nimport { TPSLOrderRowProvider } from \"./tpslOrderRowContext\";\n\nexport const DesktopOrderList: FC<\n OrdersBuilderState & { testIds?: { tableBody?: string } }\n> = (props) => {\n const { sharePnLConfig, ...rest } = props;\n const columns = useOrderColumn({\n _type: props.type,\n onSymbolChange: props.onSymbolChange,\n pnlNotionalDecimalPrecision: props.pnlNotionalDecimalPrecision,\n sharePnLConfig,\n symbolsInfo: props.symbolsInfo,\n });\n\n return (\n <OrderListProvider\n cancelOrder={props.cancelOrder}\n editOrder={props.updateOrder}\n cancelAlgoOrder={props.cancelAlgoOrder}\n editAlgoOrder={props.updateAlgoOrder}\n // cancelTPSLOrder={props.cancelTPSLOrder}\n >\n <Flex direction=\"column\" width=\"100%\" height=\"100%\" itemAlign=\"start\">\n {props.filterItems.length > 0 && (\n <DataFilter\n items={props.filterItems}\n onFilter={(value: any) => {\n props.onFilter(value);\n }}\n trailing={\n [TabType.pending, TabType.tp_sl].includes(props.type) && (\n <CancelAll {...props} />\n )\n }\n />\n )}\n <AuthGuardDataTable\n columns={columns}\n loading={props.isLoading}\n dataSource={props.dataSource}\n bordered\n ignoreLoadingCheck={true}\n testIds={{\n body: props.testIds?.tableBody,\n }}\n classNames={{\n header: \"oui-h-[38px]\",\n root: \"oui-items-start !oui-h-[calc(100%_-_49px)]\",\n }}\n onRow={(record, index) => {\n return {\n className: cn(\n \"oui-h-[48px]\",\n grayCell(record)\n ? \"oui-text-base-contrast-20\"\n : \"oui-text-base-contrast-80\",\n ),\n };\n }}\n generatedRowKey={(record, index) =>\n `${props.type}${index}${\n record.order_id || record.algo_order_id\n }_index${index}`\n }\n renderRowContainer={(record: any, index, children) => {\n if (\n props.type === TabType.tp_sl ||\n props.type === TabType.pending\n ) {\n children = (\n <TPSLOrderRowProvider order={record}>\n {children}\n </TPSLOrderRowProvider>\n );\n }\n\n return (\n <SymbolProvider symbol={record.symbol}>{children}</SymbolProvider>\n );\n }}\n pagination={props.pagination}\n manualPagination={props.manualPagination}\n features={[TableFeatures.DownloadFeature]}\n getTableInstance={(table) => {\n props.tableInstance.current = table;\n }}\n />\n </Flex>\n </OrderListProvider>\n );\n};\n\nexport const MobileOrderList: FC<\n OrdersBuilderState & {\n classNames?: { root?: string; cell?: string; content?: string };\n showFilter?: boolean;\n onExport?: () => void;\n }\n> = (props) => {\n const { t } = useTranslation();\n\n return (\n <OrderListProvider\n cancelOrder={props.cancelOrder}\n editOrder={props.updateOrder}\n cancelAlgoOrder={props.cancelAlgoOrder}\n editAlgoOrder={props.updateAlgoOrder}\n // cancelTPSLOrder={props.cancelTPSLOrder}\n >\n <Grid\n cols={1}\n rows={2}\n className=\"oui-w-full oui-grid-rows-[auto,1fr]\"\n gap={2}\n >\n {/* <Filter\n items={props.filterItems}\n onFilter={(value: any) => {\n props.onFilter(value);\n }}\n className=\"oui-px-3\"\n\n /> */}\n\n {props.showFilter ? (\n <Flex\n gap={2}\n p={2}\n justify={\"between\"}\n itemAlign={\"center\"}\n className=\"oui-rounded-b-xl oui-bg-base-9\"\n >\n <Flex gap={2}>\n {props.filterItems.map((item) => {\n // not support range type\n if (item.type !== \"select\") {\n return null;\n }\n return (\n <Picker\n key={`item-${item.name}`}\n options={item.options}\n size={\"sm\"}\n value={item.value}\n className=\"oui-text-2xs oui-text-base-contrast-54 \"\n placeholder={\n item.name === \"side\"\n ? t(\"common.side.all\")\n : item.name === \"status\"\n ? t(\"common.status.all\")\n : \"\"\n }\n onValueChange={(value) => {\n //\n props.onFilter?.({ name: item.name, value: value });\n }}\n />\n );\n })}\n </Flex>\n {props.onExport && (\n <Button\n variant=\"outlined\"\n size=\"xs\"\n color=\"secondary\"\n onClick={props.onExport}\n >\n {t(\"common.export\") || \"Export CSV\"}\n </Button>\n )}\n </Flex>\n ) : (\n <div></div>\n )}\n <ListView\n className={props.classNames?.root}\n contentClassName={props.classNames?.content}\n dataSource={props.dataSource}\n loadMore={props.loadMore}\n isLoading={props.isLoading}\n renderItem={(item, index) => {\n let children = (\n <OrderCellWidget\n item={item}\n index={index}\n className={props.classNames?.cell}\n type={props.type}\n onSymbolChange={props.onSymbolChange}\n sharePnLConfig={props.sharePnLConfig}\n />\n );\n if ([TabType.tp_sl, TabType.pending].includes(props.type)) {\n children = (\n <TPSLOrderRowProvider order={item}>\n {children}\n </TPSLOrderRowProvider>\n );\n }\n return (\n <SymbolProvider symbol={item.symbol}>{children}</SymbolProvider>\n );\n }}\n />\n </Grid>\n </OrderListProvider>\n );\n};\n\nconst CancelAll: FC<OrdersBuilderState> = (props) => {\n const { t } = useTranslation();\n\n return (\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n size=\"xs\"\n disabled={(props.dataSource?.length ?? 0) == 0}\n className=\"disabled:oui-bg-transport\"\n onClick={(e) => props.onCancelAll()}\n data-testid={`oui-testid-dataList-${props.type.toLowerCase()}-cancelAll-button`}\n >\n {t(\"orders.cancelAll\")}\n </Button>\n );\n};\n","import { useMemo } from \"react\";\nimport { API, AlgoOrderRootType, OrderStatus } from \"@kodiak-finance/orderly-types\";\n\nexport const useFormatOrderHistory = (data: API.AlgoOrderExt[]) => {\n const formattedData = useMemo(() => {\n const _data: API.AlgoOrder[] = [];\n\n for (let index = 0; index < data.length; index++) {\n const element = data[index];\n // console.log(\"element\", element);\n if (\n element.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL ||\n element.algo_type === AlgoOrderRootType.TP_SL\n ) {\n if (\n element.algo_status !== OrderStatus.FILLED &&\n element.algo_status !== OrderStatus.PARTIAL_FILLED\n ) {\n for (let j = 0; j < element.child_orders.length; j++) {\n const e = element.child_orders[j];\n if (!e.is_activated || !e.trigger_price) {\n continue;\n }\n (e as any).parent_algo_type = element.algo_type;\n _data.push(e);\n }\n } else {\n // if order is filled then show only the filled order\n for (let j = 0; j < element.child_orders.length; j++) {\n const e = element.child_orders[j];\n if (\n !!e &&\n (e.algo_status === OrderStatus.FILLED ||\n e.algo_status === OrderStatus.PARTIAL_FILLED)\n ) {\n (e as any).parent_algo_type = element.algo_type;\n _data.push(e);\n }\n }\n }\n } else {\n _data.push(element);\n }\n }\n\n return _data;\n\n // data.map((item) => {});\n }, [data]);\n\n return formattedData;\n};\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n ForwardedRef,\n useImperativeHandle,\n} from \"react\";\nimport { differenceInDays, setHours, subDays } from \"date-fns\";\nimport {\n useLocalStorage,\n useOrderStream,\n useSymbolsInfo,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { useDataTap } from \"@kodiak-finance/orderly-react-app\";\nimport {\n AlgoOrderRootType,\n OrderStatus,\n OrderSide,\n API,\n} from \"@kodiak-finance/orderly-types\";\nimport { modal, usePagination, Text, Table } from \"@kodiak-finance/orderly-ui\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { areDatesEqual } from \"../../utils/util\";\nimport { TabType } from \"../orders.widget\";\nimport { useFormatOrderHistory } from \"./useFormatOrderHistory\";\n\nexport type OrderListInstance = {\n getRowCount?: () => number;\n getDataSource?: () => any[] | null;\n};\n\nexport type useOrderListScriptOptions = {\n type: TabType;\n ordersStatus?: OrderStatus;\n symbol?: string;\n enableLoadMore?: boolean;\n onSymbolChange?: (symbol: API.Symbol) => void;\n sharePnLConfig?: SharePnLConfig;\n filterConfig?: {\n side?: OrderSide | \"all\";\n range?: {\n from?: Date;\n to?: Date;\n };\n };\n pnlNotionalDecimalPrecision?: number;\n ref?: ForwardedRef<OrderListInstance>;\n};\n\nexport const useOrderListScript = (props: useOrderListScriptOptions) => {\n const {\n ordersStatus,\n type,\n enableLoadMore = false,\n onSymbolChange,\n filterConfig,\n pnlNotionalDecimalPrecision,\n sharePnLConfig,\n } = props;\n const { t } = useTranslation();\n const symbolsInfo = useSymbolsInfo();\n\n const manualPagination = useMemo(() => {\n // pending and ts_sl list use client pagination\n return ordersStatus !== OrderStatus.INCOMPLETE;\n }, [ordersStatus]);\n\n const defaultPageSize = 50;\n const { page, pageSize, setPage, pagination, parsePagination } =\n usePagination({\n pageSize: defaultPageSize,\n });\n\n // when symbol change, reset page\n useEffect(() => {\n setPage(1);\n }, [props.symbol]);\n\n const {\n orderStatus,\n ordersSide,\n dateRange,\n filterItems,\n onFilter,\n filterDays,\n updateFilterDays,\n } = useFilter(type, {\n ordersStatus,\n setPage,\n filterConfig,\n });\n\n const includes = useMemo(() => {\n if (type === TabType.tp_sl) {\n return [AlgoOrderRootType.POSITIONAL_TP_SL, AlgoOrderRootType.TP_SL];\n }\n return undefined;\n }, [type]);\n\n const excludes = useMemo(() => {\n if (type === TabType.pending) {\n return [AlgoOrderRootType.POSITIONAL_TP_SL, AlgoOrderRootType.TP_SL];\n }\n return undefined;\n }, [type]);\n\n const tableInstance = useRef<Table<any>>();\n\n const [\n data,\n {\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n cancelAllOrders,\n cancelAllTPSLOrders,\n meta,\n refresh,\n },\n ] = useOrderStream({\n symbol: props.symbol,\n status: orderStatus,\n side: ordersSide,\n page: enableLoadMore || !manualPagination ? undefined : page,\n // pending and ts_sl list get all data\n size: manualPagination ? pageSize : 500,\n sourceTypeAll: type === TabType.orderHistory,\n dateRange,\n includes,\n excludes,\n });\n\n const localPageSizeKey = `orderly_${type}_pageSize`;\n const [typePageSize, setTypePageSize] = useLocalStorage(\n localPageSizeKey,\n defaultPageSize,\n );\n\n useEffect(() => {\n if (typePageSize !== pageSize) {\n setTypePageSize(pageSize);\n }\n }, [pageSize, typePageSize]);\n\n const onCancelAll = useCallback(() => {\n const isPending = props.type === TabType.pending;\n const isTPSL = props.type === TabType.tp_sl;\n\n const title = isPending\n ? t(\"orders.pending.cancelAll\")\n : isTPSL\n ? t(\"orders.tpsl.cancelAll\")\n : \"\";\n\n const getContent = (): React.ReactNode => {\n const baseMessage = isPending\n ? t(\"orders.pending.cancelAll.description\")\n : isTPSL\n ? t(\"orders.tpsl.cancelAll.description\")\n : \"\";\n\n if (!props.symbol) {\n return <Text size=\"sm\">{baseMessage}</Text>;\n }\n\n const messageWithSymbol = baseMessage.replace(\n \"?\",\n ` in ${props.symbol}?`,\n );\n return <Text size=\"sm\">{messageWithSymbol}</Text>;\n };\n\n modal.confirm({\n title: title,\n content: getContent(),\n onCancel: async () => {},\n onOk: async () => {\n try {\n // await cancelAll(null, { source_type: \"ALL\" });r\n if (type === TabType.tp_sl) {\n await cancelAllTPSLOrders(props.symbol);\n } else {\n await cancelAllOrders(props.symbol);\n }\n refresh();\n return Promise.resolve(true);\n } catch (error) {\n // @ts-ignore\n if (error?.message !== undefined) {\n // @ts-ignore\n toast.error(error.message);\n }\n return Promise.resolve(false);\n } finally {\n Promise.resolve();\n }\n },\n });\n }, [type, t, props.symbol]);\n\n const formattedData = useFormatOrderHistory(data ?? []);\n\n const dataSource =\n useDataTap(type !== TabType.tp_sl ? formattedData : data, {\n fallbackData: [],\n }) ?? undefined;\n\n const _pagination = useMemo(() => {\n if (manualPagination) {\n return parsePagination(meta);\n }\n return pagination;\n }, [meta, manualPagination, parsePagination, pagination]);\n\n useImperativeHandle(\n props.ref,\n () => ({\n getRowCount: () => {\n return tableInstance.current?.getRowCount?.() ?? 0;\n },\n getDataSource: () => {\n return dataSource ?? null;\n },\n }),\n [dataSource],\n );\n\n return {\n type,\n dataSource,\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n pagination: _pagination,\n manualPagination,\n pnlNotionalDecimalPrecision,\n\n // filter\n onFilter,\n filterItems,\n onCancelAll,\n\n onSymbolChange,\n\n sharePnLConfig,\n tableInstance,\n symbolsInfo,\n filterDays,\n updateFilterDays,\n };\n};\n\nconst useFilter = (\n type: TabType,\n option: {\n ordersStatus?: OrderStatus | \"all\";\n setPage: (page: number) => void;\n filterConfig?: {\n side?: OrderSide | \"all\";\n range?: {\n from?: Date;\n to?: Date;\n };\n };\n },\n) => {\n const { t } = useTranslation();\n const [orderStatus, setOrderStatus] = useState<OrderStatus | \"all\">(\n option.ordersStatus ?? \"all\",\n );\n const [ordersSide, setOrdersSide] = useState<OrderSide | \"all\">(\n option.filterConfig?.side ?? \"all\",\n );\n\n /// default is 90d\n const [filterDays, setFilterDays] = useState<1 | 7 | 30 | 90 | null>(90);\n\n const defaultRange =\n option.filterConfig?.range ??\n (type === TabType.all || type === TabType.orderHistory\n ? formatDatePickerRange({\n to: new Date(),\n from: offsetEndOfDay(subDays(new Date(), 89)),\n })\n : {});\n\n const [dateRange, setDateRange] = useState<{\n from?: Date;\n to?: Date;\n }>(defaultRange);\n\n const updateFilterDays = (days: 1 | 7 | 30 | 90) => {\n setFilterDays(days);\n setDateRange({\n from: offsetStartOfDay(subDays(new Date(), days - 1)),\n to: offsetEndOfDay(new Date()),\n });\n option.setPage(1);\n };\n\n const onFilter = (filter: { name: string; value: any }) => {\n if (filter.name === \"side\") {\n setOrdersSide(filter.value);\n option.setPage(1);\n }\n\n if (filter.name === \"status\") {\n setOrderStatus(filter.value);\n option.setPage(1);\n }\n\n if (filter.name === \"dateRange\") {\n setDateRange(formatDatePickerRange(filter.value));\n option.setPage(1);\n\n const newDateRange = formatDatePickerRange(filter.value);\n if (newDateRange.from && newDateRange.to) {\n const diffDays =\n Math.abs(differenceInDays(newDateRange.from, newDateRange.to)) + 1;\n const dateRangeMap: { [key: number]: { from: Date; to: Date } } = {\n 1: {\n from: offsetStartOfDay(new Date())!,\n to: offsetEndOfDay(new Date())!,\n },\n 7: {\n from: offsetStartOfDay(subDays(new Date(), 6))!,\n to: offsetEndOfDay(new Date())!,\n },\n 30: {\n from: offsetStartOfDay(subDays(new Date(), 29))!,\n to: offsetEndOfDay(new Date())!,\n },\n 90: {\n from: offsetStartOfDay(subDays(new Date(), 89))!,\n to: offsetEndOfDay(new Date())!,\n },\n };\n\n const dateRange = dateRangeMap[diffDays];\n if (\n dateRange &&\n areDatesEqual(dateRange.from, newDateRange.from) &&\n areDatesEqual(dateRange.to, newDateRange.to)\n ) {\n setFilterDays(diffDays as any);\n } else {\n setFilterDays(null);\n }\n }\n }\n };\n\n const filterItems = useMemo((): any[] => {\n const sideFilter = {\n type: \"select\",\n name: \"side\",\n options: [\n {\n label: t(\"common.side.all\"),\n value: \"all\",\n },\n {\n label: t(\"common.buy\"),\n value: \"BUY\",\n },\n {\n label: t(\"common.sell\"),\n value: \"SELL\",\n },\n ],\n value: ordersSide,\n };\n\n const dateRangeFilter = {\n type: \"range\",\n name: \"dateRange\",\n value: dateRange,\n };\n\n const statusFilter = {\n type: \"select\",\n name: \"status\",\n options: [\n {\n label: t(\"common.status.all\"),\n value: \"all\",\n },\n {\n label: t(\"orders.status.pending\"),\n value: OrderStatus.INCOMPLETE,\n },\n {\n label: t(\"orders.status.filled\"),\n value: OrderStatus.FILLED,\n },\n {\n label: t(\"orders.status.partialFilled\"),\n value: OrderStatus.PARTIAL_FILLED,\n },\n {\n label: t(\"orders.status.canceled\"),\n value: OrderStatus.CANCELLED,\n },\n {\n label: t(\"orders.status.rejected\"),\n value: OrderStatus.REJECTED,\n },\n ],\n value: orderStatus,\n };\n switch (type) {\n case TabType.all:\n return [sideFilter, statusFilter, dateRangeFilter];\n case TabType.pending:\n return [sideFilter];\n case TabType.tp_sl:\n return [sideFilter];\n case TabType.filled:\n return [sideFilter];\n case TabType.cancelled:\n return [sideFilter];\n case TabType.rejected:\n return [sideFilter];\n case TabType.orderHistory:\n return [sideFilter, statusFilter, dateRangeFilter];\n }\n }, [type, ordersSide, orderStatus, dateRange, t]);\n\n return {\n filterItems,\n onFilter,\n ordersSide: ordersSide === \"all\" ? undefined : ordersSide,\n dateRange,\n orderStatus: orderStatus === \"all\" ? undefined : orderStatus,\n filterDays,\n updateFilterDays,\n };\n};\n\nexport type OrdersBuilderState = ReturnType<typeof useOrderListScript>;\nexport type FilterState = ReturnType<typeof useFilter>;\n\nexport const parseDateRangeForFilter = (dateRange: {\n from: Date;\n to?: Date;\n}) => {\n let { from, to } = dateRange;\n\n if (typeof to === \"undefined\") {\n to = new Date();\n }\n\n const diff = differenceInDays(from, to);\n\n // console.log(\"diff\", diff);\n\n if (diff === 0) {\n return [from, setHours(to, 23)];\n }\n\n return [from, to];\n};\n\nfunction offsetStartOfDay(date?: Date) {\n if (date == null) return date;\n\n const newDate = new Date(date);\n newDate.setHours(0, 0, 0, 0);\n return newDate;\n}\n\nfunction offsetEndOfDay(date?: Date) {\n if (date == null) return date;\n\n const newDate = new Date(date);\n newDate.setHours(23, 59, 59, 999);\n return newDate;\n}\n\nexport const formatDatePickerRange = (option: { from?: Date; to?: Date }) => ({\n from: offsetStartOfDay(option.from),\n to: offsetEndOfDay(option.to ?? option.from),\n});\n","import React, { forwardRef } from \"react\";\nimport { OrderSide, OrderStatus, API } from \"@kodiak-finance/orderly-types\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { TabType } from \"../orders.widget\";\nimport { OrderListInstance, useOrderListScript } from \"./orderList.script\";\nimport { DesktopOrderList, MobileOrderList } from \"./orderList.ui\";\n\nexport type DesktopOrderListWidgetProps = {\n type: TabType;\n ordersStatus?: OrderStatus;\n /** if has value, will be fetch current symbol orders*/\n symbol?: string;\n onSymbolChange?: (symbol: API.Symbol) => void;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n testIds?: {\n tableBody?: string;\n };\n};\n\nexport const DesktopOrderListWidget = forwardRef<\n OrderListInstance,\n DesktopOrderListWidgetProps\n>((props, ref) => {\n const { testIds, ...rest } = props;\n const state = useOrderListScript({ ...rest, ref });\n return <DesktopOrderList {...state} testIds={testIds} />;\n});\n\nexport const MobileOrderListWidget = React.forwardRef<\n OrderListInstance,\n {\n type: TabType;\n ordersStatus?: OrderStatus;\n /** if has value, will be fetch current symbol orders*/\n symbol?: string;\n onSymbolChange?: (symbol: API.Symbol) => void;\n sharePnLConfig?: SharePnLConfig;\n classNames?: { root?: string; cell?: string; content?: string };\n showFilter?: boolean;\n filterConfig?: {\n side?: OrderSide | \"all\";\n range?: { from?: Date; to?: Date };\n };\n onExport?: () => void;\n }\n>((props, ref) => {\n const state = useOrderListScript({ ...props, enableLoadMore: true, ref });\n return (\n <MobileOrderList\n {...state}\n classNames={props.classNames}\n showFilter={props.showFilter}\n onExport={props.onExport}\n />\n );\n});\n","export { DesktopOrderList, MobileOrderList } from \"./orderList.ui\";\nexport {\n DesktopOrderListWidget,\n MobileOrderListWidget,\n} from \"./orderList.widget\";\nexport { useOrderListScript, type OrderListInstance } from \"./orderList.script\";\n","import React from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderStatus } from \"@kodiak-finance/orderly-types\";\nimport { TabPanel, Tabs } from \"@kodiak-finance/orderly-ui\";\nimport type { DesktopOrderListWidgetProps } from \"./orderList/orderList.widget\";\nimport { OrdersBuilderState } from \"./orders.script\";\nimport { TabType } from \"./orders.widget\";\n\nconst LazyDesktopOrderListWidget = React.lazy(() =>\n import(\"./orderList\").then((mod) => {\n return { default: mod.DesktopOrderListWidget };\n }),\n);\n\nexport const Orders: React.FC<OrdersBuilderState> = (props) => {\n const { t } = useTranslation();\n const { pnlNotionalDecimalPrecision, orderListRef } = props;\n const commonProps: Partial<DesktopOrderListWidgetProps> = {\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n };\n return (\n <Tabs\n defaultValue={props.current || TabType.all}\n variant=\"contained\"\n className=\"oui-h-full\"\n classNames={{\n tabsContent: \"oui-h-[calc(100%_-_28px)]\",\n }}\n >\n <TabPanel value={TabType.all} title={t(\"common.all\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.all}\n pnlNotionalDecimalPrecision={pnlNotionalDecimalPrecision}\n sharePnLConfig={props.sharePnLConfig}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.pending} title={t(\"orders.status.pending\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.pending}\n ordersStatus={OrderStatus.INCOMPLETE}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.tp_sl} title={t(\"common.tpsl\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.tp_sl}\n ordersStatus={OrderStatus.INCOMPLETE}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.filled} title={t(\"orders.status.filled\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.filled}\n ordersStatus={OrderStatus.FILLED}\n pnlNotionalDecimalPrecision={pnlNotionalDecimalPrecision}\n sharePnLConfig={props.sharePnLConfig}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.cancelled} title={t(\"orders.status.canceled\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.cancelled}\n ordersStatus={OrderStatus.CANCELLED}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.rejected} title={t(\"orders.status.rejected\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.rejected}\n ordersStatus={OrderStatus.REJECTED}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n {/* <TabPanel value={TabType.orderHistory} title={t(\"orders.orderHistory\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n type={TabType.orderHistory}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel> */}\n </Tabs>\n );\n};\n// ----------------- Orders ui component end -----------------\n","import { forwardRef } from \"react\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { OrderListInstance } from \"./orderList/orderList.script\";\nimport { useOrdersScript } from \"./orders.script\";\nimport { Orders } from \"./orders.ui\";\n\nexport enum TabType {\n all = \"all\",\n pending = \"pending\",\n tp_sl = \"tp_sl\",\n filled = \"filled\",\n cancelled = \"cancelled\",\n rejected = \"rejected\",\n orderHistory = \"orderHistory\",\n}\n\nexport type OrdersWidgetProps = {\n current?: TabType;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n};\n\nexport const OrdersWidget = forwardRef<OrderListInstance, OrdersWidgetProps>(\n (props, ref) => {\n const state = useOrdersScript({ ...props, ref });\n return <Orders {...state} />;\n },\n);\n","export {\n OrdersWidget,\n TabType,\n} from \"./components/orders.widget\";\nexport { useOrdersScript } from \"./components/orders.script\";\nexport type { OrdersBuilderState } from \"./components/orders.script\";\n\nexport * from \"./components/orderList\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/orders.script.ts","../src/utils/util.ts","../src/components/provider/symbolContext.tsx","../src/components/provider/symbolProvider.tsx","../src/components/shareButton/shareButton.ui.tsx","../src/components/shareButton/shareButton.script.tsx","../src/components/shareButton/shareButton.widget.tsx","../src/components/shareButton/index.ts","../src/components/orderList/desktop/avgPrice.tsx","../src/components/orderList/desktop/bracketOrderPrice.tsx","../src/components/orderList/orderListContext.tsx","../src/components/orderList/desktop/cancelBtn.tsx","../src/type.ts","../src/components/orderList/desktop/editOrder/confirmContent.tsx","../src/components/orderList/desktop/hooks/usePopoverState.ts","../src/components/orderList/desktop/hooks/useValidateField.ts","../src/components/orderList/desktop/components/editableCellInput.tsx","../src/components/orderList/desktop/components/previewCell.tsx","../src/components/orderList/desktop/components/activedPriceCell.tsx","../src/components/orderList/desktop/components/priceCell.tsx","../src/components/orderList/tpslOrderRowContext.tsx","../src/components/orderList/desktop/editOrder/innerInput.tsx","../src/components/orderList/desktop/components/quantityCell.tsx","../src/components/orderList/desktop/components/trailingCallbackCell.tsx","../src/components/orderList/desktop/components/triggerPriceCell.tsx","../src/components/orderList/desktop/renew.tsx","../src/components/orderList/desktop/tpslEdit.tsx","../src/components/orderList/desktop/tpslPrice.tsx","../src/components/orderList/desktop/tpslTriggerPrice.tsx","../src/components/orderList/desktop/useColumn.tsx","../src/components/orderList/mobile/items.tsx","../src/components/orderList/mobile/bracketOrderPrice/bracketOrderPrice.ui.tsx","../src/components/orderList/mobile/bracketOrderPrice/bracketOrderPrice.script.tsx","../src/components/orderList/mobile/bracketOrderPrice/bracketOrderPrice.widget.tsx","../src/components/orderList/mobile/bracketOrderPrice/index.ts","../src/components/orderList/mobile/cancelBtn/cancelBtn.ui.tsx","../src/components/orderList/mobile/cancelBtn/cancelBtn.script.tsx","../src/components/orderList/mobile/cancelBtn/cancelBtn.widget.tsx","../src/components/orderList/mobile/cancelBtn/index.ts","../src/components/orderList/mobile/editBtn/editBtn.ui.tsx","../src/components/orderList/mobile/editSheet/components/editSheetContext.ts","../src/components/orderList/mobile/editSheet/components/activitedPriceInput.tsx","../src/components/orderList/mobile/editSheet/components/editDialogContent.tsx","../src/components/orderList/mobile/editSheet/components/editSheetHeader.tsx","../src/components/orderList/mobile/editSheet/components/priceInput.tsx","../src/components/orderList/mobile/editSheet/components/quantityInput.tsx","../src/components/orderList/mobile/editSheet/components/quantitySlider.tsx","../src/components/orderList/mobile/editSheet/components/trailingCallbackInput.tsx","../src/components/orderList/mobile/editSheet/components/triggerPriceInput.tsx","../src/components/orderList/mobile/editSheet/editSheet.ui.tsx","../src/components/orderList/mobile/editSheet/hooks/useEditOrderEntry.ts","../src/components/orderList/mobile/editSheet/hooks/useEditOrderMaxQty.ts","../src/components/orderList/mobile/editSheet/editSheet.script.tsx","../src/components/orderList/mobile/editSheet/editSheet.widget.tsx","../src/components/orderList/mobile/editSheet/index.ts","../src/components/orderList/mobile/editBtn/editBtn.script.tsx","../src/components/orderList/mobile/editBtn/editBtn.widget.tsx","../src/components/orderList/mobile/editBtn/index.ts","../src/components/orderList/mobile/orderCell.ui.tsx","../src/components/orderList/mobile/orderCell.script.tsx","../src/components/orderList/mobile/orderCell.widget.tsx","../src/components/orderList/mobile/index.ts","../src/components/orderList/orderListProvider.tsx","../src/components/orderList/orderList.ui.tsx","../src/components/orderList/useFormatOrderHistory.ts","../src/components/orderList/orderList.script.tsx","../src/components/orderList/orderList.widget.tsx","../src/components/orderList/index.ts","../src/components/orders.ui.tsx","../src/components/orders.widget.tsx","../src/index.ts"],"names":["status","quantity","jsx","useMemo","useSymbolsInfo","Decimal","utils","useTranslation","Text","modal","createContext","useContext","toast","memo","ThrottledButton","jsxs","useRef","useState","useEffect","order","errors","useCallback","cn","Flex","OrderType","inputFormatter","Popover","AlgoOrderType","position","CheckIcon","Input","Tooltip","OrderSide","AlgoOrderRootType","Button","commifyOptional","Fragment","PreviewCell","price","sliderValue","useMutation","data","findTPSLFromOrder","i18n","OrderStatus","estTotal","useTpslPriceChecker","Badge","CloseToLiqPriceIcon","getTrailingStopPrice","AvgPrice","side","EditIcon","BracketOrderPrice","Price","init_bracketOrderPrice","init_cancelBtn","Slider","useOrderEntryFormErrorMsg","Divider","SimpleDialog","useOrderEntity","useMaxQty","useModal","useMemoizedFn","Grid","useImperativeHandle","useLocalStorage","dateRange","React","forwardRef","TabType"],"mappings":";;;;;;;;;;;AAAA,SAAuB,qBAAqB,cAAc;AAA1D,IAYa;AAZb;AAAA;AAAA;AAYO,IAAM,kBAAkB,CAAC,UAAkC;AAChE,YAAM,EAAE,SAAS,6BAA6B,eAAe,IAAI;AAEjE,YAAM,eAAe,OAA0B,IAAI;AAEnD,0BAAoB,MAAM,KAAK,OAAO,CAAC,EAAE;AAEzC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;ACzBA,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AAajB,SAAS,eAAe,QAAmC;AAChE,QAAM,YAAY,OAAO;AACzB,QAAM,WAAW,OAAO;AACxB,MAAI,OAAO,cAAc,aAAa;AACpC,UAAM,OAAiB,CAAC;AAExB,QAAI,CAAC,CAAC,OAAO,kBAAkB;AAC7B,UAAI,aAAa,cAAc,WAAW;AACxC,cAAM,QACJ,cAAc,UAAU,iBACpB,CAAC,KAAK,EAAE,iBAAiB,GAAG,KAAK,EAAE,SAAS,CAAC,IAC7C,CAAC,KAAK,EAAE,SAAS,CAAC;AACxB,aAAK,KAAK,GAAG,KAAK;AAAA,MACpB;AAEA,UAAI,aAAa,cAAc,aAAa;AAC1C,cAAM,QACJ,cAAc,UAAU,iBACpB,CAAC,KAAK,EAAE,iBAAiB,GAAG,KAAK,EAAE,SAAS,CAAC,IAC7C,CAAC,KAAK,EAAE,SAAS,CAAC;AACxB,aAAK,KAAK,GAAG,KAAK;AAAA,MACpB;AAEA,aAAO;AAAA,IACT;AAEA,UAAM,OACJ,OAAO,cAAc,WAAW,UAAU,QAAQ,UAAU,EAAE,IAAI;AAGpE,QAAI,C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from \"react\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { OrderListInstance } from \"./orderList/orderList.script\";\nimport { TabType } from \"./orders.widget\";\n\ntype UseOrdersScriptOptions = {\n current?: TabType;\n pnlNotionalDecimalPrecision?: number;\n ref: ForwardedRef<OrderListInstance>;\n sharePnLConfig?: SharePnLConfig;\n};\n\nexport const useOrdersScript = (props: UseOrdersScriptOptions) => {\n const { current, pnlNotionalDecimalPrecision, sharePnLConfig } = props;\n\n const orderListRef = useRef<OrderListInstance>(null);\n\n useImperativeHandle(props.ref, () => ({}));\n\n return {\n current,\n pnlNotionalDecimalPrecision,\n orderListRef,\n sharePnLConfig,\n };\n};\n\nexport type OrdersBuilderState = ReturnType<typeof useOrdersScript>;\n","import { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { i18n } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport {\n AlgoOrderRootType,\n AlgoOrderType,\n API,\n OrderStatus,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\n\nexport const upperCaseFirstLetter = (str: string) => {\n if (str === undefined) return str;\n if (str.length === 0) return str;\n if (str.length === 1) return str.charAt(0).toUpperCase();\n return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1);\n};\n\n/**\n * order_type: LIMIT、MARKET、CLOSE_POSITION\n * algo_type: STOP、TPSL、positional_TPSL、BRACKET\n */\nexport function parseBadgesFor(record: any): undefined | string[] {\n const orderType = record.type;\n const algoType = record.algo_type;\n if (typeof orderType !== \"undefined\") {\n const list: string[] = [];\n\n if (!!record.parent_algo_type) {\n if (algoType === AlgoOrderType.STOP_LOSS) {\n const types =\n orderType === OrderType.CLOSE_POSITION\n ? [i18n.t(\"common.position\"), i18n.t(\"tpsl.sl\")]\n : [i18n.t(\"tpsl.sl\")];\n list.push(...types);\n }\n\n if (algoType === AlgoOrderType.TAKE_PROFIT) {\n const types =\n orderType === OrderType.CLOSE_POSITION\n ? [i18n.t(\"common.position\"), i18n.t(\"tpsl.tp\")]\n : [i18n.t(\"tpsl.tp\")];\n list.push(...types);\n }\n\n return list;\n }\n\n const type =\n typeof orderType === \"string\" ? orderType.replace(\"_ORDER\", \"\") : \"\";\n\n // bbo(ask, bid) order as a limit type\n if ([OrderType.ASK, OrderType.BID].includes(orderType)) {\n return [i18n.t(\"orderEntry.orderType.limit\")];\n }\n\n if (\n record.algo_order_id === undefined ||\n (record.algo_order_id && algoType === \"BRACKET\")\n ) {\n const typeMap = {\n [OrderType.LIMIT]: i18n.t(\"orderEntry.orderType.limit\"),\n [OrderType.MARKET]: i18n.t(\"orderEntry.orderType.market\"),\n [OrderType.POST_ONLY]: i18n.t(\"orderEntry.orderType.postOnly\"),\n [OrderType.IOC]: i18n.t(\"orderEntry.orderType.ioc\"),\n [OrderType.FOK]: i18n.t(\"orderEntry.orderType.fok\"),\n };\n\n return [\n typeMap[type as keyof typeof typeMap] || upperCaseFirstLetter(type),\n ];\n }\n\n if (algoType === AlgoOrderRootType.TRAILING_STOP) {\n return [i18n.t(\"orderEntry.orderType.trailingStop\")];\n }\n\n // stop limit, stop market\n if (type) {\n const typeMap = {\n [OrderType.LIMIT]: i18n.t(\"orderEntry.orderType.stopLimit\"),\n [OrderType.MARKET]: i18n.t(\"orderEntry.orderType.stopMarket\"),\n };\n return [typeMap[type as keyof typeof typeMap] || type];\n }\n }\n\n if (typeof algoType !== \"undefined\") {\n const list: string[] = [];\n\n if (algoType === AlgoOrderRootType.POSITIONAL_TP_SL) {\n list.push(i18n.t(\"common.position\"));\n }\n\n const tpOrder = record?.child_orders?.find(\n (order: any) =>\n order.algo_type === AlgoOrderType.TAKE_PROFIT && !!order.trigger_price,\n );\n\n const slOrder = record?.child_orders?.find(\n (order: any) =>\n order.algo_type === AlgoOrderType.STOP_LOSS && !!order.trigger_price,\n );\n\n if (tpOrder || slOrder) {\n list.push(\n tpOrder && slOrder\n ? i18n.t(\"common.tpsl\")\n : tpOrder\n ? i18n.t(\"tpsl.tp\")\n : i18n.t(\"tpsl.sl\"),\n );\n }\n\n return list;\n }\n\n return undefined;\n}\n\nexport function grayCell(record: any): boolean {\n return (\n (record as API.Order).status === OrderStatus.CANCELLED ||\n (record as API.AlgoOrder).algo_status === OrderStatus.CANCELLED\n );\n}\n\nexport function getOrderStatus(record: any) {\n return (record as API.Order).status || (record as API.AlgoOrder).algo_status;\n}\n\nexport function isGrayCell(status?: string): boolean {\n return status === OrderStatus.CANCELLED;\n}\n\nfunction findBracketTPSLOrder(order: API.AlgoOrderExt) {\n if (order.algo_type !== AlgoOrderRootType.BRACKET) {\n return {\n tpOrder: undefined,\n slOrder: undefined,\n };\n }\n\n const innerOrder = order.child_orders?.[0];\n if (!innerOrder)\n return {\n tpOrder: undefined,\n slOrder: undefined,\n };\n\n const tpOrder = innerOrder?.child_orders?.find(\n (item) => item.algo_type === AlgoOrderType.TAKE_PROFIT,\n );\n\n const slOrder = innerOrder?.child_orders?.find(\n (item) => item.algo_type === AlgoOrderType.STOP_LOSS,\n );\n\n return {\n tpOrder,\n slOrder,\n };\n}\n\nexport function calcBracketRoiAndPnL(order: API.AlgoOrderExt) {\n const defaultCallback = {\n pnl: {\n tpPnL: undefined,\n slPnL: undefined,\n },\n // roi: {\n // tpRoi: undefined,\n // slRoi: undefined,\n // },\n };\n const { tpOrder, slOrder } = findBracketTPSLOrder(order);\n if (!tpOrder && !slOrder) return defaultCallback;\n\n if (typeof order.price === undefined || !order.price) return defaultCallback;\n\n const quantity =\n order.side === OrderSide.BUY ? order.quantity : order.quantity * -1;\n\n const tpPnL =\n tpOrder?.trigger_price &&\n utils.priceToPnl({\n qty: quantity,\n price: tpOrder?.trigger_price,\n entryPrice: order.price,\n // @ts-ignore\n orderSide: order.side,\n // @ts-ignore\n orderType: tpOrder.algo_type,\n });\n const slPnL =\n slOrder?.trigger_price &&\n utils.priceToPnl({\n qty: quantity,\n // trigger price\n price: slOrder?.trigger_price,\n //\n entryPrice: order.price,\n // @ts-ignore\n orderSide: order.side,\n // @ts-ignore\n orderType: slOrder.algo_type,\n });\n\n // UI not show ROI, so we don't need to calculate ROI\n // const tpRoi = tpPnL\n // ? utils.calcTPSL_ROI({\n // pnl: tpPnL,\n // qty: order.quantity,\n // price: order.price,\n // })\n // : undefined;\n // const slRoi = slPnL\n // ? utils.calcTPSL_ROI({\n // pnl: slPnL,\n // qty: order.quantity,\n // price: order.price,\n // })\n // : undefined;\n\n return {\n pnl: {\n tpPnL,\n slPnL,\n },\n // roi: {\n // tpRoi,\n // slRoi,\n // },\n };\n}\n\nexport function areDatesEqual(date1?: Date, date2?: Date): boolean {\n if (!date1 || !date2) return false;\n return (\n date1.getFullYear() === date2.getFullYear() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getDate() === date2.getDate()\n );\n}\n\nexport function isTrailingStopOrder(order: API.AlgoOrderExt) {\n return order.algo_type === OrderType.TRAILING_STOP;\n}\n\nexport function getNotional(order: API.AlgoOrderExt, dp = 2) {\n if (order.price && order.quantity) {\n return new Decimal(order.price)\n .mul(order.quantity)\n .toFixed(dp, Decimal.ROUND_DOWN);\n }\n\n return 0;\n}\n/**\n * api order type ==> orderEntry type\n */\nexport function convertApiOrderTypeToOrderEntryType(order: API.AlgoOrderExt) {\n if (order.algo_type === OrderType.TRAILING_STOP) {\n return order.algo_type;\n }\n\n const isAlgoOrder = order.algo_order_id !== undefined;\n\n if (isAlgoOrder && order.algo_type !== AlgoOrderRootType.BRACKET) {\n return `STOP_${order.type}` as OrderType;\n }\n\n return order.type;\n}\n","import { createContext, useContext } from \"react\";\nimport type { API } from \"@kodiak-finance/orderly-types\";\n\nexport interface SymbolContextState {\n base_dp: number;\n quote_dp: number;\n base_tick: number;\n quote_tick: number;\n base: string;\n quote: string;\n symbol: string;\n origin: API.SymbolExt;\n quote_min: number;\n quote_max: number;\n}\n\nexport const SymbolContext = createContext<SymbolContextState>(\n {} as SymbolContextState,\n);\n\nexport const useSymbolContext = () => {\n return useContext<SymbolContextState>(SymbolContext);\n};\n","import { FC, PropsWithChildren, useMemo } from \"react\";\nimport { useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { SymbolContext, SymbolContextState } from \"./symbolContext\";\n\ninterface FormatterProviderProps {\n symbol: string;\n}\n\nexport const SymbolProvider: FC<PropsWithChildren<FormatterProviderProps>> = (\n props,\n) => {\n const { symbol, children } = props;\n const symbolInfo = useSymbolsInfo()[symbol];\n const memoizedValue = useMemo<SymbolContextState>(() => {\n return {\n symbol: symbol,\n base_dp: symbolInfo(\"base_dp\"),\n quote_dp: symbolInfo(\"quote_dp\"),\n base_tick: symbolInfo(\"base_tick\"),\n quote_tick: symbolInfo(\"quote_tick\"),\n base: symbolInfo(\"base\"),\n quote: symbolInfo(\"quote\"),\n origin: symbolInfo(),\n quote_max: symbolInfo(\"quote_max\"),\n quote_min: symbolInfo(\"quote_min\"),\n };\n }, [symbol, symbolInfo]);\n return (\n <SymbolContext.Provider value={memoizedValue}>\n {children}\n </SymbolContext.Provider>\n );\n};\n","import { FC } from \"react\";\nimport { ShareIcon } from \"@kodiak-finance/orderly-ui\";\nimport { ShareButtonScriptReturn } from \"./shareButton.script\";\n\nexport const ShareButton: FC<ShareButtonScriptReturn> = (props) => {\n if (props.sharePnLConfig == null) {\n return null;\n }\n\n return (\n <button\n type=\"button\"\n onClick={(e: any) => {\n e.stopPropagation();\n props.showModal();\n }}\n >\n <ShareIcon color=\"white\" opacity={0.54} size={props.iconSize ?? 16} />\n </button>\n );\n};\n","import { useMemo } from \"react\";\nimport { useReferralInfo, useLeverageBySymbol } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { modal } from \"@kodiak-finance/orderly-ui\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\n\nexport type ShareButtonScriptReturn = ReturnType<typeof useShareButtonScript>;\n\nexport const useShareButtonScript = (props: {\n order: any;\n sharePnLConfig?: SharePnLConfig;\n modalId: string;\n iconSize?: number;\n}) => {\n const { sharePnLConfig, order, iconSize } = props;\n const { t } = useTranslation();\n const { getFirstRefCode } = useReferralInfo();\n const refCode = useMemo(() => {\n return getFirstRefCode()?.code;\n }, [getFirstRefCode]);\n const leverage = useLeverageBySymbol(order.symbol);\n\n const showModal = () => {\n modal.show(props.modalId, {\n pnl: {\n entity: {\n symbol: order.symbol,\n pnl: order.realized_pnl,\n side:\n order.side == \"BUY\"\n ? t(\"share.pnl.share.long\")\n : t(\"share.pnl.share.short\"),\n openPrice: order.average_executed_price,\n openTime: order.updated_time,\n quantity: order.quantity,\n },\n refCode,\n leverage,\n ...sharePnLConfig,\n },\n });\n };\n\n return {\n iconSize,\n sharePnLConfig,\n showModal,\n };\n};\n","import React from \"react\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { useShareButtonScript } from \"./shareButton.script\";\nimport { ShareButton } from \"./shareButton.ui\";\n\nexport const ShareButtonWidget: React.FC<{\n order: any;\n sharePnLConfig?: SharePnLConfig;\n modalId: string;\n iconSize?: number;\n}> = (props) => {\n const state = useShareButtonScript(props);\n return <ShareButton {...state} />;\n};\n","export { ShareButton } from \"./shareButton.ui\";\nexport { ShareButtonWidget } from \"./shareButton.widget\";\n","import { memo } from \"react\";\nimport { useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { Text } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\n\ntype AvgPriceProps = {\n symbol: string;\n value: string;\n};\n\nexport const AvgPrice = memo((props: AvgPriceProps) => {\n const symbolsInfo = useSymbolsInfo();\n\n const info = symbolsInfo[props.symbol];\n\n if (!props.value) {\n return \"--\";\n }\n\n return (\n <Text.numeral\n padding={false}\n dp={info(\"quote_dp\", 2)}\n rm={Decimal.ROUND_UP}\n >\n {props.value}\n </Text.numeral>\n );\n});\n","import { useMemo } from \"react\";\nimport { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport {\n Flex,\n Tooltip,\n Text,\n cn,\n EditIcon,\n useModal,\n modal,\n} from \"@kodiak-finance/orderly-ui\";\nimport { calcBracketRoiAndPnL } from \"../../../utils/util\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\n\nexport const BracketOrderPrice = (props: { order: API.AlgoOrderExt }) => {\n const { order } = props;\n const { quote_dp, base_dp } = useSymbolContext();\n const { t } = useTranslation();\n\n const { sl_trigger_price, tp_trigger_price } = useMemo(() => {\n if (!(\"algo_type\" in order) || !Array.isArray(order.child_orders)) {\n return {};\n }\n return utils.findTPSLFromOrder(props.order.child_orders[0]);\n }, [props.order]);\n\n const { pnl } = calcBracketRoiAndPnL(order);\n\n if (!tp_trigger_price && !sl_trigger_price) {\n return \"--\";\n }\n\n return (\n <Tooltip\n // @ts-ignore\n content={\n <Flex direction={\"column\"} itemAlign={\"start\"} gap={1}>\n {typeof pnl.tpPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.tpPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={quote_dp}\n color=\"buy\"\n showIdentifier\n >\n {pnl.tpPnL}\n </Text.numeral>\n )}\n {typeof pnl.slPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.slPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={quote_dp}\n color=\"sell\"\n >\n {pnl.slPnL}\n </Text.numeral>\n )}\n </Flex>\n }\n className=\"oui-bg-base-6\"\n >\n <Flex itemAlign={\"center\"} justify={\"start\"} gap={2}>\n <Flex direction={\"column\"} justify={\"start\"} itemAlign={\"start\"}>\n <Price type=\"TP\" value={tp_trigger_price} quote_dp={quote_dp} />\n <Price type=\"SL\" value={sl_trigger_price} quote_dp={quote_dp} />\n </Flex>\n <EditBracketOrder order={order} />\n </Flex>\n </Tooltip>\n );\n};\n\nconst EditBracketOrder = (props: { order: API.AlgoOrderExt }) => {\n const { order } = props;\n\n const onEdit = () => {\n modal.show(\"EditBracketOrderDialogId\", {\n order,\n });\n };\n\n return (\n <EditIcon\n size={16}\n className=\"oui-text-base-contrast oui-cursor-pointer\"\n onClick={() => {\n onEdit();\n }}\n />\n );\n};\n\nconst Price = (props: {\n type: \"TP\" | \"SL\";\n value?: number | string;\n quote_dp: number;\n}) => {\n const { type, value, quote_dp } = props;\n const { t } = useTranslation();\n\n return value ? (\n <Text.numeral\n className={cn(\n \"oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12\",\n type === \"TP\" ? \"oui-text-trade-profit\" : \"oui-text-trade-loss\",\n )}\n key={\"tp\"}\n rule=\"price\"\n dp={quote_dp}\n // @ts-ignore\n prefix={\n <span className={\"oui-text-base-contrast-54\"}>\n {type === \"TP\" ? `${t(\"tpsl.tp\")} -` : `${t(\"tpsl.sl\")} -`}\n \n </span>\n }\n >\n {value}\n </Text.numeral>\n ) : (\n <></>\n );\n};\n","import { createContext, useContext } from \"react\";\nimport { API, OrderEntity } from \"@kodiak-finance/orderly-types\";\n\nexport interface OrderListContextState {\n onCancelOrder: (order: API.Order | API.AlgoOrder) => Promise<any>;\n editOrder: (id: string, order: OrderEntity) => Promise<any>;\n editAlgoOrder: (id: string, order: OrderEntity) => Promise<any>;\n checkMinNotional: (\n symbol: string,\n price?: string | number,\n qty?: string | number,\n ) => string | undefined;\n}\n\nexport const OrderListContext = createContext<OrderListContextState>(\n {} as OrderListContextState,\n);\n\nexport const useOrderListContext = () => {\n return useContext(OrderListContext);\n};\n\nexport interface OrderListProviderProps {\n cancelOrder: (orderId: number, symbol: string) => Promise<any>;\n editOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n cancelAlgoOrder: (orderId: number, symbol: string) => Promise<any>;\n editAlgoOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n}\n","import { FC, useState } from \"react\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { ThrottledButton, toast } from \"@kodiak-finance/orderly-ui\";\nimport { useOrderListContext } from \"../orderListContext\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\n\nexport const CancelButton: FC<{\n order: API.Order;\n}> = (props) => {\n const { order } = props;\n const { t } = useTranslation();\n\n const { onCancelOrder } = useOrderListContext();\n const [isLoading, setIsLoading] = useState(false);\n\n return (\n <ThrottledButton\n size=\"sm\"\n variant={\"outlined\"}\n color={\"secondary\"}\n onClick={(event) => {\n if (!onCancelOrder) return;\n event.preventDefault();\n event.stopPropagation();\n setIsLoading(true);\n onCancelOrder(order)\n .then(\n (res: any) => res,\n (error: any) => {\n toast.error(error.message);\n }\n )\n .finally(() => {\n setIsLoading(false);\n });\n }}\n loading={isLoading}\n >\n {t(\"common.cancel\")}\n </ThrottledButton>\n );\n};\n","export enum EditType {\n quantity,\n price,\n triggerPrice,\n callbackValue,\n callbackRate,\n}\n","import { memo } from \"react\";\nimport { useTranslation, Trans } from \"@kodiak-finance/orderly-i18n\";\nimport { Button, CloseIcon, ThrottledButton } from \"@kodiak-finance/orderly-ui\";\nimport { commify } from \"@kodiak-finance/orderly-utils\";\nimport { EditType } from \"../../../../type\";\n\ntype ConfirmContentProps = {\n type: EditType;\n base: string;\n value: string;\n cancelPopover: () => void;\n isSubmitting: boolean;\n onConfirm: (e: any) => void;\n};\n\nexport const ConfirmContent = memo((props: ConfirmContentProps) => {\n const { type, base, value, cancelPopover, isSubmitting, onConfirm } = props;\n const { t } = useTranslation();\n\n const renderLabel = () => {\n const common = {\n values: { base, value: commify(value) },\n components: [<span key=\"0\" className=\"oui-text-warning-darken\" />],\n };\n\n switch (type) {\n case EditType.quantity:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.quantity\" {...common} />\n );\n case EditType.price:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.price\" {...common} />\n );\n case EditType.triggerPrice:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.triggerPrice\" {...common} />\n );\n case EditType.callbackValue:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.callbackValue\" {...common} />\n );\n case EditType.callbackRate:\n return (\n // @ts-ignore\n <Trans i18nKey=\"order.edit.confirm.callbackRate\" {...common} />\n );\n }\n };\n\n return (\n <div className=\"oui-relative oui-pt-5\">\n <div className=\"desktop:oui-text-sm oui-text-2xs oui-text-base-contrast-54\">\n {renderLabel()}\n </div>\n <div className=\"oui-mt-5 oui-grid oui-grid-cols-2 oui-gap-2\">\n <Button\n color=\"secondary\"\n size={\"md\"}\n onClick={cancelPopover}\n disabled={isSubmitting}\n >\n {t(\"common.cancel\")}\n </Button>\n <ThrottledButton size={\"md\"} loading={isSubmitting} onClick={onConfirm}>\n {t(\"common.confirm\")}\n </ThrottledButton>\n </div>\n <button\n className=\"oui-absolute oui-right-0 oui-top-0 oui-text-base-contrast-54\"\n onClick={cancelPopover}\n >\n <CloseIcon size={16} color=\"white\" opacity={1} />\n </button>\n </div>\n );\n});\n\nConfirmContent.displayName = \"ConfirmContent\";\n","import { useCallback, useEffect, useRef, useState, MouseEvent } from \"react\";\n\ntype PopoverStateProps = {\n originValue: string;\n value: string;\n setValue: (value: string) => void;\n};\n\nexport function usePopoverState(props: PopoverStateProps) {\n const { originValue, value, setValue } = props;\n\n const [open, setOpen] = useState(false);\n const [editing, setEditing] = useState(false);\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const closePopover = useCallback(() => {\n setOpen(false);\n setEditing(false);\n }, []);\n\n const cancelPopover = useCallback(() => {\n closePopover();\n setValue(originValue);\n }, [originValue]);\n\n const onClick = useCallback(\n async (event: MouseEvent) => {\n event.stopPropagation();\n event.preventDefault();\n\n // if value is not changed, then don't open popover\n if (value === originValue) {\n setEditing(false);\n return;\n }\n\n setOpen(true);\n },\n [value, originValue],\n );\n\n useEffect(() => {\n const handleClickOutside = (event: any) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(event.target as Node) &&\n !open\n ) {\n cancelPopover();\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [open, cancelPopover]);\n\n return {\n value,\n setValue,\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n };\n}\n","import { useEffect, useMemo } from \"react\";\nimport { OrderValidationResult, useOrderEntity } from \"@kodiak-finance/orderly-hooks\";\nimport { useOrderEntryFormErrorMsg } from \"@kodiak-finance/orderly-react-app\";\nimport { API, OrderlyOrder, OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { convertApiOrderTypeToOrderEntryType } from \"../../../../utils/util\";\n\nexport function useValidateField(props: {\n order: API.OrderExt | API.AlgoOrderExt;\n originValue?: string;\n value: string;\n field: keyof OrderValidationResult;\n fieldValues?: Partial<OrderlyOrder>;\n}) {\n const { order, field, originValue, value, fieldValues } = props;\n const changeFields = fieldValues || { [field]: value };\n\n const orderType = useMemo(\n () => convertApiOrderTypeToOrderEntryType(order as API.AlgoOrderExt),\n [order],\n );\n\n const { errors, validate, clearErrors } = useOrderEntity({\n symbol: order.symbol,\n order_type: orderType,\n side: order.side as OrderSide,\n ...(changeFields as any),\n });\n const { getErrorMsg } = useOrderEntryFormErrorMsg(errors);\n\n const error = useMemo(\n () => (field ? getErrorMsg(field) : undefined),\n [getErrorMsg, field],\n );\n\n useEffect(() => {\n // if value is not changed, then don't validate\n if (value === originValue) {\n clearErrors();\n return;\n }\n validate()\n .then((order) => {\n console.log(\"order\", order);\n })\n .catch((errors) => {\n console.error(`${field} validate error:`, errors);\n });\n }, [value, originValue]);\n\n return { error, errors, getErrorMsg };\n}\n","import { FC, useCallback, useEffect, useRef, MouseEvent } from \"react\";\nimport { EMPTY_LIST } from \"@kodiak-finance/orderly-types\";\nimport {\n inputFormatter,\n Input,\n InputProps,\n CheckIcon,\n cn,\n Flex,\n} from \"@kodiak-finance/orderly-ui\";\n\nexport type EditableCellInputProps = {\n id?: string;\n name?: string;\n placeholder?: string;\n suffix?: React.ReactNode;\n value?: InputProps[\"value\"];\n onChange?: (value: string) => void;\n error?: string;\n formatters?: InputProps[\"formatters\"];\n overrideFormatters?: InputProps[\"formatters\"];\n classNames?: InputProps[\"classNames\"];\n readonly?: boolean;\n onClick: (e: MouseEvent) => void;\n onFocus?: (e: any) => void;\n onBlur?: (e: any) => void;\n handleKeyDown?: (e: any) => void;\n};\n\nexport const EditableCellInput: FC<EditableCellInputProps> = (props) => {\n const { onClick } = props;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleKeyDown = useCallback(\n (event: any) => {\n if (event.key === \"Enter\") {\n onClick(event);\n }\n },\n [onClick],\n );\n\n useEffect(() => {\n const input = inputRef.current;\n if (input) {\n const length = input.value.length;\n input.setSelectionRange(length, length);\n }\n }, [props.value]);\n\n return (\n <Input.tooltip\n ref={inputRef}\n tooltip={props.error}\n autoComplete=\"off\"\n autoFocus\n type=\"text\"\n size=\"sm\"\n placeholder={props.readonly ? \"\" : props.placeholder || \"\"}\n id={props.id}\n name={props.name}\n color={props.error ? \"danger\" : undefined}\n value={props.readonly ? \"\" : props.value || \"\"}\n onValueChange={props.onChange}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n onFocus={props.onFocus}\n onBlur={props.onBlur}\n onKeyDown={props.handleKeyDown || handleKeyDown}\n inputMode=\"decimal\"\n formatters={\n props.overrideFormatters || [\n ...(props.formatters ?? EMPTY_LIST),\n inputFormatter.numberFormatter,\n inputFormatter.decimalPointFormatter,\n ]\n }\n classNames={{\n root: \"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded\",\n input: \"oui-pr-2\",\n }}\n readOnly={props.readonly}\n suffix={\n <Flex gapX={1}>\n {props.suffix}\n <button onClick={onClick} disabled={!!props.error}>\n <CheckIcon\n size={18}\n color=\"white\"\n opacity={1}\n className={cn(\n \"oui-opacity-50\",\n props.error\n ? \"oui-cursor-not-allowed\"\n : \"oui-cursor-pointer hover:oui-opacity-100\",\n )}\n />\n </button>\n </Flex>\n }\n />\n );\n};\n","import { memo } from \"react\";\nimport { cn, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { commifyOptional } from \"@kodiak-finance/orderly-utils\";\nimport { isGrayCell } from \"../../../../utils/util\";\n\ntype PreviewCellProps = {\n status?: string;\n value: string;\n setEditing: (isEditing: boolean) => void;\n disabled?: boolean;\n suffix?: string;\n className?: string;\n};\n\nexport const PreviewCell = memo((props: PreviewCellProps) => {\n const { status, value, disabled } = props;\n\n return (\n <div\n className={cn(\n \"oui-flex oui-items-center oui-justify-start\",\n \"oui-relative oui-max-w-[110px] oui-gap-1 oui-font-semibold\",\n isGrayCell(status) && \"oui-text-base-contrast-20\",\n props.className,\n )}\n onClick={(e) => {\n if (!disabled) {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }\n }}\n >\n <Flex\n r=\"base\"\n className={cn(\n \"oui-h-[28px] oui-min-w-[70px]\",\n !disabled && \"oui-border oui-border-line-12 oui-bg-base-7 oui-px-2\",\n )}\n >\n <Text size=\"2xs\">\n {commifyOptional(value)}\n {props.suffix}\n </Text>\n </Flex>\n </div>\n );\n});\n","import { useCallback, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderType } from \"@kodiak-finance/orderly-types\";\nimport { inputFormatter, Popover, toast } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const ActivedPriceCell = (props: {\n order: API.AlgoOrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { t } = useTranslation();\n // the value before editing, initial value\n const originValue = order.activated_price?.toString() ?? \"\";\n\n const [value, setValue] = useState<string>(originValue);\n const [submitting, setSubmitting] = useState(false);\n const disabled = props.disabled || order.is_activated || order.is_triggered;\n\n const { editAlgoOrder } = useOrderListContext();\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error } = useValidateField({\n order,\n field: \"activated_price\",\n originValue,\n value,\n });\n\n const onConfirm = useCallback(() => {\n setSubmitting(true);\n\n const data: any = {\n algo_order_id: order.algo_order_id,\n activated_price: value,\n };\n\n editAlgoOrder(order.algo_order_id.toString(), data)\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setSubmitting(false));\n }, [order.algo_order_id, value, cancelPopover]);\n\n if (!order.activated_price && order.type === OrderType.MARKET) {\n return <span>{t(\"common.marketPrice\")}</span>;\n }\n\n const renderContent = () => {\n if (!editing || disabled) {\n return (\n <PreviewCell\n value={value}\n status={getOrderStatus(order)}\n setEditing={setEditing}\n disabled={disabled}\n />\n );\n }\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n // when editing, value should not be empty\n error={value ? error : t(\"orderEntry.triggerPrice.error.required\")}\n formatters={[inputFormatter.dpFormatter(quote_dp)]}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.triggerPrice}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={submitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import { useMemo, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { OrderType } from \"@kodiak-finance/orderly-types\";\nimport { inputFormatter, Popover, toast } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const PriceCell = (props: {\n order: API.OrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { t } = useTranslation();\n\n const originValue = useMemo(() => {\n if (order.type === OrderType.MARKET && !order.price) {\n return \"Market\";\n }\n return order.price?.toString() ?? \"Market\";\n }, [order.price, order.type]);\n\n const [value, setValue] = useState<string>(originValue);\n\n const isAlgoOrder = order?.algo_order_id !== undefined;\n\n const [submitting, setSubmitting] = useState(false);\n\n const { editOrder, editAlgoOrder } = useOrderListContext();\n\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error, getErrorMsg } = useValidateField({\n order,\n field: \"order_price\",\n originValue,\n value,\n fieldValues: {\n order_price: value,\n // add order quantity to validate total\n order_quantity: order.quantity?.toString(),\n // need to pass trigger_price to validate order_price, because order_price is depend on trigger_price when type is stop limit\n trigger_price: order.trigger_price?.toString(),\n },\n });\n\n const onConfirm = () => {\n setSubmitting(true);\n\n let order_id = order.order_id;\n // if reduce only is true, edit order must add symbol, order_type, side, order_price, order_quantity, reduce_only\n let data: any = {\n symbol: order.symbol,\n order_type: order.type,\n side: order.side,\n order_quantity: order.quantity,\n order_price: value,\n };\n\n if (order.reduce_only) {\n data.reduce_only = order.reduce_only;\n }\n\n if (order.order_tag) {\n data.order_tag = order.order_tag;\n }\n\n if (order.client_order_id) {\n data.client_order_id = order.client_order_id;\n }\n\n if (isAlgoOrder) {\n order_id = order.algo_order_id as number;\n data = {\n ...data,\n order_id,\n price: value,\n algo_order_id: order_id,\n };\n }\n\n // edit order don't need to set visible quantity again\n // if (order?.visible_quantity === 0) {\n // data[\"visible_quantity\"] = 0;\n // }\n\n // TODO: remove this, because order not have this field\n // @ts-ignore\n if (order.tag !== undefined) {\n // @ts-ignore\n data[\"order_tag\"] = order.tag;\n }\n\n let future;\n if (order.algo_order_id !== undefined) {\n future = editAlgoOrder(order.algo_order_id.toString(), data);\n } else {\n future = editOrder(order.order_id.toString(), data);\n }\n\n future\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setSubmitting(false));\n };\n\n const isAlgoMarketOrder = order.algo_order_id && order.type == \"MARKET\";\n\n if (isAlgoMarketOrder || value === \"Market\") {\n return <span>{t(\"common.marketPrice\")}</span>;\n }\n\n const renderContent = () => {\n if (!editing || props.disabled) {\n return (\n <PreviewCell\n value={value}\n status={getOrderStatus(order)}\n setEditing={setEditing}\n disabled={props.disabled}\n />\n );\n }\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n error={error || getErrorMsg(\"total\")}\n formatters={[inputFormatter.dpFormatter(quote_dp)]}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.price}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={submitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport {\n unstable_serialize,\n useAccount,\n useMemoizedFn,\n useMutation,\n useSWRConfig,\n utils,\n} from \"@kodiak-finance/orderly-hooks\";\nimport {\n findTPSLOrderPriceFromOrder,\n findTPSLFromOrder,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { API, OrderType } from \"@kodiak-finance/orderly-types\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { AlgoOrderType } from \"@kodiak-finance/orderly-types\";\nimport { useSymbolContext } from \"../provider/symbolContext\";\n\nexport type TPSLOrderRowContextState = {\n order: API.AlgoOrderExt;\n tp_trigger_price?: number;\n sl_trigger_price?: number;\n sl_order_price?: number | OrderType;\n tp_order_price?: number | OrderType;\n tpPnL?: number;\n slPnL?: number;\n\n onCancelOrder: (order: API.AlgoOrderExt) => Promise<void>;\n onUpdateOrder: (order: API.AlgoOrderExt, params: any) => Promise<void>;\n\n getRelatedPosition: (symbol: string) => API.PositionTPSLExt | undefined;\n\n position?: API.PositionTPSLExt;\n};\n\nexport const TPSLOrderRowContext = createContext<TPSLOrderRowContextState>(\n {} as TPSLOrderRowContextState,\n);\n\nexport const useTPSLOrderRowContext = () => {\n return useContext(TPSLOrderRowContext);\n};\n\nexport const TPSLOrderRowProvider: FC<\n PropsWithChildren<{ order: API.AlgoOrderExt }>\n> = (props) => {\n const { order, children } = props;\n const { quote_dp } = useSymbolContext();\n const [position, setPosition] = useState<API.PositionTPSLExt>();\n\n const [doDeleteOrder] = useMutation(\"/v1/algo/order\", \"DELETE\");\n const [doUpdateOrder] = useMutation(\"/v1/algo/order\", \"PUT\");\n\n const config = useSWRConfig();\n const { state } = useAccount();\n\n const positionKey = useMemo(() => {\n return unstable_serialize(() => [\"/v1/positions\", state.accountId]);\n }, [state.accountId]);\n\n const onCancelOrder = useMemoizedFn(async (order: API.AlgoOrderExt) => {\n return doDeleteOrder(null, {\n order_id: order.algo_order_id,\n symbol: order.symbol,\n });\n });\n\n const onUpdateOrder = useMemoizedFn(\n async (order: API.AlgoOrderExt, params: any) => {\n return doUpdateOrder({\n order_id: order.algo_order_id,\n child_orders: order.child_orders.map((order) => ({\n order_id: order.algo_order_id,\n quantity: params.order_quantity,\n })),\n });\n },\n );\n\n const getRelatedPosition = useMemoizedFn(\n (symbol: string): API.PositionTPSLExt => {\n const positions = config.cache.get(positionKey);\n return positions?.data?.rows?.find(\n (p: API.PositionTPSLExt) => p.symbol === symbol,\n );\n },\n );\n\n const {\n sl_trigger_price,\n tp_trigger_price,\n tpPnL,\n slPnL,\n sl_order_price,\n tp_order_price,\n } = calcTPSLPnL({\n order: order,\n position,\n quote_dp,\n });\n\n useEffect(() => {\n if (\"algo_type\" in order || ((order as any)?.reduce_only ?? false)) {\n const position = getRelatedPosition(order.symbol);\n if (position) {\n setPosition(position);\n }\n }\n }, [order.symbol]);\n\n const memoizedValue = useMemo<TPSLOrderRowContextState>(() => {\n return {\n order: order,\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n tpPnL,\n slPnL,\n position,\n onCancelOrder,\n onUpdateOrder,\n getRelatedPosition,\n };\n }, [\n order,\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n tpPnL,\n slPnL,\n position,\n onCancelOrder,\n onUpdateOrder,\n getRelatedPosition,\n ]);\n\n return (\n <TPSLOrderRowContext.Provider value={memoizedValue}>\n {children}\n </TPSLOrderRowContext.Provider>\n );\n};\n\nfunction calcTPSLPnL(props: {\n order: API.AlgoOrderExt;\n position?: API.PositionTPSLExt;\n quote_dp: number;\n}) {\n const { order, position, quote_dp } = props;\n\n if (!position)\n return {\n sl_trigger_price: undefined,\n tp_trigger_price: undefined,\n slPnL: undefined,\n tpPnL: undefined,\n };\n\n const isTPSLOrder = \"algo_type\" in order && Array.isArray(order.child_orders);\n\n const { sl_trigger_price, tp_trigger_price } = isTPSLOrder\n ? findTPSLFromOrder(order)\n : {\n sl_trigger_price: undefined,\n tp_trigger_price: undefined,\n };\n const { sl_order_price, tp_order_price } = isTPSLOrder\n ? findTPSLOrderPriceFromOrder(order)\n : {\n sl_order_price: undefined,\n tp_order_price: undefined,\n };\n\n let quantity = order.quantity;\n\n if (quantity === 0) {\n if (order.child_orders?.[0].type === \"CLOSE_POSITION\") {\n quantity = position.position_qty;\n }\n }\n\n const avgOpenPrice = position.average_open_price;\n const tpPnL =\n typeof quantity === \"number\" &&\n typeof tp_trigger_price === \"number\" &&\n typeof avgOpenPrice === \"number\"\n ? utils.priceToPnl(\n {\n qty: quantity,\n price: tp_trigger_price,\n entryPrice: position.average_open_price,\n orderSide: order.side as OrderSide,\n orderType: AlgoOrderType.TAKE_PROFIT,\n },\n { symbol: { quote_dp } },\n )\n : undefined;\n\n const slPnL =\n typeof quantity === \"number\" &&\n typeof sl_trigger_price === \"number\" &&\n typeof avgOpenPrice === \"number\"\n ? utils.priceToPnl(\n {\n qty: quantity,\n price: sl_trigger_price,\n entryPrice: position.average_open_price,\n orderSide: order.side as OrderSide,\n orderType: AlgoOrderType.STOP_LOSS,\n },\n { symbol: { quote_dp } },\n )\n : undefined;\n\n return {\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n slPnL,\n tpPnL,\n };\n}\n","import { FC, useEffect } from \"react\";\nimport { CheckIcon, Input, inputFormatter, Tooltip } from \"@kodiak-finance/orderly-ui\";\n\nexport const InnerInput: FC<{\n inputRef: any;\n value: string;\n setValue: any;\n setEditing: any;\n error?: string;\n handleKeyDown: (e: any) => void;\n onClick: (e: any) => void;\n onClose: (e: any) => void;\n onFocus?: (e: any) => void;\n onBlur?: (e: any) => void;\n dp: number;\n hintInfo?: string;\n}> = (props) => {\n const {\n inputRef,\n dp,\n value,\n setValue,\n setEditing,\n error,\n handleKeyDown,\n onClick,\n onClose,\n onFocus,\n onBlur,\n hintInfo,\n } = props;\n\n useEffect(() => {\n const input = inputRef.current;\n if (input) {\n const length = input.value.length;\n input.setSelectionRange(length, length);\n }\n setEditing(true);\n }, []);\n const open = (hintInfo?.length || 0) > 0;\n return (\n <Tooltip content={hintInfo} open={open}>\n <Input\n ref={inputRef}\n type=\"text\"\n size=\"sm\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(dp),\n inputFormatter.currencyFormatter,\n ]}\n value={value}\n onValueChange={(e) => setValue(e)}\n helpText={error}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n autoComplete=\"off\"\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={handleKeyDown}\n autoFocus\n color={open ? \"danger\" : undefined}\n classNames={{\n root: \"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded\",\n input: \"oui-pr-2\",\n }}\n // prefix={\n // <CloseIcon\n // size={14}\n // color=\"white\"\n // opacity={1}\n // className=\"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100\"\n // onClick={(e) => {\n // e.stopPropagation();\n // e.preventDefault();\n // onClose(e);\n // }}\n // />\n // }\n suffix={\n <button onClick={onClick}>\n <CheckIcon\n size={18}\n color=\"white\"\n opacity={1}\n className=\"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100\"\n />\n </button>\n }\n />\n </Tooltip>\n );\n};\n","import { FC, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useMaxQty, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { AlgoOrderRootType } from \"@kodiak-finance/orderly-types\";\nimport {\n cn,\n Flex,\n Popover,\n toast,\n Text,\n Slider,\n Button,\n PopoverTrigger,\n PopoverRoot,\n PopoverContent,\n} from \"@kodiak-finance/orderly-ui\";\nimport { commifyOptional, Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { EditType } from \"../../../../type\";\nimport { grayCell } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { useTPSLOrderRowContext } from \"../../tpslOrderRowContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { InnerInput } from \"../editOrder/innerInput\";\n\nexport const QuantityCell = (props: {\n order: API.OrderExt | API.AlgoOrder;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { reduce_only } = order;\n const originValue = order.quantity.toString();\n const [value, setValue] = useState(originValue);\n\n const [editing, setEditing] = useState(false);\n\n const { t } = useTranslation();\n\n const [open, setOpen] = useState(false);\n const [error, setError] = useState<string>();\n\n const { editOrder, editAlgoOrder, checkMinNotional } = useOrderListContext();\n const { onUpdateOrder: onUpdateTPSLOrder, position } =\n useTPSLOrderRowContext();\n\n const { base_dp, base, base_tick } = useSymbolContext();\n\n const setQuantity = async (qty: string, maxQty?: number): Promise<void> => {\n setValue(qty);\n const positionQty = Math.abs(position?.position_qty || 0);\n\n if (position && reduce_only && Number(qty) > positionQty) {\n setError(\n t(\"orders.quantity.lessThanPosition\", {\n quantity: positionQty,\n }),\n );\n } else {\n const quantity = Number(qty);\n if (maxQty && quantity > maxQty) {\n setError(\n t(\"orders.quantity.lessThan\", {\n quantity: commifyOptional(maxQty, {\n fix: base_dp,\n }),\n }),\n );\n } else {\n setError(undefined);\n }\n }\n return Promise.resolve();\n };\n\n useEffect(() => {\n setQuantity(order.quantity.toString());\n }, [props.order.quantity]);\n\n const closePopover = () => {\n setOpen(false);\n setEditing(false);\n };\n const cancelPopover = () => {\n setOpen(false);\n setQuantity(order.quantity.toString());\n setEditing(false);\n };\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const clickHandler = () => {\n if (!!error) {\n return;\n }\n\n if (Number(value) === Number(order.quantity)) {\n setEditing(false);\n return;\n }\n\n const price =\n order.algo_order_id !== undefined ? order.trigger_price : order.price;\n if (price !== null && order.reduce_only !== true) {\n const notionalText = checkMinNotional(order.symbol, price, value);\n if (notionalText) {\n toast.error(notionalText);\n setIsSubmitting(false);\n cancelPopover();\n return;\n }\n }\n\n setOpen(true);\n };\n\n const onClick = (event: any) => {\n event?.stopPropagation();\n event?.preventDefault();\n\n clickHandler();\n };\n\n const handleKeyDown = (event: any) => {\n if (event.key === \"Enter\") {\n event?.stopPropagation();\n event?.preventDefault();\n clickHandler();\n }\n };\n\n const onConfirm = useCallback(() => {\n setIsSubmitting(true);\n\n let params: any = {\n symbol: order.symbol,\n order_type: order.type,\n side: order.side,\n order_price: order.price,\n order_quantity: value,\n // reduce_only: Boolean(order.reduce_only),\n algo_order_id: order.algo_order_id,\n };\n\n if (\n typeof params.algo_order_id !== \"undefined\" &&\n params.order_type === \"MARKET\"\n ) {\n // stop market order\n const { order_price, ...rest } = params;\n params = rest;\n }\n\n if (typeof order.reduce_only !== \"undefined\") {\n params.reduce_only = order.reduce_only;\n }\n\n if (order.order_tag) {\n params.order_tag = order.order_tag;\n }\n\n if (order.client_order_id) {\n params.client_order_id = order.client_order_id;\n }\n\n if (order?.visible_quantity === 0) {\n params[\"visible_quantity\"] = 0;\n }\n\n // @ts-ignore\n if (order?.tag !== undefined) {\n // @ts-ignore\n params[\"order_tag\"] = order.tag;\n }\n\n let future;\n\n if (\"algo_type\" in order && order.algo_type === AlgoOrderRootType.TP_SL) {\n future = onUpdateTPSLOrder(order as API.AlgoOrderExt, params);\n } else {\n if (order.algo_order_id !== undefined) {\n future = editAlgoOrder(order.algo_order_id.toString(), params);\n } else {\n future = editOrder((order as API.OrderExt).order_id.toString(), params);\n }\n }\n\n future\n .then(\n (result: any) => {\n closePopover();\n setQuantity(value.toString());\n },\n (err: any) => {\n toast.error(err.message);\n setQuantity(order.quantity.toString());\n cancelPopover();\n },\n )\n .finally(() => setIsSubmitting(false));\n }, [value]);\n\n const componentRef = useRef<HTMLDivElement | null>(null);\n const quantitySliderRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = (event: any) => {\n if (\n componentRef.current &&\n quantitySliderRef.current &&\n !componentRef.current.contains(event.target as Node) &&\n !quantitySliderRef.current.contains(event.target as Node) &&\n !open\n ) {\n cancelPopover();\n }\n };\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [open, order.quantity]);\n\n const renderContent = () => {\n if (!editing || props.disabled) {\n return (\n <PreviewCell\n order={order}\n value={value}\n setEditing={setEditing}\n disable={props.disabled}\n />\n );\n }\n\n return (\n <EditState\n inputRef={inputRef}\n quantitySliderRef={quantitySliderRef}\n base_dp={base_dp}\n base_tick={base_tick}\n quantity={value}\n setQuantity={setQuantity}\n editing={editing}\n setEditing={setEditing}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={cancelPopover}\n symbol={order.symbol}\n reduce_only={reduce_only}\n positionQty={position?.position_qty}\n error={error}\n confirmOpen={open}\n side={order.side}\n order={order}\n setError={setError}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.quantity}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n contentProps={{\n onOpenAutoFocus: (e) => {\n // e.preventDefault();\n // e.stopPropagation();\n },\n }}\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={componentRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n\nconst PreviewCell: FC<{\n order: API.AlgoOrder | API.OrderExt;\n value: string;\n setEditing: any;\n disable?: boolean;\n}> = (props) => {\n const { order, value } = props;\n\n const executed = (order as API.OrderExt).total_executed_quantity;\n\n return (\n <Flex\n direction=\"row\"\n justify={\"start\"}\n gap={1}\n className={cn(\n \"oui-relative oui-max-w-[110px]\",\n order.side === OrderSide.BUY && \"oui-text-trade-profit\",\n order.side === OrderSide.SELL && \"oui-text-trade-loss\",\n grayCell(order) && \"oui-text-base-contrast-20\",\n )}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.setEditing(true);\n }}\n >\n {\"algo_type\" in order &&\n order.algo_type === AlgoOrderRootType.TP_SL ? null : (\n <>\n <span>{executed}</span>\n <span>/</span>\n </>\n )}\n\n <Flex\n r=\"base\"\n className={cn(\n \"oui-h-[28px] oui-min-w-[70px]\",\n !props.disable &&\n \"oui-border oui-border-line-12 oui-bg-base-7 oui-px-2\",\n )}\n >\n <Text size=\"2xs\">{value}</Text>\n </Flex>\n </Flex>\n );\n};\n\nconst EditState: FC<{\n inputRef: any;\n quantitySliderRef: any;\n base_dp: number;\n base_tick: number;\n quantity: string;\n setQuantity: (quantity: string, maxQty: number) => Promise<void>;\n editing: boolean;\n confirmOpen: boolean;\n setEditing: (value: boolean) => void;\n handleKeyDown: (e: any) => void;\n onClick: (e: any) => void;\n onClose: () => void;\n error?: string;\n symbol: string;\n reduce_only: boolean;\n positionQty?: number;\n side?: string;\n order: any;\n setError: (err: string) => void;\n}> = (props) => {\n const {\n inputRef,\n quantitySliderRef,\n base_dp,\n base_tick,\n quantity,\n setQuantity,\n setEditing,\n handleKeyDown,\n onClick,\n onClose,\n error,\n symbol,\n reduce_only,\n positionQty,\n confirmOpen,\n order,\n } = props;\n\n const maxBuyQty = useMaxQty(symbol, order.side, order.reduce_only);\n\n const maxQty = useMemo(() => {\n if (reduce_only) {\n return Math.abs(positionQty ?? 0);\n }\n return order.quantity + Math.abs(maxBuyQty);\n }, [order.quantity, maxBuyQty, reduce_only, positionQty]);\n\n const [sliderValue, setSliderValue] = useState<number | undefined>(undefined);\n\n useEffect(() => {\n if (sliderValue === undefined) {\n const sliderValue = new Decimal(quantity)\n .div(maxQty)\n .abs()\n .mul(100)\n .toNumber();\n setSliderValue(sliderValue);\n }\n }, [sliderValue, maxQty, quantity]);\n\n const formatQuantity = async (_qty: string | number): Promise<void> => {\n if (base_tick > 0) {\n _qty = utils.formatNumber(_qty, base_tick) ?? _qty;\n }\n return setQuantity(`${_qty}`, maxQty);\n };\n\n return (\n <PopoverRoot open={!confirmOpen}>\n <PopoverTrigger>\n <InnerInput\n inputRef={inputRef}\n dp={base_dp}\n value={quantity}\n setValue={(e: string) => {\n const quantity = Math.abs(Math.min(Number(e), maxQty)).toString();\n setQuantity(e, maxQty);\n if (e.endsWith(\".\")) return;\n if (Number(quantity) === 0) {\n setSliderValue(0);\n return;\n }\n const sliderValue = new Decimal(e)\n .div(maxQty)\n .mul(100)\n .toDecimalPlaces(2, Decimal.ROUND_DOWN)\n .toNumber();\n setSliderValue(Math.min(100, sliderValue));\n }}\n setEditing={setEditing}\n handleKeyDown={handleKeyDown}\n onClick={onClick}\n onClose={onClose}\n onBlur={(e) => {\n formatQuantity(e.target.value);\n }}\n hintInfo={error}\n />\n </PopoverTrigger>\n <PopoverContent\n className=\"oui-w-[360px] oui-rounded-xl\"\n align=\"start\"\n side=\"bottom\"\n onOpenAutoFocus={(event) => {\n // event.stopPropagation();\n event.preventDefault();\n }}\n >\n <Flex\n p={1}\n gap={2}\n width={\"100%\"}\n itemAlign={\"start\"}\n ref={quantitySliderRef}\n >\n <Text.numeral\n size=\"xs\"\n intensity={98}\n className=\"oui-min-w-[30px] \"\n dp={2}\n padding={false}\n unit=\"%\"\n rm={Decimal.ROUND_DOWN}\n >\n {`${sliderValue}`}\n </Text.numeral>\n <Flex\n direction={\"column\"}\n width={\"100%\"}\n gap={2}\n className=\"oui-mt-[6px]\"\n >\n <Slider\n markCount={4}\n value={[sliderValue ?? 0]}\n onValueChange={(e) => {\n const values = Array.from(e.values());\n setSliderValue(values[0]);\n const quantity = new Decimal(values[0])\n .div(100)\n .mul(maxQty)\n .abs()\n .toFixed(base_dp, Decimal.ROUND_DOWN);\n setQuantity(quantity, maxQty);\n }}\n onValueCommit={(values) => {\n const quantity = new Decimal(values[0])\n .div(100)\n .mul(maxQty)\n .abs()\n .toFixed(base_dp, Decimal.ROUND_DOWN);\n formatQuantity(quantity).finally(() => {\n inputRef.current.focus();\n });\n }}\n />\n <Buttons\n onClick={(value) => {\n setSliderValue(value * 100);\n let quantity = new Decimal(value)\n .mul(maxQty)\n .abs()\n .toFixed(base_dp, Decimal.ROUND_DOWN);\n quantity = utils.formatNumber(quantity, base_tick) ?? quantity;\n\n setQuantity(quantity, maxQty);\n setTimeout(() => {\n inputRef.current.focus();\n inputRef.current.setSelectionRange(\n quantity.length,\n quantity.length,\n );\n }, 100);\n }}\n />\n </Flex>\n </Flex>\n </PopoverContent>\n </PopoverRoot>\n );\n};\n\nconst Buttons = (props: { onClick: (value: number) => void }) => {\n const { t } = useTranslation();\n const list = [\n {\n label: \"0%\",\n value: 0,\n },\n {\n label: \"25%\",\n value: 0.25,\n },\n {\n label: \"50%\",\n value: 0.5,\n },\n {\n label: \"75%\",\n value: 0.75,\n },\n {\n label: t(\"common.max\"),\n value: 1,\n },\n ];\n\n return (\n <Flex gap={2} width={\"100%\"}>\n {list.map((item, index) => {\n return (\n <Button\n key={index}\n variant=\"outlined\"\n color=\"secondary\"\n size=\"xs\"\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick(item.value);\n }}\n className=\"oui-w-1/5\"\n >\n {item.label}\n </Button>\n );\n })}\n </Flex>\n );\n};\n","import { useCallback, useMemo, useState } from \"react\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { Popover, toast, inputFormatter } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const TrailingCallbackCell = (props: {\n order: API.AlgoOrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const { callback_value, callback_rate } = order;\n\n const isCallbackValue = !!callback_value;\n const isCallbackRate = !!callback_rate;\n\n const originValue = useMemo(() => {\n return callback_rate\n ? (callback_rate * 100).toString()\n : callback_value?.toString()!;\n }, [callback_value, callback_rate]);\n\n const [value, setValue] = useState<string>(originValue!);\n const [submitting, setSubmitting] = useState(false);\n\n const disabled = props.disabled || order.is_triggered;\n\n const { editAlgoOrder } = useOrderListContext();\n\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error } = useValidateField({\n order,\n originValue,\n value,\n field: isCallbackValue ? \"callback_value\" : \"callback_rate\",\n fieldValues: {\n callback_value: isCallbackValue ? value : undefined,\n callback_rate: isCallbackRate ? value : undefined,\n },\n });\n\n const onConfirm = useCallback(() => {\n setSubmitting(true);\n\n const data: any = {\n algo_order_id: order.algo_order_id,\n callback_value: isCallbackValue ? value : undefined,\n callback_rate: isCallbackRate ? `${Number(value) / 100}` : undefined,\n };\n\n editAlgoOrder(order.algo_order_id.toString(), data)\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setSubmitting(false));\n }, [order.algo_order_id, value, cancelPopover]);\n\n const renderContent = () => {\n const suffix = isCallbackRate ? \"%\" : undefined;\n\n if (!editing || disabled) {\n return (\n <PreviewCell\n status={getOrderStatus(order)}\n value={value}\n setEditing={setEditing}\n disabled={disabled}\n suffix={suffix}\n />\n );\n }\n\n const formatters = isCallbackRate\n ? [inputFormatter.dpFormatter(1)]\n : [\n inputFormatter.currencyFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ];\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n error={error}\n suffix={suffix}\n formatters={formatters}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={isCallbackRate ? EditType.callbackRate : EditType.callbackValue}\n base={base}\n value={isCallbackRate ? `${value}%` : value}\n cancelPopover={cancelPopover}\n isSubmitting={submitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import { useCallback, useState } from \"react\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { Popover, toast, inputFormatter } from \"@kodiak-finance/orderly-ui\";\nimport { EditType } from \"../../../../type\";\nimport { getOrderStatus } from \"../../../../utils/util\";\nimport { useSymbolContext } from \"../../../provider/symbolContext\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { ConfirmContent } from \"../editOrder/confirmContent\";\nimport { usePopoverState } from \"../hooks/usePopoverState\";\nimport { useValidateField } from \"../hooks/useValidateField\";\nimport { EditableCellInput } from \"./editableCellInput\";\nimport { PreviewCell } from \"./previewCell\";\n\nexport const TriggerPriceCell = (props: {\n order: API.AlgoOrderExt;\n disabled?: boolean;\n}) => {\n const { order } = props;\n const originValue = order.trigger_price?.toString();\n\n const [value, setValue] = useState<string>(originValue);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const disabled = props.disabled || order.is_triggered;\n\n const { editAlgoOrder } = useOrderListContext();\n const { base, quote_dp } = useSymbolContext();\n\n const {\n open,\n setOpen,\n editing,\n setEditing,\n containerRef,\n closePopover,\n cancelPopover,\n onClick,\n } = usePopoverState({\n originValue,\n value,\n setValue,\n });\n\n const { error } = useValidateField({\n order,\n field: \"trigger_price\",\n originValue,\n value,\n });\n\n const onConfirm = useCallback(() => {\n setIsSubmitting(true);\n\n const data: any = {\n trigger_price: value,\n algo_order_id: order.algo_order_id,\n };\n\n editAlgoOrder(`${order.algo_order_id}`, data)\n .then((result: any) => {\n closePopover();\n setValue(value);\n })\n .catch((err: any) => {\n toast.error(err.message);\n cancelPopover();\n })\n .finally(() => setIsSubmitting(false));\n }, [order.algo_order_id, value, cancelPopover]);\n\n const renderContent = () => {\n if (!editing || disabled) {\n return (\n <PreviewCell\n value={value}\n status={getOrderStatus(order)}\n setEditing={setEditing}\n disabled={disabled}\n />\n );\n }\n\n return (\n <EditableCellInput\n value={value}\n onChange={setValue}\n onClick={onClick}\n error={error}\n formatters={[inputFormatter.dpFormatter(quote_dp)]}\n />\n );\n };\n\n return (\n <Popover\n open={open}\n onOpenChange={setOpen}\n content={\n <ConfirmContent\n type={EditType.triggerPrice}\n base={base}\n value={value}\n cancelPopover={cancelPopover}\n isSubmitting={isSubmitting}\n onConfirm={onConfirm}\n />\n }\n >\n <div\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n ref={containerRef}\n >\n {renderContent()}\n </div>\n </Popover>\n );\n};\n","import { FC, useCallback, useState } from \"react\";\nimport { useConfig, useMutation } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderEntity } from \"@kodiak-finance/orderly-types\";\nimport { Button } from \"@kodiak-finance/orderly-ui\";\n\nexport const Renew: FC<{ record: any }> = (props) => {\n const { record } = props;\n const [open, setOpen] = useState(false);\n const [doCreateOrder, { data, error, reset, isMutating }] = useMutation<\n OrderEntity,\n any\n >(\"/v1/order\");\n\n const { t } = useTranslation();\n\n const brokerId = useConfig(\"brokerId\");\n const onSubmit = useCallback(() => {\n setOpen(false);\n const data: OrderEntity = {\n symbol: record.symbol,\n order_type: record.type,\n order_price: record.price,\n order_quantity: record.quantity,\n order_amount: record.amount,\n side: record.side,\n broker_id: brokerId,\n };\n\n if (Number(record.visible_quantity) < Number(record.quantity)) {\n data.visible_quantity = 0;\n }\n\n if (typeof record.reduce_only !== \"undefined\") {\n data.reduce_only = record.reduce_only;\n }\n\n if (record.order_tag) {\n data.order_tag = record.order_tag;\n }\n\n if (record.client_order_id) {\n data.client_order_id = record.client_order_id;\n }\n\n doCreateOrder(data);\n }, []);\n\n return (\n <Button\n size={\"sm\"}\n variant={\"outlined\"}\n color={\"secondary\"}\n loading={isMutating}\n disabled={isMutating}\n onClick={(event) => {\n if (isMutating) return;\n event.preventDefault();\n event.stopPropagation();\n onSubmit();\n }}\n >\n {t(\"orders.history.renew\")}\n </Button>\n );\n};\n","import { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API } from \"@kodiak-finance/orderly-types\";\nimport { PositionTPSLPopover } from \"@kodiak-finance/orderly-ui-tpsl\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\n\nexport const TP_SLEditButton = (props: { order: API.Order }) => {\n const { position, order } = useTPSLOrderRowContext();\n const { quote_dp, base_dp } = useSymbolContext();\n const { t } = useTranslation();\n\n return (\n <PositionTPSLPopover\n quoteDP={quote_dp}\n baseDP={base_dp}\n position={position!}\n order={order}\n label={t(\"common.edit\")}\n isEditing\n />\n );\n};\n","import {\n findTPSLOrderPriceFromOrder,\n findTPSLFromOrder,\n useSymbolsInfo,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { i18n, useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderType } from \"@kodiak-finance/orderly-types\";\nimport { Text } from \"@kodiak-finance/orderly-ui\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\n\nexport const TPSLOrderPrice = () => {\n const {\n sl_trigger_price,\n tp_trigger_price,\n sl_order_price,\n tp_order_price,\n order,\n } = useTPSLOrderRowContext();\n const { t } = useTranslation();\n const symbolInfo = useSymbolsInfo()[order.symbol]();\n return (\n <div>\n {!!tp_trigger_price ? (\n <div className={\"oui-text-base-contrast-80 oui-td-bg-transparent\"}>\n <Text intensity={54}>{`${t(\"tpsl.tp\")} -`} </Text>\n <TPSLOrderPriceItem\n price={tp_order_price}\n quoteDP={symbolInfo.quote_dp}\n />\n </div>\n ) : null}\n {!!sl_trigger_price ? (\n <div className={\"oui-text-base-contrast-80 oui-td-bg-transparent\"}>\n <span className={\"oui-text-base-contrast-54\"}>\n {`${t(\"tpsl.sl\")} -`} \n </span>\n <TPSLOrderPriceItem\n price={sl_order_price}\n quoteDP={symbolInfo.quote_dp}\n />\n </div>\n ) : null}\n </div>\n );\n};\n\nconst TPSLOrderPriceItem = ({\n price,\n quoteDP,\n}: {\n price?: number | OrderType;\n quoteDP: number;\n}) => {\n const { t } = useTranslation();\n if (!price) {\n return null;\n }\n if (price === OrderType.MARKET) {\n return <span>{t(\"common.marketPrice\")}</span>;\n }\n\n return (\n <Text.numeral\n className=\"oui-text-base-contrast-80\"\n rule={\"price\"}\n dp={quoteDP}\n >\n {price}\n </Text.numeral>\n );\n};\n\nexport function useTPSLOrderPrice(order: any) {\n // @ts-ignore\n const { sl_trigger_price, tp_trigger_price } =\n !(\"algo_type\" in order) || !Array.isArray(order.child_orders)\n ? {}\n : findTPSLFromOrder(order);\n\n const tpTriggerPrice = tp_trigger_price\n ? `${i18n.t(\"tpsl.tp\")} - ${i18n.t(\"common.marketPrice\")}`\n : undefined;\n const slTriggerPrice = sl_trigger_price\n ? `${i18n.t(\"tpsl.sl\")} - ${i18n.t(\"common.marketPrice\")}`\n : undefined;\n\n return { tpTriggerPrice, slTriggerPrice };\n}\n","import { FC, useMemo } from \"react\";\nimport {\n OrderValidationResult,\n useSymbolsInfo,\n useTpslPriceChecker,\n utils,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, AlgoOrderType } from \"@kodiak-finance/orderly-types\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { cn, Text, Tooltip } from \"@kodiak-finance/orderly-ui\";\nimport { CloseToLiqPriceIcon } from \"@kodiak-finance/orderly-ui-tpsl\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\n\nexport const OrderTriggerPrice = () => {\n const { sl_trigger_price, tp_trigger_price, order, position } =\n useTPSLOrderRowContext();\n\n const positionSide =\n position?.position_qty && position.position_qty > 0\n ? OrderSide.BUY\n : OrderSide.SELL;\n const slPriceError = useTpslPriceChecker({\n slPrice: sl_trigger_price?.toString() ?? undefined,\n liqPrice: position?.est_liq_price ?? null,\n side: positionSide,\n });\n\n return (\n <TPSLTriggerPrice\n stopLossPrice={sl_trigger_price}\n takeProfitPrice={tp_trigger_price}\n direction={\"column\"}\n order={order}\n position={position}\n slPriceError={slPriceError}\n tooltip\n />\n );\n};\n\nexport const TPSLTriggerPrice: FC<{\n takeProfitPrice: number | undefined;\n stopLossPrice: number | undefined;\n className?: string;\n direction?: \"row\" | \"column\";\n tooltip?: boolean;\n order?: API.AlgoOrder;\n position?: API.PositionTPSLExt;\n slPriceError: OrderValidationResult | null;\n}> = (props) => {\n const { direction = \"row\", order, position } = props;\n // const symbolInfo = useSymbolsInfo()[position?.symbol ?? \"\"]();\n const symbolInfo = useSymbolsInfo();\n const { t } = useTranslation();\n\n const pnl = useMemo(() => {\n const msgs = [];\n\n if (!props.tooltip || !order || !position) return;\n\n let quantity = order.quantity;\n\n if (quantity === 0) {\n if (order.child_orders?.[0].type === \"CLOSE_POSITION\") {\n quantity = position.position_qty;\n }\n }\n\n if (!!props.takeProfitPrice) {\n msgs.push(\n <TriggerPriceItem\n key={\"tp\"}\n qty={quantity}\n price={props.takeProfitPrice}\n entryPrice={position.average_open_price}\n orderSide={order.side as OrderSide}\n orderType={AlgoOrderType.TAKE_PROFIT}\n symbolInfo={symbolInfo[order.symbol]()}\n />,\n );\n }\n\n if (!!props.stopLossPrice) {\n msgs.push(\n <TriggerPriceItem\n key={\"sl\"}\n qty={quantity}\n price={props.stopLossPrice}\n entryPrice={position.average_open_price}\n orderSide={order.side as OrderSide}\n orderType={AlgoOrderType.STOP_LOSS}\n symbolInfo={symbolInfo[order.symbol]()}\n />,\n );\n }\n\n return <div>{msgs}</div>;\n }, [\n props.takeProfitPrice,\n props.stopLossPrice,\n position?.average_open_price,\n order?.side,\n order?.quantity,\n order?.algo_type,\n ]);\n\n const child = useMemo(() => {\n const children = [];\n\n if (!order?.symbol) return <span>-</span>;\n if (props.takeProfitPrice) {\n children.push(\n <Text.numeral\n className={cn(\n \"oui-text-trade-profit oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12\",\n )}\n key={\"tp\"}\n rule=\"price\"\n dp={symbolInfo[order!.symbol](\"quote_dp\", 2)}\n children={props.takeProfitPrice}\n // @ts-ignore\n prefix={\n !props.stopLossPrice || direction === \"column\" ? (\n <span className={\"oui-text-base-contrast-54\"}>\n {`${t(\"tpsl.tp\")} -`} \n </span>\n ) : (\n \"\"\n )\n }\n />,\n );\n }\n if (props.stopLossPrice) {\n children.push(\n <Text.numeral\n key={\"sl\"}\n className={cn(\n \"oui-text-trade-loss oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12\",\n \"oui-flex oui-items-center\",\n )}\n as=\"div\"\n rule={\"price\"}\n dp={symbolInfo[order!.symbol](\"quote_dp\", 2)}\n children={props.stopLossPrice}\n // @ts-ignore\n prefix={\n !props.takeProfitPrice || direction === \"column\" ? (\n <span className={\"oui-text-base-contrast-54\"}>\n {`${t(\"tpsl.sl\")} -`} \n </span>\n ) : (\n \"\"\n )\n }\n suffix={\n <CloseToLiqPriceIcon\n slPriceError={props.slPriceError}\n className=\"oui-ml-1\"\n />\n }\n />,\n );\n }\n\n if (children.length === 0) return <span>-</span>;\n\n if (children.length === 2 && direction === \"row\") {\n children.splice(1, 0, <span key={\"split\"}>/</span>);\n }\n\n return children;\n }, [\n props.takeProfitPrice,\n props.stopLossPrice,\n order?.symbol,\n t,\n props.slPriceError,\n ]);\n\n const content = (\n <div\n className={cn(\n \"oui-inline-flex oui-text-base-contrast-36\",\n props.direction === \"column\"\n ? \"oui-flex-col\"\n : \"oui-flex-row oui-gap-1\",\n props.className,\n )}\n >\n {child}\n </div>\n );\n\n if (props.tooltip) {\n // @ts-ignore\n return (\n <Tooltip\n // @ts-ignore\n content={pnl}\n className=\"oui-bg-base-5\"\n arrow={{ className: \"oui-fill-base-5\" }}\n >\n {content}\n </Tooltip>\n );\n }\n\n return content;\n};\n\nconst TriggerPriceItem: FC<{\n qty: number;\n price: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n symbolInfo: API.SymbolExt;\n}> = (props) => {\n const { qty, price, entryPrice, orderSide, orderType, symbolInfo } = props;\n const { t } = useTranslation();\n\n const pnl = utils.priceToPnl(\n {\n qty,\n price,\n entryPrice,\n orderSide,\n orderType,\n },\n {\n symbol: symbolInfo,\n },\n );\n\n const type = orderType === AlgoOrderType.TAKE_PROFIT ? \"TP\" : \"SL\";\n const label = type === \"TP\" ? `${t(\"tpsl.tpPnl\")}:` : `${t(\"tpsl.slPnl\")}:`;\n\n // console.log(\"trigger price item\", \"dp\", symbolInfo.quote_dp);\n\n return (\n <div className=\"oui-flex oui-items-center\">\n <span className=\"oui-text-base-contrast-54 oui-mr-1\">{label}</span>\n <Text.numeral\n rule=\"price\"\n dp={symbolInfo.quote_dp}\n padding={false}\n className={\n pnl === 0\n ? \"oui-text-base-contrast-36\"\n : pnl > 0\n ? \"oui-text-trade-profit oui-gap-0\"\n : \"oui-text-trade-loss oui-gap-0\"\n }\n // @ts-ignore\n prefix={\n // @ts-ignore\n <span>{pnl === 0 ? \"\" : pnl > 0 ? \"+\" : \"-\"}</span>\n }\n suffix={\n <span className=\"oui-text-base-contrast-36 oui-ml-1\">USDC</span>\n }\n >{`${Math.abs(pnl)}`}</Text.numeral>\n </div>\n );\n};\n","import { useMemo } from \"react\";\nimport { format } from \"date-fns\";\nimport { SymbolsInfo, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation, i18n } from \"@kodiak-finance/orderly-i18n\";\nimport {\n AlgoOrderRootType,\n AlgoOrderType,\n API,\n OrderSide,\n OrderStatus,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\nimport { cn, Column, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { Badge } from \"@kodiak-finance/orderly-ui\";\nimport {\n SharePnLConfig,\n SharePnLDialogId,\n} from \"@kodiak-finance/orderly-ui-share\";\nimport {\n commifyOptional,\n Decimal,\n formatNum,\n getTrailingStopPrice,\n} from \"@kodiak-finance/orderly-utils\";\nimport {\n grayCell,\n parseBadgesFor,\n upperCaseFirstLetter,\n isTrailingStopOrder,\n getNotional,\n} from \"../../../utils/util\";\nimport { TabType } from \"../../orders.widget\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\nimport { ShareButtonWidget } from \"../../shareButton\";\nimport { AvgPrice } from \"./avgPrice\";\nimport { BracketOrderPrice } from \"./bracketOrderPrice\";\nimport { CancelButton } from \"./cancelBtn\";\nimport { ActivedPriceCell } from \"./components/activedPriceCell\";\nimport { PriceCell } from \"./components/priceCell\";\nimport { QuantityCell } from \"./components/quantityCell\";\nimport { TrailingCallbackCell } from \"./components/trailingCallbackCell\";\nimport { TriggerPriceCell } from \"./components/triggerPriceCell\";\nimport { Renew } from \"./renew\";\nimport { TP_SLEditButton } from \"./tpslEdit\";\nimport { TPSLOrderPrice, useTPSLOrderPrice } from \"./tpslPrice\";\nimport { OrderTriggerPrice } from \"./tpslTriggerPrice\";\n\nexport const useOrderColumn = (props: {\n _type: TabType;\n onSymbolChange?: (symbol: API.Symbol) => void;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n symbolsInfo?: SymbolsInfo;\n}) => {\n const {\n _type,\n onSymbolChange,\n pnlNotionalDecimalPrecision,\n sharePnLConfig,\n symbolsInfo,\n } = props;\n const { t } = useTranslation();\n\n const columns = useMemo(() => {\n switch (_type) {\n case TabType.all:\n return [\n instrument({\n width: 130,\n showType: true,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n side({ width: 130 }),\n fillAndQuantity({\n width: 130,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n enableSort: false,\n }),\n price({\n width: 130,\n title: t(\"common.orderPrice\"),\n disableEdit: true,\n enableSort: false,\n }),\n avgOpen({ width: 130, enableSort: false, symbolsInfo }),\n tpslTriggerPrice({ width: 130, symbolsInfo: props.symbolsInfo }),\n realizedPnL({\n width: 124,\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n sharePnLConfig: sharePnLConfig,\n symbolsInfo: props.symbolsInfo,\n hideShare: true,\n }),\n estTotal({ width: 130, enableSort: false }),\n fee({ width: 130 }),\n status({ width: 130 }),\n reduceOnly({ width: 130 }),\n hidden({ width: 130 }),\n cancelBtn({ width: 130 }),\n orderTime({ width: 160, enableSort: false }),\n ];\n case TabType.pending:\n return [\n instrument({\n width: 172,\n showType: true,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n // side({ width: 162 }),\n fillAndQuantity({\n width: 162,\n className: \"oui-pr-0\",\n enableSort: false,\n }),\n price({ width: 162, className: \"oui-pr-0\", enableSort: false }),\n trailingCallback({ width: 162 }),\n triggerPrice({ width: 162, className: \"oui-pr-0\", isPending: true }),\n bracketOrderPrice({ width: 130 }),\n estTotal({ width: 162, isPending: true }),\n reduceOnly({ width: 162 }),\n hidden({ width: 162 }),\n orderTime({ width: 162, enableSort: false }),\n pendingTabCancelBtn({ width: 80 }),\n ];\n case TabType.tp_sl:\n return [\n instrument({\n width: 176,\n showType: true,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n // side({ width: 176 }),\n quantity({ width: 176 }),\n tpslTriggerPrice({ width: 176, symbolsInfo }),\n tpslPrice({ width: 176, disableEdit: true }),\n tpslNotional({ width: 176 }),\n reduceOnly({ width: 176 }),\n orderTime({ width: 176, enableSort: false }),\n tpslAction({ width: 176 }),\n ];\n case TabType.filled:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n }),\n // type({ width: 124 }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 124,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n }),\n price({\n width: 124,\n title: t(\"common.orderPrice\"),\n disableEdit: true,\n }),\n avgPrice({ width: 124 }),\n triggerPrice({ width: 124, disableEdit: true }),\n realizedPnL({\n width: 124,\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n sharePnLConfig: sharePnLConfig,\n symbolsInfo,\n hideShare: true,\n }),\n estTotal({ width: 124 }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n orderTime({ width: 176 }),\n ];\n case TabType.cancelled:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n enableSort: false,\n }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 124,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n enableSort: false,\n }),\n price({ width: 124, disableEdit: true, enableSort: false }),\n avgOpen({ width: 124, enableSort: false }),\n triggerPrice({ width: 124, disableEdit: true }),\n estTotal({ width: 124 }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n ];\n case TabType.rejected:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 124,\n disableEdit: true,\n className: \"oui-pl-0 oui-pr-0\",\n }),\n price({ width: 124, disableEdit: true }),\n avgOpen({ width: 124 }),\n triggerPrice({ width: 124, disableEdit: true }),\n estTotal({ width: 124 }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n orderTime({ width: 176 }),\n ];\n case TabType.orderHistory:\n return [\n instrument({\n showType: true,\n width: 154,\n onSymbolChange: onSymbolChange,\n }),\n // side({ width: 124 }),\n fillAndQuantity({\n width: 150,\n disableEdit: true,\n className: \"oui-pl-6 oui-pr-0\",\n }),\n price({\n width: 124,\n disableEdit: true,\n tabType: TabType.orderHistory,\n }),\n avgOpen({ width: 124 }),\n triggerPrice({ width: 124, disableEdit: true }),\n realizedPnL({\n width: 124,\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n sharePnLConfig: sharePnLConfig,\n symbolsInfo: props.symbolsInfo,\n hideShare: true,\n }),\n estTotal({ width: 124 }),\n trailingCallback({ width: 124, disableEdit: true }),\n fee({ width: 124 }),\n status({ width: 124 }),\n reduceOnly({ width: 124 }),\n hidden({ width: 124 }),\n orderTime({ width: 150 }),\n cancelBtn({ width: 80 }),\n ];\n }\n }, [_type, pnlNotionalDecimalPrecision, sharePnLConfig, t]);\n\n return columns as Column[];\n\n // return columns();\n};\n\nfunction instrument(option?: {\n showType?: boolean;\n enableSort?: boolean;\n width?: number;\n onSymbolChange?: (symbol: API.Symbol) => void;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.symbol\"),\n dataIndex: \"symbol\",\n fixed: \"left\",\n // className: \"oui-h-[48px]\",\n width: option?.width,\n onSort: option?.enableSort\n ? (r1, r2) => {\n return r1.symbol.localeCompare(r2.symbol);\n // if (sortOrder === \"asc\") {\n // return r1.symbol.localeCompare(r2.symbol);\n // }\n // return r2.symbol.localeCompare(r1.symbol);\n }\n : undefined,\n renderPlantText: (value: string, record) => {\n const badges = parseBadgesFor(record)?.join(\",\");\n const displayBadges = badges?.length ? ` (${badges})` : \"\";\n return `${value.split(\"_\")[1]}-PERP${displayBadges}`;\n },\n render: (value: string, record) => {\n const showGray = grayCell(record);\n\n return (\n <Flex gap={2}>\n <div\n className={cn(\n \"oui-h-7 oui-w-1 oui-shrink-0 oui-rounded-[1px]\",\n record.side === OrderSide.BUY\n ? \"oui-bg-trade-profit\"\n : \"oui-bg-trade-loss\",\n )}\n />\n <Flex direction=\"column\" itemAlign={\"start\"}>\n <Text.formatted\n // rule={\"symbol\"}\n size=\"xs\"\n className=\"oui-cursor-pointer oui-text-xs\"\n onClick={(e) => {\n option?.onSymbolChange?.({ symbol: value } as API.Symbol);\n e.stopPropagation();\n e.preventDefault();\n }}\n >\n {`${value.split(\"_\")[1]}-PERP`}\n </Text.formatted>\n\n {option?.showType && (\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(record)?.map((e, index) => (\n <Badge\n key={index}\n color={\n e.toLocaleLowerCase() === \"position\"\n ? showGray\n ? \"neutral\"\n : \"primary\"\n : \"neutral\"\n }\n size=\"xs\"\n className=\"oui-whitespace-nowrap oui-break-normal\"\n >\n {e}\n </Badge>\n ))}\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n },\n };\n}\n\nfunction side(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.side\"),\n dataIndex: \"side\",\n width: option?.width,\n // className: \"oui-h-[48px]\",\n onSort: option?.enableSort\n ? (r1, r2, sortOrder) => {\n return r2.side.localeCompare(r1.side);\n // if (sortOrder === \"asc\") {\n // return r2.side.localeCompare(r1.side);\n // }\n // return r1.side.localeCompare(r2.side);\n }\n : undefined,\n renderPlantText: (value: string, record) => upperCaseFirstLetter(value),\n render: (value: string, record) => {\n const clsName = grayCell(record)\n ? \"oui-text-base-contrast-20\"\n : value === OrderSide.BUY\n ? \"oui-text-trade-profit\"\n : \"oui-text-trade-loss\";\n return (\n <span className={cn(\"oui-font-semibold\", clsName)}>\n {upperCaseFirstLetter(value)}\n </span>\n );\n },\n };\n}\n\nfunction type(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.type\"),\n dataIndex: \"type\",\n width: option?.width,\n className: option?.className,\n formatter: (value: string, record: any) => {\n if (!!record.parent_algo_type) {\n if (record.algo_type === AlgoOrderType.STOP_LOSS) {\n return record.type === OrderType.CLOSE_POSITION\n ? `Position SL`\n : \"SL\";\n }\n\n if (record.algo_type === AlgoOrderType.TAKE_PROFIT) {\n return record.type === OrderType.CLOSE_POSITION\n ? `Position TP`\n : \"TP\";\n }\n }\n\n if (record.algo_order_id) {\n return `Stop ` + `${record.type}`.toLowerCase();\n }\n return upperCaseFirstLetter(value);\n },\n };\n}\n\nfunction fillAndQuantity(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.AlgoOrderExt> {\n return {\n title: i18n.t(\"orders.column.fill&Quantity\"),\n dataIndex: \"fill_quantity\",\n className: option?.className,\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b) => {\n const aQuantity =\n (a.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : a.quantity) ?? 0;\n const bQuantity =\n (b.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : b.quantity) ?? 0;\n\n return compareNumbers(aQuantity, bQuantity);\n\n // if (type == \"asc\") {\n // return compareNumbers(aQuantity, bQuantity);\n // }\n // return compareNumbers(bQuantity, aQuantity);\n }\n : undefined,\n\n renderPlantText: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n const executed = (record as API.OrderExt).total_executed_quantity;\n const first =\n \"algo_type\" in record && record.algo_type === AlgoOrderRootType.TP_SL\n ? \"\"\n : `${executed} / `;\n return first + `${record.quantity}`;\n },\n render: (value: string, record: any) => {\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n return <QuantityCell order={record} disabled={option?.disableEdit} />;\n // return value;\n },\n };\n}\n\nfunction quantity(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.AlgoOrderExt> {\n return {\n title: i18n.t(\"common.quantity\"),\n className: option?.className,\n dataIndex: \"quantity\",\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b) => {\n const aQuantity =\n (a.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : a.quantity) ?? 0;\n const bQuantity =\n (b.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL\n ? 0\n : b.quantity) ?? 0;\n return compareNumbers(aQuantity, bQuantity);\n // if (type == \"asc\") {\n // return compareNumbers(aQuantity, bQuantity);\n // }\n // return compareNumbers(bQuantity, aQuantity);\n }\n : undefined,\n renderPlantText: (value: string, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n const executed = (record as API.OrderExt).total_executed_quantity;\n const first =\n \"algo_type\" in record && record.algo_type === AlgoOrderRootType.TP_SL\n ? \"\"\n : `${executed}/`;\n return first + `${record.quantity}`;\n },\n render: (value: string, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n return <QuantityCell order={record} />;\n // return value;\n },\n };\n}\n\nfunction price(option?: {\n title?: string;\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n tabType?: TabType;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"common.price\"),\n dataIndex: \"price\",\n className: option?.className,\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b, type) => {\n return compareNumbers(a.price ?? 0, b.price ?? 0);\n }\n : undefined,\n renderPlantText: (value: string, record: any) => {\n const isTrailingStop = isTrailingStopOrder(record);\n if (isTrailingStop) {\n // TODO: fix precision\n return option?.tabType === TabType.orderHistory\n ? i18n.t(\"common.marketPrice\")\n : getTrailingStopPrice(record) || \"--\";\n }\n return commifyOptional(record.price, {\n fallback: i18n.t(\"common.marketPrice\"),\n });\n },\n render: (value: string, record: any) => {\n const isTrailingStop = isTrailingStopOrder(record);\n if (isTrailingStop) {\n // TODO: fix precision\n return option?.tabType === TabType.orderHistory\n ? i18n.t(\"common.marketPrice\")\n : getTrailingStopPrice(record) || \"--\";\n }\n\n return <PriceCell order={record} disabled={option?.disableEdit} />;\n },\n };\n}\n\nfunction tpslPrice(option?: {\n title?: string;\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"common.price\"),\n dataIndex: \"price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n const { tpTriggerPrice, slTriggerPrice } = useTPSLOrderPrice(record);\n const callback = `${tpTriggerPrice || \"\"}${\n slTriggerPrice ? `${tpTriggerPrice ? \"\\n\" : \"\"}${slTriggerPrice}` : \"\"\n }`;\n\n return callback.length > 0 ? callback : \"--\";\n },\n render: (value: string, record: any) => {\n return <TPSLOrderPrice />;\n },\n };\n}\n\nfunction avgPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n symbolsInfo?: SymbolsInfo;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.avgPrice\"),\n dataIndex: \"average_executed_price\",\n className: option?.className,\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n return commifyOptional(value);\n },\n render: (value: string, record: any) => {\n return <AvgPrice symbol={record.symbol} value={value} />;\n },\n };\n}\n\nfunction triggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n isPending?: boolean;\n}): Column<API.Order> {\n const { isPending } = option || {};\n const checkOrderType = (record: any) => {\n const isAlgoOrder = record?.algo_order_id !== undefined;\n const isBracketOrder = record?.algo_type === \"BRACKET\";\n return isAlgoOrder && !isBracketOrder;\n };\n\n return {\n title: i18n.t(\"common.trigger\"),\n className: option?.className,\n dataIndex: \"trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n if (!checkOrderType(record)) {\n return \"--\";\n }\n if (isTrailingStopOrder(record) && isPending) {\n return record.activated_price\n ? commifyOptional(record.activated_price)\n : \"--\";\n }\n return commifyOptional(value);\n },\n render: (value: string, record: any) => {\n if (!checkOrderType(record)) {\n return \"--\";\n }\n\n if (isTrailingStopOrder(record) && isPending) {\n return (\n <ActivedPriceCell order={record} disabled={option?.disableEdit} />\n );\n }\n return <TriggerPriceCell order={record} disabled={option?.disableEdit} />;\n },\n };\n}\n\nfunction tpslTriggerPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n title?: string;\n symbolsInfo?: SymbolsInfo;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"common.trigger\"),\n className: option?.className,\n dataIndex: \"tpsl_trigger_price\",\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n const info = option?.symbolsInfo?.[record.symbol];\n const quote_dp = info?.(\"quote_dp\");\n // @ts-ignore\n const { sl_trigger_price, tp_trigger_price } =\n !(\"algo_type\" in record) || !Array.isArray(record.child_orders)\n ? {}\n : utils.findTPSLFromOrder(record);\n\n const callback =\n (tp_trigger_price != null\n ? `${i18n.t(\"tpsl.tp\")}: ${commifyOptional(tp_trigger_price, {\n fix: quote_dp,\n padEnd: true,\n })}`\n : \"\") +\n (sl_trigger_price != null\n ? `${tp_trigger_price ? \"\\n\" : \"\"}${i18n.t(\n \"tpsl.sl\",\n )}: ${commifyOptional(sl_trigger_price, {\n fix: quote_dp,\n padEnd: true,\n })}`\n : \"\");\n return callback.length > 0 ? callback : \"--\";\n },\n render: (value: string, record: any) => <OrderTriggerPrice />,\n };\n}\n\nfunction bracketOrderPrice(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}) {\n return {\n title: i18n.t(\"common.tpsl\"),\n className: option?.className,\n dataIndex: \"bracketOrderPrice\",\n width: option?.width,\n onSort: option?.enableSort,\n renderPlantText: (value: string, record: any) => {\n const getTPSLTriggerPrice = (): {\n sl_trigger_price?: number;\n tp_trigger_price?: number;\n } => {\n if (!(\"algo_type\" in record) || !Array.isArray(record.child_orders)) {\n return {};\n }\n return utils.findTPSLFromOrder(record.child_orders[0]);\n };\n\n const { sl_trigger_price, tp_trigger_price } = getTPSLTriggerPrice();\n\n const callback =\n (tp_trigger_price != null\n ? `${i18n.t(\"tpsl.tp\")}: ${tp_trigger_price}`\n : \"\") +\n (sl_trigger_price != null\n ? `${tp_trigger_price ? \"\\n\" : \"\"}${i18n.t(\n \"tpsl.sl\",\n )}: ${sl_trigger_price}`\n : \"\");\n return callback.length > 0 ? callback : \"--\";\n },\n render: (value: string, record: any) => (\n <BracketOrderPrice order={record} />\n ),\n };\n}\n\nfunction estTotal(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n isPending?: boolean;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.notional\"),\n dataIndex: \"executed\",\n width: option?.width,\n className: option?.className,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b, type) => {\n const aTotal =\n a.type === OrderType.CLOSE_POSITION &&\n a.status !== OrderStatus.FILLED\n ? 0\n : a.total_executed_quantity === 0 ||\n Number.isNaN(a.average_executed_price) ||\n a.average_executed_price === null\n ? 0\n : a.total_executed_quantity * a.average_executed_price;\n const bTotal =\n b.type === OrderType.CLOSE_POSITION &&\n b.status !== OrderStatus.FILLED\n ? 0\n : b.total_executed_quantity === 0 ||\n Number.isNaN(b.average_executed_price) ||\n b.average_executed_price === null\n ? 0\n : b.total_executed_quantity * b.average_executed_price;\n return compareNumbers(aTotal, bTotal);\n // if (type === \"asc\") {\n // return compareNumbers(aTotal, bTotal);\n // }\n // return compareNumbers(bTotal, aTotal);\n }\n : undefined,\n renderPlantText: (value: string, record: any) => {\n const estTotal = estTotalValue(record, option?.isPending ?? false);\n\n if (estTotal === \"Entire position\") {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return commifyOptional(\n estTotalValue(record, option?.isPending ?? false),\n { fix: 2 },\n );\n },\n render: (value: string, record: any) => {\n const estTotal = estTotalValue(record, option?.isPending ?? false);\n\n if (estTotal === \"Entire position\") {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return (\n <Text.numeral rm={Decimal.ROUND_DOWN} dp={2}>\n {estTotal}\n </Text.numeral>\n );\n },\n };\n}\n\nfunction realizedPnL(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n symbolsInfo?: SymbolsInfo;\n hideShare?: boolean;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.realizedPnl\"),\n dataIndex: \"realized_pnl\",\n width: option?.width,\n className: option?.className,\n renderPlantText: (_value: string, record: any) => {\n const info = option?.symbolsInfo?.[record.symbol];\n const quote_dp = info?.(\"quote_dp\");\n const dp = option?.pnlNotionalDecimalPrecision ?? quote_dp;\n const value = new Decimal(_value ?? 0)\n .toDecimalPlaces(dp, Decimal.ROUND_DOWN)\n .toNumber();\n\n const formatValue = commifyOptional(value);\n\n return value > 0 ? `+${formatValue}` : formatValue;\n },\n render: (_value: number | undefined, record: any) => {\n const { quote_dp } = useSymbolContext();\n const dp = option?.pnlNotionalDecimalPrecision ?? quote_dp;\n const value = new Decimal(_value ?? 0).toNumber();\n // wraper flex\n return (\n <Flex gap={1}>\n <Text.pnl\n dp={dp}\n padding={false}\n intensity={(value ?? 0) == 0 ? 80 : undefined}\n showIdentifier={(value ?? 0) > 0}\n coloring={(value ?? 0) != 0}\n >\n {value ?? \"--\"}\n </Text.pnl>\n {!option?.hideShare && (\n <ShareButtonWidget\n order={record}\n sharePnLConfig={option?.sharePnLConfig}\n modalId={SharePnLDialogId}\n />\n )}\n </Flex>\n );\n },\n };\n}\n\nfunction reduceOnly(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"orderEntry.reduceOnly\"),\n dataIndex: \"reduce_only\",\n width: option?.width,\n className: option?.className,\n renderPlantText: (value: string, record: any) => {\n return value ? i18n.t(\"common.yes\") : i18n.t(\"common.no\");\n },\n render: (value: boolean) => {\n return <Text>{value ? i18n.t(\"common.yes\") : i18n.t(\"common.no\")}</Text>;\n },\n };\n}\n\nfunction hidden(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"orders.column.hidden\"),\n dataIndex: \"visible\",\n width: option?.width,\n className: option?.className,\n renderPlantText: (value: number, record: any) => {\n return value !== 0 ? i18n.t(\"common.no\") : i18n.t(\"common.yes\");\n },\n render: (value: number, record) => {\n return (\n <Text>\n {record.visible_quantity !== 0\n ? i18n.t(\"common.no\")\n : i18n.t(\"common.yes\")}\n </Text>\n );\n },\n };\n}\n\nfunction orderTime(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n formatString?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"orders.column.orderTime\"),\n dataIndex: \"created_time\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: string, record: any) => {\n const date = new Date(value);\n const formattedDate = format(date, \"yyyy-MM-dd HH:mm:ss\");\n return formattedDate;\n },\n render: (value: string) => (\n <Text.formatted\n rule={\"date\"}\n formatString={option?.formatString || \"yyyy-MM-dd HH:mm:ss\"}\n className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\"\n >\n {value}\n </Text.formatted>\n ),\n };\n}\n\nfunction fee(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.fee\"),\n dataIndex: \"total_fee\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n };\n}\n\nfunction notional(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.notional\"),\n dataIndex: \"notional\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: number, record: any) => {\n return commifyOptional(value, { fix: 2 });\n },\n render: (value?: string) => (\n <Text.notional className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {value ?? \"--\"}\n </Text.notional>\n ),\n };\n}\n\nfunction tpslNotional(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.notional\"),\n dataIndex: \"executed\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: any, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n return commifyOptional(\n record.quantity === 0\n ? \"--\"\n : `${formatNum\n .notional(new Decimal(record.mark_price).mul(record.quantity))\n ?.toNumber()}`,\n );\n },\n render: (value: any, record: any) => {\n if (record.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return (\n <Text.numeral className=\"oui-break-normal oui-whitespace-nowrap oui-font-semibold\">\n {record.quantity === 0\n ? \"--\"\n : `${formatNum\n .notional(new Decimal(record.mark_price).mul(record.quantity))\n ?.toNumber()}`}\n </Text.numeral>\n );\n },\n };\n}\n\nfunction status(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n}): Column<API.Order> {\n const statusMap = {\n [OrderStatus.NEW]: i18n.t(\"orders.status.pending\"),\n [OrderStatus.FILLED]: i18n.t(\"orders.status.filled\"),\n [OrderStatus.PARTIAL_FILLED]: i18n.t(\"orders.status.partialFilled\"),\n [OrderStatus.CANCELLED]: i18n.t(\"orders.status.canceled\"),\n [OrderStatus.REJECTED]: i18n.t(\"orders.status.rejected\"),\n [OrderStatus.INCOMPLETE]: i18n.t(\"orders.status.incomplete\"),\n [OrderStatus.COMPLETED]: i18n.t(\"orders.status.completed\"),\n };\n return {\n title: i18n.t(\"common.status\"),\n dataIndex: \"status\",\n width: option?.width,\n onSort: option?.enableSort,\n className: option?.className,\n renderPlantText: (value: string, record: any) => {\n const status = value || record.algo_status;\n return (\n statusMap[status as keyof typeof statusMap] ||\n upperCaseFirstLetter(status)\n );\n },\n render: (value: string, record: any) => {\n const status = value || record.algo_status;\n return (\n statusMap[status as keyof typeof statusMap] ||\n upperCaseFirstLetter(status)\n );\n },\n };\n}\n\nfunction avgOpen(option?: {\n enableSort?: boolean;\n width?: number;\n className?: string;\n symbolsInfo?: SymbolsInfo;\n}): Column<API.Order> {\n return {\n title: i18n.t(\"common.avgPrice\"),\n dataIndex: \"average_executed_price\",\n width: option?.width,\n onSort:\n (option?.enableSort ?? false)\n ? (a, b) => {\n return compareNumbers(\n a.average_executed_price ?? 0,\n b.average_executed_price ?? 0,\n );\n }\n : undefined,\n className: option?.className,\n render: (value: string, record) => {\n if (record.type === OrderType.MARKET && !value) {\n return \"--\";\n }\n\n return <AvgPrice symbol={record.symbol} value={value} />;\n },\n renderPlantText: (value: string, record: any) => {\n return value ? commifyOptional(value) : \"--\";\n },\n };\n}\n\nfunction cancelBtn(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n type: \"action\",\n dataIndex: \"action\",\n width: option?.width,\n className: option?.className,\n align: \"right\",\n fixed: \"right\",\n render: (_: string, record: any) => {\n if (record.status === OrderStatus.CANCELLED) {\n return <Renew record={record} />;\n }\n\n if (\n record.status === OrderStatus.NEW ||\n record.algo_status === OrderStatus.NEW\n ) {\n return <CancelButton order={record} />;\n }\n\n return null;\n },\n };\n}\n\nfunction pendingTabCancelBtn(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n type: \"action\",\n dataIndex: \"action\",\n width: option?.width,\n className: option?.className,\n align: \"right\",\n fixed: \"right\",\n render: (_: string, record: any) => {\n return <CancelButton order={record} />;\n },\n };\n}\n\nfunction tpslAction(option?: {\n width?: number;\n className?: string;\n}): Column<API.Order> {\n return {\n title: \"\",\n type: \"action\",\n dataIndex: \"action\",\n width: option?.width,\n className: option?.className,\n align: \"right\",\n fixed: \"right\",\n render: (_: string, record: any) => {\n return (\n <Flex gap={3}>\n <TP_SLEditButton order={record} />\n <CancelButton order={record} />\n </Flex>\n );\n },\n };\n}\n\nfunction compareNumbers(a: number, b: number): number {\n if (a > b) return 1;\n if (a < b) return -1;\n return 0;\n}\n\n// estTotal\nfunction estTotalValue(record: any, isPending: boolean): string {\n if (isPending) {\n return getNotional(record) || \"--\";\n }\n\n if (\n record.type === OrderType.CLOSE_POSITION &&\n record.status !== OrderStatus.FILLED\n ) {\n return i18n.t(\"tpsl.entirePosition\");\n }\n\n return record.total_executed_quantity === 0 ||\n Number.isNaN(record.average_executed_price) ||\n record.average_executed_price === null\n ? \"--\"\n : `${record.total_executed_quantity * record.average_executed_price}`;\n}\n\nfunction trailingCallback(option?: {\n title?: string;\n width?: number;\n className?: string;\n disableEdit?: boolean;\n}): Column<API.Order> {\n return {\n title: option?.title ?? i18n.t(\"orderEntry.trailing\"),\n dataIndex: \"callback_value\",\n className: option?.className,\n width: option?.width,\n renderPlantText: (value: string, record: any) => {\n const { callback_value, callback_rate } = record;\n const val =\n callback_value || (callback_rate ? `${callback_rate * 100}%` : \"--\");\n return val?.toString();\n },\n render: (value: string, record: any) => {\n if (isTrailingStopOrder(record)) {\n return (\n <TrailingCallbackCell order={record} disabled={option?.disableEdit} />\n );\n }\n\n return \"--\";\n },\n };\n}\n","import {\n FC,\n PropsWithChildren,\n ReactNode,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { useTpslPriceChecker } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport {\n AlgoOrderRootType,\n API,\n OrderStatus,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport {\n Badge,\n cn,\n Flex,\n Statistic,\n Text,\n Tooltip,\n} from \"@kodiak-finance/orderly-ui\";\nimport { SharePnLBottomSheetId } from \"@kodiak-finance/orderly-ui-share\";\nimport { CloseToLiqPriceIcon } from \"@kodiak-finance/orderly-ui-tpsl\";\nimport { Decimal, getTrailingStopPrice } from \"@kodiak-finance/orderly-utils\";\nimport {\n getNotional,\n parseBadgesFor,\n upperCaseFirstLetter,\n} from \"../../../utils/util\";\nimport { ShareButtonWidget } from \"../../shareButton\";\nimport { useTPSLOrderRowContext } from \"../tpslOrderRowContext\";\nimport { OrderCellState } from \"./orderCell.script\";\n\nexport const SymbolToken: FC<OrderCellState> = (props) => {\n const { item } = props;\n const isBuy = item.side === OrderSide.BUY;\n const { t } = useTranslation();\n\n return (\n <Text.formatted\n intensity={80}\n rule=\"symbol\"\n formatString=\"base-type\"\n size=\"sm\"\n // @ts-ignore\n prefix={\n <Badge color={isBuy ? \"success\" : \"danger\"} size=\"xs\">\n {isBuy ? t(\"common.buy\") : t(\"common.sell\")}\n </Badge>\n }\n onClick={() => {\n props.onSymbolChange?.({ symbol: item.symbol } as API.Symbol);\n }}\n // showIcon\n >\n {item.symbol}\n </Text.formatted>\n );\n};\n\nexport const OrderTypeView: FC<OrderCellState> = (props) => {\n const { item } = props;\n\n const orderType = useCallback(() => {\n const type =\n typeof item.type === \"string\"\n ? item.type.replace(\"_ORDER\", \"\").toLowerCase()\n : item.type;\n const isAlgoOrder =\n item.algo_order_id && item.algo_type !== AlgoOrderRootType.BRACKET;\n if (isAlgoOrder) {\n return `Stop ${type}`;\n }\n return upperCaseFirstLetter(item.type);\n }, [item]);\n\n return (\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(props.item)?.map((e, index) => (\n <Badge\n key={index}\n color={e.toLocaleLowerCase() === \"position\" ? \"primary\" : \"neutral\"}\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n </Flex>\n );\n};\n\nexport const OrderTime: FC<OrderCellState> = (props) => {\n const { item } = props;\n\n return (\n <Text.formatted\n rule={\"date\"}\n formatString=\"yyyy-MM-dd HH:mm:ss\"\n intensity={36}\n size=\"2xs\"\n >\n {item.created_time}\n </Text.formatted>\n );\n};\n\nexport const OrderState: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n // @ts-ignore\n const status = item.status || item.algo_status;\n\n const statusMap = useMemo(() => {\n return {\n [OrderStatus.NEW]: t(\"orders.status.pending\"),\n [OrderStatus.FILLED]: t(\"orders.status.filled\"),\n [OrderStatus.PARTIAL_FILLED]: t(\"orders.status.partialFilled\"),\n [OrderStatus.CANCELLED]: t(\"orders.status.canceled\"),\n [OrderStatus.REJECTED]: t(\"orders.status.rejected\"),\n [OrderStatus.INCOMPLETE]: t(\"orders.status.incomplete\"),\n [OrderStatus.COMPLETED]: t(\"orders.status.completed\"),\n };\n }, [t]);\n\n return (\n <Text.formatted intensity={80} size=\"2xs\">\n {statusMap[status as keyof typeof statusMap] ||\n upperCaseFirstLetter(status)}\n </Text.formatted>\n );\n};\n\nexport const Qty: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n const isEntirePosition =\n item.type === OrderType.CLOSE_POSITION &&\n // @ts-ignore\n item?.status !== OrderStatus.FILLED;\n\n return (\n <Statistic\n label={t(\"common.qty\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.base_dp}\n padding={false}\n coloring\n placeholder={t(\"tpsl.entirePosition\")}\n intensity={80}\n >\n {isEntirePosition ? t(\"tpsl.entirePosition\") : item.quantity}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const Filled: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={<Text>{t(\"orders.status.filled\")}</Text>}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.base_dp}\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {/* {item.algo_order_id\n ? item.total_executed_quantity\n : (item as unknown as API.OrderExt).executed} */}\n {item.total_executed_quantity}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const Notional: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Statistic\n align=\"end\"\n label={\n <Text>\n {t(\"common.notional\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n coloring\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {(item as any).notional ?? \"--\"}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const EstTotal: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const value = useMemo(() => getNotional(item), [item.price, item.quantity]);\n\n const rendrerContent = () => {\n if (value) {\n return (\n <Text.numeral\n dp={props.quote_dp}\n coloring\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {value}\n </Text.numeral>\n );\n }\n\n return \"--\";\n };\n\n return (\n <Statistic\n align=\"end\"\n label={\n <Text>\n {t(\"common.notional\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {rendrerContent()}\n </Statistic>\n );\n};\n\nexport const TriggerPrice: FC<\n OrderCellState & {\n align?: \"start\" | \"end\";\n isPending?: boolean;\n }\n> = (props) => {\n const { item, isPending } = props;\n const { t } = useTranslation();\n\n const isTrailingStop = item?.algo_type === AlgoOrderRootType.TRAILING_STOP;\n\n const rendrerContent = () => {\n if (isTrailingStop && isPending && item.activated_price) {\n return (\n <Text.numeral\n dp={props.quote_dp}\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {item.activated_price}\n </Text.numeral>\n );\n }\n\n if (item.trigger_price) {\n return (\n <Text.numeral\n dp={props.quote_dp}\n intensity={80}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {item.trigger_price}\n </Text.numeral>\n );\n }\n\n return \"--\";\n };\n\n return (\n <Statistic\n label={isTrailingStop ? t(\"common.trigger\") : t(\"common.triggerPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n align={props.align}\n >\n {rendrerContent()}\n </Statistic>\n );\n};\n\nexport const MarkPrice: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={t(\"common.markPrice\")}\n align=\"end\"\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {item.mark_price}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const LimitPrice: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const isAlgoOrder = item?.algo_order_id !== undefined;\n const isTrailingStop = item?.algo_type === AlgoOrderRootType.TRAILING_STOP;\n const isStopMarket = item?.type === \"MARKET\" && isAlgoOrder;\n\n const rendrerContent = () => {\n if (isTrailingStop) {\n return \"--\";\n }\n if (isStopMarket) {\n return <Text>{t(\"common.marketPrice\")}</Text>;\n }\n\n return (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {item.price ?? \"--\"}\n </Text.numeral>\n );\n };\n\n return (\n <Statistic\n label={t(\"common.limitPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {rendrerContent()}\n </Statistic>\n );\n};\n\nexport const TPTrigger: FC<OrderCellState> = (props) => {\n const { tp_trigger_price, tpPnL } = useTPSLOrderRowContext();\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={t(\"tpsl.tpTrigger\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <MobileTooltip\n content={\n tpPnL && (\n <Text.numeral\n size=\"2xs\"\n showIdentifier\n // @ts-ignore\n prefix={<Text intensity={54}>{`${t(\"tpsl.tpPnl\")}:`} </Text>}\n suffix={<Text intensity={20}> USDC</Text>}\n coloring\n >\n {tpPnL}\n </Text.numeral>\n )\n }\n classNames={{\n content: \"oui-bg-base-6 oui-ml-2\",\n arrow: \"oui-fill-base-6\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n color=\"buy\"\n padding={false}\n className={\n tp_trigger_price\n ? \"oui-border-b oui-border-dashed oui-border-base-contrast-12\"\n : undefined\n }\n >\n {tp_trigger_price ?? \"--\"}\n </Text.numeral>\n </MobileTooltip>\n </Statistic>\n );\n};\n\nexport const SLTrigger: FC<OrderCellState> = (props) => {\n const { sl_trigger_price, slPnL, position: item } = useTPSLOrderRowContext();\n const { t } = useTranslation();\n\n const side = (item?.position_qty ?? 0) > 0 ? OrderSide.BUY : OrderSide.SELL;\n const slPriceError = useTpslPriceChecker({\n slPrice: sl_trigger_price?.toString() ?? undefined,\n liqPrice: item?.est_liq_price ?? null,\n side: side,\n });\n\n return (\n <Statistic\n label={t(\"tpsl.slTrigger\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <MobileTooltip\n content={\n slPnL && (\n <Text.numeral\n size=\"2xs\"\n // @ts-ignore\n prefix={\n <Text intensity={54}>{`${t(\"tpsl.slPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}> USDC</Text>}\n coloring\n >\n {slPnL}\n </Text.numeral>\n )\n }\n classNames={{\n content: \"oui-bg-base-6 oui-ml-2\",\n arrow: \"oui-fill-base-6\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n as=\"div\"\n rm={Decimal.ROUND_DOWN}\n color=\"sell\"\n padding={false}\n suffix={<CloseToLiqPriceIcon slPriceError={slPriceError} />}\n className={cn(\n sl_trigger_price\n ? \"oui-border-b oui-border-dashed oui-border-base-contrast-12\"\n : undefined,\n \"oui-flex oui-items-center\",\n )}\n >\n {sl_trigger_price ?? \"--\"}\n </Text.numeral>\n </MobileTooltip>\n </Statistic>\n );\n};\n\nexport const TPPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n const { tp_order_price } = useTPSLOrderRowContext();\n\n const renderOrderPrice = useMemo(() => {\n if (tp_order_price === undefined) {\n return <Text>--</Text>;\n }\n if (tp_order_price === OrderType.MARKET) {\n return <Text>{t(\"common.marketPrice\")}</Text>;\n }\n return (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {tp_order_price}\n </Text.numeral>\n );\n }, [tp_order_price]);\n\n return (\n <Statistic\n label={t(\"tpsl.tpPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {renderOrderPrice}\n </Statistic>\n );\n};\nexport const SLPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n const { sl_order_price } = useTPSLOrderRowContext();\n\n const renderOrderPrice = useMemo(() => {\n if (sl_order_price === undefined) {\n return <Text>--</Text>;\n }\n if (sl_order_price === OrderType.MARKET) {\n return <Text>{t(\"common.marketPrice\")}</Text>;\n }\n return (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {sl_order_price}\n </Text.numeral>\n );\n }, [sl_order_price]);\n\n return (\n <Statistic\n label={t(\"tpsl.slPrice\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {renderOrderPrice}\n </Statistic>\n );\n};\n\nexport const TPSLQuantity: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const quantity = useMemo(() => {\n if (item.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {\n return (\n <span className=\"oui-text-base-contrast-80\">\n {t(\"tpsl.entirePosition\")}\n </span>\n );\n }\n\n return (\n <Text.numeral\n dp={props.base_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {item.quantity}\n </Text.numeral>\n );\n }, [item, t]);\n\n return (\n <Statistic\n label={t(\"common.quantity\")}\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n align=\"end\"\n >\n {quantity}\n </Statistic>\n );\n};\n\nexport const AvgPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n return (\n <Statistic\n label={\n <Text>\n {t(\"common.avgPrice\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {/* @ts-ignore */}\n {props.item?.average_executed_price ?? \"--\"}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const OrderPrice: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n return (\n <Statistic\n label={\n <Text>\n {t(\"common.orderPrice\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n placeholder={t(\"common.marketPrice\")}\n >\n {/* @ts-ignore */}\n {props.item?.price ?? \"--\"}\n </Text.numeral>\n </Statistic>\n );\n};\n\nexport const RealizedPnL: FC<OrderCellState> = (props) => {\n // @ts-ignore\n const value = props?.item?.realized_pnl;\n const { t } = useTranslation();\n\n return (\n <Statistic\n label={\n <Text>\n {t(\"common.realizedPnl\")}\n <Text intensity={20}>(USDC)</Text>\n </Text>\n }\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n align=\"end\"\n >\n <Flex gap={1}>\n <Text.pnl\n dp={props.quote_dp}\n padding={false}\n intensity={(value ?? 0) == 0 ? 80 : undefined}\n showIdentifier={(value ?? 0) > 0}\n coloring={(value ?? 0) != 0}\n >\n {value ?? \"--\"}\n </Text.pnl>\n </Flex>\n </Statistic>\n );\n};\n\nexport const MobileTooltip: FC<\n PropsWithChildren<{\n content?: string | ReactNode;\n classNames?: {\n content?: string;\n arrow?: string;\n };\n }>\n> = (props) => {\n const { classNames, content } = props;\n const [open, setOpen] = useState(false);\n if (typeof content === \"undefined\") return props.children;\n return (\n <Tooltip\n // @ts-ignore\n content={content}\n className={classNames?.content}\n open={open}\n onOpenChange={setOpen}\n arrow={{ className: classNames?.arrow }}\n >\n <div onClick={() => setOpen((e) => !e)}>{props.children}</div>\n </Tooltip>\n );\n};\n\nexport const Fee: FC<OrderCellState> = (props) => {\n const { t } = useTranslation();\n return (\n <Flex justify=\"end\" gapX={1} mt={1}>\n <Text size=\"2xs\" intensity={36}>\n {t(\"common.fee\")}:\n </Text>\n <Text size=\"2xs\" intensity={80}>\n {props.item?.total_fee ?? \"--\"}\n </Text>\n </Flex>\n );\n};\n\nexport const TrailingCallback: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const { callback_value, callback_rate } = item;\n\n return (\n <Statistic\n label={t(\"orderEntry.trailing\")}\n align=\"end\"\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {callback_rate ? (\n <Text intensity={80}>{`${callback_rate * 100}%`}</Text>\n ) : (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {callback_value ?? \"--\"}\n </Text.numeral>\n )}\n </Statistic>\n );\n};\n\nexport const TrailingPrice: FC<OrderCellState> = (props) => {\n const { item } = props;\n const { t } = useTranslation();\n\n const value = useMemo(() => {\n return getTrailingStopPrice(item);\n }, [item]);\n\n return (\n <Statistic\n label={t(\"common.price\")}\n align=\"start\"\n classNames={{\n root: \"oui-text-xs\",\n label: \"oui-text-2xs\",\n }}\n >\n {value ? (\n <Text.numeral\n dp={props.quote_dp}\n rm={Decimal.ROUND_DOWN}\n intensity={80}\n padding={false}\n >\n {value}\n </Text.numeral>\n ) : (\n \"--\"\n )}\n </Statistic>\n );\n};\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, EditIcon, Flex, Text, modal } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { MobileTooltip } from \"../items\";\nimport { BracketOrderPriceState } from \"./bracketOrderPrice.script\";\n\nexport const BracketOrderPrice: FC<BracketOrderPriceState> = (props) => {\n const { t } = useTranslation();\n\n const onEdit = () => {\n modal.show(\"EditBracketOrderSheetId\", {\n order: props.order,\n });\n };\n\n if (!props.sl_trigger_price && !props.tp_trigger_price) return <></>;\n\n return (\n <Flex gap={1} itemAlign={\"center\"} justify={\"start\"}>\n <MobileTooltip\n classNames={{\n content: \"oui-bg-base-6 oui-ml-2\",\n arrow: \"oui-fill-base-6\",\n }}\n content={\n <Flex direction={\"column\"} itemAlign={\"start\"} gap={1}>\n {typeof props.pnl?.tpPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.tpPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={props.quote_dp}\n color=\"buy\"\n showIdentifier\n >\n {props.pnl?.tpPnL}\n </Text.numeral>\n )}\n {typeof props.pnl?.slPnL !== \"undefined\" && (\n <Text.numeral\n // @ts-ignore\n prefix={\n <Text intensity={80}>{`${t(\"tpsl.slPnl\")}:`} </Text>\n }\n suffix={<Text intensity={20}>{\" USDC\"}</Text>}\n dp={props.quote_dp}\n color=\"sell\"\n >\n {props.pnl?.slPnL}\n </Text.numeral>\n )}\n </Flex>\n }\n >\n <button\n onClick={() => {\n props.setOpen(!props.open);\n }}\n >\n <Flex gap={1} width={\"1\"}>\n {props.tp_trigger_price && (\n <Price\n type=\"TP\"\n value={props.tp_trigger_price}\n quote_dp={props.quote_dp}\n />\n )}\n {props.sl_trigger_price && (\n <Price\n type=\"SL\"\n value={props.sl_trigger_price}\n quote_dp={props.quote_dp}\n />\n )}\n </Flex>\n </button>\n </MobileTooltip>\n <EditIcon\n onClick={onEdit}\n opacity={1}\n className=\"oui-cursor-pointer oui-text-base-contrast-54\"\n size={16}\n />\n </Flex>\n );\n};\n\nconst Price = (props: {\n type: \"TP\" | \"SL\";\n value?: number | string;\n quote_dp: number;\n}) => {\n const { type, value, quote_dp } = props;\n\n return value ? (\n <Text.numeral\n size=\"2xs\"\n className={cn(\n \"oui-border-b oui-border-dashed oui-border-base-contrast-12\",\n type === \"TP\" ? \"oui-text-trade-profit\" : \"oui-text-trade-loss\",\n )}\n key={\"tp\"}\n rule=\"price\"\n dp={quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n // @ts-ignore\n prefix={\n <span className={\"oui-text-base-contrast-36\"}>\n {`${type} `}: \n </span>\n }\n >\n {value}\n </Text.numeral>\n ) : (\n <></>\n );\n};\n","import { useMemo, useState } from \"react\";\nimport { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { calcBracketRoiAndPnL } from \"../../../../utils/util\";\nimport { OrderCellState } from \"../orderCell.script\";\n\nexport const useBracketOrderPriceScript = (props: OrderCellState) => {\n const { item: order, quote_dp, base_dp } = props;\n\n const [open, setOpen] = useState(false);\n\n const { sl_trigger_price, tp_trigger_price } = useMemo(() => {\n if (!(\"algo_type\" in order) || !Array.isArray(order.child_orders)) {\n return {};\n }\n return utils.findTPSLFromOrder(order.child_orders[0]);\n }, [order]);\n\n const { pnl } = calcBracketRoiAndPnL(order);\n\n return {\n sl_trigger_price,\n order,\n tp_trigger_price,\n pnl,\n quote_dp,\n open,\n setOpen,\n };\n};\n\nexport type BracketOrderPriceState = ReturnType<\n typeof useBracketOrderPriceScript\n>;\n","import { FC } from \"react\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useBracketOrderPriceScript } from \"./bracketOrderPrice.script\";\nimport { BracketOrderPrice } from \"./bracketOrderPrice.ui\";\n\nexport const BracketOrderPriceWidget: FC<OrderCellState> = (props) => {\n const state = useBracketOrderPriceScript(props);\n return <BracketOrderPrice {...state} />;\n};\n","export { BracketOrderPrice } from \"./bracketOrderPrice.ui\";\nexport { BracketOrderPriceWidget } from \"./bracketOrderPrice.widget\";\nexport { useBracketOrderPriceScript } from \"./bracketOrderPrice.script\";\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Button, SimpleDialog, Text } from \"@kodiak-finance/orderly-ui\";\nimport { CancelBtnState } from \"./cancelBtn.script\";\n\nexport const CancelBtn: FC<CancelBtnState> = (props) => {\n const { t } = useTranslation();\n\n return (\n <Button\n variant=\"outlined\"\n fullWidth\n color=\"secondary\"\n size=\"sm\"\n className=\"oui-border-base-contrast-36\"\n onClick={(e) => props.onCancel(e)}\n >\n {t(\"common.cancel\")}\n </Button>\n );\n};\n","import { FC, useState } from \"react\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { toast } from \"@kodiak-finance/orderly-ui\";\n\nexport const useCancelBtnScript = (props: { state: OrderCellState }) => {\n const { state } = props;\n const [open, setOpen] = useState(false);\n\n const { onCancelOrder } = useOrderListContext();\n const [isLoading, setIsLoading] = useState(false);\n\n const onCancel = (event?: any) => {\n if (!onCancelOrder) return Promise.resolve();\n event?.preventDefault();\n event?.stopPropagation();\n setIsLoading(true);\n return onCancelOrder(state.item)\n .then(\n (res: any) => {\n setOpen(false);\n },\n (error: any) => {\n toast.error(error.message);\n }\n ).finally(() => {\n setIsLoading(false);\n });\n };\n\n const onClose = () => {\n setOpen(false);\n };\n\n return {\n ...state,\n\n open,\n setOpen,\n onCancel,\n onClose,\n isLoading,\n };\n};\n\nexport type CancelBtnState = ReturnType<typeof useCancelBtnScript>;\n","import { FC } from \"react\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useCancelBtnScript } from \"./cancelBtn.script\";\nimport { CancelBtn } from \"./cancelBtn.ui\";\n\nexport const CancelBtnWidget = (props: { state: OrderCellState }) => {\n const state = useCancelBtnScript(props);\n return <CancelBtn {...state} />;\n};\n","export { CancelBtn } from \"./cancelBtn.ui\";\nexport { CancelBtnWidget } from \"./cancelBtn.widget\";\nexport { useCancelBtnScript } from \"./cancelBtn.script\";\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Button } from \"@kodiak-finance/orderly-ui\";\nimport { EditBtnState } from \"./editBtn.script\";\n\nexport const EditBtn: FC<EditBtnState> = (props) => {\n const { t } = useTranslation();\n\n return (\n <>\n <Button\n variant=\"outlined\"\n fullWidth\n color=\"secondary\"\n size=\"sm\"\n className=\"oui-border-base-contrast-36\"\n onClick={() => {\n props.onShowEditSheet();\n }}\n >\n {t(\"common.edit\")}\n </Button>\n </>\n );\n};\n","import { createContext, useContext } from \"react\";\nimport { OrderValidationResult } from \"@kodiak-finance/orderly-hooks\";\nimport { OrderlyOrder } from \"@kodiak-finance/orderly-types\";\nimport { SymbolContextState } from \"../../../../provider/symbolContext\";\n\nexport type EditSheetContextState = {\n symbolInfo: SymbolContextState;\n getErrorMsg: (\n key: keyof OrderValidationResult,\n customValue?: string,\n ) => string;\n setOrderValue: (key: keyof OrderlyOrder, value: any) => void;\n};\n\nexport const EditSheetContext = createContext({} as EditSheetContextState);\n\nexport function useEditSheetContext() {\n return useContext(EditSheetContext);\n}\n","import { memo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype ActivitedPriceInputProps = {\n activated_price?: string | number;\n disabled?: boolean;\n};\n\nexport const ActivitedPriceInput = memo((props: ActivitedPriceInputProps) => {\n const { activated_price } = props;\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const error = activated_price\n ? getErrorMsg(\"activated_price\")\n : t(\"orderEntry.triggerPrice.error.required\");\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.trigger\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]}\n value={activated_price}\n onValueChange={(val) => setOrderValue(\"activated_price\", val)}\n disabled={props.disabled}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-5 oui-max-w-[360px]\",\n },\n arrow: {\n className: \"oui-fill-base-5\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nActivitedPriceInput.displayName = \"ActivitedPriceInput\";\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { Badge, Checkbox, Divider, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { parseBadgesFor } from \"../../../../../utils/util\";\nimport { EditSheetState } from \"../editSheet.script\";\n\nexport const ConfirmDialogContent: FC<EditSheetState> = (props) => {\n const { item } = props;\n const {\n formattedOrder,\n symbolInfo,\n isStopMarket,\n showTriggerPrice,\n isTrailingStop,\n } = props;\n const { t } = useTranslation();\n\n const showPrice = !isTrailingStop;\n const showActivatedPrice = isTrailingStop && formattedOrder.activated_price;\n const showTrailingCallback = isTrailingStop;\n\n const header = (\n <>\n <Text\n intensity={80}\n >{`You agree to edit your ${props.base}-PERP order.`}</Text>\n <Flex gap={2} mb={3} mt={2} justify={\"between\"}>\n <Text.formatted\n rule=\"symbol\"\n formatString=\"base-type\"\n size=\"base\"\n showIcon\n >\n {item.symbol}\n </Text.formatted>\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(item)?.map((e, index) => (\n <Badge\n key={index}\n color={\n e.toLocaleLowerCase() === \"position\" ? \"primary\" : \"neutral\"\n }\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n {item.side === OrderSide.BUY ? (\n <Badge color=\"success\" size=\"xs\">\n {t(\"common.buy\")}\n </Badge>\n ) : (\n <Badge color=\"danger\" size=\"xs\">\n {t(\"common.sell\")}\n </Badge>\n )}\n </Flex>\n </Flex>\n </>\n );\n\n const triggerPriceItem = showTriggerPrice && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.triggerPrice\")}</Text>\n <Text.numeral\n intensity={80}\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n suffix={<Text intensity={54}>{\" USDC\"}</Text>}\n >\n {formattedOrder.trigger_price ?? \"--\"}\n </Text.numeral>\n </Flex>\n );\n\n const priceItem = showPrice && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.price\")}</Text>\n <Text.numeral\n intensity={80}\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n suffix={<Text intensity={54}>{\" USDC\"}</Text>}\n placeholder={isStopMarket ? t(\"common.marketPrice\") : \"--\"}\n >\n {isStopMarket\n ? t(\"common.marketPrice\")\n : (formattedOrder.order_price ?? \"--\")}\n </Text.numeral>\n </Flex>\n );\n\n const activatedPriceItem = showActivatedPrice && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.triggerPrice\")}</Text>\n {formattedOrder.activated_price ? (\n <Text.numeral\n intensity={80}\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n suffix={<Text intensity={54}>{\" USDC\"}</Text>}\n >\n {formattedOrder.activated_price}\n </Text.numeral>\n ) : (\n t(\"common.marketPrice\")\n )}\n </Flex>\n );\n\n const trailingCallbackItem = showTrailingCallback && (\n <>\n {formattedOrder.callback_value && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"orderEntry.trailingValue\")}</Text>\n <Text.numeral\n dp={symbolInfo.quote_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {formattedOrder.callback_value}\n </Text.numeral>\n </Flex>\n )}\n {formattedOrder.callback_rate && (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"orderEntry.trailingRate\")}</Text>\n <Text className=\"oui-text-base-contrast\">\n {formattedOrder.callback_rate}%\n </Text>\n </Flex>\n )}\n </>\n );\n\n const quantityItem = (\n <Flex justify={\"between\"} width={\"100%\"} gap={1}>\n <Text>{t(\"common.qty\")}</Text>\n <Text.numeral\n color={item.side === OrderSide.BUY ? \"buy\" : \"sell\"}\n dp={symbolInfo.base_dp}\n padding={false}\n rm={Decimal.ROUND_DOWN}\n >\n {formattedOrder.order_quantity}\n </Text.numeral>\n </Flex>\n );\n\n const orderConfirmCheckbox = (\n <Flex className=\"oui-gap-[2px]\">\n <Checkbox\n color=\"white\"\n id=\"oui-checkbox-disableOrderConfirmation\"\n checked={!props.orderConfirm}\n onCheckedChange={(e: boolean) => {\n props.setOrderConfirm(!e);\n }}\n />\n <label\n className=\"oui-text-2xs oui-text-base-contrast-54\"\n htmlFor=\"oui-checkbox-disableOrderConfirmation\"\n >\n {t(\"orderEntry.disableOrderConfirm\")}\n </label>\n </Flex>\n );\n\n return (\n <div className=\"oui-pt-2\">\n {header}\n <Divider />\n <Flex\n direction={\"column\"}\n gap={1}\n width={\"100%\"}\n className=\"oui-text-sm oui-text-base-contrast-54\"\n py={3}\n >\n {triggerPriceItem}\n {priceItem}\n {quantityItem}\n {activatedPriceItem}\n {trailingCallbackItem}\n </Flex>\n\n {orderConfirmCheckbox}\n </div>\n );\n};\n","import { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderSide } from \"@kodiak-finance/orderly-types\";\nimport { Badge, Flex, Text } from \"@kodiak-finance/orderly-ui\";\nimport { parseBadgesFor } from \"../../../../../utils/util\";\n\ntype EditSheetHeaderProps = {\n item: API.AlgoOrderExt;\n};\n\nexport const EditSheetHeader = (props: EditSheetHeaderProps) => {\n const { item } = props;\n const { t } = useTranslation();\n\n return (\n <Flex width={\"100%\"} justify={\"between\"}>\n <Text.formatted rule={\"symbol\"} showIcon intensity={80}>\n {item.symbol}\n </Text.formatted>\n <Flex direction={\"row\"} gap={1}>\n {parseBadgesFor(props.item)?.map((e, index) => (\n <Badge\n key={index}\n color={e.toLocaleLowerCase() === \"position\" ? \"primary\" : \"neutral\"}\n size=\"xs\"\n >\n {e}\n </Badge>\n ))}\n {item.side === OrderSide.BUY ? (\n <Badge color=\"success\" size=\"xs\">\n {t(\"common.buy\")}\n </Badge>\n ) : (\n <Badge color=\"danger\" size=\"xs\">\n {t(\"common.sell\")}\n </Badge>\n )}\n </Flex>\n </Flex>\n );\n};\n","import { memo, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype PriceInputProps = {\n order_price?: string | number;\n disabled?: boolean;\n};\n\nexport const PriceInput = memo((props: PriceInputProps) => {\n const [focus, setFocus] = useState(false);\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const error =\n getErrorMsg(\"order_price\") || (focus ? getErrorMsg(\"total\") : \"\");\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.price\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]}\n disabled={props.disabled}\n value={props.order_price}\n onValueChange={(val) => setOrderValue(\"order_price\", val)}\n onBlur={() => {\n setFocus(false);\n }}\n onFocus={() => {\n setFocus(true);\n }}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-5\",\n },\n arrow: {\n className: \"oui-fill-base-5\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nPriceInput.displayName = \"PriceInput\";\n","import { memo, useState } from \"react\";\nimport { utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype QuantityInputProps = {\n value: string | number;\n};\n\nexport const QuantityInput = memo((props: QuantityInputProps) => {\n const [focus, setFocus] = useState(false);\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n\n const { base_dp, base_tick, base } = symbolInfo;\n\n const error =\n getErrorMsg(\"order_quantity\") || (focus ? getErrorMsg(\"total\") : \"\");\n\n const setQuantity = (val: string) => {\n setOrderValue(\"order_quantity\", val);\n };\n\n const onBlur = (value: string) => {\n if (base_tick && base_tick > 0) {\n const formatQty = utils.formatNumber(value, base_tick) ?? value;\n setQuantity(formatQty);\n }\n };\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.quantity\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {base}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(base_dp),\n // inputFormatter.rangeFormatter({ max: props.maxQty }),\n ]}\n value={props.value}\n onValueChange={setQuantity}\n onBlur={(event) => {\n onBlur(event.target.value);\n setFocus(false);\n }}\n onFocus={() => {\n setFocus(true);\n }}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-6\",\n },\n arrow: {\n className: \"oui-fill-base-6\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nQuantityInput.displayName = \"QuantityInput\";\n","import { memo, useMemo } from \"react\";\nimport { useThrottledCallback, utils } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Flex, Slider, Text } from \"@kodiak-finance/orderly-ui\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype QuantitySliderProps = {\n maxQty: number;\n quantity: string | number;\n};\n\nexport const QuantitySlider = memo((props: QuantitySliderProps) => {\n const { quantity, maxQty } = props;\n const { t } = useTranslation();\n\n const { symbolInfo, setOrderValue } = useEditSheetContext();\n const { base_dp, base_tick } = symbolInfo;\n\n const sliderValue = useMemo(() => {\n if (quantity && Number(quantity) !== 0 && maxQty !== 0) {\n const value = new Decimal(quantity)\n .div(maxQty)\n .mul(100)\n .toDecimalPlaces(2, Decimal.ROUND_DOWN)\n .toNumber();\n return value;\n }\n return 0;\n }, [quantity, maxQty]);\n\n const sliderToQuantity = useThrottledCallback(\n (value: number) => {\n const newQty = new Decimal(value)\n .div(100)\n .mul(maxQty)\n .toDecimalPlaces(base_dp, Decimal.ROUND_DOWN)\n .toNumber();\n\n setOrderValue(\"order_quantity\", utils.formatNumber(newQty, base_tick));\n },\n 50,\n {},\n );\n\n const percentages =\n props.quantity && props.maxQty\n ? Math.min(Number(props.quantity) / props.maxQty, 1)\n : undefined;\n\n return (\n <>\n <Slider\n markCount={4}\n value={[sliderValue]}\n onValueChange={(e) => {\n sliderToQuantity(e[0]);\n }}\n color=\"primary\"\n />\n <Flex width={\"100%\"} justify={\"between\"}>\n <Text.numeral\n color=\"primary\"\n size=\"2xs\"\n dp={2}\n padding={false}\n rule=\"percentages\"\n >{`${percentages ?? 0}`}</Text.numeral>\n <Flex\n gap={1}\n onClick={() => {\n setOrderValue(\"order_quantity\", maxQty.toString());\n }}\n >\n <Text size=\"2xs\" color=\"primary\">\n {t(\"common.max\")}\n </Text>\n <Text.numeral intensity={54} size=\"2xs\" dp={base_dp}>\n {props.maxQty}\n </Text.numeral>\n </Flex>\n </Flex>\n </>\n );\n});\n\nQuantitySlider.displayName = \"QuantitySlider\";\n","import { memo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype TrailingCallbackInputProps = {\n isCallbackValue?: boolean;\n callback_value?: number;\n callback_rate?: number;\n};\n\nexport const TrailingCallbackInput = memo(\n (props: TrailingCallbackInputProps) => {\n const { isCallbackValue, callback_value, callback_rate } = props;\n const { t } = useTranslation();\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const label = isCallbackValue\n ? t(\"orderEntry.trailingValue\")\n : t(\"orderEntry.trailingRate\");\n\n const field = isCallbackValue ? \"callback_value\" : \"callback_rate\";\n\n const suffix = isCallbackValue ? (\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n ) : (\n \"%\"\n );\n\n const error = getErrorMsg(field);\n\n const formatters = [\n inputFormatter.numberFormatter,\n inputFormatter.decimalPointFormatter,\n ];\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {label}\n </Text>\n }\n suffix={suffix}\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={\n isCallbackValue\n ? [\n ...formatters,\n inputFormatter.currencyFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]\n : [...formatters, inputFormatter.dpFormatter(1)]\n }\n value={isCallbackValue ? callback_value : callback_rate}\n onValueChange={(val) => setOrderValue(field, val)}\n tooltip={error}\n tooltipProps={{\n content: {\n // mobile max width\n className: \"oui-bg-base-5 oui-max-w-[360px]\",\n },\n arrow: {\n className: \"oui-fill-base-5\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n },\n);\n\nTrailingCallbackInput.displayName = \"TrailingCallbackInput\";\n","import { memo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { cn, Input, inputFormatter, Text } from \"@kodiak-finance/orderly-ui\";\nimport { useEditSheetContext } from \"./editSheetContext\";\n\ntype TriggerPriceInputProps = {\n trigger_price?: string | number;\n disabled?: boolean;\n};\n\nexport const TriggerPriceInput = memo((props: TriggerPriceInputProps) => {\n const { t } = useTranslation();\n\n const { symbolInfo, setOrderValue, getErrorMsg } = useEditSheetContext();\n const { quote, quote_dp } = symbolInfo;\n\n const error = getErrorMsg(\"trigger_price\");\n\n return (\n <Input.tooltip\n prefix={\n <Text intensity={54} className=\"oui-px-3\">\n {t(\"common.triggerPrice\")}\n </Text>\n }\n suffix={\n <Text intensity={54} className=\"oui-px-3\">\n {quote}\n </Text>\n }\n color={error ? \"danger\" : undefined}\n align=\"right\"\n fullWidth\n autoComplete=\"off\"\n inputMode=\"decimal\"\n formatters={[\n inputFormatter.numberFormatter,\n inputFormatter.dpFormatter(quote_dp),\n ]}\n value={props.trigger_price}\n onValueChange={(val) => setOrderValue(\"trigger_price\", val)}\n disabled={props.disabled}\n tooltip={error}\n tooltipProps={{\n content: {\n className: \"oui-bg-base-6 oui-text-base-contrast-80\",\n },\n arrow: {\n className: \"oui-fill-base-6\",\n },\n }}\n classNames={{\n input: \"oui-text-base-contrast oui-w-full\",\n root: cn(\"oui-outline-line-12\", error && \"oui-outline-danger\"),\n }}\n />\n );\n});\n\nTriggerPriceInput.displayName = \"TriggerPriceInput\";\n","import { FC, useMemo } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { useOrderEntryFormErrorMsg } from \"@kodiak-finance/orderly-react-app\";\nimport {\n Button,\n Divider,\n Flex,\n SimpleDialog,\n Text,\n ThrottledButton,\n} from \"@kodiak-finance/orderly-ui\";\nimport { ActivitedPriceInput } from \"./components/activitedPriceInput\";\nimport { ConfirmDialogContent } from \"./components/editDialogContent\";\nimport { EditSheetContext } from \"./components/editSheetContext\";\nimport { EditSheetHeader } from \"./components/editSheetHeader\";\nimport { PriceInput } from \"./components/priceInput\";\nimport { QuantityInput } from \"./components/quantityInput\";\nimport { QuantitySlider } from \"./components/quantitySlider\";\nimport { TrailingCallbackInput } from \"./components/trailingCallbackInput\";\nimport { TriggerPriceInput } from \"./components/triggerPriceInput\";\nimport { EditSheetState } from \"./editSheet.script\";\n\nexport const EditSheet: FC<EditSheetState> = (props) => {\n const {\n item,\n symbolInfo,\n formattedOrder,\n isStopMarket,\n isTrailingStop,\n setOrderValue,\n errors,\n } = props;\n const { t } = useTranslation();\n\n const { getErrorMsg } = useOrderEntryFormErrorMsg(errors!);\n\n const disabled =\n !props.isChanged ||\n Object.keys(errors!).length > 0 ||\n // when activated price is not empty, the activated price input should not be empty\n (!!item.activated_price && !formattedOrder.activated_price);\n\n const header = <EditSheetHeader item={item} />;\n\n const lastPrice = (\n <Flex width={\"100%\"} justify={\"between\"}>\n <Text>{t(\"common.lastPrice\")}</Text>\n <Text.numeral dp={symbolInfo.quote_dp}>\n {props.markPrice ?? \"--\"}\n </Text.numeral>\n </Flex>\n );\n\n const triggerPriceInput = props.showTriggerPrice && (\n <TriggerPriceInput\n trigger_price={formattedOrder.trigger_price}\n disabled={!!item.is_triggered}\n />\n );\n\n const renderPriceInput = () => {\n if (isTrailingStop) {\n return (\n item.activated_price && (\n <ActivitedPriceInput\n activated_price={formattedOrder.activated_price}\n disabled={item.is_activated}\n />\n )\n );\n }\n\n return (\n <PriceInput\n order_price={\n isStopMarket\n ? t(\"orderEntry.orderType.market\")\n : formattedOrder.order_price\n }\n disabled={isStopMarket}\n />\n );\n };\n\n const trailingCallbackInput = isTrailingStop && (\n <TrailingCallbackInput\n isCallbackValue={!!item.callback_value}\n callback_value={formattedOrder.callback_value}\n callback_rate={formattedOrder.callback_rate}\n />\n );\n\n const quantityInput = <QuantityInput value={formattedOrder.order_quantity} />;\n\n const quantitySlider = (\n <QuantitySlider\n maxQty={props.maxQty}\n quantity={formattedOrder.order_quantity}\n />\n );\n\n const buttons = (\n <Flex width={\"100%\"} gap={3} mt={2}>\n <Button\n fullWidth\n color=\"secondary\"\n onClick={(e) => {\n props.onClose();\n }}\n >\n {t(\"common.cancel\")}\n </Button>\n <ThrottledButton\n fullWidth\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onSheetConfirm();\n }}\n loading={props.submitting}\n disabled={disabled}\n >\n {t(\"common.confirm\")}\n </ThrottledButton>\n </Flex>\n );\n\n const ctxValue = useMemo(() => {\n return {\n symbolInfo,\n getErrorMsg,\n setOrderValue,\n };\n }, [symbolInfo, getErrorMsg, setOrderValue]);\n\n return (\n <EditSheetContext.Provider value={ctxValue}>\n <Flex\n direction={\"column\"}\n gap={3}\n width={\"100%\"}\n itemAlign={\"start\"}\n className=\"oui-text-sm\"\n >\n {header}\n <Divider intensity={8} className=\"oui-w-full\" />\n {lastPrice}\n <Flex width={\"100%\"} direction={\"column\"} itemAlign={\"stretch\"} gap={2}>\n {triggerPriceInput}\n {renderPriceInput()}\n {trailingCallbackInput}\n {quantityInput}\n {quantitySlider}\n </Flex>\n {buttons}\n </Flex>\n\n <SimpleDialog\n open={props.dialogOpen}\n onOpenChange={props.setDialogOpen}\n title={t(\"orders.editOrder\")}\n size=\"xs\"\n actions={{\n primary: {\n label: t(\"common.confirm\"),\n onClick: props.onDialogConfirm,\n loading: props.submitting,\n fullWidth: true,\n },\n secondary: {\n label: t(\"common.cancel\"),\n onClick: props.onCloseDialog,\n fullWidth: true,\n },\n }}\n classNames={{\n content: \"oui-pb-4\",\n body: \"oui-p-0\",\n footer: \"oui-pt-3 oui-pb-0\",\n }}\n >\n <ConfirmDialogContent {...props} />\n </SimpleDialog>\n </EditSheetContext.Provider>\n );\n};\n","import { useCallback, useEffect, useState } from \"react\";\nimport { useOrderEntity } from \"@kodiak-finance/orderly-hooks\";\nimport {\n API,\n OrderlyOrder,\n OrderSide,\n OrderType,\n} from \"@kodiak-finance/orderly-types\";\n\nexport const useEditOrderEntry = (props: {\n order: API.AlgoOrderExt;\n orderType: OrderType;\n maxQty: number;\n}) => {\n const { order, orderType, maxQty } = props;\n\n const [formattedOrder, setFormattedOrder] = useState({\n symbol: order.symbol,\n side: order.side as OrderSide,\n reduce_only: order.reduce_only,\n order_type: orderType,\n // TODO: trailing stop order edit price twice, order.price will be 0\n order_price: order.price || undefined,\n order_quantity: order.quantity,\n trigger_price: order.trigger_price,\n activated_price: order.activated_price,\n callback_value: order.callback_value,\n callback_rate: order.callback_rate ? order.callback_rate * 100 : undefined,\n });\n\n const { markPrice, errors, validate, clearErrors } = useOrderEntity(\n formattedOrder,\n {\n maxQty,\n },\n );\n\n const setOrderValue = useCallback((key: keyof OrderlyOrder, value: any) => {\n setFormattedOrder((oldValue) => ({\n ...oldValue,\n [key]: value,\n }));\n }, []);\n\n const {\n order_price,\n order_quantity,\n trigger_price,\n activated_price,\n callback_value,\n callback_rate,\n } = formattedOrder;\n\n const isChanged =\n (order.price && order.price != order_price) ||\n (order.quantity && order.quantity != order_quantity) ||\n (order.trigger_price && order.trigger_price != trigger_price) ||\n // trailing stop fields\n (order.activated_price && order.activated_price != activated_price) ||\n (order.callback_value && order.callback_value != callback_value) ||\n (order.callback_rate && order.callback_rate * 100 != callback_rate);\n\n useEffect(() => {\n if (isChanged) {\n validate()\n .then((order) => {\n console.log(\"validate success\", order);\n })\n .catch((err) => {\n console.log(\"validate error\", err);\n });\n } else {\n clearErrors();\n }\n }, [\n isChanged,\n order_price,\n order_quantity,\n trigger_price,\n activated_price,\n callback_value,\n callback_rate,\n ]);\n\n return {\n markPrice,\n errors,\n validate,\n setOrderValue,\n formattedOrder,\n isChanged,\n };\n};\n","import { useMemo } from \"react\";\nimport { useMaxQty } from \"@kodiak-finance/orderly-hooks\";\nimport { API, OrderSide } from \"@kodiak-finance/orderly-types\";\n\nexport function useEditOrderMaxQty(\n order: API.AlgoOrderExt,\n positionQty?: number,\n) {\n const { reduce_only } = order;\n\n const maxQty = useMaxQty(order.symbol, order.side as OrderSide, reduce_only);\n\n return useMemo(() => {\n if (reduce_only) {\n return Math.abs(positionQty ?? 0);\n }\n return order.quantity + Math.abs(maxQty);\n }, [order.quantity, maxQty, reduce_only, positionQty]);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useLocalStorage } from \"@kodiak-finance/orderly-hooks\";\nimport { API, OrderEntity, OrderType } from \"@kodiak-finance/orderly-types\";\nimport { AlgoOrderRootType } from \"@kodiak-finance/orderly-types\";\nimport { toast, useModal } from \"@kodiak-finance/orderly-ui\";\nimport { convertApiOrderTypeToOrderEntryType } from \"../../../../utils/util\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useEditOrderEntry } from \"./hooks/useEditOrderEntry\";\nimport { useEditOrderMaxQty } from \"./hooks/useEditOrderMaxQty\";\n\nexport const useEditSheetScript = (props: {\n state: OrderCellState;\n position?: API.PositionTPSLExt;\n editAlgoOrder: (id: string, order: OrderEntity) => Promise<any>;\n editOrder: (id: string, order: OrderEntity) => Promise<any>;\n}) => {\n const { state, editAlgoOrder, editOrder, position } = props;\n const { item: order } = state;\n const { hide: onClose } = useModal();\n const [dialogOpen, setDialogOpen] = useState(false);\n const [submitting, setSubmitting] = useState(false);\n\n const isAlgoOrder =\n order.algo_order_id !== undefined &&\n order.algo_type !== AlgoOrderRootType.BRACKET;\n\n const isStopMarket = order?.type === \"MARKET\" && isAlgoOrder;\n const isTrailingStop = order.algo_type === OrderType.TRAILING_STOP;\n\n const showTriggerPrice = isAlgoOrder && !isTrailingStop;\n\n const orderType = useMemo(\n () => convertApiOrderTypeToOrderEntryType(order),\n [order],\n );\n\n const [orderConfirm, setOrderConfirm] = useLocalStorage(\n \"orderly_order_confirm\",\n true,\n );\n\n const maxQty = useEditOrderMaxQty(order, position?.position_qty);\n\n const {\n formattedOrder,\n setOrderValue,\n markPrice,\n errors,\n validate,\n isChanged,\n } = useEditOrderEntry({\n order,\n orderType,\n maxQty,\n });\n\n useEffect(() => {}, [order.price, formattedOrder.order_price]);\n\n const onCloseDialog = useCallback(() => {\n setDialogOpen(false);\n }, []);\n\n const onSubmit = useCallback(\n async (values: OrderEntity) => {\n let future;\n const isHidden =\n order.visible_quantity !== undefined\n ? order.visible_quantity === 0\n : (order as any).visible !== undefined\n ? (order as any).visible === 0\n : false;\n\n if (order.order_tag) {\n values.order_tag = order.order_tag;\n }\n\n if (order.client_order_id) {\n values.client_order_id = order.client_order_id;\n }\n\n if (order.algo_order_id !== undefined) {\n if (isTrailingStop) {\n if (values.callback_rate) {\n values = {\n ...values,\n callback_rate: (Number(values.callback_rate) / 100).toString(),\n };\n } else if (isStopMarket && \"order_price\" in values) {\n const { order_price, ...rest } = values;\n values = rest;\n }\n }\n\n future = editAlgoOrder(order.algo_order_id.toString(), {\n ...values,\n });\n } else {\n future = editOrder((order as any).order_id.toString(), {\n ...values,\n ...(isHidden ? { visible_quantity: 0 } : {}),\n });\n }\n try {\n setSubmitting(true);\n\n const res = await future;\n onClose();\n } catch (err: any) {\n toast.error(err?.message ?? `${err}`);\n } finally {\n setSubmitting(false);\n }\n },\n [editAlgoOrder, editOrder, isTrailingStop],\n );\n\n const onDialogConfirm = () => {\n if (formattedOrder) {\n return onSubmit(formattedOrder as any);\n }\n return Promise.reject();\n };\n\n const onSheetConfirm = () => {\n validate()\n .then(\n (result) => {\n if (orderConfirm) {\n setDialogOpen(true);\n } else {\n // @ts-ignore\n onSubmit(formattedOrder);\n }\n },\n (error) => {\n // rejected\n if (error?.total?.message) {\n toast.error(error?.total.message);\n }\n },\n )\n .catch((err) => {});\n };\n\n return {\n ...state,\n markPrice,\n isStopMarket,\n isTrailingStop,\n showTriggerPrice,\n formattedOrder,\n setOrderValue,\n maxQty,\n onClose,\n onSheetConfirm,\n errors,\n isChanged,\n dialogOpen,\n setDialogOpen,\n onDialogConfirm,\n onCloseDialog,\n submitting,\n\n orderConfirm,\n setOrderConfirm,\n };\n};\n\nexport type EditSheetState = ReturnType<typeof useEditSheetScript>;\n","import { API, OrderEntity } from \"@kodiak-finance/orderly-types\";\nimport { OrderCellState } from \"../orderCell.script\";\nimport { useEditSheetScript } from \"./editSheet.script\";\nimport { EditSheet } from \"./editSheet.ui\";\n\ntype EditSheetWidgetProps = {\n state: OrderCellState;\n editAlgoOrder: (id: string, order: OrderEntity) => Promise<any>;\n editOrder: (id: string, order: OrderEntity) => Promise<any>;\n position?: API.PositionTPSLExt;\n};\n\nexport const EditSheetWidget = (props: EditSheetWidgetProps) => {\n const state = useEditSheetScript(props);\n return <EditSheet {...state} />;\n};\n","export { EditSheet } from \"./editSheet.ui\";\nexport { EditSheetWidget } from \"./editSheet.widget\";\nexport { useEditSheetScript } from \"./editSheet.script\";\n","import { useCallback } from \"react\";\nimport { useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { modal } from \"@kodiak-finance/orderly-ui\";\nimport { PositionTPSLSheet } from \"@kodiak-finance/orderly-ui-tpsl\";\nimport { TabType } from \"../../../orders.widget\";\nimport { useOrderListContext } from \"../../orderListContext\";\nimport { useTPSLOrderRowContext } from \"../../tpslOrderRowContext\";\nimport { EditSheetWidget } from \"../editSheet\";\nimport { OrderCellState } from \"../orderCell.script\";\n\nexport const useEditBtnScript = (props: { state: OrderCellState }) => {\n const { state } = props;\n const { t } = useTranslation();\n const symbolInfo = useSymbolsInfo()[props.state.item.symbol]();\n\n const { editAlgoOrder, editOrder } = useOrderListContext();\n const { position } = useTPSLOrderRowContext();\n\n const onShowEditSheet = useCallback(() => {\n if (props.state.type === TabType.tp_sl) {\n modal\n .sheet({\n content: (\n <PositionTPSLSheet\n symbol={props.state.item.symbol}\n symbolInfo={symbolInfo}\n isEditing\n order={props.state.item}\n />\n ),\n })\n .catch((error) => {\n console.log(error);\n });\n } else {\n modal\n .sheet({\n title: t(\"orders.editOrder\"),\n // size: \"xs\",\n classNames: {\n content: \"oui-bg-base-8\",\n },\n content: (\n <EditSheetWidget\n state={state}\n position={position}\n editAlgoOrder={editAlgoOrder}\n editOrder={editOrder}\n />\n ),\n })\n .catch((error) => {\n console.log(error);\n });\n }\n }, [state]);\n\n return {\n ...state,\n onShowEditSheet,\n };\n};\n\nexport type EditBtnState = ReturnType<typeof useEditBtnScript>;\n","import { OrderCellState } from \"../orderCell.script\";\nimport { useEditBtnScript } from \"./editBtn.script\";\nimport { EditBtn } from \"./editBtn.ui\";\n\nexport const EditBtnWidget = (props: { state: OrderCellState }) => {\n const state = useEditBtnScript(props);\n return <EditBtn {...state} />;\n};\n","export { EditBtn } from \"./editBtn.ui\";\nexport { EditBtnWidget } from \"./editBtn.widget\";\nexport { useEditBtnScript } from \"./editBtn.script\";\n","import React, { FC } from \"react\";\nimport { AlgoOrderRootType } from \"@kodiak-finance/orderly-types\";\nimport { Divider, Flex, Grid, Text } from \"@kodiak-finance/orderly-ui\";\nimport { TabType } from \"../../orders.widget\";\nimport { BracketOrderPriceWidget } from \"./bracketOrderPrice\";\nimport { CancelBtnWidget } from \"./cancelBtn\";\nimport { EditBtnWidget } from \"./editBtn\";\nimport {\n OrderTime,\n SymbolToken,\n OrderTypeView,\n Qty,\n Filled,\n EstTotal,\n TriggerPrice,\n LimitPrice,\n MarkPrice,\n TPTrigger,\n TPPrice,\n TPSLQuantity,\n SLTrigger,\n SLPrice,\n AvgPrice,\n OrderPrice,\n RealizedPnL,\n OrderState,\n Fee,\n TrailingCallback,\n TrailingPrice,\n} from \"./items\";\nimport { OrderCellState } from \"./orderCell.script\";\n\nexport const OrderCell: FC<\n OrderCellState & {\n className?: string;\n }\n> = (props) => {\n return (\n <Flex\n direction={\"column\"}\n width={\"100%\"}\n gap={2}\n itemAlign={\"start\"}\n className={props.className}\n >\n <Header {...props} />\n <Divider intensity={6} className=\"oui-w-full\" />\n <Body {...props} />\n {props.type === TabType.pending && <BracketOrderPriceWidget {...props} />}\n {props.type !== TabType.orderHistory && <Btns {...props} />}\n </Flex>\n );\n};\n\nexport const Header: FC<OrderCellState> = (props) => {\n return (\n <Flex direction={\"column\"} gap={1} width={\"100%\"}>\n <Flex justify={\"between\"} width={\"100%\"}>\n <SymbolToken {...props} />\n <OrderTime {...props} />\n </Flex>\n <Flex width={\"100%\"} justify={\"between\"}>\n <OrderTypeView {...props} />\n {props.type === TabType.orderHistory && <OrderState {...props} />}\n </Flex>\n </Flex>\n );\n};\n\nexport const Body: FC<OrderCellState> = (props) => {\n return (\n <Grid cols={3} rows={2} width={\"100%\"} gap={1}>\n {itemsWithType(props)}\n </Grid>\n );\n};\n\nexport const Btns: FC<OrderCellState> = (props) => {\n return (\n <Grid cols={3} rows={1} width={\"100%\"} gap={2}>\n <div></div>\n <EditBtnWidget state={props} />\n <CancelBtnWidget state={props} />\n </Grid>\n );\n};\n\nfunction itemsWithType(props: OrderCellState) {\n switch (props.type) {\n case TabType.all:\n return <></>;\n case TabType.pending:\n const isTrailingStop =\n props.item?.algo_type === AlgoOrderRootType.TRAILING_STOP;\n\n if (isTrailingStop) {\n return (\n <>\n <Qty {...props} />\n <Filled {...props} />\n <EstTotal {...props} />\n <TriggerPrice {...props} isPending={true} />\n <TrailingPrice {...props} />\n <TrailingCallback {...props} />\n </>\n );\n }\n\n return (\n <>\n <Qty {...props} />\n <Filled {...props} />\n <EstTotal {...props} />\n <TriggerPrice {...props} isPending={true} />\n <LimitPrice {...props} />\n <MarkPrice {...props} />\n </>\n );\n\n case TabType.tp_sl:\n return (\n <>\n <TPTrigger {...props} />\n <TPPrice {...props} />\n <TPSLQuantity {...props} />\n <SLTrigger {...props} />\n <SLPrice {...props} />\n </>\n );\n case TabType.filled:\n return <></>;\n case TabType.cancelled:\n return <></>;\n case TabType.rejected:\n return <></>;\n case TabType.orderHistory:\n return (\n <>\n <Qty {...props} />\n <Filled {...props} />\n <TriggerPrice {...props} align=\"end\" />\n <AvgPrice {...props} />\n <OrderPrice {...props} />\n <RealizedPnL {...props} />\n {/* placeholder */}\n <div></div>\n {/* placeholder */}\n <div></div>\n <Fee {...props} />\n </>\n );\n }\n}\n","import { API } from \"@kodiak-finance/orderly-types\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { TabType } from \"../../orders.widget\";\nimport { useSymbolContext } from \"../../provider/symbolContext\";\n\nexport const useOrderCellScript = (props: {\n item: API.AlgoOrderExt;\n index: number;\n type: TabType;\n sharePnLConfig?: SharePnLConfig;\n onSymbolChange?: (symbol: API.Symbol) => void;\n}) => {\n const symbolInfo = useSymbolContext();\n return {\n ...props,\n ...symbolInfo,\n // use symbolInfo replace ...symbolInfo\n symbolInfo,\n };\n};\n\nexport type OrderCellState = ReturnType<typeof useOrderCellScript>;\n","import { API } from \"@kodiak-finance/orderly-types\";\nimport { useOrderCellScript } from \"./orderCell.script\";\nimport { OrderCell } from \"./orderCell.ui\";\nimport { TabType } from \"../../orders.widget\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\n\nexport const OrderCellWidget = (props: {\n item: API.AlgoOrderExt;\n index: number;\n className?: string;\n type: TabType;\n sharePnLConfig?: SharePnLConfig;\n onSymbolChange?: (symbol: API.Symbol) => void;\n}) => {\n const { className, ...rest } = props;\n\n const state = useOrderCellScript(rest);\n return <OrderCell {...state} className={className} />;\n};\n","export { OrderCell } from \"./orderCell.ui\";\nexport { OrderCellWidget } from \"./orderCell.widget\";\nexport { useOrderCellScript } from \"./orderCell.script\";\n","import { FC, PropsWithChildren, useMemo } from \"react\";\nimport { getMinNotional, useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { useMemoizedFn } from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { API, OrderEntity } from \"@kodiak-finance/orderly-types\";\nimport { OrderListContext, OrderListContextState } from \"./orderListContext\";\n\nexport interface OrderListProviderProps {\n cancelOrder: (orderId: number, symbol: string) => Promise<any>;\n editOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n cancelAlgoOrder: (orderId: number, symbol: string) => Promise<any>;\n editAlgoOrder: (orderId: string, order: OrderEntity) => Promise<any>;\n}\n\nexport const OrderListProvider: FC<\n PropsWithChildren<OrderListProviderProps>\n> = (props) => {\n const { cancelOrder, editOrder, cancelAlgoOrder, editAlgoOrder } = props;\n const { t } = useTranslation();\n const symbolsInfo = useSymbolsInfo();\n\n const onCancelOrder = useMemoizedFn(\n async (order: API.Order | API.AlgoOrder) => {\n if (order.algo_order_id !== undefined) {\n if (\n \"root_algo_order_id\" in order &&\n order.root_algo_order_id !== order.algo_order_id\n ) {\n return cancelAlgoOrder(order.root_algo_order_id, order.symbol);\n }\n\n return cancelAlgoOrder(order.algo_order_id, order.symbol).then(\n () => {},\n );\n }\n // @ts-ignore\n return cancelOrder(order.order_id, order.symbol).then(() => {\n // toast.success(\"Order canceled successfully\");\n });\n },\n );\n\n const checkMinNotional = useMemoizedFn(\n (symbol: string, price?: string | number, qty?: string | number) => {\n const { min_notional } = symbolsInfo[symbol]();\n const minNotional = getMinNotional({ price, qty, min_notional });\n if (minNotional !== undefined) {\n return t(\"orderEntry.total.error.min\", { value: minNotional });\n }\n },\n );\n\n const memoizedValue = useMemo<OrderListContextState>(() => {\n return {\n onCancelOrder,\n editOrder,\n editAlgoOrder,\n checkMinNotional,\n };\n }, [onCancelOrder, editOrder, editAlgoOrder, checkMinNotional]);\n\n return (\n <OrderListContext.Provider value={memoizedValue}>\n {props.children}\n </OrderListContext.Provider>\n );\n};\n","import { FC } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport {\n Flex,\n ListView,\n Button,\n Grid,\n Picker,\n DataFilter,\n cn,\n TableFeatures,\n} from \"@kodiak-finance/orderly-ui\";\nimport { AuthGuardDataTable } from \"@kodiak-finance/orderly-ui-connector\";\nimport { formatSymbol } from \"@kodiak-finance/orderly-utils\";\nimport { grayCell } from \"../../utils/util\";\nimport { TabType } from \"../orders.widget\";\nimport { SymbolProvider } from \"../provider/symbolProvider\";\nimport { useOrderColumn } from \"./desktop/useColumn\";\nimport { OrderCellWidget } from \"./mobile\";\nimport { OrdersBuilderState } from \"./orderList.script\";\nimport { OrderListProvider } from \"./orderListProvider\";\nimport { TPSLOrderRowProvider } from \"./tpslOrderRowContext\";\n\nexport const DesktopOrderList: FC<\n OrdersBuilderState & { testIds?: { tableBody?: string } }\n> = (props) => {\n const { sharePnLConfig, ...rest } = props;\n const columns = useOrderColumn({\n _type: props.type,\n onSymbolChange: props.onSymbolChange,\n pnlNotionalDecimalPrecision: props.pnlNotionalDecimalPrecision,\n sharePnLConfig,\n symbolsInfo: props.symbolsInfo,\n });\n\n return (\n <OrderListProvider\n cancelOrder={props.cancelOrder}\n editOrder={props.updateOrder}\n cancelAlgoOrder={props.cancelAlgoOrder}\n editAlgoOrder={props.updateAlgoOrder}\n // cancelTPSLOrder={props.cancelTPSLOrder}\n >\n <Flex direction=\"column\" width=\"100%\" height=\"100%\" itemAlign=\"start\">\n {props.filterItems.length > 0 && (\n <DataFilter\n items={props.filterItems}\n onFilter={(value: any) => {\n props.onFilter(value);\n }}\n trailing={\n [TabType.pending, TabType.tp_sl].includes(props.type) && (\n <CancelAll {...props} />\n )\n }\n />\n )}\n <AuthGuardDataTable\n columns={columns}\n loading={props.isLoading}\n dataSource={props.dataSource}\n bordered\n ignoreLoadingCheck={true}\n testIds={{\n body: props.testIds?.tableBody,\n }}\n classNames={{\n header: \"oui-h-[38px]\",\n root: \"oui-items-start !oui-h-[calc(100%_-_49px)]\",\n }}\n onRow={(record, index) => {\n return {\n className: cn(\n \"oui-h-[48px]\",\n grayCell(record)\n ? \"oui-text-base-contrast-20\"\n : \"oui-text-base-contrast-80\",\n ),\n };\n }}\n generatedRowKey={(record, index) =>\n `${props.type}${index}${\n record.order_id || record.algo_order_id\n }_index${index}`\n }\n renderRowContainer={(record: any, index, children) => {\n if (\n props.type === TabType.tp_sl ||\n props.type === TabType.pending\n ) {\n children = (\n <TPSLOrderRowProvider order={record}>\n {children}\n </TPSLOrderRowProvider>\n );\n }\n\n return (\n <SymbolProvider symbol={record.symbol}>{children}</SymbolProvider>\n );\n }}\n pagination={props.pagination}\n manualPagination={props.manualPagination}\n features={[TableFeatures.DownloadFeature]}\n getTableInstance={(table) => {\n props.tableInstance.current = table;\n }}\n />\n </Flex>\n </OrderListProvider>\n );\n};\n\nexport const MobileOrderList: FC<\n OrdersBuilderState & {\n classNames?: { root?: string; cell?: string; content?: string };\n showFilter?: boolean;\n onExport?: () => void;\n }\n> = (props) => {\n const { t } = useTranslation();\n\n return (\n <OrderListProvider\n cancelOrder={props.cancelOrder}\n editOrder={props.updateOrder}\n cancelAlgoOrder={props.cancelAlgoOrder}\n editAlgoOrder={props.updateAlgoOrder}\n // cancelTPSLOrder={props.cancelTPSLOrder}\n >\n <Grid\n cols={1}\n rows={2}\n className=\"oui-w-full oui-grid-rows-[auto,1fr]\"\n gap={2}\n >\n {/* <Filter\n items={props.filterItems}\n onFilter={(value: any) => {\n props.onFilter(value);\n }}\n className=\"oui-px-3\"\n\n /> */}\n\n {props.showFilter ? (\n <Flex\n gap={2}\n p={2}\n justify={\"between\"}\n itemAlign={\"center\"}\n className=\"oui-rounded-b-xl oui-bg-base-9\"\n >\n <Flex gap={2}>\n {props.filterItems.map((item) => {\n // not support range type\n if (item.type !== \"select\") {\n return null;\n }\n return (\n <Picker\n key={`item-${item.name}`}\n options={item.options}\n size={\"sm\"}\n value={item.value}\n className=\"oui-text-2xs oui-text-base-contrast-54 \"\n placeholder={\n item.name === \"side\"\n ? t(\"common.side.all\")\n : item.name === \"status\"\n ? t(\"common.status.all\")\n : \"\"\n }\n onValueChange={(value) => {\n //\n props.onFilter?.({ name: item.name, value: value });\n }}\n />\n );\n })}\n </Flex>\n {props.onExport && (\n <Button\n variant=\"outlined\"\n size=\"xs\"\n color=\"secondary\"\n onClick={props.onExport}\n >\n {t(\"common.export\") || \"Export CSV\"}\n </Button>\n )}\n </Flex>\n ) : (\n <div></div>\n )}\n <ListView\n className={props.classNames?.root}\n contentClassName={props.classNames?.content}\n dataSource={props.dataSource}\n loadMore={props.loadMore}\n isLoading={props.isLoading}\n renderItem={(item, index) => {\n let children = (\n <OrderCellWidget\n item={item}\n index={index}\n className={props.classNames?.cell}\n type={props.type}\n onSymbolChange={props.onSymbolChange}\n sharePnLConfig={props.sharePnLConfig}\n />\n );\n if ([TabType.tp_sl, TabType.pending].includes(props.type)) {\n children = (\n <TPSLOrderRowProvider order={item}>\n {children}\n </TPSLOrderRowProvider>\n );\n }\n return (\n <SymbolProvider symbol={item.symbol}>{children}</SymbolProvider>\n );\n }}\n />\n </Grid>\n </OrderListProvider>\n );\n};\n\nconst CancelAll: FC<OrdersBuilderState> = (props) => {\n const { t } = useTranslation();\n const { symbol } = props;\n\n const formattedSymbol = symbol ? formatSymbol(symbol, \"base\") : symbol;\n\n return (\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n size=\"xs\"\n disabled={(props.dataSource?.length ?? 0) == 0}\n className=\"disabled:oui-bg-transport\"\n onClick={(e) => props.onCancelAll()}\n data-testid={`oui-testid-dataList-${props.type.toLowerCase()}-cancelAll-button`}\n >\n {symbol\n ? t(\"orders.cancelAll.ofSymbol\", { symbol: formattedSymbol })\n : t(\"orders.cancelAll\")}\n </Button>\n );\n};\n","import { useMemo } from \"react\";\nimport { API, AlgoOrderRootType, OrderStatus } from \"@kodiak-finance/orderly-types\";\n\nexport const useFormatOrderHistory = (data: API.AlgoOrderExt[]) => {\n const formattedData = useMemo(() => {\n const _data: API.AlgoOrder[] = [];\n\n for (let index = 0; index < data.length; index++) {\n const element = data[index];\n // console.log(\"element\", element);\n if (\n element.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL ||\n element.algo_type === AlgoOrderRootType.TP_SL\n ) {\n if (\n element.algo_status !== OrderStatus.FILLED &&\n element.algo_status !== OrderStatus.PARTIAL_FILLED\n ) {\n for (let j = 0; j < element.child_orders.length; j++) {\n const e = element.child_orders[j];\n if (!e.is_activated || !e.trigger_price) {\n continue;\n }\n (e as any).parent_algo_type = element.algo_type;\n _data.push(e);\n }\n } else {\n // if order is filled then show only the filled order\n for (let j = 0; j < element.child_orders.length; j++) {\n const e = element.child_orders[j];\n if (\n !!e &&\n (e.algo_status === OrderStatus.FILLED ||\n e.algo_status === OrderStatus.PARTIAL_FILLED)\n ) {\n (e as any).parent_algo_type = element.algo_type;\n _data.push(e);\n }\n }\n }\n } else {\n _data.push(element);\n }\n }\n\n return _data;\n\n // data.map((item) => {});\n }, [data]);\n\n return formattedData;\n};\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n ForwardedRef,\n useImperativeHandle,\n} from \"react\";\nimport { differenceInDays, setHours, subDays } from \"date-fns\";\nimport {\n useLocalStorage,\n useOrderStream,\n useSymbolsInfo,\n} from \"@kodiak-finance/orderly-hooks\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { useDataTap } from \"@kodiak-finance/orderly-react-app\";\nimport {\n AlgoOrderRootType,\n OrderStatus,\n OrderSide,\n API,\n} from \"@kodiak-finance/orderly-types\";\nimport { modal, usePagination, Text, Table } from \"@kodiak-finance/orderly-ui\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { areDatesEqual } from \"../../utils/util\";\nimport { TabType } from \"../orders.widget\";\nimport { useFormatOrderHistory } from \"./useFormatOrderHistory\";\n\nexport type OrderListInstance = {\n getRowCount?: () => number;\n getDataSource?: () => any[] | null;\n};\n\nexport type useOrderListScriptOptions = {\n type: TabType;\n ordersStatus?: OrderStatus;\n symbol?: string;\n enableLoadMore?: boolean;\n onSymbolChange?: (symbol: API.Symbol) => void;\n sharePnLConfig?: SharePnLConfig;\n filterConfig?: {\n side?: OrderSide | \"all\";\n range?: {\n from?: Date;\n to?: Date;\n };\n };\n pnlNotionalDecimalPrecision?: number;\n ref?: ForwardedRef<OrderListInstance>;\n};\n\nexport const useOrderListScript = (props: useOrderListScriptOptions) => {\n const {\n ordersStatus,\n type,\n enableLoadMore = false,\n onSymbolChange,\n filterConfig,\n pnlNotionalDecimalPrecision,\n sharePnLConfig,\n } = props;\n const { t } = useTranslation();\n const symbolsInfo = useSymbolsInfo();\n\n const manualPagination = useMemo(() => {\n // pending and ts_sl list use client pagination\n return ordersStatus !== OrderStatus.INCOMPLETE;\n }, [ordersStatus]);\n\n const defaultPageSize = 50;\n const { page, pageSize, setPage, pagination, parsePagination } =\n usePagination({\n pageSize: defaultPageSize,\n });\n\n // when symbol change, reset page\n useEffect(() => {\n setPage(1);\n }, [props.symbol]);\n\n const {\n orderStatus,\n ordersSide,\n dateRange,\n filterItems,\n onFilter,\n filterDays,\n updateFilterDays,\n } = useFilter(type, {\n ordersStatus,\n setPage,\n filterConfig,\n });\n\n const includes = useMemo(() => {\n if (type === TabType.tp_sl) {\n return [AlgoOrderRootType.POSITIONAL_TP_SL, AlgoOrderRootType.TP_SL];\n }\n return undefined;\n }, [type]);\n\n const excludes = useMemo(() => {\n if (type === TabType.pending) {\n return [AlgoOrderRootType.POSITIONAL_TP_SL, AlgoOrderRootType.TP_SL];\n }\n return undefined;\n }, [type]);\n\n const tableInstance = useRef<Table<any>>();\n\n const [\n data,\n {\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n cancelAllPendingOrders,\n cancelAllTPSLOrders,\n meta,\n refresh,\n },\n ] = useOrderStream({\n symbol: props.symbol,\n status: orderStatus,\n side: ordersSide,\n page: enableLoadMore || !manualPagination ? undefined : page,\n // pending and ts_sl list get all data\n size: manualPagination ? pageSize : 500,\n sourceTypeAll: type === TabType.orderHistory,\n dateRange,\n includes,\n excludes,\n });\n\n const localPageSizeKey = `orderly_${type}_pageSize`;\n const [typePageSize, setTypePageSize] = useLocalStorage(\n localPageSizeKey,\n defaultPageSize,\n );\n\n useEffect(() => {\n if (typePageSize !== pageSize) {\n setTypePageSize(pageSize);\n }\n }, [pageSize, typePageSize]);\n\n const onCancelAll = useCallback(() => {\n const isPending = props.type === TabType.pending;\n const isTPSL = props.type === TabType.tp_sl;\n\n const title = isPending\n ? t(\"orders.pending.cancelAll\")\n : isTPSL\n ? t(\"orders.tpsl.cancelAll\")\n : \"\";\n\n const getContent = (): React.ReactNode => {\n const baseMessage = isPending\n ? t(\"orders.pending.cancelAll.description\")\n : isTPSL\n ? t(\"orders.tpsl.cancelAll.description\")\n : \"\";\n\n if (!props.symbol) {\n return <Text size=\"sm\">{baseMessage}</Text>;\n }\n\n const messageWithSymbol = baseMessage.replace(\n \"?\",\n ` in ${props.symbol}?`,\n );\n return <Text size=\"sm\">{messageWithSymbol}</Text>;\n };\n\n modal.confirm({\n title: title,\n content: getContent(),\n onCancel: async () => {},\n onOk: async () => {\n try {\n // await cancelAll(null, { source_type: \"ALL\" });r\n if (type === TabType.tp_sl) {\n await cancelAllTPSLOrders(props.symbol);\n } else {\n await cancelAllPendingOrders(props.symbol);\n }\n refresh();\n return Promise.resolve(true);\n } catch (error) {\n // @ts-ignore\n if (error?.message !== undefined) {\n // @ts-ignore\n toast.error(error.message);\n }\n return Promise.resolve(false);\n } finally {\n Promise.resolve();\n }\n },\n });\n }, [type, t, props.symbol]);\n\n const formattedData = useFormatOrderHistory(data ?? []);\n\n const dataSource =\n useDataTap(type !== TabType.tp_sl ? formattedData : data, {\n fallbackData: [],\n }) ?? undefined;\n\n const _pagination = useMemo(() => {\n if (manualPagination) {\n return parsePagination(meta);\n }\n return pagination;\n }, [meta, manualPagination, parsePagination, pagination]);\n\n useImperativeHandle(\n props.ref,\n () => ({\n getRowCount: () => {\n return tableInstance.current?.getRowCount?.() ?? 0;\n },\n getDataSource: () => {\n return dataSource ?? null;\n },\n }),\n [dataSource],\n );\n\n return {\n type,\n symbol: props.symbol,\n dataSource,\n isLoading,\n loadMore,\n cancelOrder,\n updateOrder,\n cancelAlgoOrder,\n updateAlgoOrder,\n pagination: _pagination,\n manualPagination,\n pnlNotionalDecimalPrecision,\n\n // filter\n onFilter,\n filterItems,\n onCancelAll,\n\n onSymbolChange,\n\n sharePnLConfig,\n tableInstance,\n symbolsInfo,\n filterDays,\n updateFilterDays,\n };\n};\n\nconst useFilter = (\n type: TabType,\n option: {\n ordersStatus?: OrderStatus | \"all\";\n setPage: (page: number) => void;\n filterConfig?: {\n side?: OrderSide | \"all\";\n range?: {\n from?: Date;\n to?: Date;\n };\n };\n },\n) => {\n const { t } = useTranslation();\n const [orderStatus, setOrderStatus] = useState<OrderStatus | \"all\">(\n option.ordersStatus ?? \"all\",\n );\n const [ordersSide, setOrdersSide] = useState<OrderSide | \"all\">(\n option.filterConfig?.side ?? \"all\",\n );\n\n /// default is 90d\n const [filterDays, setFilterDays] = useState<1 | 7 | 30 | 90 | null>(90);\n\n const defaultRange =\n option.filterConfig?.range ??\n (type === TabType.all || type === TabType.orderHistory\n ? formatDatePickerRange({\n to: new Date(),\n from: offsetEndOfDay(subDays(new Date(), 89)),\n })\n : {});\n\n const [dateRange, setDateRange] = useState<{\n from?: Date;\n to?: Date;\n }>(defaultRange);\n\n const updateFilterDays = (days: 1 | 7 | 30 | 90) => {\n setFilterDays(days);\n setDateRange({\n from: offsetStartOfDay(subDays(new Date(), days - 1)),\n to: offsetEndOfDay(new Date()),\n });\n option.setPage(1);\n };\n\n const onFilter = (filter: { name: string; value: any }) => {\n if (filter.name === \"side\") {\n setOrdersSide(filter.value);\n option.setPage(1);\n }\n\n if (filter.name === \"status\") {\n setOrderStatus(filter.value);\n option.setPage(1);\n }\n\n if (filter.name === \"dateRange\") {\n setDateRange(formatDatePickerRange(filter.value));\n option.setPage(1);\n\n const newDateRange = formatDatePickerRange(filter.value);\n if (newDateRange.from && newDateRange.to) {\n const diffDays =\n Math.abs(differenceInDays(newDateRange.from, newDateRange.to)) + 1;\n const dateRangeMap: { [key: number]: { from: Date; to: Date } } = {\n 1: {\n from: offsetStartOfDay(new Date())!,\n to: offsetEndOfDay(new Date())!,\n },\n 7: {\n from: offsetStartOfDay(subDays(new Date(), 6))!,\n to: offsetEndOfDay(new Date())!,\n },\n 30: {\n from: offsetStartOfDay(subDays(new Date(), 29))!,\n to: offsetEndOfDay(new Date())!,\n },\n 90: {\n from: offsetStartOfDay(subDays(new Date(), 89))!,\n to: offsetEndOfDay(new Date())!,\n },\n };\n\n const dateRange = dateRangeMap[diffDays];\n if (\n dateRange &&\n areDatesEqual(dateRange.from, newDateRange.from) &&\n areDatesEqual(dateRange.to, newDateRange.to)\n ) {\n setFilterDays(diffDays as any);\n } else {\n setFilterDays(null);\n }\n }\n }\n };\n\n const filterItems = useMemo((): any[] => {\n const sideFilter = {\n type: \"select\",\n name: \"side\",\n options: [\n {\n label: t(\"common.side.all\"),\n value: \"all\",\n },\n {\n label: t(\"common.buy\"),\n value: \"BUY\",\n },\n {\n label: t(\"common.sell\"),\n value: \"SELL\",\n },\n ],\n value: ordersSide,\n };\n\n const dateRangeFilter = {\n type: \"range\",\n name: \"dateRange\",\n value: dateRange,\n };\n\n const statusFilter = {\n type: \"select\",\n name: \"status\",\n options: [\n {\n label: t(\"common.status.all\"),\n value: \"all\",\n },\n {\n label: t(\"orders.status.pending\"),\n value: OrderStatus.INCOMPLETE,\n },\n {\n label: t(\"orders.status.filled\"),\n value: OrderStatus.FILLED,\n },\n {\n label: t(\"orders.status.partialFilled\"),\n value: OrderStatus.PARTIAL_FILLED,\n },\n {\n label: t(\"orders.status.canceled\"),\n value: OrderStatus.CANCELLED,\n },\n {\n label: t(\"orders.status.rejected\"),\n value: OrderStatus.REJECTED,\n },\n ],\n value: orderStatus,\n };\n switch (type) {\n case TabType.all:\n return [sideFilter, statusFilter, dateRangeFilter];\n case TabType.pending:\n return [sideFilter];\n case TabType.tp_sl:\n return [sideFilter];\n case TabType.filled:\n return [sideFilter];\n case TabType.cancelled:\n return [sideFilter];\n case TabType.rejected:\n return [sideFilter];\n case TabType.orderHistory:\n return [sideFilter, statusFilter, dateRangeFilter];\n }\n }, [type, ordersSide, orderStatus, dateRange, t]);\n\n return {\n filterItems,\n onFilter,\n ordersSide: ordersSide === \"all\" ? undefined : ordersSide,\n dateRange,\n orderStatus: orderStatus === \"all\" ? undefined : orderStatus,\n filterDays,\n updateFilterDays,\n };\n};\n\nexport type OrdersBuilderState = ReturnType<typeof useOrderListScript>;\nexport type FilterState = ReturnType<typeof useFilter>;\n\nexport const parseDateRangeForFilter = (dateRange: {\n from: Date;\n to?: Date;\n}) => {\n let { from, to } = dateRange;\n\n if (typeof to === \"undefined\") {\n to = new Date();\n }\n\n const diff = differenceInDays(from, to);\n\n // console.log(\"diff\", diff);\n\n if (diff === 0) {\n return [from, setHours(to, 23)];\n }\n\n return [from, to];\n};\n\nfunction offsetStartOfDay(date?: Date) {\n if (date == null) return date;\n\n const newDate = new Date(date);\n newDate.setHours(0, 0, 0, 0);\n return newDate;\n}\n\nfunction offsetEndOfDay(date?: Date) {\n if (date == null) return date;\n\n const newDate = new Date(date);\n newDate.setHours(23, 59, 59, 999);\n return newDate;\n}\n\nexport const formatDatePickerRange = (option: { from?: Date; to?: Date }) => ({\n from: offsetStartOfDay(option.from),\n to: offsetEndOfDay(option.to ?? option.from),\n});\n","import React, { forwardRef } from \"react\";\nimport { OrderSide, OrderStatus, API } from \"@kodiak-finance/orderly-types\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { TabType } from \"../orders.widget\";\nimport { OrderListInstance, useOrderListScript } from \"./orderList.script\";\nimport { DesktopOrderList, MobileOrderList } from \"./orderList.ui\";\n\nexport type DesktopOrderListWidgetProps = {\n type: TabType;\n ordersStatus?: OrderStatus;\n /** if has value, will be fetch current symbol orders*/\n symbol?: string;\n onSymbolChange?: (symbol: API.Symbol) => void;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n testIds?: {\n tableBody?: string;\n };\n};\n\nexport const DesktopOrderListWidget = forwardRef<\n OrderListInstance,\n DesktopOrderListWidgetProps\n>((props, ref) => {\n const { testIds, ...rest } = props;\n const state = useOrderListScript({ ...rest, ref });\n return <DesktopOrderList {...state} testIds={testIds} />;\n});\n\nexport const MobileOrderListWidget = React.forwardRef<\n OrderListInstance,\n {\n type: TabType;\n ordersStatus?: OrderStatus;\n /** if has value, will be fetch current symbol orders*/\n symbol?: string;\n onSymbolChange?: (symbol: API.Symbol) => void;\n sharePnLConfig?: SharePnLConfig;\n classNames?: { root?: string; cell?: string; content?: string };\n showFilter?: boolean;\n filterConfig?: {\n side?: OrderSide | \"all\";\n range?: { from?: Date; to?: Date };\n };\n onExport?: () => void;\n }\n>((props, ref) => {\n const state = useOrderListScript({ ...props, enableLoadMore: true, ref });\n return (\n <MobileOrderList\n {...state}\n classNames={props.classNames}\n showFilter={props.showFilter}\n onExport={props.onExport}\n />\n );\n});\n","export { DesktopOrderList, MobileOrderList } from \"./orderList.ui\";\nexport {\n DesktopOrderListWidget,\n MobileOrderListWidget,\n} from \"./orderList.widget\";\nexport { useOrderListScript, type OrderListInstance } from \"./orderList.script\";\n","import React from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { OrderStatus } from \"@kodiak-finance/orderly-types\";\nimport { TabPanel, Tabs } from \"@kodiak-finance/orderly-ui\";\nimport type { DesktopOrderListWidgetProps } from \"./orderList/orderList.widget\";\nimport { OrdersBuilderState } from \"./orders.script\";\nimport { TabType } from \"./orders.widget\";\n\nconst LazyDesktopOrderListWidget = React.lazy(() =>\n import(\"./orderList\").then((mod) => {\n return { default: mod.DesktopOrderListWidget };\n }),\n);\n\nexport const Orders: React.FC<OrdersBuilderState> = (props) => {\n const { t } = useTranslation();\n const { pnlNotionalDecimalPrecision, orderListRef } = props;\n const commonProps: Partial<DesktopOrderListWidgetProps> = {\n pnlNotionalDecimalPrecision: pnlNotionalDecimalPrecision,\n };\n return (\n <Tabs\n defaultValue={props.current || TabType.all}\n variant=\"contained\"\n className=\"oui-h-full\"\n classNames={{\n tabsContent: \"oui-h-[calc(100%_-_28px)]\",\n }}\n >\n <TabPanel value={TabType.all} title={t(\"common.all\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.all}\n pnlNotionalDecimalPrecision={pnlNotionalDecimalPrecision}\n sharePnLConfig={props.sharePnLConfig}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.pending} title={t(\"orders.status.pending\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.pending}\n ordersStatus={OrderStatus.INCOMPLETE}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.tp_sl} title={t(\"common.tpsl\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.tp_sl}\n ordersStatus={OrderStatus.INCOMPLETE}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.filled} title={t(\"orders.status.filled\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.filled}\n ordersStatus={OrderStatus.FILLED}\n pnlNotionalDecimalPrecision={pnlNotionalDecimalPrecision}\n sharePnLConfig={props.sharePnLConfig}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.cancelled} title={t(\"orders.status.canceled\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.cancelled}\n ordersStatus={OrderStatus.CANCELLED}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n <TabPanel value={TabType.rejected} title={t(\"orders.status.rejected\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n ref={orderListRef}\n type={TabType.rejected}\n ordersStatus={OrderStatus.REJECTED}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel>\n {/* <TabPanel value={TabType.orderHistory} title={t(\"orders.orderHistory\")}>\n <React.Suspense fallback={null}>\n <LazyDesktopOrderListWidget\n type={TabType.orderHistory}\n {...commonProps}\n />\n </React.Suspense>\n </TabPanel> */}\n </Tabs>\n );\n};\n// ----------------- Orders ui component end -----------------\n","import { forwardRef } from \"react\";\nimport { SharePnLConfig } from \"@kodiak-finance/orderly-ui-share\";\nimport { OrderListInstance } from \"./orderList/orderList.script\";\nimport { useOrdersScript } from \"./orders.script\";\nimport { Orders } from \"./orders.ui\";\n\nexport enum TabType {\n all = \"all\",\n pending = \"pending\",\n tp_sl = \"tp_sl\",\n filled = \"filled\",\n cancelled = \"cancelled\",\n rejected = \"rejected\",\n orderHistory = \"orderHistory\",\n}\n\nexport type OrdersWidgetProps = {\n current?: TabType;\n pnlNotionalDecimalPrecision?: number;\n sharePnLConfig?: SharePnLConfig;\n};\n\nexport const OrdersWidget = forwardRef<OrderListInstance, OrdersWidgetProps>(\n (props, ref) => {\n const state = useOrdersScript({ ...props, ref });\n return <Orders {...state} />;\n },\n);\n","export {\n OrdersWidget,\n TabType,\n} from \"./components/orders.widget\";\nexport { useOrdersScript } from \"./components/orders.script\";\nexport type { OrdersBuilderState } from \"./components/orders.script\";\n\nexport * from \"./components/orderList\";\n"]}
|